-
Apologies if this is already answered I tried searching but couldn't find anything. If I have code blocks in markdown files like this: echo "Hello World" The block has syntax highlighting in vscode and in the markdown preview window (as long as I use a language identifier after the backticks). But the printed output has no such coloring. Is this something I'm messing up or is it expected behavior ? I tried a few language identifiers but none seemed to have any effect. Thanks ! I'm attaching an example to illustrate what I mean. |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 1 reply
-
It's a good question. The short version is not currently but it's coming [back] soon. Historically we've hooked into the Markdown rendering pipeline VS Code uses for its built-in preview pane. The rationale was to allow Markdown extensions people install for use with the preview to also work with printing. A long time ago syntax colouring in fenced blocks did work, but despite my protests Microsoft's disregard for printing is so extreme it could be mistaken for antipathy. They don't seem to care if their decisions interfere with printing. I suppose from their point of view people who want printing are a fringe group. The CSS resources for the colouring are not available to an external web browser. We plan to abandon using the VS Code renderer and build our own pipeline. An ever more elaborate proof of concept exists, the core of which is a library called Marked. There are a lot of moving parts to extend it to support all the popular Markdown extensions but we're getting there. One consequence of all this is that we will be able to support syntax colouring in fenced code in rendered markdown. There will also be support for LaTeX, SMILES, mhchem and enhanced tables in which you can specify number formats. You've probably seen a table like this:
where the colon at the right hand end of the rule means the column should be right-aligned. We've decided to extend this so that if you use a digit in that position, it means right-aligned and it also specifies the number of decimal places to render, and if you use a $ there it means currency ie right-aligned with 2 decimal places. |
Beta Was this translation helpful? Give feedback.
-
The new rendering pipeline is released. Now I can look at handling source code in fenced blocks. |
Beta Was this translation helpful? Give feedback.
-
Source code highlighting is now supported in fenced blocks. Let me know if you have any questions. |
Beta Was this translation helpful? Give feedback.
-
Confirmed, working fine for me too (tried a few file types). You are awesome 🎆 |
Beta Was this translation helpful? Give feedback.
-
Well thank you. It's nice to get positive feedback, and it means more coming from people using the more advanced aspects. If you decide to write a review at some point, I have lots of "thank you" reviews, but people don't often discuss their use-case or why they find it more useful than, say, printing raw view on github. Incidentally, the new rendering pipeline just acquired support for 28 diagram engines, including PlantUML and Mermaid. One of my more demanding users wants support for include files in diagrams, apparently some extension to the built in renderer used to do this for PlantUML. This is actually an incredibly good idea, but for me it's the same amount of effort to do it for all the diagram types. So... Oh. we abandoned the table syntax extension but everything else I mentioned is already delivered. |
Beta Was this translation helpful? Give feedback.
-
Sorry to come really late to this, got busy with work, lost the open tab, eventually remembered. Tbh I don't have much a review - I'm a recent user of this extension. I started on a new, fairly difficult project and it helped me to print both a diagram of modules and relevant code snippets to arrange all nicely for my tired brain :) At this point I found something not working as expected I decided to ask. Visual helps me a lot so that's why I was searching for something nicer than the raw github print or similar. Also I spend a lot of time inside vscode these days so having this built in is nice. |
Beta Was this translation helpful? Give feedback.
Source code highlighting is now supported in fenced blocks. Let me know if you have any questions.