From 0d80def72aeeb9dcb40b5fd04e578fd784304a09 Mon Sep 17 00:00:00 2001 From: VinsWorldcom Date: Wed, 19 May 2021 12:39:13 -0400 Subject: [PATCH 01/15] version bump --- NppMarkdownPanel/Properties/AssemblyInfo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NppMarkdownPanel/Properties/AssemblyInfo.cs b/NppMarkdownPanel/Properties/AssemblyInfo.cs index 0f8d51c..644cfc1 100644 --- a/NppMarkdownPanel/Properties/AssemblyInfo.cs +++ b/NppMarkdownPanel/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.6.3.*")] -[assembly: AssemblyFileVersion("0.6.3.1")] +[assembly: AssemblyVersion("0.6.4.*")] +[assembly: AssemblyFileVersion("0.6.4.1")] From 2a861e1124dbe4943965e32d7546852e0a51e784 Mon Sep 17 00:00:00 2001 From: VinsWorldcom Date: Wed, 19 May 2021 12:39:41 -0400 Subject: [PATCH 02/15] PoC for Perl pod2html --- NppMarkdownPanel/MarkdownPanelController.cs | 32 +++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/NppMarkdownPanel/MarkdownPanelController.cs b/NppMarkdownPanel/MarkdownPanelController.cs index b5a824a..ae880a3 100644 --- a/NppMarkdownPanel/MarkdownPanelController.cs +++ b/NppMarkdownPanel/MarkdownPanelController.cs @@ -2,6 +2,7 @@ using NppMarkdownPanel.Forms; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Drawing; using System.Drawing.Imaging; using System.IO; @@ -133,6 +134,18 @@ private bool ValidateHtmlExtension() return false; } + private bool ValidatePerlExtension() + { + StringBuilder sbFileExtension = new StringBuilder(Win32.MAX_PATH); + Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_GETEXTPART, Win32.MAX_PATH, sbFileExtension); + var fileExtension = sbFileExtension.ToString(); + + if (".pl,.pm".Contains(fileExtension.ToLower())) + return true; + else + return false; + } + protected void UpdateEditorInformation() { scintillaGateway.SetScintillaHandle(PluginBase.GetCurrentScintilla()); @@ -160,6 +173,25 @@ private void OnRenderTimerElapsed(object source, EventArgs e) markdownPreviewForm.RenderMarkdown(GetCurrentEditorText(), notepadPPGateway.GetCurrentFilePath()); else if (ValidateHtmlExtension()) markdownPreviewForm.RenderHtml(GetCurrentEditorText(), notepadPPGateway.GetCurrentFilePath()); + else if (ValidatePerlExtension()) + { + var process = new Process + { + StartInfo = new ProcessStartInfo + { + FileName = "pod2html.bat", + Arguments = $"--css C:/usr/bin/npp64/plugins/NppMarkdownPanel/style.css {notepadPPGateway.GetCurrentFilePath()}", + UseShellExecute = false, + RedirectStandardOutput = true, + CreateNoWindow = true + } + }; + + process.Start(); + string data = process.StandardOutput.ReadToEnd(); + process.WaitForExit(); + markdownPreviewForm.RenderHtml(data, notepadPPGateway.GetCurrentFilePath()); + } else markdownPreviewForm.RenderMarkdown($"Not a valid Markdown file extension: {MkdnExtensions}\n\nNot a valid HTML file extension: {HtmlExtensions}", notepadPPGateway.GetCurrentFilePath()); } From ecae7580b521c8c1da590bb02180ff5ff2d10962 Mon Sep 17 00:00:00 2001 From: VinsWorldcom Date: Wed, 19 May 2021 14:33:38 -0400 Subject: [PATCH 03/15] variables for filter program and args --- NppMarkdownPanel/MarkdownPanelController.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/NppMarkdownPanel/MarkdownPanelController.cs b/NppMarkdownPanel/MarkdownPanelController.cs index ae880a3..af6e029 100644 --- a/NppMarkdownPanel/MarkdownPanelController.cs +++ b/NppMarkdownPanel/MarkdownPanelController.cs @@ -175,12 +175,14 @@ private void OnRenderTimerElapsed(object source, EventArgs e) markdownPreviewForm.RenderHtml(GetCurrentEditorText(), notepadPPGateway.GetCurrentFilePath()); else if (ValidatePerlExtension()) { + var filterProgram = "pod2html.bat"; + var filterArguments = "--css C:/usr/bin/npp64/plugins/NppMarkdownPanel/style.css"; var process = new Process { StartInfo = new ProcessStartInfo { - FileName = "pod2html.bat", - Arguments = $"--css C:/usr/bin/npp64/plugins/NppMarkdownPanel/style.css {notepadPPGateway.GetCurrentFilePath()}", + FileName = filterProgram, + Arguments = $"{filterArguments} {notepadPPGateway.GetCurrentFilePath()}", UseShellExecute = false, RedirectStandardOutput = true, CreateNoWindow = true From 54605cb6724331e30f1bafdc721aa7d90132ab6d Mon Sep 17 00:00:00 2001 From: VinsWorldcom Date: Wed, 19 May 2021 15:39:13 -0400 Subject: [PATCH 04/15] clean up code --- NppMarkdownPanel/MarkdownPanelController.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/NppMarkdownPanel/MarkdownPanelController.cs b/NppMarkdownPanel/MarkdownPanelController.cs index af6e029..532c5ec 100644 --- a/NppMarkdownPanel/MarkdownPanelController.cs +++ b/NppMarkdownPanel/MarkdownPanelController.cs @@ -54,8 +54,11 @@ public void OnNotification(ScNotification notification) { if (isPanelVisible) { - if (notification.Header.Code == (uint)SciMsg.SCN_UPDATEUI && (ValidateMkdnExtension() || ValidateHtmlExtension())) + if (notification.Header.Code == (uint)SciMsg.SCN_UPDATEUI) { + if ( ! (ValidateMkdnExtension() || ValidateHtmlExtension()) ) + return; + var firstVisible = scintillaGateway.GetFirstVisibleLine(); var buffer = scintillaGateway.LinesOnScreen()/2; var lastLine = scintillaGateway.GetLineCount(); @@ -90,8 +93,7 @@ public void OnNotification(ScNotification notification) } } } - else - if (notification.Header.Code == (uint)NppMsg.NPPN_BUFFERACTIVATED) + else if (notification.Header.Code == (uint)NppMsg.NPPN_BUFFERACTIVATED) { UpdateEditorInformation(); RenderMarkdown(); From da12f5f96dced38a675fa6568ad22f571835dff8 Mon Sep 17 00:00:00 2001 From: VinsWorldcom Date: Wed, 19 May 2021 15:46:35 -0400 Subject: [PATCH 05/15] SCN_MODIFY only render on MD or HTML, NPPN_FILESAVED render in all cases --- NppMarkdownPanel/MarkdownPanelController.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/NppMarkdownPanel/MarkdownPanelController.cs b/NppMarkdownPanel/MarkdownPanelController.cs index 532c5ec..c9f5ef5 100644 --- a/NppMarkdownPanel/MarkdownPanelController.cs +++ b/NppMarkdownPanel/MarkdownPanelController.cs @@ -105,10 +105,17 @@ public void OnNotification(ScNotification notification) // // Any modifications made ? // if (isInsert || isDelete) // { + if ( ValidateMkdnExtension() || ValidateHtmlExtension() ) + { lastTickCount = Environment.TickCount; RenderMarkdown(); + } // } } + else if (notification.Header.Code == (uint)NppMsg.NPPN_FILESAVED) + { + RenderMarkdown(); + } } } From 55c07beb81d20df9c7241d1f630684dbce798129 Mon Sep 17 00:00:00 2001 From: VinsWorldcom Date: Wed, 19 May 2021 17:10:11 -0400 Subject: [PATCH 06/15] read single filter from INI file - need to get loop working --- NppMarkdownPanel/MarkdownPanelController.cs | 28 ++++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/NppMarkdownPanel/MarkdownPanelController.cs b/NppMarkdownPanel/MarkdownPanelController.cs index c9f5ef5..02b7f71 100644 --- a/NppMarkdownPanel/MarkdownPanelController.cs +++ b/NppMarkdownPanel/MarkdownPanelController.cs @@ -40,6 +40,10 @@ public class MarkdownPanelController private bool syncViewWithCaretPosition; private bool syncViewWithScrollPosition; + private string filterExts; + private string filterProgs; + private string filterArgs; + public MarkdownPanelController() { scintillaGateway = new ScintillaGateway(PluginBase.GetCurrentScintilla()); @@ -143,13 +147,13 @@ private bool ValidateHtmlExtension() return false; } - private bool ValidatePerlExtension() + private bool ValidateFilterExtension() { StringBuilder sbFileExtension = new StringBuilder(Win32.MAX_PATH); Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_GETEXTPART, Win32.MAX_PATH, sbFileExtension); var fileExtension = sbFileExtension.ToString(); - if (".pl,.pm".Contains(fileExtension.ToLower())) + if (filterExts.Contains(fileExtension.ToLower())) return true; else return false; @@ -182,10 +186,10 @@ private void OnRenderTimerElapsed(object source, EventArgs e) markdownPreviewForm.RenderMarkdown(GetCurrentEditorText(), notepadPPGateway.GetCurrentFilePath()); else if (ValidateHtmlExtension()) markdownPreviewForm.RenderHtml(GetCurrentEditorText(), notepadPPGateway.GetCurrentFilePath()); - else if (ValidatePerlExtension()) + else if (ValidateFilterExtension()) { - var filterProgram = "pod2html.bat"; - var filterArguments = "--css C:/usr/bin/npp64/plugins/NppMarkdownPanel/style.css"; + var filterProgram = filterProgs; + var filterArguments = filterArgs; var process = new Process { StartInfo = new ProcessStartInfo @@ -197,7 +201,7 @@ private void OnRenderTimerElapsed(object source, EventArgs e) CreateNoWindow = true } }; - + process.Start(); string data = process.StandardOutput.ReadToEnd(); process.WaitForExit(); @@ -239,6 +243,18 @@ public void InitCommandMenu() HtmlExtensions = Win32.ReadIniValue("Options", "HtmlExtensions", iniFilePath, ".html,.htm"); markdownPreviewForm.HtmlFileName = Win32.ReadIniValue("Options", "HtmlFileName", iniFilePath); markdownPreviewForm.ShowToolbar = Utils.ReadIniBool("Options", "ShowToolbar", iniFilePath); + + var i = 0; + // for ( int i = 0; i <= 50; i++ ) + // { + var section = $"Filter{i}"; + filterExts = Win32.ReadIniValue(section, "Extensions", iniFilePath, "!!!"); + filterProgs = Win32.ReadIniValue(section, "Program", iniFilePath, "!!!"); + filterArgs = Win32.ReadIniValue(section, "Arguments", iniFilePath, "!!!"); + // if ( filterExts[i].Contains("!!!") ) + // break; + // } + PluginBase.SetCommand(0, "Toggle &Markdown Panel", TogglePanelVisible); PluginBase.SetCommand(1, "Synchronize with &caret position", SyncViewWithCaret, syncViewWithCaretPosition); PluginBase.SetCommand(2, "Synchronize on &vertical scroll", SyncViewWithScroll, syncViewWithScrollPosition); From d25e4aabdfa9ff9255532e7ed7c16d5367ccc9a2 Mon Sep 17 00:00:00 2001 From: VinsWorldcom Date: Wed, 19 May 2021 17:22:41 -0400 Subject: [PATCH 07/15] closer still - TODO: loop to test filter exts for the one to use --- NppMarkdownPanel/MarkdownPanelController.cs | 32 ++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/NppMarkdownPanel/MarkdownPanelController.cs b/NppMarkdownPanel/MarkdownPanelController.cs index 02b7f71..87413fd 100644 --- a/NppMarkdownPanel/MarkdownPanelController.cs +++ b/NppMarkdownPanel/MarkdownPanelController.cs @@ -40,9 +40,9 @@ public class MarkdownPanelController private bool syncViewWithCaretPosition; private bool syncViewWithScrollPosition; - private string filterExts; - private string filterProgs; - private string filterArgs; + private string[] filterExts = new string[10]; + private string[] filterProgs = new string[10]; + private string[] filterArgs = new string[10]; public MarkdownPanelController() { @@ -149,11 +149,12 @@ private bool ValidateHtmlExtension() private bool ValidateFilterExtension() { +// TODO:20210519:MVINCENT: for loop here on FilterExts and change return to -1 on fail, index of filterExts on success StringBuilder sbFileExtension = new StringBuilder(Win32.MAX_PATH); Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_GETEXTPART, Win32.MAX_PATH, sbFileExtension); var fileExtension = sbFileExtension.ToString(); - if (filterExts.Contains(fileExtension.ToLower())) + if (filterExts[0].Contains(fileExtension.ToLower())) return true; else return false; @@ -188,8 +189,8 @@ private void OnRenderTimerElapsed(object source, EventArgs e) markdownPreviewForm.RenderHtml(GetCurrentEditorText(), notepadPPGateway.GetCurrentFilePath()); else if (ValidateFilterExtension()) { - var filterProgram = filterProgs; - var filterArguments = filterArgs; + var filterProgram = filterProgs[0]; + var filterArguments = filterArgs[0]; var process = new Process { StartInfo = new ProcessStartInfo @@ -244,16 +245,15 @@ public void InitCommandMenu() markdownPreviewForm.HtmlFileName = Win32.ReadIniValue("Options", "HtmlFileName", iniFilePath); markdownPreviewForm.ShowToolbar = Utils.ReadIniBool("Options", "ShowToolbar", iniFilePath); - var i = 0; - // for ( int i = 0; i <= 50; i++ ) - // { - var section = $"Filter{i}"; - filterExts = Win32.ReadIniValue(section, "Extensions", iniFilePath, "!!!"); - filterProgs = Win32.ReadIniValue(section, "Program", iniFilePath, "!!!"); - filterArgs = Win32.ReadIniValue(section, "Arguments", iniFilePath, "!!!"); - // if ( filterExts[i].Contains("!!!") ) - // break; - // } + for ( int i = 0; i < 10; i++ ) + { + var section = $"Filter{i}"; + filterExts[i] = Win32.ReadIniValue(section, "Extensions", iniFilePath, "!!!"); + filterProgs[i] = Win32.ReadIniValue(section, "Program", iniFilePath, "!!!"); + filterArgs[i] = Win32.ReadIniValue(section, "Arguments", iniFilePath, "!!!"); + if ( filterExts[i].Contains("!!!") ) + break; + } PluginBase.SetCommand(0, "Toggle &Markdown Panel", TogglePanelVisible); PluginBase.SetCommand(1, "Synchronize with &caret position", SyncViewWithCaret, syncViewWithCaretPosition); From f181e5084bf44ea12c6a262bbf9a3459a9e46880 Mon Sep 17 00:00:00 2001 From: VinsWorldcom Date: Wed, 19 May 2021 18:18:29 -0400 Subject: [PATCH 08/15] define FILTERS size --- NppMarkdownPanel/MarkdownPanelController.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/NppMarkdownPanel/MarkdownPanelController.cs b/NppMarkdownPanel/MarkdownPanelController.cs index 87413fd..3161ca9 100644 --- a/NppMarkdownPanel/MarkdownPanelController.cs +++ b/NppMarkdownPanel/MarkdownPanelController.cs @@ -40,9 +40,10 @@ public class MarkdownPanelController private bool syncViewWithCaretPosition; private bool syncViewWithScrollPosition; - private string[] filterExts = new string[10]; - private string[] filterProgs = new string[10]; - private string[] filterArgs = new string[10]; + private const int FILTERS = 10; + private string[] filterExts = new string[FILTERS]; + private string[] filterProgs = new string[FILTERS]; + private string[] filterArgs = new string[FILTERS]; public MarkdownPanelController() { @@ -245,7 +246,7 @@ public void InitCommandMenu() markdownPreviewForm.HtmlFileName = Win32.ReadIniValue("Options", "HtmlFileName", iniFilePath); markdownPreviewForm.ShowToolbar = Utils.ReadIniBool("Options", "ShowToolbar", iniFilePath); - for ( int i = 0; i < 10; i++ ) + for ( int i = 0; i < FILTERS; i++ ) { var section = $"Filter{i}"; filterExts[i] = Win32.ReadIniValue(section, "Extensions", iniFilePath, "!!!"); From 3d2dd7b3aef2610db80ac2f9ae08f8f5d8c05485 Mon Sep 17 00:00:00 2001 From: VinsWorldcom Date: Wed, 19 May 2021 18:47:52 -0400 Subject: [PATCH 09/15] First Fully Working PoC, manully configure Filter# in .ini file --- NppMarkdownPanel/MarkdownPanelController.cs | 57 ++++++++++++--------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/NppMarkdownPanel/MarkdownPanelController.cs b/NppMarkdownPanel/MarkdownPanelController.cs index 3161ca9..169f760 100644 --- a/NppMarkdownPanel/MarkdownPanelController.cs +++ b/NppMarkdownPanel/MarkdownPanelController.cs @@ -44,6 +44,7 @@ public class MarkdownPanelController private string[] filterExts = new string[FILTERS]; private string[] filterProgs = new string[FILTERS]; private string[] filterArgs = new string[FILTERS]; + private int filterFound = 0; public MarkdownPanelController() { @@ -148,17 +149,18 @@ private bool ValidateHtmlExtension() return false; } - private bool ValidateFilterExtension() + private int ValidateFilterExtension() { -// TODO:20210519:MVINCENT: for loop here on FilterExts and change return to -1 on fail, index of filterExts on success StringBuilder sbFileExtension = new StringBuilder(Win32.MAX_PATH); Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_GETEXTPART, Win32.MAX_PATH, sbFileExtension); var fileExtension = sbFileExtension.ToString(); - if (filterExts[0].Contains(fileExtension.ToLower())) - return true; - else - return false; + for ( int i = 0; i < filterFound; i++ ) + { + if (filterExts[i].Contains(fileExtension.ToLower())) + return i; + } + return -1; } protected void UpdateEditorInformation() @@ -188,29 +190,33 @@ private void OnRenderTimerElapsed(object source, EventArgs e) markdownPreviewForm.RenderMarkdown(GetCurrentEditorText(), notepadPPGateway.GetCurrentFilePath()); else if (ValidateHtmlExtension()) markdownPreviewForm.RenderHtml(GetCurrentEditorText(), notepadPPGateway.GetCurrentFilePath()); - else if (ValidateFilterExtension()) + else { - var filterProgram = filterProgs[0]; - var filterArguments = filterArgs[0]; - var process = new Process + int filter = ValidateFilterExtension(); + if ( filter >= 0 ) { - StartInfo = new ProcessStartInfo + var filterProgram = filterProgs[filter]; + var filterArguments = filterArgs[filter]; + var process = new Process { - FileName = filterProgram, - Arguments = $"{filterArguments} {notepadPPGateway.GetCurrentFilePath()}", - UseShellExecute = false, - RedirectStandardOutput = true, - CreateNoWindow = true - } - }; - - process.Start(); - string data = process.StandardOutput.ReadToEnd(); - process.WaitForExit(); - markdownPreviewForm.RenderHtml(data, notepadPPGateway.GetCurrentFilePath()); + StartInfo = new ProcessStartInfo + { + FileName = filterProgram, + Arguments = $"{filterArguments} {notepadPPGateway.GetCurrentFilePath()}", + UseShellExecute = false, + RedirectStandardOutput = true, + CreateNoWindow = true + } + }; + + process.Start(); + string data = process.StandardOutput.ReadToEnd(); + process.WaitForExit(); + markdownPreviewForm.RenderHtml(data, notepadPPGateway.GetCurrentFilePath()); + } + else + markdownPreviewForm.RenderMarkdown($"Not a valid Markdown file extension: {MkdnExtensions}\n\nNot a valid HTML file extension: {HtmlExtensions}", notepadPPGateway.GetCurrentFilePath()); } - else - markdownPreviewForm.RenderMarkdown($"Not a valid Markdown file extension: {MkdnExtensions}\n\nNot a valid HTML file extension: {HtmlExtensions}", notepadPPGateway.GetCurrentFilePath()); } catch { @@ -254,6 +260,7 @@ public void InitCommandMenu() filterArgs[i] = Win32.ReadIniValue(section, "Arguments", iniFilePath, "!!!"); if ( filterExts[i].Contains("!!!") ) break; + filterFound++; } PluginBase.SetCommand(0, "Toggle &Markdown Panel", TogglePanelVisible); From 4655b982a55d570bc05aa00d8586d112a1c10532 Mon Sep 17 00:00:00 2001 From: VinsWorldcom Date: Wed, 19 May 2021 19:10:06 -0400 Subject: [PATCH 10/15] update README.md --- README.md | 84 +++++++++++++++++++++---------------------------------- 1 file changed, 32 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index b2e5821..d397476 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,25 @@ Plugin to preview Markdown files in Notepad++ ### Current Version -My ([VinsWorldcom](https://github.com/VinsWorldcom/NppMarkdownPanel)) changes to [UrsineRaven's repo](https://github.com/UrsineRaven/NppMarkdownPanel) can be found in the [version history](#version-history) below. -The current version with my modifications can be found [here](https://github.com/VinsWorldcom/NppMarkdownPanel/releases) +My ([VinsWorldcom](https://github.com/VinsWorldcom/NppMarkdownPanel)) changes to [UrsineRaven's repo](https://github.com/UrsineRaven/NppMarkdownPanel) can be found [here](https://github.com/VinsWorldcom/NppMarkdownPanel/releases) + +The plugin renders Markdown as HTML and provides a viewer. The plugin can also +render HTML documents. Additionally, 10 filters can be created manually in the +configuration file to render documents to HTML for viewing. For example: + +``` +[Filter0] +Extensions=.pl,.pm +Program=pod2html.bat +Arguments="--css C:\notepad++\plugins\NppMarkdownPanel\style.css" +``` + +will render Perl POD to HTML and display in the viewer panel. There are some +limitations with filters. The rendered views do not synchronize scrolling no +matter what the plugin menu setting is and they do not update "live" with typing, +only update after document save. + + + ### Used libs and icons Using **Markdig** v 0.16.0 by xoofx - [https://github.com/lunet-io/markdig](https://github.com/lunet-io/markdig) @@ -66,65 +85,26 @@ To open the settings for this plugin: Plugins -> NppMarkdownPanel -> Edit Settin * #### Show Toolbar in Preview Window Checking this box will enable the toolbar in the preview window. By default, this is unchecked. +* #### Markdown Extensions + A comma-separated list of file extensions to recognize as Markdown (default = `.md,.mkdn,.mkd`) + +* #### HTML Extensions + A comma-separated list of file extensions to recognize as HTML (default = `.html,.htm`) + ### Preview Window Toolbar * #### Save As... (![save-btn](help/save-btn.png "Picture of the Save button on the preview panel toolbar")) Clicking this button allows you to save the rendered preview as an HTML document. -### Synchronize viewer with caret position - -Enabling this in the plugin's menu (Plugins -> NppMarkdownPanel) makes the preview panel stay in sync with the caret in the markdown document that is being edited. -This is similar to the _Synchronize Vertical Scrolling_ option of Notepad++ for keeping two open editing panels scrolling together. - - -## Version History +### Synchronize with caret position -Refer to Git commit history for latest changes. - -### VinsWorldcom (Version 0.6.2.1) -- now previews / parses HTML files natively -- fix statusbar overlay issue in preview panel - -### VinsWorldcom (Version 0.6.1.1) -- rename plugin menu to "Markdown Panel" -- add status bar to panel for mouse-over URL status -- add file extensions to settings dialogue -- sync view with vertical scroll option -- bugfix: now parses when document is in Scintilla second view -- bugfix: automatically update view when typing in N++ - -### UrsineRaven change set 1 (Version 0.5.0.1) -- add ability to save the preview to HTML document - - can automatically save every time it's rendered - - can show a toolbar on the preview panel to allow saving on button click -- add settings to settings window to allow: - - selecting the file for automatic saving - - enabling/disabling the preview panel toolbar - - added some basic validation for some of the fields -- updated README.md - - added a section describing the Settings options - - added my changes to version history - -### Version 0.5.0 -- change zoomlevel for the preview in settings dialog -- change css file for the markdown style -- the new settings are persistent -- open settings dialog: Plugins-> NppMarkdownPanel -> Edit Settings -![npp-settings](help/open-settings.png "open settings dialog") - -### Version 0.4.0 -- switched from CommonMark.Net to markdig rendering library - -### Version 0.3.0 -- synchronize viewer with caret position - -### Version 0.2.0 -- Initial release +Enabling this in the plugin's menu (Plugins -> Markdown Panel) makes the preview panel stay in sync with the caret in the markdown document that is being edited. This is similar to the _Synchronize Vertical Scrolling_ option of Notepad++ for keeping two open editing panels scrolling together. +![npp-sync-caret](help/sync_caret.gif "Synchronize viewer with caret position") -### Feature - Synchronize viewer with caret position +### Synchronize on vertical scroll -![npp-sync-caret](help/sync_caret.gif "Synchronize viewer with caret position") +Enabling this in the plugin's menu (Plugins -> Markdown Panel) attempts to do a better job at synchronizing scrolling between the preview panel and the document that is being edited without the need for caret movement (in other words, just using scrollbars should sync too). ## License From ff91641a6179fd5a16b13b869687a4584c0e9c37 Mon Sep 17 00:00:00 2001 From: VinsWorldcom Date: Wed, 19 May 2021 21:25:01 -0400 Subject: [PATCH 11/15] handle spaces in file path/names --- NppMarkdownPanel/MarkdownPanelController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NppMarkdownPanel/MarkdownPanelController.cs b/NppMarkdownPanel/MarkdownPanelController.cs index 169f760..d7c55df 100644 --- a/NppMarkdownPanel/MarkdownPanelController.cs +++ b/NppMarkdownPanel/MarkdownPanelController.cs @@ -202,7 +202,7 @@ private void OnRenderTimerElapsed(object source, EventArgs e) StartInfo = new ProcessStartInfo { FileName = filterProgram, - Arguments = $"{filterArguments} {notepadPPGateway.GetCurrentFilePath()}", + Arguments = $"{filterArguments} \"{notepadPPGateway.GetCurrentFilePath()}\"", UseShellExecute = false, RedirectStandardOutput = true, CreateNoWindow = true From e6c42a2f80213a772b77ae78069f5d7732164fbd Mon Sep 17 00:00:00 2001 From: VinsWorldcom Date: Wed, 19 May 2021 21:34:11 -0400 Subject: [PATCH 12/15] fix no file extension always rendering bug --- NppMarkdownPanel/MarkdownPanelController.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/NppMarkdownPanel/MarkdownPanelController.cs b/NppMarkdownPanel/MarkdownPanelController.cs index d7c55df..850338d 100644 --- a/NppMarkdownPanel/MarkdownPanelController.cs +++ b/NppMarkdownPanel/MarkdownPanelController.cs @@ -130,6 +130,8 @@ private bool ValidateMkdnExtension() StringBuilder sbFileExtension = new StringBuilder(Win32.MAX_PATH); Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_GETEXTPART, Win32.MAX_PATH, sbFileExtension); var fileExtension = sbFileExtension.ToString(); + if ( String.IsNullOrEmpty(fileExtension) ) + return false; if (MkdnExtensions.ToLower().Contains(fileExtension.ToLower())) return true; @@ -142,6 +144,8 @@ private bool ValidateHtmlExtension() StringBuilder sbFileExtension = new StringBuilder(Win32.MAX_PATH); Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_GETEXTPART, Win32.MAX_PATH, sbFileExtension); var fileExtension = sbFileExtension.ToString(); + if ( String.IsNullOrEmpty(fileExtension) ) + return false; if (HtmlExtensions.ToLower().Contains(fileExtension.ToLower())) return true; @@ -154,6 +158,8 @@ private int ValidateFilterExtension() StringBuilder sbFileExtension = new StringBuilder(Win32.MAX_PATH); Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_GETEXTPART, Win32.MAX_PATH, sbFileExtension); var fileExtension = sbFileExtension.ToString(); + if ( String.IsNullOrEmpty(fileExtension) ) + return -1; for ( int i = 0; i < filterFound; i++ ) { From c0cfdbee9a9ed2777d13c086d3dcf68003be41f5 Mon Sep 17 00:00:00 2001 From: VinsWorldcom Date: Wed, 19 May 2021 21:46:18 -0400 Subject: [PATCH 13/15] remove double quotes from filter example in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d397476..d532af5 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ configuration file to render documents to HTML for viewing. For example: [Filter0] Extensions=.pl,.pm Program=pod2html.bat -Arguments="--css C:\notepad++\plugins\NppMarkdownPanel\style.css" +Arguments=--css C:\notepad++\plugins\NppMarkdownPanel\style.css ``` will render Perl POD to HTML and display in the viewer panel. There are some From b3db11507be3e5ab033939bb354599e0ce7d6c27 Mon Sep 17 00:00:00 2001 From: VinsWorldcom Date: Thu, 20 May 2021 09:46:01 -0400 Subject: [PATCH 14/15] add separators to menu --- NppMarkdownPanel/MarkdownPanelController.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/NppMarkdownPanel/MarkdownPanelController.cs b/NppMarkdownPanel/MarkdownPanelController.cs index 850338d..bf66fff 100644 --- a/NppMarkdownPanel/MarkdownPanelController.cs +++ b/NppMarkdownPanel/MarkdownPanelController.cs @@ -270,10 +270,12 @@ public void InitCommandMenu() } PluginBase.SetCommand(0, "Toggle &Markdown Panel", TogglePanelVisible); - PluginBase.SetCommand(1, "Synchronize with &caret position", SyncViewWithCaret, syncViewWithCaretPosition); - PluginBase.SetCommand(2, "Synchronize on &vertical scroll", SyncViewWithScroll, syncViewWithScrollPosition); - PluginBase.SetCommand(3, "Edit &Settings", EditSettings); - PluginBase.SetCommand(4, "&About", ShowAboutDialog, new ShortcutKey(false, false, false, Keys.None)); + PluginBase.SetCommand(1, "---", null); + PluginBase.SetCommand(2, "Synchronize with &caret position", SyncViewWithCaret, syncViewWithCaretPosition); + PluginBase.SetCommand(3, "Synchronize on &vertical scroll", SyncViewWithScroll, syncViewWithScrollPosition); + PluginBase.SetCommand(4, "---", null); + PluginBase.SetCommand(5, "&Settings", EditSettings); + PluginBase.SetCommand(6, "&About", ShowAboutDialog, new ShortcutKey(false, false, false, Keys.None)); idMyDlg = 0; } From 7eca58f126c643f397faf86b90d4c17ab988a552 Mon Sep 17 00:00:00 2001 From: VinsWorldcom Date: Fri, 28 May 2021 16:16:35 -0400 Subject: [PATCH 15/15] Update README for XML render --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index d532af5..5148def 100644 --- a/README.md +++ b/README.md @@ -48,12 +48,17 @@ Using portions of nea's **MarkdownViewerPlusPlus** Plugin code - [https://github Using the **Markdown icon** by dcurtis - [https://github.com/dcurtis/markdown-mark](https://github.com/dcurtis/markdown-mark) ## Prerequisites + - .NET 4.5 or higher ## Installation + ### Installation over Notepad++ + The plugin can be installed over the integrated Notepad++ "Plugin Admin..". + ### Manual Installation + Create the folder "NppMarkdownPanel" in your Notepad++ plugin folder (e.g. "C:\Program Files\Notepad++\plugins") and extract the appropriate zip (x86 or x64) to it. It should look like this: @@ -90,6 +95,8 @@ To open the settings for this plugin: Plugins -> NppMarkdownPanel -> Edit Settin * #### HTML Extensions A comma-separated list of file extensions to recognize as HTML (default = `.html,.htm`) + + **Note**: Adding `.xml` to this list will "render" XML files in the viewer if they at least have a valid XML header ``. ### Preview Window Toolbar