-
Notifications
You must be signed in to change notification settings - Fork 198
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
Syntax highlight doesn't support fenced code block #98
Comments
Confirmed, though it would require serious highlighter refactoring since it only operates on individual lines currently. Original comment by: mandriver |
I saw #253 and thought fenced code blocks are not supported by markdown, only by commonmark? The original markdown page does not mention it. Anyway I have a more complex example. A fenced code block within a list. I'm using retext 7.2.3. If you paste it as comment, Github renders it as intended. |
Hi @emanuel-th!
The fenced code blocks are not part of the standard Markdown syntax, however Python-Markdown supports them via the Fenced Code Blocks extension. And in ReText, the Extra extension set (which includes fenced_code) is enabled by default.
As the documentation of the Fenced Code extension says, Warning Fenced Code Blocks are only supported at the document root level. Therefore, they cannot be nested inside lists or blockquotes. If you need to nest fenced code blocks, you may want to try the third party extension SuperFences instead. So, indeed, SuperFences should solve the problem of using the fenced code block in a list. See our wiki for details on how to enable extensions.
Yes, in order for something to be appended to a list item, it needs to be indented with 4 spaces. Otherwise it is not part of the list. Alternatively, you can use normal code blocks. For that, you need 8 spaces indentation (first 4 for a list item and another 4 for a code block). So, this will render as you expect: 1. some bash file
#!/bin/bash
echo "Hello World!"
2. second headline |
I'd prefer 4 space indent. But I have to convince all colleagues first. :) I don't get superfences to work. I installed the extention with pip3. In python console I can "import pymdownx.superfences" without problems. Any way to debug this? |
There was a bug in interaction between mdx_posmap (used for synchronized scrolling) and superfences in lists. I fixed it in master branch, commit 8bd8f58. Any chance you could try the version from master? |
Tested it, still produces a heading. |
Can you paste or attach your Markdown file, please? |
Same as above. |
I mean, can you show me your Markdown source file? Either by attaching it here, or at least by providing a screenshot. Ideally, please also attach the generated HTML (either by copying it from “View HTML code” dialog or by exporting to a file). If the file cannot be shared, maybe you can try to make a minimal synthetic example that triggers this problem? |
html files: "We don’t support that file type." Using gist. When pasting html there it adds the empty lines. |
Your input file produces the correct result with ReText version from master branch (e72f17c): I notice that your HTML file has this line: <meta name="generator" content="ReText 7.2.3"> which means you are using an older version. The version from master will identify itself as Anyway, the next stable release will include this fix. |
I'm using a python env to run it. Maybe I did it wrong at some point. It only works sometimes. I simple do: open retext, open the file, hit preview. |
Right, I can reproduce this. It looks like it depends on the order in which extensions are applied: both To solve this, add the virtual
This way it should work always. Also, I will try to make the order of extensions deterministic, to handle similar situations better. |
Although the parser supports fenced code block, the syntax highlighter seems not.
e.g.
Reported by: colinfang
Original Ticket: retext/tickets/98
The text was updated successfully, but these errors were encountered: