readme icon indicating copy to clipboard operation
readme copied to clipboard

Fix for # in code block

Open ProfessorManhattan opened this issue 4 years ago • 0 comments

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.

ProfessorManhattan avatar Sep 10 '21 02:09 ProfessorManhattan