forked from UrsineRaven/NppMarkdownPanel
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
53 changed files
with
1,955 additions
and
350 deletions.
There are no files selected for viewing
File renamed without changes.
50 changes: 50 additions & 0 deletions
50
MarkdigWrapper/Markdig/SyntaxHighlighting/StyleToCssWriter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using ColorCode; | ||
using ColorCode.Styling; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace MarkdigWrapper.Markdig.SyntaxHighlighting | ||
{ | ||
public class StyleToCssWriter | ||
{ | ||
//Usage | ||
//StyleToCssWriter.WriteStylesToCssFile(styleSheet.Styles, @"C:\development\NppMarkdownPanel\out.css"); | ||
|
||
private static string WriteColorToHex(Color color) | ||
{ | ||
return string.Format("#{0:X2}{1:X2}{2:X2}", color.R, color.G, color.B); | ||
} | ||
|
||
public static void WriteStylesToCssFile(StyleDictionary styles, string filePath) | ||
{ | ||
string completeCss = ""; | ||
|
||
foreach (var s in styles) | ||
{ | ||
string cssClass = ""; | ||
cssClass += "." + s.CssClassName + " {\n"; | ||
if (s.Background != null) | ||
cssClass += " background-color: " + WriteColorToHex(s.Background) + ";\n"; | ||
if (s.Foreground != null) | ||
cssClass += " color: " + WriteColorToHex(s.Foreground)+ ";\n"; | ||
if (s.Bold) | ||
{ | ||
cssClass += " font-weight: bold;\n"; | ||
} | ||
if (s.Italic) | ||
{ | ||
cssClass += " font-style: italic;\n"; | ||
} | ||
cssClass += "}\n"; | ||
|
||
completeCss += cssClass; | ||
|
||
} | ||
File.WriteAllText(filePath, completeCss); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
31 changes: 31 additions & 0 deletions
31
MarkdigWrapper/Markdig/YamlFrontMatter/YamlFrontMatterAsCodeBlockExtension.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Markdig; | ||
using Markdig.Extensions.Yaml; | ||
using Markdig.Renderers; | ||
using Markdig.Renderers.Html; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace MarkdigWrapper.Markdig.YamlFrontMatter | ||
{ | ||
public class YamlFrontMatterAsCodeBlockExtension : IMarkdownExtension | ||
{ | ||
public void Setup(MarkdownPipelineBuilder pipeline) { } | ||
|
||
public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer) | ||
{ | ||
if (renderer.ObjectRenderers.Contains<YamlFrontMatterHtmlRenderer>()) | ||
{ | ||
var yamlFrontMatterRenderer = renderer.ObjectRenderers.FindExact<YamlFrontMatterHtmlRenderer>(); | ||
renderer.ObjectRenderers.Remove(yamlFrontMatterRenderer); | ||
} | ||
|
||
if (!renderer.ObjectRenderers.Contains<YamlFrontMatterAsCodeBlockHtmlRenderer>()) | ||
{ | ||
renderer.ObjectRenderers.InsertBefore<CodeBlockRenderer>(new YamlFrontMatterAsCodeBlockHtmlRenderer()); | ||
} | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
MarkdigWrapper/Markdig/YamlFrontMatter/YamlFrontMatterAsCodeBlockExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Markdig; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace MarkdigWrapper.Markdig.YamlFrontMatter | ||
{ | ||
public static class YamlFrontMatterAsCodeBlockExtensions | ||
{ | ||
public static MarkdownPipelineBuilder UseRenderYamlFrontMatterAsCodeBlock(this MarkdownPipelineBuilder pipeline) | ||
{ | ||
pipeline.Extensions.Add(new YamlFrontMatterAsCodeBlockExtension()); | ||
return pipeline; | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
MarkdigWrapper/Markdig/YamlFrontMatter/YamlFrontMatterAsCodeBlockHtmlRenderer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Markdig.Extensions.Yaml; | ||
using Markdig.Renderers; | ||
using Markdig.Renderers.Html; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace MarkdigWrapper.Markdig.YamlFrontMatter | ||
{ | ||
public class YamlFrontMatterAsCodeBlockHtmlRenderer : HtmlObjectRenderer<YamlFrontMatterBlock> | ||
{ | ||
private CodeBlockRenderer codeBlockRenderer; | ||
public YamlFrontMatterAsCodeBlockHtmlRenderer() | ||
{ | ||
codeBlockRenderer = new CodeBlockRenderer(); | ||
} | ||
protected override void Write(HtmlRenderer renderer, YamlFrontMatterBlock obj) | ||
{ | ||
// Render Yaml Frontmatter as simple code block | ||
codeBlockRenderer.Write(renderer, obj); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.