Skip to content

Commit

Permalink
Changed: CommonMark converter to Markdig
Browse files Browse the repository at this point in the history
Changed: Updated PDFSharp and HTMLRenderer.PDFSharp accordingly
Changed: Updated NPP.net Plugin Template
  • Loading branch information
Savas Ziplies committed Feb 15, 2018
1 parent 859f0b8 commit e8e3f2a
Show file tree
Hide file tree
Showing 28 changed files with 155 additions and 185 deletions.
2 changes: 1 addition & 1 deletion MarkdownViewerPlusPlus/Forms/AboutDialog.cs
Expand Up @@ -32,7 +32,7 @@ public AboutDialog()
Many thanks to:
Notepad++ PluginPack.net by kbilsted
CommonMark.NET by Knagis
Markdig by lunet-io
PDFSharp by empira Software GmbH
HTMLRenderer by ArthurHub
SVG.NET by vvvv
Expand Down
9 changes: 7 additions & 2 deletions MarkdownViewerPlusPlus/Forms/AbstractRenderer.cs
Expand Up @@ -12,14 +12,14 @@
using Outlook = Microsoft.Office.Interop.Outlook;
using static com.insanitydesign.MarkdownViewerPlusPlus.Windows.WindowsMessage;
using System.Drawing.Printing;
using CommonMark;
using TheArtOfDev.HtmlRenderer.PdfSharp;
using System.Xml.Linq;
using PdfSharp.Pdf;
using System.IO;
using System.Net;
using com.insanitydesign.MarkdownViewerPlusPlus.Helper;
using static com.insanitydesign.MarkdownViewerPlusPlus.MarkdownViewer;
using Markdig;

/// <summary>
///
Expand Down Expand Up @@ -61,6 +61,11 @@ public abstract partial class AbstractRenderer : Form
/// </summary>
protected virtual FileInformation FileInfo { get; set; }

/// <summary>
///
/// </summary>
protected MarkdownPipeline markdownPipeline = new MarkdownPipelineBuilder().UseAdvancedExtensions().Build();

/// <summary>
///
/// </summary>
Expand Down Expand Up @@ -141,7 +146,7 @@ public virtual void Render(string text, FileInformation fileInfo)
{
FileInfo = fileInfo;
RawText = text;
ConvertedText = CommonMarkConverter.Convert(text);
ConvertedText = Markdown.ToHtml(text, this.markdownPipeline);
}

/// <summary>
Expand Down
3 changes: 0 additions & 3 deletions MarkdownViewerPlusPlus/MarkdownViewer.cs
@@ -1,6 +1,5 @@
using com.insanitydesign.MarkdownViewerPlusPlus.Forms;
using com.insanitydesign.MarkdownViewerPlusPlus.Properties;
using CommonMark;
using Kbg.NppPluginNET;
using Kbg.NppPluginNET.PluginInfrastructure;
using System;
Expand Down Expand Up @@ -125,8 +124,6 @@ public MarkdownViewer()
this.Notepad = new NotepadPPGateway();
//Init the actual renderer
this.renderer = new MarkdownViewerRenderer(this);
//Set our custom formatter
CommonMarkSettings.Default.OutputDelegate = (doc, output, settings) => new MarkdownViewerFormatter(output, settings).WriteDocument(doc);
}

/// <summary>
Expand Down
57 changes: 0 additions & 57 deletions MarkdownViewerPlusPlus/MarkdownViewerFormatter.cs

This file was deleted.

58 changes: 30 additions & 28 deletions MarkdownViewerPlusPlus/MarkdownViewerPlusPlus.csproj
Expand Up @@ -81,34 +81,35 @@
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup>
<!-- Default values for debugging sso it start correct version of Notepad++
$(ProgramW6432) and $(MSBuildProgramFiles32) points to the 64 and 32 bit "Program Files" directories -->
<StartAction>Program</StartAction>
<StartProgram Condition="'$(Platform)'=='x64'">$(ProgramW6432)\Notepad++\notepad++.exe</StartProgram>
<StartProgram Condition="'$(Platform)'=='x86'">$(MSBuildProgramFiles32)\Notepad++\notepad++.exe</StartProgram>
</PropertyGroup>
<ItemGroup>
<Reference Include="CommonMark, Version=0.1.0.0, Culture=neutral, PublicKeyToken=001ef8810438905d, processorArchitecture=MSIL">
<HintPath>..\packages\CommonMark.NET.0.15.1\lib\net40-client\CommonMark.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="HtmlRenderer, Version=1.5.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\HtmlRenderer.Core.1.5.1-beta1\lib\net40-client\HtmlRenderer.dll</HintPath>
<Private>True</Private>
<HintPath>..\packages\HtmlRenderer.Core.1.5.1-beta2\lib\net40-client\HtmlRenderer.dll</HintPath>
</Reference>
<Reference Include="HtmlRenderer.PdfSharp, Version=1.5.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\HtmlRenderer.PdfSharp.1.5.1-beta1\lib\net40-client\HtmlRenderer.PdfSharp.dll</HintPath>
<Private>True</Private>
<HintPath>..\packages\HtmlRenderer.PdfSharp.1.5.1-beta2\lib\net40-client\HtmlRenderer.PdfSharp.dll</HintPath>
</Reference>
<Reference Include="HtmlRenderer.WinForms, Version=1.5.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\HtmlRenderer.WinForms.1.5.1-beta1\lib\net40-client\HtmlRenderer.WinForms.dll</HintPath>
<Private>True</Private>
<HintPath>..\packages\HtmlRenderer.WinForms.1.5.1-beta2\lib\net40-client\HtmlRenderer.WinForms.dll</HintPath>
</Reference>
<Reference Include="Markdig, Version=0.14.9.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Markdig.0.14.9\lib\net40\Markdig.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.Office.Interop.Outlook, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="PdfSharp, Version=1.50.4000.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb, processorArchitecture=MSIL">
<HintPath>..\packages\PDFsharp.1.50.4000-beta3b\lib\net20\PdfSharp.dll</HintPath>
<Private>True</Private>
<Reference Include="PdfSharp, Version=1.50.4790.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb, processorArchitecture=MSIL">
<HintPath>..\packages\PDFsharp.1.50.4790-beta5a\lib\net20\PdfSharp.dll</HintPath>
</Reference>
<Reference Include="PdfSharp.Charting, Version=1.50.4000.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb, processorArchitecture=MSIL">
<HintPath>..\packages\PDFsharp.1.50.4000-beta3b\lib\net20\PdfSharp.Charting.dll</HintPath>
<Private>True</Private>
<Reference Include="PdfSharp.Charting, Version=1.50.4790.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb, processorArchitecture=MSIL">
<HintPath>..\packages\PDFsharp.1.50.4790-beta5a\lib\net20\PdfSharp.Charting.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
Expand Down Expand Up @@ -173,7 +174,6 @@
<Compile Include="Helper\ClipboardHelper.cs" />
<Compile Include="MarkdownViewer.cs" />
<Compile Include="MarkdownViewerConfiguration.cs" />
<Compile Include="MarkdownViewerFormatter.cs" />
<Compile Include="PluginInfrastructure\ClikeStringArray.cs" />
<Compile Include="PluginInfrastructure\DllExport\DllExportAttribute.cs" />
<Compile Include="PluginInfrastructure\Win32.cs" />
Expand Down Expand Up @@ -225,7 +225,10 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="ILMerge.props" />
<None Include="app.config" />
<None Include="ILMerge.props">
<SubType>Designer</SubType>
</None>
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
Expand Down Expand Up @@ -258,30 +261,29 @@
<EmbeddedResource Include="Resources\MarkdownViewerHTML.css" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildProjectDirectory)\PluginInfrastructure\DllExport\NppPlugin.DllExport.targets" />
<Import Condition="Exists('$(DevEnvDir)\..\..\VC\Auxiliary\Build')" Project="$(DevEnvDir)\..\..\VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.props" />
<Import Project="$(MSBuildProjectDirectory)\PluginInfrastructure\DllExport\NppPlugin.DllExport.targets" />
<Import Condition="Exists('$(DevEnvDir)\..\..\VC\Auxiliary\Build')" Project="$(DevEnvDir)\..\..\VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.props" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<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>
</PropertyGroup>
<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'))" />
<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'))" />
<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'))" />
<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'))" />
</Target>
<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')" />
<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')" />
<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')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
-->
-->
<Target Name="AfterBuild">
<!-- Visual Studio < 2017 -->
<!-- Visual Studio < 2017 -->
<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)" />
<!-- Visual Studio >= 2017 -->
<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)" />

<Message Condition="Exists('C:\Program Files (x86)\Notepad++\plugins\') AND '$(PlatformTarget)'=='x86'" Text="Copying to C:\Program Files (x86)\Notepad++\plugins\" Importance="high" />
<!-- Visual Studio >= 2017 -->
<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)" />
<Message Condition="Exists('C:\Program Files (x86)\Notepad++\plugins\') AND '$(PlatformTarget)'=='x86'" Text="Copying to C:\Program Files (x86)\Notepad++\plugins\" Importance="high" />
<Copy Condition="Exists('C:\Program Files (x86)\Notepad++\plugins\') AND '$(PlatformTarget)'=='x86'" SourceFiles="$(TargetPath)" DestinationFolder="C:\Program Files (x86)\Notepad++\plugins\" ContinueOnError="false" />
<Message Condition="Exists('C:\Program Files\Notepad++\plugins\') AND '$(PlatformTarget)'=='x86'" Text="Copying to C:\Program Files\Notepad++\plugins\" Importance="high" />
<Copy Condition="Exists('C:\Program Files\Notepad++\plugins\') AND '$(PlatformTarget)'=='x64'" SourceFiles="$(TargetPath)" DestinationFolder="C:\Program Files\Notepad++\plugins\" ContinueOnError="false" />
Expand Down
@@ -1,4 +1,4 @@
// NPP plugin platform for .Net v0.93.96 by Kasper B. Graversen etc.
// NPP plugin platform for .Net v0.94.00 by Kasper B. Graversen etc.
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
Expand Down
@@ -1,4 +1,4 @@
// NPP plugin platform for .Net v0.93.96 by Kasper B. Graversen etc.
// NPP plugin platform for .Net v0.94.00 by Kasper B. Graversen etc.
using System;
using System.Runtime.InteropServices;

Expand Down
Expand Up @@ -5,6 +5,11 @@
<Target Name="AfterBuild"
DependsOnTargets="GetFrameworkPaths"
>
<PropertyGroup>
<!-- LibToolPath is optional - it's needed to debug C++, but you can still debug the C# code without it
If you don't have the C++ toolchain installed this is missing, but then you can't' debug C++ anyway -->
<LibToolPath Condition="Exists('$(DevEnvDir)\..\..\VC\bin')">$(DevEnvDir)\..\..\VC\bin</LibToolPath>
</PropertyGroup>
<DllExportTask Platform="$(Platform)"
PlatformTarget="$(PlatformTarget)"
CpuType="$(CpuType)"
Expand All @@ -17,14 +22,23 @@
ProjectDirectory="$(MSBuildProjectDirectory)"
InputFileName="$(TargetPath)"
FrameworkPath="$(TargetedFrameworkDir);$(TargetFrameworkDirectory)"
LibToolPath="$(DevEnvDir)\..\..\VC\bin"
LibToolPath="$(LibToolPath)"
LibToolDllPath="$(DevEnvDir)"
SdkPath="$(SDK40ToolsPath)"/>

<!-- $(MSBuildProgramFiles32) points to the 32 bit program files dir.
On 32 bit windows usually C:\Program Files\
On 64 bit windows usually C:\Program Files (x86)\
$(ProgramW6432) points to the 64bit Program Files (on 32 bit windows it is blank) -->
<Copy
SourceFiles="$(TargetPath)"
DestinationFolder="C:\Program Files (x86)\Notepad++\plugins\"
Condition="Exists('C:\Program Files (x86)\Notepad++\plugins\')"
DestinationFolder="$(MSBuildProgramFiles32)\Notepad++\plugins\"
Condition="Exists('$(MSBuildProgramFiles32)\Notepad++\plugins\') AND '$(Platform)'=='x86'"
ContinueOnError="false" />
<Copy
SourceFiles="$(TargetPath)"
DestinationFolder="$(ProgramW6432)\Notepad++\plugins\"
Condition="Exists('$(ProgramW6432)\Notepad++\plugins\') AND '$(Platform)'=='x64'"
ContinueOnError="false" />
</Target>
</Project>
2 changes: 1 addition & 1 deletion MarkdownViewerPlusPlus/PluginInfrastructure/Docking_h.cs
@@ -1,4 +1,4 @@
// NPP plugin platform for .Net v0.93.96 by Kasper B. Graversen etc.
// NPP plugin platform for .Net v0.94.00 by Kasper B. Graversen etc.
//
// This file should stay in sync with the CPP project file
// "notepad-plus-plus/PowerEditor/src/WinControls/DockingWnd/Docking.h"
Expand Down
15 changes: 8 additions & 7 deletions MarkdownViewerPlusPlus/PluginInfrastructure/GatewayDomain.cs
@@ -1,6 +1,7 @@
// NPP plugin platform for .Net v0.93.96 by Kasper B. Graversen etc.
// NPP plugin platform for .Net v0.94.00 by Kasper B. Graversen etc.
using System;
using System.Runtime.InteropServices;
using System.Text;

namespace Kbg.NppPluginNET.PluginInfrastructure
{
Expand All @@ -15,11 +16,11 @@ public class Colour
public readonly int Red, Green, Blue;

public Colour(int rgb)
{
Red = rgb ^ 0xFF;
Green = rgb ^ 0x00FF;
Blue = rgb ^ 0x0000FF;
}
{
Red = rgb & 0xFF;
Green = (rgb >> 8) & 0xFF;
Blue = (rgb >> 16) & 0xFF;
}

/// <summary>
///
Expand All @@ -42,7 +43,7 @@ public Colour(int red, int green, int blue)

public int Value
{
get { return Red + (Blue << 8 ) + (Green << 16); }
get { return Red + (Green << 8) + (Blue << 16); }
}
}

Expand Down
@@ -1,5 +1,4 @@
// NPP plugin platform for .Net v0.93.96 by Kasper B. Graversen etc.

// NPP plugin platform for .Net v0.94.00 by Kasper B. Graversen etc.
using System;
using static Kbg.NppPluginNET.PluginInfrastructure.Win32;

Expand Down
2 changes: 1 addition & 1 deletion MarkdownViewerPlusPlus/PluginInfrastructure/MenuCmdID_h.cs
@@ -1,4 +1,4 @@
// NPP plugin platform for .Net v0.93.96 by Kasper B. Graversen etc.
// NPP plugin platform for .Net v0.94.00 by Kasper B. Graversen etc.
//
// This file should stay in sync with the CPP project file
// "notepad-plus-plus/PowerEditor/src/menuCmdID.h"
Expand Down
2 changes: 1 addition & 1 deletion MarkdownViewerPlusPlus/PluginInfrastructure/Msgs_h.cs
@@ -1,4 +1,4 @@
// NPP plugin platform for .Net v0.93.96 by Kasper B. Graversen etc.
// NPP plugin platform for .Net v0.94.00 by Kasper B. Graversen etc.
//
// This file should stay in sync with the CPP project file
// "notepad-plus-plus/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h"
Expand Down
@@ -1,10 +1,11 @@
// NPP plugin platform for .Net v0.93.96 by Kasper B. Graversen etc.
using NppPluginNET.PluginInfrastructure;
// NPP plugin platform for .Net v0.94.00 by Kasper B. Graversen etc.
using System;
using System.Text;
using NppPluginNET.PluginInfrastructure;

namespace Kbg.NppPluginNET.PluginInfrastructure
{
public interface INotepadPPGateway
public interface INotepadPPGateway
{
void FileNew();

Expand All @@ -21,7 +22,7 @@ public interface INotepadPPGateway
/// </summary>
/// <returns></returns>
string GetCurrentDirectory();
}
}

/// <summary>
/// This class holds helpers for sending messages defined in the Msgs_h.cs file. It is at the moment
Expand Down
@@ -1,4 +1,4 @@
// NPP plugin platform for .Net v0.93.96 by Kasper B. Graversen etc.
// NPP plugin platform for .Net v0.94.00 by Kasper B. Graversen etc.
using System;

namespace Kbg.NppPluginNET.PluginInfrastructure
Expand Down

0 comments on commit e8e3f2a

Please sign in to comment.