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

Provide a function to determine lang-mode #792

Open
gekoke opened this issue Aug 13, 2023 · 0 comments
Open

Provide a function to determine lang-mode #792

gekoke opened this issue Aug 13, 2023 · 0 comments

Comments

@gekoke
Copy link

gekoke commented Aug 13, 2023

Currently, the mode for fenced code blocks is determined using the markdown-code-lang-modes alist. It maps the first occuring word in the infostring to a language mode.

This is generally fine, however, the CommonMark Spec doesn't say that this is how the infostring MUST be used:

The first word of the info string is typically used to specify the language of the code sample, and rendered in the class attribute of the code tag. However, this spec does not mandate any particular treatment of the info string.

Therefore, it would be nice if the mode could be determined using a user-defined function that takes the infostring as input.

I specifically ran into this corner case when using this MDX plugin that was using the infostring to add a title attribute to code blocks using the format lang:title.

For example:

def foo():
    pass

I would want to use python-mode in this case, even though the first word is py:Python.

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