mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-10 21:40:00 +00:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b941a58ad0 | ||
|
|
3fa20fa92f | ||
|
|
5dcd4ea4aa | ||
|
|
9c03683913 | ||
|
|
2fed1b3ebf | ||
|
|
9da3eef65f | ||
|
|
0b4fe3f02f | ||
|
|
96b39e1856 | ||
|
|
6d90f517cc | ||
|
|
c17630e3b6 | ||
|
|
6eecfe2edc | ||
|
|
9abeb97394 |
BIN
images/markdig.png
Normal file
BIN
images/markdig.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.1 KiB |
124
images/markdig.svg
Normal file
124
images/markdig.svg
Normal file
@@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="192"
|
||||
height="192"
|
||||
viewBox="0 0 192 192"
|
||||
id="svg2"
|
||||
version="1.1"
|
||||
inkscape:version="0.91 r13725"
|
||||
sodipodi:docname="markdig.svg">
|
||||
<defs
|
||||
id="defs4" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="3.6203867"
|
||||
inkscape:cx="274.42608"
|
||||
inkscape:cy="145.36182"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="g4154"
|
||||
showgrid="false"
|
||||
inkscape:window-width="2560"
|
||||
inkscape:window-height="1377"
|
||||
inkscape:window-x="-8"
|
||||
inkscape:window-y="-8"
|
||||
inkscape:window-maximized="1"
|
||||
units="px" />
|
||||
<metadata
|
||||
id="metadata7">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
style="display:inline"
|
||||
transform="translate(0,-860.36216)">
|
||||
<g
|
||||
id="g4154"
|
||||
transform="matrix(38.543914,0,0,38.552171,-1185.0408,-955.47573)">
|
||||
<path
|
||||
style="fill:#000000"
|
||||
inkscape:connector-curvature="0"
|
||||
d="m 31.644129,50.284653 c -0.02217,0.02214 -0.04404,0.04469 -0.05945,0.0741 l -0.735055,1.351325 c -0.04175,0.07002 -0.04056,0.138759 5.12e-4,0.181019 0.0272,0.02824 0.06784,0.0361 0.11251,0.02579 0.01796,-0.0042 0.04467,-0.01031 0.06465,-0.02343 L 32.366,51.153314 c 0.02869,-0.01511 0.05106,-0.03775 0.07307,-0.05991 l 1.33603,-1.352005 -0.797174,-0.799407 -1.333959,1.342865 z"
|
||||
id="path4140" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path4142"
|
||||
d="m 33.629834,47.14509 c -0.05143,0 -0.102813,0.02035 -0.143929,0.06185 l -0.452371,0.453699 -0.339289,-0.340288 c -0.08223,-0.08249 -0.205627,-0.08249 -0.287859,0 -0.08223,0.08249 -0.08223,0.206242 0,0.288728 l 0.339289,0.340288 -0.287859,0.278382 2.128264,2.113818 0.28786,-0.288728 0.359871,0.350578 c 0.04097,0.04127 0.09255,0.06185 0.143929,0.06185 0.05143,0 0.102814,-0.02035 0.14393,-0.06185 0.08223,-0.08249 0.08223,-0.206243 0,-0.288728 l -0.359871,-0.340288 0.45237,-0.44341 c 0.03061,-0.04127 0.05143,-0.09283 0.05143,-0.154681 0,-0.05145 -0.02072,-0.103121 -0.0617,-0.144336 l -1.830134,-1.825022 c -0.04097,-0.04127 -0.09255,-0.06185 -0.143929,-0.06185 z m 0.411725,0.538446 0.246508,0.247174 -0.104933,0.599544 0.597939,-0.105213 0.246508,0.247174 -0.955889,0.958455 -0.246507,-0.247174 0.548227,-0.549696 -0.597934,0.105213 0.104933,-0.59955 -0.548232,0.549696 -0.246508,-0.247174 0.955888,-0.958454 z"
|
||||
style="fill:#000000;fill-opacity:1" />
|
||||
<rect
|
||||
y="34.228416"
|
||||
x="34.416744"
|
||||
width="0"
|
||||
height="0"
|
||||
ry="0"
|
||||
mask="url(#a)"
|
||||
id="rect4168" />
|
||||
<rect
|
||||
y="33.914825"
|
||||
x="33.238689"
|
||||
width="0"
|
||||
height="0"
|
||||
ry="0"
|
||||
mask="url(#a)"
|
||||
id="rect4184" />
|
||||
<rect
|
||||
y="31.953135"
|
||||
x="33.002754"
|
||||
width="0.004530983"
|
||||
height="0.0037847031"
|
||||
ry="0.056770544"
|
||||
mask="url(#a)"
|
||||
id="rect4200" />
|
||||
<flowRoot
|
||||
transform="matrix(0.00453098,0,0,0.0037847,43.709468,34.287871)"
|
||||
style="font-style:normal;font-weight:normal;font-size:40px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
id="flowRoot4797"
|
||||
xml:space="preserve"><flowRegion
|
||||
id="flowRegion4799"><rect
|
||||
y="-976.15039"
|
||||
x="959.01355"
|
||||
height="618.71844"
|
||||
width="972.27185"
|
||||
id="rect4801" /></flowRegion><flowPara
|
||||
id="flowPara4803"></flowPara></flowRoot> <g
|
||||
transform="matrix(0.00246733,0,0,0.00235052,43.616236,34.351245)"
|
||||
id="g4833">
|
||||
<rect
|
||||
style="fill:#ffffff"
|
||||
y="0"
|
||||
x="0"
|
||||
width="1"
|
||||
height="1"
|
||||
id="rect4823" />
|
||||
</g>
|
||||
<path
|
||||
style="fill:#000000;fill-opacity:1"
|
||||
d="m 33.629834,47.14509 c -0.05143,0 -0.102813,0.02035 -0.143929,0.06185 l -0.452371,0.453699 -0.339289,-0.340288 c -0.08223,-0.08249 -0.205627,-0.08249 -0.287859,0 -0.08223,0.08249 -0.08223,0.206242 0,0.288728 l 0.339289,0.340288 -0.287859,0.278382 2.128264,2.113818 0.28786,-0.288728 0.359871,0.350578 c 0.04097,0.04127 0.09255,0.06185 0.143929,0.06185 0.05143,0 0.102814,-0.02035 0.14393,-0.06185 0.08223,-0.08249 0.08223,-0.206243 0,-0.288728 l -0.359871,-0.340288 0.45237,-0.44341 c 0.03061,-0.04127 0.05143,-0.09283 0.05143,-0.154681 0,-0.05145 -0.02072,-0.103121 -0.0617,-0.144336 l -1.830134,-1.825022 c -0.04097,-0.04127 -0.09255,-0.06185 -0.143929,-0.06185 z m 0.411725,0.538446 0.246508,0.247174 -0.104933,0.599544 0.597939,-0.105213 0.246508,0.247174 -0.955889,0.958455 -0.246507,-0.247174 0.548227,-0.549696 -0.597934,0.105213 0.104933,-0.59955 -0.548232,0.549696 -0.246508,-0.247174 0.955888,-0.958454 z"
|
||||
id="path4886"
|
||||
inkscape:connector-curvature="0" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.7 KiB |
BIN
images/markdig64.png
Normal file
BIN
images/markdig64.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
@@ -1,9 +1,13 @@
|
||||
# Markdig [](https://ci.appveyor.com/project/xoofx/markdig) [](https://www.nuget.org/packages/Markdig/)
|
||||
|
||||
<img align="right" width="128px" height="128px" src="images/markdig.png">
|
||||
|
||||
Markdig is a fast, powerfull, [CommonMark](http://commonmark.org/) compliant, extensible Markdown processor for .NET.
|
||||
|
||||
> NOTE: The repository is under construction. There will be a dedicated website and proper documentation at some point!
|
||||
|
||||
You can **try Markdig online** and compare it to other implems on [babelmark3](http://babelmark.github.io/)
|
||||
|
||||
## Features
|
||||
|
||||
- **Very fast parser** (no-regexp), very lightweight in terms of GC pressure. See benchmarks
|
||||
|
||||
@@ -14,10 +14,10 @@ namespace Markdig.Tests
|
||||
{
|
||||
foreach (var pipeline in GetPipeline(extensions))
|
||||
{
|
||||
Console.WriteLine($"Pipeline configured with extensions: {extensions}");
|
||||
Console.WriteLine($"Pipeline configured with extensions: {pipeline.Key}");
|
||||
// Uncomment this line to get more debug information for process inlines.
|
||||
//pipeline.DebugLog = Console.Out;
|
||||
var result = Markdown.ToHtml(inputText, pipeline);
|
||||
var result = Markdown.ToHtml(inputText, pipeline.Value);
|
||||
|
||||
result = Compact(result);
|
||||
expectedOutputText = Compact(expectedOutputText);
|
||||
@@ -34,11 +34,30 @@ namespace Markdig.Tests
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<MarkdownPipeline> GetPipeline(string extensionsGroupText)
|
||||
private static IEnumerable<KeyValuePair<string, MarkdownPipeline>> GetPipeline(string extensionsGroupText)
|
||||
{
|
||||
// For the standard case, we make sure that both the CommmonMark core and Extra/Advanced are CommonMark compliant!
|
||||
if (string.IsNullOrEmpty(extensionsGroupText))
|
||||
{
|
||||
yield return new MarkdownPipelineBuilder().Build();
|
||||
yield return new KeyValuePair<string, MarkdownPipeline>("default", new MarkdownPipelineBuilder().Build());
|
||||
|
||||
yield return new KeyValuePair<string, MarkdownPipeline>("advanced", new MarkdownPipelineBuilder() // Use similar to advanced extension without auto-identifier
|
||||
.UseAbbreviation()
|
||||
//.UseAutoIdentifier()
|
||||
.UseCite()
|
||||
.UseCustomContainer()
|
||||
.UseDefinitionList()
|
||||
.UseEmphasisExtra()
|
||||
.UseFigure()
|
||||
.UseFooter()
|
||||
.UseFootnotes()
|
||||
.UseGridTable()
|
||||
.UseMath()
|
||||
.UseMedia()
|
||||
.UsePipeTable()
|
||||
.UseListExtra()
|
||||
.UseGenericAttributes().Build());
|
||||
|
||||
yield break;
|
||||
}
|
||||
|
||||
@@ -46,7 +65,7 @@ namespace Markdig.Tests
|
||||
foreach (var extensionsText in extensionGroups)
|
||||
{
|
||||
var pipeline = new MarkdownPipelineBuilder().Configure(extensionsText);
|
||||
yield return pipeline.Build();
|
||||
yield return new KeyValuePair<string, MarkdownPipeline>(extensionsText, pipeline.Build());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,8 @@ namespace Markdig.Extensions.Medias
|
||||
if (linkInline.IsImage && linkInline.Url != null)
|
||||
{
|
||||
Uri uri;
|
||||
if (Uri.TryCreate(linkInline.Url, UriKind.RelativeOrAbsolute, out uri))
|
||||
// Only process absolute Uri
|
||||
if (Uri.TryCreate(linkInline.Url, UriKind.RelativeOrAbsolute, out uri) && uri.IsAbsoluteUri)
|
||||
{
|
||||
var htmlAttributes = new HtmlAttributes();
|
||||
var fromAttributes = linkInline.TryGetAttributes();
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Markdig
|
||||
public static class MarkdownExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Uses all extensions except the Emoji, SmartyPants and soft line as hard line breaks.
|
||||
/// Uses all extensions except the BootStrap, Emoji, SmartyPants and soft line as hard line breaks extensions.
|
||||
/// </summary>
|
||||
/// <param name="pipeline">The pipeline.</param>
|
||||
/// <returns>The modified pipeline</returns>
|
||||
@@ -41,7 +41,6 @@ namespace Markdig
|
||||
return pipeline
|
||||
.UseAbbreviation()
|
||||
.UseAutoIdentifier()
|
||||
.UseBootstrap()
|
||||
.UseCite()
|
||||
.UseCustomContainer()
|
||||
.UseDefinitionList()
|
||||
@@ -53,6 +52,7 @@ namespace Markdig
|
||||
.UseMath()
|
||||
.UseMedia()
|
||||
.UsePipeTable()
|
||||
.UseListExtra()
|
||||
.UseGenericAttributes(); // Must be last as it is one parser that is modifying other parsers
|
||||
}
|
||||
|
||||
|
||||
@@ -260,12 +260,10 @@ namespace Markdig.Parsers
|
||||
public void GoToColumn(int newColumn)
|
||||
{
|
||||
// Optimized path when we are moving above the previous start of indent
|
||||
if (newColumn > ColumnBeforeIndent)
|
||||
if (newColumn >= ColumnBeforeIndent)
|
||||
{
|
||||
Line.Start = StartBeforeIndent;
|
||||
Column = ColumnBeforeIndent;
|
||||
ColumnBeforeIndent = 0;
|
||||
StartBeforeIndent = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Markdig.Parsers
|
||||
}
|
||||
|
||||
// If we don't have a blank line, we reset to the indent
|
||||
if (processor.Indent >= 4)
|
||||
if (processor.Indent > 4)
|
||||
{
|
||||
processor.GoToCodeIndent();
|
||||
}
|
||||
|
||||
@@ -25,6 +25,6 @@ namespace Markdig
|
||||
{
|
||||
public static partial class Markdown
|
||||
{
|
||||
public const string Version = "0.3.0";
|
||||
public const string Version = "0.3.3";
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"title": "Markdig",
|
||||
"version": "0.3.0",
|
||||
"version": "0.3.3",
|
||||
"authors": [ "Alexandre Mutel" ],
|
||||
"description": "A fast, powerfull, CommonMark compliant, extensible Markdown processor for .NET",
|
||||
"copyright": "Alexandre Mutel",
|
||||
@@ -9,8 +9,9 @@
|
||||
"owners": [ "Alexandre Mutel" ],
|
||||
"licenseUrl": "https://github.com/lunet-io/markdig/blob/master/license.txt",
|
||||
"projectUrl": "https://github.com/lunet-io/markdig",
|
||||
"iconUrl": "https://raw.githubusercontent.com/lunet-io/markdig/master/images/markdig64.png",
|
||||
"requireLicenseAcceptance": false,
|
||||
"releaseNotes": "Fix potential IndexOutOfRange exception when a backstick were not matched. Add Configure method. Rename UseAllExtensions() by UseAdvancedExtensions()",
|
||||
"releaseNotes": "Update logo for NuGet",
|
||||
"tags": [ "Markdown CommonMark md html md2html" ]
|
||||
},
|
||||
"configurations": {
|
||||
|
||||
Reference in New Issue
Block a user