Skip to content

Code blocks wrongly highlighted #902

Closed

Description

@obestwalter

A block like this:

Obtaining file:///</path/to/your/clone>
Installing collected packages: mau-mau
  Running setup.py develop for mau-mau
Successfully installed mau-mau

should simply be rendered with <pre></pre> - like here in this issue. But instead it is somehow detected as some language and wrongly highlighted as (in this case) elixir syntax . See for example: http://oliver.bestwalter.de/mau-mau/dev/getting-started/

Is this kind of automatic detection a bug or a feature? If it's a feature: Is there a way to switch it off? I don't see any highlighting settings in the configuration docs.

Activity

  1. waylan commented on Apr 18, 2016

    @waylan
    Contributor

    This is a duplicate of #467.

  2. obestwalter commented on Apr 18, 2016

    @obestwalter
    Author

    I read #467 and the surrounding discussions. They all revolve around giving users the ability to easier modify themes or even add a plugin API. What I describe here is a bug that already occurs in the default theme.

    Steps to reproduce: with a fresh install of MkDocs and a new project add this line to the code block in the autogenerated index.md (or add an additional code block - same result):

    from here to there: this should not be highlighted
    

    The code block gets recognized as livescript and is wrongly highlighted.

    2016-04-18-202457_1916x1041_scrot

    IMHO this should be fixed independently from what is proposed and discussed in #467 or other issues.

  3. d0ugal commented on Apr 18, 2016

    @d0ugal
    Contributor

    IMHO this should be fixed independently from what is proposed and discussed in #467 or other issues.

    Fixed how?

  4. obestwalter commented on Apr 18, 2016

    @obestwalter
    Author

    In the way that a verbatim block does not get wrongly highlighted as some random language in the default theme with the default settings?

  5. waylan commented on Apr 18, 2016

    @waylan
    Contributor

    It sounds as if the "fix" you ask for would be a "fix" to the highlight.js library. In that case, the "bug" (incorrectly identifying plain text blocks) should be reported upstream to that library. If you would like a "fix" at the MkDocs level, then that falls under #467. In other words, any changes to MkDocs to address this issue would be the changes discussed in #467. Even if we were to make the drastic change of having highlighting disabled by default for all code blocks, the changes discussed in #467 would be how users would then enable/configure code highlighting. In the unlikely event that such a change was made, it would only happen after a provision to enable/configure code highlighting was available.

    My point is that unless I'm missing something obvious, any fix for this issue at the MkDocs level is directly connected with #467.

  6. obestwalter commented on Apr 18, 2016

    @obestwalter
    Author

    Do I understand this correctly then that unless #467 is resolved there is no way to prevent verbatim text like this (log output) being randomly highlighted using the available settings and any of the themes MkDocs ships with? Or is there something obvious that I (as a new user) am missing?

  7. waylan commented on Apr 18, 2016

    @waylan
    Contributor

    Per my comments on #467 you may be able to use a Markdown extension to trick things into working the way you want. Outside of that, yes #467 is it.

  8. obestwalter commented on Apr 18, 2016

    @obestwalter
    Author

    o.k. thanks for the clarification.

  9. astorm commented on Jul 20, 2019

    @astorm

    @obestwalter Hello from three plus years into the future! Did you ever find a pragmatic fix for this at any (read the docs, mkdocs, or highlight.js) level?

  10. obestwalter commented on Jul 20, 2019

    @obestwalter
    Author

    Using material theme by @squidfunk and explicitly declaring which highlighting you want in code blocks was basically what did the trick for me.

  11. astorm commented on Jul 20, 2019

    @astorm

    Thank you @obestwalter! I wasn't aware of that theme and it looks pretty nice.

    Also for anyone coming along later I ended up dropping an extra.css file into the docs folder with rules like this

    code.plaintext span.hljs-keyword,
    code.plaintext span.hljs-symbol,
    code.plaintext span.hljs-string
    {
        font-weight:normal;
        color:black;
    }
    

    Not ideal, but it worked. Annoying that highlight.js doesn't let you turn off its auto detection (or does it but MkDocs doesn't expose that? ¯\_(ツ)_/¯)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions