Search code examples
ms-wordmarkdown

How to insert Code to Word and save as MD - writage plugin drops code formatting


How does one format code snippets (in JavaScript, Java, C#, Etc...) in Word so they keep the formatting on save as MD with Writage plugin (or any other way)?

I copy form VS Code to Word, and it looks fine. What I would like to do is add line numbering in the code and shading of lines, and most importantly keep the original font / color format. Here is my word version after pasting code from VS Code:

Code in Word

and here is the MD file that is generated with Writage: (preview on the right)... the comments are not green, nor is func blue, font is different, etc Preview of MD via Writage plugin


Solution

  • Add three backqoute/backtick (```) at the beginning and at the end of your code snippet along with the language name.

    Input image

    Preview:

    Output image

    For more details: