Skip to content

Fix for # in code block #12

@ProfessorManhattan

Description

@ProfessorManhattan

There's an issue with having # in code blocks.

The following fixes the TOC in generators.ts:

const generateToc = {
  name: "toc",
  regex: placeholderRegexCallback("template:toc"),
  template: tocTemplate,
  params: ({
    config,
    blueprint
  }) => {
    const codeBlockRegex = /(```.+?```)/gms // NEW CODE
    const titles = blueprint.replace(codeBlockRegex, '').match(/^[#]{1,6} .*$/gm); // NEW CODE
    // const titles = blueprint.replace(codeBlockRegex, '').match(/^[#]{1,6} .*$/gm); // OLD CODE

    if (titles == null) {
      return {
        error: "it could not find any titles"
      };
    }

    return {
      titles,
      config
    };
  }
};

However, I was unable to figure out where the section seperator was being injected so this bug still needs to be fixed.

I appreciate your work. Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions