-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
writers: Recognize extra syntax definitions #7241
Conversation
Since Skylighting does not support Nix syntax, we need to add custom syntax definition using --syntax-definition flag, otherwise files with nix extension will be recognized as bash scripts by the default syntax map. This means that code blocks with nix class will end up with language=bash when converted to DocBook and other formats. Unfortunately, the writers always use the default syntax map so adding custom definition will not help. This patch corrects that, allowing the writers to see all custom definitions. The LaTeX reader suffers from the same issue but it has not been fixed there since it would require wider changes.
19f78d2
to
dd25f84
Compare
Fixed the |
[T.toLower (sName s) | s <- syntaxesByExtension defaultSyntaxMap (T.unpack ext)] | ||
languagesByExtension :: SyntaxMap -> T.Text -> [T.Text] | ||
languagesByExtension syntaxmap ext = | ||
[T.toLower (sName s) | s <- syntaxesByExtension syntaxmap (T.unpack ext)] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this would be a breaking API change. (Not a reason against, necessarily, but should be noted very clearly in the commit log.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I add something like + Text.Pandoc.Highlighting: languages and languagesByExtension now take an additional SyntaxMap argument. Get it from writerOpts or use Skylighting’s defaultSyntaxMap. [API change]
.
Or I can create new functions and make the old ones call them with defaultSyntaxMap
.
It looks good otherwise. I just merged it, and (doh!) forgot to add the commit message noted above. |
Also taking this opportunity to note, for the record, that the commit for #7241 should be marked [API change]. It changes the type of `languagesByExtension` in Highlighting, adding a parameter for a `SyntaxMap`.
Since Skylighting does not support Nix syntax, we need to add custom syntax definition using --syntax-definition flag, otherwise files with nix extension will be recognized as bash scripts by the default syntax map. This means that code blocks with nix class will end up with language=bash when converted to DocBook and other formats.
Unfortunately, the writers always use the default syntax map so adding custom definition will not help.
This patch corrects that, allowing the writers to see all custom definitions.
The LaTeX reader suffers from the same issue but it has not been fixed there since it would require wider changes.
Test