Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for # in code block #12

Open
ProfessorManhattan opened this issue Sep 10, 2021 · 0 comments
Open

Fix for # in code block #12

ProfessorManhattan opened this issue Sep 10, 2021 · 0 comments

Comments

@ProfessorManhattan
Copy link

ProfessorManhattan commented Sep 10, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant