nea / MarkdownViewerPlusPlus

A Notepad++ Plugin to view a Markdown file rendered on-the-fly
MIT License
1.17k stars 143 forks source link

[Feature Request] Markdown Literary Programming that don't break the syntax of any programming language #104

Open linpengcheng opened 5 years ago

linpengcheng commented 5 years ago

Issue description

Markdown Literary programming for compatible codes

Markdown to reproduce

Compatible code for Markdown literary programming. Just add a custom line comment character before each line of Markdown.

In the comments of code, you can draw flowcharts, tasklist, display data visualizations image, etc.

When previewing or converting a format, you only need to simply preprocess: replace the \r\n\\\\\ with \r\n

Note:

when we edit the code, we can preview the effect in real time. Editing literary code has a live preview like most markdown editors.

The editor has a Live Preview panel to do the following work:

  1. Get the current text

  2. replace the \r\n\; with \r\n

  3. live Preview markdown string

For example:


//# Markdown literary programming

//## example01:

//```csharp

////The comment of the code requires at least two line comment characters

public void PluginCleanUp()

{

this.configuration.Save();

}

//```


Screenshot

mdv


mv1

linpengcheng commented 5 years ago

Its advantages:

  1. It don't break the syntax of any programming language, you can compile directly. comment area markup method can be applied to any programming language and any markup (including Org,rst, asciidoc, etc.), which is the greatest advantage.

  2. you only need a single line of regular replacement preprocessing, then you can use any Markdown parse or converter.

  3. Support any code editor that supports Markdwon Live preview, allowing the source code of any programming language to become rich text in real time. In the code's comment area, You can use the markdown to draw flowcharts, tables, task lists, and display images on the live preview panel, enhance the readability of your code.

  4. If you extend the Markdwon tag, you can implement the eval code, print result, display data visualization and other instruction tags, to achieve live programming, live test.

linpengcheng commented 5 years ago

If you let the plug-in judge that the file extension is not . MD or . markdown,

elseif the line comment character is empty, it is treated as a normal text file. :

  1. Gets the current file text.
  2. get the line breaks and line comment char of the current file by notepad++ API.
  3. Regular expressions replace "line breaks and line comment char (for example, in C # is: \r\n\\\\)" with "line breaks(\r\n)" , then get standard Markdwon text.
    //reference MarkdownViewerPlusPlus:  MarkdownViewer.cs, AbstractRenderer.cs
    using System.Text.RegularExpressions;
    editor = new ScintillaGateway(PluginBase.GetCurrentScintilla());
    txt = editor.GetText(editor.GetLength() + 1);
    markdown_txt = Replace(txt, "\r\n\\\\","\r\n");
    Markdig.Markdown.ToHtml(markdown_txt, this.markdownPipeline);
  4. convert markdown to html with Markdown Library
  5. Preview html.

    I am not a .net programmer, is a clojure language programmer, not installing vs, Compiling this project with msbuild.exe failed.

linpengcheng commented 5 years ago

Now, I have a temporary NPP solution and patch.