backstage / mkdocs-techdocs-core

The core MkDocs plugin used by Backstage's TechDocs as a wrapper around multiple MkDocs plugins and Python Markdown extensions
Apache License 2.0
83 stars 61 forks source link

feat: add language class to code blocks #59

Closed johanneswuerbach closed 2 years ago

johanneswuerbach commented 2 years ago

Simplify custom processing of code blocks by telling pymdown to add the language as class.

This option was added in pymdown-extensions 9.2 https://github.com/facelessuser/pymdown-extensions/pull/1596, but I've bumped to 9.3 instead, which is the last version that still supports pygments < 2.12

Related discussion: https://github.com/backstage/backstage/issues/4123#issuecomment-1111530166, cc @iamEAP

webark commented 1 year ago

@johanneswuerbach so since "mermaid" isn't a supported language by default, it just adds language-text, what's the way to add a new language for mermaid?

webark commented 1 year ago

ahh

markdown_extensions:
  - pymdownx.highlight:
      extend_pygments_lang:
        - name: mermaid
          lang: text

@iamEAP Is this something that it would be expected to be added to each mkdocs file? Is there a way to add this with an addon? Could we add this in the core?

johanneswuerbach commented 1 year ago

@webark might be also worth to comment in https://github.com/facelessuser/pymdown-extensions/pull/1702.

This was a proposed change to expose the language without any additional parsing, but was sadly rejected 🤔

webark commented 1 year ago

Hmmm.. I wonder if they would be open to a "unrecognized-language-" class. I'll try asking there.