Sign in

Markdown editor and line-numbers

  • This topic has 1 reply, 1 voice, and was last updated 2 years, 6 months ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #5265
    Avatar photocangel

    Hi there,

    One of the built-in features that I really like for Publii is the Markdown editor. I ended up purchasing the ProDocs theme because it seemed especially suited for code-type blogging.

    I noticed that you can enable line numbers, but when using the MD editor, it seems those stay absent and the `line-numbers` class doesn’t get added to the `pre`

    Is there a workaround for this, even if a bit hackish?


    Avatar photocangel

    I got it… I guess.

    I had to modify the `footer.hbs` file where the `syntaxHighlighterLineNumbers` is checked. I ended up adding this so that it searches for any code tags, grabs the parent tag, and appends the `line-numbers` class before prism line-numbers initializes:

    {{#checkIfAll @config.custom.syntaxHighlighter @config.custom.syntaxHighlighterLineNumbers}}
    var code_snippets = document.querySelectorAll('code');
    for (var i = 0; i < code_snippets.length; i++) {
    <script defer src="{{js "prism-line-numbers.min.js"}}"></script>

    This could be specific to the ProDocs theme. I’ve only used that one so far. But for now it works. Your mileage my vary…

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.