NppMarkdownPanel icon indicating copy to clipboard operation
NppMarkdownPanel copied to clipboard

[Feature Request] YAML and Code Block Syntax Highlighting

Open whoibrar opened this issue 3 years ago • 1 comments

Context :

  • Front Matter is added to .md files by Jekyll and many other services

Request :

  • Render with Syntax Highlighting for
    • YAML in FrontMatter
    • And Code Blocks

Images:

Left Side Source File Right Side Rendered View

How it is looks in Obsidian

Obsidian

How it is looks in NPP

NPP

Issue

  • Without proper syntax highlighting it breaks the format for YAML
  • The code blocks are hard to read

whoibrar avatar Jun 23 '22 17:06 whoibrar

I used highlight.js but it doesn't work in NPP, it can only be converted to html and read in Chrome.😒

914802951 avatar Jul 19 '22 05:07 914802951

Possible solution is to use Markdig extension markdown-colorcode which uses ColorCode-Universal.

Seems pretty simple to just add to the pipeline in 'nppMarkdownPanel\MarkdigWrapper\MarkdigMarkdownGenerator.cs'

27:         public string ConvertToHtml(string markDownText, string filepath)
28:         {
29:             var pipeline = new MarkdownPipelineBuilder()
30:                 .UseAdvancedExtensions()
+                   .UseColorCode() 
31:                 .UsePreciseSourceLocation()
32:                 .Build();

Then just having to figure out how to include in the build and distribute the proper assemblies.

Cheers.

vinsworldcom avatar Dec 08 '22 12:12 vinsworldcom

That sounds straightforward. I will add the ColorCode lib for the next release.

mohzy83 avatar Dec 08 '22 14:12 mohzy83

This feature is now partly implemented in version 0.7.0. Fenced code blocks will be highlighted. grafik becomes: grafik

The markdig extension https://github.com/RichardSlater/Markdig.SyntaxHighlighting is being used.

The parsing of the Frontmatter block (with YAML) needs more investigation. By default markdig will remove that block from the output, when using new MarkdownPipelineBuilder().UseYamlFrontMatter(). Maybe it can be converted to a standard "code block", but that has to be implemented.

mohzy83 avatar Dec 10 '22 14:12 mohzy83

In version 0.7.1 YAML Frontmatter blocks are rendered as standard code blocks (no syntax highlighting yet). grafik grafik

mohzy83 avatar Dec 27 '22 16:12 mohzy83

closing this issue in favor of a new issue, concerning the support of further languages

mohzy83 avatar Dec 29 '22 20:12 mohzy83