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

SuperFences and CodeHilite problem #1604

Closed
4 tasks done
tjapro opened this issue Apr 15, 2020 · 2 comments
Closed
4 tasks done

SuperFences and CodeHilite problem #1604

tjapro opened this issue Apr 15, 2020 · 2 comments

Comments

@tjapro
Copy link

tjapro commented Apr 15, 2020

I checked that...

  • ... the documentation does not mention anything about my problem
  • ... the problem doesn't occur with the default MkDocs template
  • ... the problem is not in any of my customizations (CSS, JS, template)
  • ... there are no open or closed issues that are related to my problem

Description

I have a Mkdocs project with CodeHilite and SuperFences.
I notice that CodeHilite doesn't show anymore the line numbers (it is true globally).
So I remove one by one the extensions and plugins and discover that SuperFences somehow disables the line numbers.

See facelessuser/pymdown-extensions#893

A solution: an alert in documentation like "SuperFences is incompatible with CodeHilite; use Highlight instead".

PS: I made a test with SuperFences and Highlight and worked as expected.
Actual .yml:

...
  - pymdownx.highlight:
      linenums:          true
...

Expected behavior

In this case an alert in documentation.

Actual behavior

No alert.

Steps to reproduce the bug

  1. Add Super Fences and CodeHilite (activate the linenums in CodeHilite)
  2. Write some code inside ```
  3. No linenums appear.

Package versions

  • Python: Python 3.7.6
  • MkDocs: mkdocs, version 1.1
  • Material: Version: 5.1.0

Project configuration

...

# Configuration
theme:
  name:                  material
  custom_dir:            theme/
  language:              en
  features:
    - instant
    - tabs
  palette:
    primary:             black
    accent:              blue
  font:
    text:                Roboto
    code:                Fira Code
  logo:                  assets/img/logo/logo.svg
  favicon:               assets/img/logo/favicon.ico

...

# Extensions / Plugins
markdown_extensions:
  - admonition # notes make pretty
  - footnotes
  - meta # page-specific context
  - toc:
      permalink:         true # inserts an anchor
  - sane_lists # better ul and ol
  - nl2br # newline hard break
  - pymdownx.betterem:   # better italic and bold
      smart_enable:      asterisk
  - pymdownx.caret # insert text and superscript
  - pymdownx.details # details and summary; work with admonition
  - pymdownx.emoji:
      emoji_index:       !!python/name:pymdownx.emoji.twemoji
      emoji_generator:   !!python/name:pymdownx.emoji.to_svg
  - pymdownx.highlight:  # better code, instead of CodeHilite           <--------
      linenums:          true
  - pymdownx.inlinehilite # like codehilite but inline
  - pymdownx.magiclink # auto links
  - pymdownx.mark # highlight text
  - pymdownx.smartsymbols # special symbols
  - pymdownx.superfences: # nest code blocks under other blocks   <-------
  - pymdownx.tasklist:   # better tasks lists
      custom_checkbox:   true
  - pymdownx.tabbed # auto tabs
  - pymdownx.tilde # strike through cross out text

plugins:
  - search:
      prebuild_index:    true
  - localsearch:
      promise_delay:     100
  - minify:
      minify_html:       true
      htmlmin_opts:
        remove_comments: true
  - git-revision-date-localized
  - autolinks # for relative links to docs files
  - progress # to show the rendered files in console

System information

  • OS: Fedora 31
  • Browser: Google Chrome
@facelessuser
Copy link
Contributor

I'd like to clarify, SuperFences isn't incompatible with CodeHilite, it just doesn't use or care what you set for CodeHilite. They are separate highlighters. Now SuperFences and Python Markdown's fenced_code extension are incompatible and is noted in PyMdown Extensions docs: https://facelessuser.github.io/pymdown-extensions/usage_notes/#incompatible-extensions.

You can see that if I do this in my documents, that it will work just fine:

    #!pycon
    >>> import markdown
    >>> text = "A link https://google.com"
    >>> html = markdown.markdown(text, extensions=['pymdownx.magiclink'])
    '<p>A link <a href="https://google.com">https://google.com</a></p>'

```pycon
>>> import markdown
>>> text = "A link https://google.com"
>>> html = markdown.markdown(text, extensions=['pymdownx.magiclink'])
'<p>A link <a href="https://google.com">https://google.com</a></p>'
```

chrome_QpgpgJ9DD6

The colors are different in highlighting as my custom CSS does not bother to apply to CodeHilite's default class.

Anyways, with that said, if you are using SuperFences, I'm not sure why you'd want to mix the indented highlight style with language headers and the fenced style with language headers. I'd recommend that people pick their favorite (mine being SuperFences).

If we aren't already, it may make sense to make a note of this if we haven't already.

@tjapro
Copy link
Author

tjapro commented Apr 15, 2020

Thank you. In my case SuperFences ignored CodeHilite's linenums option.

If we aren't already, it may make sense to make a note of this if we haven't already.

Good!

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

3 participants