Skip to content

Commit e8e3f2a

Browse files
author
Savas Ziplies
committed
Changed: CommonMark converter to Markdig
Changed: Updated PDFSharp and HTMLRenderer.PDFSharp accordingly Changed: Updated NPP.net Plugin Template
1 parent 859f0b8 commit e8e3f2a

28 files changed

+155
-185
lines changed

MarkdownViewerPlusPlus/Forms/AboutDialog.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public AboutDialog()
3232
3333
Many thanks to:
3434
Notepad++ PluginPack.net by kbilsted
35-
CommonMark.NET by Knagis
35+
Markdig by lunet-io
3636
PDFSharp by empira Software GmbH
3737
HTMLRenderer by ArthurHub
3838
SVG.NET by vvvv

MarkdownViewerPlusPlus/Forms/AbstractRenderer.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
using Outlook = Microsoft.Office.Interop.Outlook;
1313
using static com.insanitydesign.MarkdownViewerPlusPlus.Windows.WindowsMessage;
1414
using System.Drawing.Printing;
15-
using CommonMark;
1615
using TheArtOfDev.HtmlRenderer.PdfSharp;
1716
using System.Xml.Linq;
1817
using PdfSharp.Pdf;
1918
using System.IO;
2019
using System.Net;
2120
using com.insanitydesign.MarkdownViewerPlusPlus.Helper;
2221
using static com.insanitydesign.MarkdownViewerPlusPlus.MarkdownViewer;
22+
using Markdig;
2323

2424
/// <summary>
2525
///
@@ -61,6 +61,11 @@ public abstract partial class AbstractRenderer : Form
6161
/// </summary>
6262
protected virtual FileInformation FileInfo { get; set; }
6363

64+
/// <summary>
65+
///
66+
/// </summary>
67+
protected MarkdownPipeline markdownPipeline = new MarkdownPipelineBuilder().UseAdvancedExtensions().Build();
68+
6469
/// <summary>
6570
///
6671
/// </summary>
@@ -141,7 +146,7 @@ public virtual void Render(string text, FileInformation fileInfo)
141146
{
142147
FileInfo = fileInfo;
143148
RawText = text;
144-
ConvertedText = CommonMarkConverter.Convert(text);
149+
ConvertedText = Markdown.ToHtml(text, this.markdownPipeline);
145150
}
146151

147152
/// <summary>

MarkdownViewerPlusPlus/MarkdownViewer.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using com.insanitydesign.MarkdownViewerPlusPlus.Forms;
22
using com.insanitydesign.MarkdownViewerPlusPlus.Properties;
3-
using CommonMark;
43
using Kbg.NppPluginNET;
54
using Kbg.NppPluginNET.PluginInfrastructure;
65
using System;
@@ -125,8 +124,6 @@ public MarkdownViewer()
125124
this.Notepad = new NotepadPPGateway();
126125
//Init the actual renderer
127126
this.renderer = new MarkdownViewerRenderer(this);
128-
//Set our custom formatter
129-
CommonMarkSettings.Default.OutputDelegate = (doc, output, settings) => new MarkdownViewerFormatter(output, settings).WriteDocument(doc);
130127
}
131128

132129
/// <summary>

MarkdownViewerPlusPlus/MarkdownViewerFormatter.cs

Lines changed: 0 additions & 57 deletions
This file was deleted.

MarkdownViewerPlusPlus/MarkdownViewerPlusPlus.csproj

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -81,34 +81,35 @@
8181
<ErrorReport>prompt</ErrorReport>
8282
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
8383
</PropertyGroup>
84+
<PropertyGroup>
85+
<!-- Default values for debugging sso it start correct version of Notepad++
86+
$(ProgramW6432) and $(MSBuildProgramFiles32) points to the 64 and 32 bit "Program Files" directories -->
87+
<StartAction>Program</StartAction>
88+
<StartProgram Condition="'$(Platform)'=='x64'">$(ProgramW6432)\Notepad++\notepad++.exe</StartProgram>
89+
<StartProgram Condition="'$(Platform)'=='x86'">$(MSBuildProgramFiles32)\Notepad++\notepad++.exe</StartProgram>
90+
</PropertyGroup>
8491
<ItemGroup>
85-
<Reference Include="CommonMark, Version=0.1.0.0, Culture=neutral, PublicKeyToken=001ef8810438905d, processorArchitecture=MSIL">
86-
<HintPath>..\packages\CommonMark.NET.0.15.1\lib\net40-client\CommonMark.dll</HintPath>
87-
<Private>True</Private>
88-
</Reference>
8992
<Reference Include="HtmlRenderer, Version=1.5.1.0, Culture=neutral, processorArchitecture=MSIL">
90-
<HintPath>..\packages\HtmlRenderer.Core.1.5.1-beta1\lib\net40-client\HtmlRenderer.dll</HintPath>
91-
<Private>True</Private>
93+
<HintPath>..\packages\HtmlRenderer.Core.1.5.1-beta2\lib\net40-client\HtmlRenderer.dll</HintPath>
9294
</Reference>
9395
<Reference Include="HtmlRenderer.PdfSharp, Version=1.5.1.0, Culture=neutral, processorArchitecture=MSIL">
94-
<HintPath>..\packages\HtmlRenderer.PdfSharp.1.5.1-beta1\lib\net40-client\HtmlRenderer.PdfSharp.dll</HintPath>
95-
<Private>True</Private>
96+
<HintPath>..\packages\HtmlRenderer.PdfSharp.1.5.1-beta2\lib\net40-client\HtmlRenderer.PdfSharp.dll</HintPath>
9697
</Reference>
9798
<Reference Include="HtmlRenderer.WinForms, Version=1.5.1.0, Culture=neutral, processorArchitecture=MSIL">
98-
<HintPath>..\packages\HtmlRenderer.WinForms.1.5.1-beta1\lib\net40-client\HtmlRenderer.WinForms.dll</HintPath>
99-
<Private>True</Private>
99+
<HintPath>..\packages\HtmlRenderer.WinForms.1.5.1-beta2\lib\net40-client\HtmlRenderer.WinForms.dll</HintPath>
100+
</Reference>
101+
<Reference Include="Markdig, Version=0.14.9.0, Culture=neutral, processorArchitecture=MSIL">
102+
<HintPath>..\packages\Markdig.0.14.9\lib\net40\Markdig.dll</HintPath>
100103
</Reference>
101104
<Reference Include="Microsoft.CSharp" />
102105
<Reference Include="Microsoft.Office.Interop.Outlook, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
103106
<EmbedInteropTypes>True</EmbedInteropTypes>
104107
</Reference>
105-
<Reference Include="PdfSharp, Version=1.50.4000.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb, processorArchitecture=MSIL">
106-
<HintPath>..\packages\PDFsharp.1.50.4000-beta3b\lib\net20\PdfSharp.dll</HintPath>
107-
<Private>True</Private>
108+
<Reference Include="PdfSharp, Version=1.50.4790.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb, processorArchitecture=MSIL">
109+
<HintPath>..\packages\PDFsharp.1.50.4790-beta5a\lib\net20\PdfSharp.dll</HintPath>
108110
</Reference>
109-
<Reference Include="PdfSharp.Charting, Version=1.50.4000.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb, processorArchitecture=MSIL">
110-
<HintPath>..\packages\PDFsharp.1.50.4000-beta3b\lib\net20\PdfSharp.Charting.dll</HintPath>
111-
<Private>True</Private>
111+
<Reference Include="PdfSharp.Charting, Version=1.50.4790.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb, processorArchitecture=MSIL">
112+
<HintPath>..\packages\PDFsharp.1.50.4790-beta5a\lib\net20\PdfSharp.Charting.dll</HintPath>
112113
</Reference>
113114
<Reference Include="PresentationCore" />
114115
<Reference Include="PresentationFramework" />
@@ -173,7 +174,6 @@
173174
<Compile Include="Helper\ClipboardHelper.cs" />
174175
<Compile Include="MarkdownViewer.cs" />
175176
<Compile Include="MarkdownViewerConfiguration.cs" />
176-
<Compile Include="MarkdownViewerFormatter.cs" />
177177
<Compile Include="PluginInfrastructure\ClikeStringArray.cs" />
178178
<Compile Include="PluginInfrastructure\DllExport\DllExportAttribute.cs" />
179179
<Compile Include="PluginInfrastructure\Win32.cs" />
@@ -225,7 +225,10 @@
225225
</EmbeddedResource>
226226
</ItemGroup>
227227
<ItemGroup>
228-
<None Include="ILMerge.props" />
228+
<None Include="app.config" />
229+
<None Include="ILMerge.props">
230+
<SubType>Designer</SubType>
231+
</None>
229232
<None Include="packages.config">
230233
<SubType>Designer</SubType>
231234
</None>
@@ -258,30 +261,29 @@
258261
<EmbeddedResource Include="Resources\MarkdownViewerHTML.css" />
259262
</ItemGroup>
260263
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
261-
<Import Project="$(MSBuildProjectDirectory)\PluginInfrastructure\DllExport\NppPlugin.DllExport.targets" />
262-
<Import Condition="Exists('$(DevEnvDir)\..\..\VC\Auxiliary\Build')" Project="$(DevEnvDir)\..\..\VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.props" />
264+
<Import Project="$(MSBuildProjectDirectory)\PluginInfrastructure\DllExport\NppPlugin.DllExport.targets" />
265+
<Import Condition="Exists('$(DevEnvDir)\..\..\VC\Auxiliary\Build')" Project="$(DevEnvDir)\..\..\VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.props" />
263266
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
264267
<PropertyGroup>
265268
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
266269
</PropertyGroup>
267270
<Error Condition="!Exists('..\packages\MSBuild.ILMerge.Task.1.0.5\build\MSBuild.ILMerge.Task.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSBuild.ILMerge.Task.1.0.5\build\MSBuild.ILMerge.Task.props'))" />
268271
<Error Condition="!Exists('..\packages\MSBuild.ILMerge.Task.1.0.5\build\MSBuild.ILMerge.Task.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSBuild.ILMerge.Task.1.0.5\build\MSBuild.ILMerge.Task.targets'))" />
269-
<Error Condition="!Exists('..\packages\MSBuild.Extension.Pack.1.9.0\build\net40\MSBuild.Extension.Pack.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSBuild.Extension.Pack.1.9.0\build\net40\MSBuild.Extension.Pack.targets'))" />
272+
<Error Condition="!Exists('..\packages\MSBuild.Extension.Pack.1.9.1\build\net40\MSBuild.Extension.Pack.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSBuild.Extension.Pack.1.9.1\build\net40\MSBuild.Extension.Pack.targets'))" />
270273
</Target>
271274
<Import Project="..\packages\MSBuild.ILMerge.Task.1.0.5\build\MSBuild.ILMerge.Task.targets" Condition="Exists('..\packages\MSBuild.ILMerge.Task.1.0.5\build\MSBuild.ILMerge.Task.targets')" />
272-
<Import Project="..\packages\MSBuild.Extension.Pack.1.9.0\build\net40\MSBuild.Extension.Pack.targets" Condition="Exists('..\packages\MSBuild.Extension.Pack.1.9.0\build\net40\MSBuild.Extension.Pack.targets')" />
275+
<Import Project="..\packages\MSBuild.Extension.Pack.1.9.1\build\net40\MSBuild.Extension.Pack.targets" Condition="Exists('..\packages\MSBuild.Extension.Pack.1.9.1\build\net40\MSBuild.Extension.Pack.targets')" />
273276
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
274277
Other similar extension points exist, see Microsoft.Common.targets.
275278
<Target Name="BeforeBuild">
276279
</Target>
277-
-->
280+
-->
278281
<Target Name="AfterBuild">
279-
<!-- Visual Studio < 2017 -->
282+
<!-- Visual Studio < 2017 -->
280283
<DllExportTask Condition="Exists('$(DevEnvDir)\..\..\VC\bin')" Platform="$(Platform)" PlatformTarget="$(PlatformTarget)" CpuType="$(CpuType)" EmitDebugSymbols="$(DebugSymbols)" DllExportAttributeAssemblyName="$(DllExportAttributeAssemblyName)" DllExportAttributeFullName="$(DllExportAttributeFullName)" Timeout="$(DllExportTimeout)" KeyContainer="$(KeyContainerName)$(AssemblyKeyContainerName)" KeyFile="$(KeyOriginatorFile)" ProjectDirectory="$(MSBuildProjectDirectory)" InputFileName="$(TargetPath)" FrameworkPath="$(TargetedFrameworkDir);$(TargetFrameworkDirectory)" LibToolPath="$(DevEnvDir)\..\..\VC\bin" LibToolDllPath="$(DevEnvDir)" SdkPath="$(SDK40ToolsPath)" />
281-
<!-- Visual Studio >= 2017 -->
282-
<DllExportTask Condition="Exists('$(DevEnvDir)\..\..\VC\Tools\MSVC\$(VCToolsVersion)\bin\Host$(Platform)\$(Platform)')" Platform="$(Platform)" PlatformTarget="$(PlatformTarget)" CpuType="$(CpuType)" EmitDebugSymbols="$(DebugSymbols)" DllExportAttributeAssemblyName="$(DllExportAttributeAssemblyName)" DllExportAttributeFullName="$(DllExportAttributeFullName)" Timeout="$(DllExportTimeout)" KeyContainer="$(KeyContainerName)$(AssemblyKeyContainerName)" KeyFile="$(KeyOriginatorFile)" ProjectDirectory="$(MSBuildProjectDirectory)" InputFileName="$(TargetPath)" FrameworkPath="$(TargetedFrameworkDir);$(TargetFrameworkDirectory)" LibToolPath="$(DevEnvDir)\..\..\VC\Tools\MSVC\$(VCToolsVersion)\bin\Host$(Platform)\$(Platform)" LibToolDllPath="$(DevEnvDir)" SdkPath="$(SDK40ToolsPath)" />
283-
284-
<Message Condition="Exists('C:\Program Files (x86)\Notepad++\plugins\') AND '$(PlatformTarget)'=='x86'" Text="Copying to C:\Program Files (x86)\Notepad++\plugins\" Importance="high" />
284+
<!-- Visual Studio >= 2017 -->
285+
<DllExportTask Condition="Exists('$(DevEnvDir)\..\..\VC\Tools\MSVC\$(VCToolsVersion)\bin\Host$(Platform)\$(Platform)')" Platform="$(Platform)" PlatformTarget="$(PlatformTarget)" CpuType="$(CpuType)" EmitDebugSymbols="$(DebugSymbols)" DllExportAttributeAssemblyName="$(DllExportAttributeAssemblyName)" DllExportAttributeFullName="$(DllExportAttributeFullName)" Timeout="$(DllExportTimeout)" KeyContainer="$(KeyContainerName)$(AssemblyKeyContainerName)" KeyFile="$(KeyOriginatorFile)" ProjectDirectory="$(MSBuildProjectDirectory)" InputFileName="$(TargetPath)" FrameworkPath="$(TargetedFrameworkDir);$(TargetFrameworkDirectory)" LibToolPath="$(DevEnvDir)\..\..\VC\Tools\MSVC\$(VCToolsVersion)\bin\Host$(Platform)\$(Platform)" LibToolDllPath="$(DevEnvDir)" SdkPath="$(SDK40ToolsPath)" />
286+
<Message Condition="Exists('C:\Program Files (x86)\Notepad++\plugins\') AND '$(PlatformTarget)'=='x86'" Text="Copying to C:\Program Files (x86)\Notepad++\plugins\" Importance="high" />
285287
<Copy Condition="Exists('C:\Program Files (x86)\Notepad++\plugins\') AND '$(PlatformTarget)'=='x86'" SourceFiles="$(TargetPath)" DestinationFolder="C:\Program Files (x86)\Notepad++\plugins\" ContinueOnError="false" />
286288
<Message Condition="Exists('C:\Program Files\Notepad++\plugins\') AND '$(PlatformTarget)'=='x86'" Text="Copying to C:\Program Files\Notepad++\plugins\" Importance="high" />
287289
<Copy Condition="Exists('C:\Program Files\Notepad++\plugins\') AND '$(PlatformTarget)'=='x64'" SourceFiles="$(TargetPath)" DestinationFolder="C:\Program Files\Notepad++\plugins\" ContinueOnError="false" />

MarkdownViewerPlusPlus/PluginInfrastructure/ClikeStringArray.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// NPP plugin platform for .Net v0.93.96 by Kasper B. Graversen etc.
1+
// NPP plugin platform for .Net v0.94.00 by Kasper B. Graversen etc.
22
using System;
33
using System.Collections.Generic;
44
using System.Runtime.InteropServices;

MarkdownViewerPlusPlus/PluginInfrastructure/DllExport/DllExportAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// NPP plugin platform for .Net v0.93.96 by Kasper B. Graversen etc.
1+
// NPP plugin platform for .Net v0.94.00 by Kasper B. Graversen etc.
22
using System;
33
using System.Runtime.InteropServices;
44

MarkdownViewerPlusPlus/PluginInfrastructure/DllExport/NppPlugin.DllExport.targets

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
<Target Name="AfterBuild"
66
DependsOnTargets="GetFrameworkPaths"
77
>
8+
<PropertyGroup>
9+
<!-- LibToolPath is optional - it's needed to debug C++, but you can still debug the C# code without it
10+
If you don't have the C++ toolchain installed this is missing, but then you can't' debug C++ anyway -->
11+
<LibToolPath Condition="Exists('$(DevEnvDir)\..\..\VC\bin')">$(DevEnvDir)\..\..\VC\bin</LibToolPath>
12+
</PropertyGroup>
813
<DllExportTask Platform="$(Platform)"
914
PlatformTarget="$(PlatformTarget)"
1015
CpuType="$(CpuType)"
@@ -17,14 +22,23 @@
1722
ProjectDirectory="$(MSBuildProjectDirectory)"
1823
InputFileName="$(TargetPath)"
1924
FrameworkPath="$(TargetedFrameworkDir);$(TargetFrameworkDirectory)"
20-
LibToolPath="$(DevEnvDir)\..\..\VC\bin"
25+
LibToolPath="$(LibToolPath)"
2126
LibToolDllPath="$(DevEnvDir)"
2227
SdkPath="$(SDK40ToolsPath)"/>
2328

29+
<!-- $(MSBuildProgramFiles32) points to the 32 bit program files dir.
30+
On 32 bit windows usually C:\Program Files\
31+
On 64 bit windows usually C:\Program Files (x86)\
32+
$(ProgramW6432) points to the 64bit Program Files (on 32 bit windows it is blank) -->
2433
<Copy
2534
SourceFiles="$(TargetPath)"
26-
DestinationFolder="C:\Program Files (x86)\Notepad++\plugins\"
27-
Condition="Exists('C:\Program Files (x86)\Notepad++\plugins\')"
35+
DestinationFolder="$(MSBuildProgramFiles32)\Notepad++\plugins\"
36+
Condition="Exists('$(MSBuildProgramFiles32)\Notepad++\plugins\') AND '$(Platform)'=='x86'"
37+
ContinueOnError="false" />
38+
<Copy
39+
SourceFiles="$(TargetPath)"
40+
DestinationFolder="$(ProgramW6432)\Notepad++\plugins\"
41+
Condition="Exists('$(ProgramW6432)\Notepad++\plugins\') AND '$(Platform)'=='x64'"
2842
ContinueOnError="false" />
2943
</Target>
3044
</Project>

MarkdownViewerPlusPlus/PluginInfrastructure/Docking_h.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// NPP plugin platform for .Net v0.93.96 by Kasper B. Graversen etc.
1+
// NPP plugin platform for .Net v0.94.00 by Kasper B. Graversen etc.
22
//
33
// This file should stay in sync with the CPP project file
44
// "notepad-plus-plus/PowerEditor/src/WinControls/DockingWnd/Docking.h"

MarkdownViewerPlusPlus/PluginInfrastructure/GatewayDomain.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
// NPP plugin platform for .Net v0.93.96 by Kasper B. Graversen etc.
1+
// NPP plugin platform for .Net v0.94.00 by Kasper B. Graversen etc.
22
using System;
33
using System.Runtime.InteropServices;
4+
using System.Text;
45

56
namespace Kbg.NppPluginNET.PluginInfrastructure
67
{
@@ -15,11 +16,11 @@ public class Colour
1516
public readonly int Red, Green, Blue;
1617

1718
public Colour(int rgb)
18-
{
19-
Red = rgb ^ 0xFF;
20-
Green = rgb ^ 0x00FF;
21-
Blue = rgb ^ 0x0000FF;
22-
}
19+
{
20+
Red = rgb & 0xFF;
21+
Green = (rgb >> 8) & 0xFF;
22+
Blue = (rgb >> 16) & 0xFF;
23+
}
2324

2425
/// <summary>
2526
///
@@ -42,7 +43,7 @@ public Colour(int red, int green, int blue)
4243

4344
public int Value
4445
{
45-
get { return Red + (Blue << 8 ) + (Green << 16); }
46+
get { return Red + (Green << 8) + (Blue << 16); }
4647
}
4748
}
4849

0 commit comments

Comments
 (0)