From f328ceef014a0bb36cdccb38e0c4b55b6bb68b09 Mon Sep 17 00:00:00 2001 From: D3-LucaPiombino Date: Sun, 1 Feb 2015 00:26:55 +0100 Subject: [PATCH] Enable syntax highlighting for code in the Markdown Preview - Replaced MarkdownSharp with CommonMark.net given that it support natively fenced code blocks. It also provide a more robust markdown specification that make markdown more predictable to write and parse. - Removed the setting that were used to customize MarkdownSharp behavior. - Added the ability for the user to define a custom html template that is used to display the markdown preview. Syntax highlighting can then be applied by using one of the many javascript libraries available on the web. Just include the required external dependecies (js,css, etc..) like one would have to do when hosting the markdown in a normal webpage. External resources can be pulled also directly from the web. The code will look for an html file called WE-Markdown.html first in the project folder and then in the solution folder. The same behavior has been extended to the WE-Markdown.css file. Four custom place holder are provided: {##SOLUTION_PATH_PLACEHOLDER##} {##PROJECT_PATH_PLACEHOLDER##} {##DOCUMENT_PATH_PLACEHOLDER##} {##MARKDOWN_HTML_PLACEHOLDER##} These placeholders can be used for instance to control where the external dependencies are pulled from. The base element is set in the default template generated by the menu item to {##DOCUMENT_PATH_PLACEHOLDER##}. This ensure the most confortable experience in VS, given that, for example, when an images is pasted or dragged into a markdown document, the generated path to the image is relative to the markdown document itself. - Added a menu to generate a default global solution html template (like the one for the custom stylesheet). Note that the generated html does not include any reference to a javascript library to provide syntax highlighting. The user will need to choose one and modify the template accordingly. - Added Code to try to automatically enable the internet features required to load and execute javascript in the embedded WebBrowser. A message will be printed in the visual studio output pane if something goes wrong. --- EditorExtensions/CommandConstants.cs | 1 + EditorExtensions/EditorExtensions.vsct | 9 + .../Markdown/Margin/MarkdownMargin.cs | 685 ++++++++++++++++-- .../Markdown/MenuItems/Markdown.cs | 20 +- EditorExtensions/Settings/LegacySettings.cs | 7 - EditorExtensions/Settings/WESettings.cs | 46 +- .../Shared/Compilers/CompilerRunner.cs | 7 +- EditorExtensions/WebEssentials2013.csproj | 7 +- EditorExtensions/packages.config | 1 + MarkdownSharp.dll | Bin 62464 -> 0 bytes WebEssentials2013.sln | 3 +- WebEssentialsTests/WebEssentialsTests.csproj | 4 - 12 files changed, 687 insertions(+), 103 deletions(-) delete mode 100644 MarkdownSharp.dll diff --git a/EditorExtensions/CommandConstants.cs b/EditorExtensions/CommandConstants.cs index cc61aa4af..4c3dd3c6e 100644 --- a/EditorExtensions/CommandConstants.cs +++ b/EditorExtensions/CommandConstants.cs @@ -114,6 +114,7 @@ enum CommandId CreateMarkdownStylesheet = 0x1046, CreateJavaScriptIntellisenseFile = 0x1047, CreateTypeScriptIntellisenseFile = 0x1048, + CreateMarkdownHtmlTemplate = 0x1102, MarkdownCompile = 0x1039, HandlebarsCompile = 0x1101, EditGlobalJsHint = 0x1038, diff --git a/EditorExtensions/EditorExtensions.vsct b/EditorExtensions/EditorExtensions.vsct index 9dfb1f000..b9cf6dd4a 100644 --- a/EditorExtensions/EditorExtensions.vsct +++ b/EditorExtensions/EditorExtensions.vsct @@ -457,6 +457,14 @@ + +