mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-04 05:44:50 +00:00
Compare commits
52 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc47d33c7d | ||
|
|
fedbe2adc5 | ||
|
|
8efc082d1d | ||
|
|
6c2702f9fd | ||
|
|
4824f460c0 | ||
|
|
46fc840c35 | ||
|
|
ce3078dcf2 | ||
|
|
b8255a87cf | ||
|
|
4f6ad47c6a | ||
|
|
d6d6f9c5c1 | ||
|
|
92b06f0954 | ||
|
|
ecd625d40b | ||
|
|
7e81747662 | ||
|
|
cffe5b2f4b | ||
|
|
c349ead32c | ||
|
|
07e6a13378 | ||
|
|
1b54bb157c | ||
|
|
e23fae26c8 | ||
|
|
2501c6aaf6 | ||
|
|
e390a870cc | ||
|
|
e4892fc86d | ||
|
|
dfc67021ee | ||
|
|
25db2774c3 | ||
|
|
22271db431 | ||
|
|
446764873d | ||
|
|
bdb5119806 | ||
|
|
f3bb06531e | ||
|
|
9a74f3708e | ||
|
|
57033311dc | ||
|
|
bda2f8c9ad | ||
|
|
0d5d3ddb2a | ||
|
|
3f8e50031b | ||
|
|
949d5c0c25 | ||
|
|
31e163f9f7 | ||
|
|
b1440ab788 | ||
|
|
6e55d84f01 | ||
|
|
595dbb9af4 | ||
|
|
d1576fd2ee | ||
|
|
1fe05639c9 | ||
|
|
8afff09b3e | ||
|
|
694747471a | ||
|
|
dfcd5cddfa | ||
|
|
a99b7f4572 | ||
|
|
7d7598db54 | ||
|
|
8767a1d8ed | ||
|
|
16c0829d9e | ||
|
|
fc5d832432 | ||
|
|
7292acc27a | ||
|
|
d05bc1572d | ||
|
|
5aa138425f | ||
|
|
c56041811b | ||
|
|
790bff3baf |
279
changelog.md
279
changelog.md
@@ -1,130 +1,149 @@
|
||||
# Changelog
|
||||
|
||||
## 0.15.1 (10 July 2018)
|
||||
- Add support for `netstandard2.0`
|
||||
- Make AutoIdentifierExtension thread safe
|
||||
|
||||
## 0.15.0 (4 Apr 2018)
|
||||
- Add `ConfigureNewLine` extension method to `MarkdownPipelineBuilder` ([(PR #214)](https://github.com/lunet-io/markdig/pull/214))
|
||||
- Add alternative `Use` extension method to `MarkdownPipelineBuilder` that receives an object instance ([(PR #213)](https://github.com/lunet-io/markdig/pull/213))
|
||||
- Added class attribute to media link extension ([(PR #203)](https://github.com/lunet-io/markdig/pull/203))
|
||||
- Optional link rewriter func for HtmlRenderer #143 ([(PR #201)](https://github.com/lunet-io/markdig/pull/201))
|
||||
- Upgrade NUnit3TestAdapter from 3.2 to 3.9 to address Resharper test runner problems ([(PR #199)](https://github.com/lunet-io/markdig/pull/199))
|
||||
- HTML renderer supports converting relative URLs on links and images to absolute #143 ([(PR #197)](https://github.com/lunet-io/markdig/pull/197))
|
||||
|
||||
## 0.14.9 (15 Jan 2018)
|
||||
- AutoLinkParser should to remove mailto: in outputted text ([(PR #195)](https://github.com/lunet-io/markdig/pull/195))
|
||||
- Add support for `music.yandex.ru` and `ok.ru` for MediaLinks extension ([(PR #193)](https://github.com/lunet-io/markdig/pull/193))
|
||||
## 0.14.8 (05 Dec 2017)
|
||||
- Fix potential StackOverflow exception when processing deep nested `|` delimiters (#179)
|
||||
## 0.14.7 (25 Nov 2017)
|
||||
- Fix autolink attached attributes not being displayed properly (#175)
|
||||
## 0.14.6 (21 Nov 2017)
|
||||
- Fix yaml frontmatter issue when ending with a empty line (#170)
|
||||
## 0.14.5 (18 Nov 2017)
|
||||
- Fix changelog link from nuget package
|
||||
## 0.14.4 (18 Nov 2017)
|
||||
- Add changelog.md
|
||||
- Fix bug when a thematic break is inside a fenced code block inside a pending list (#164)
|
||||
- Add support for GFM autolinks (#165, #169)
|
||||
- Better handle YAML frontmatter in case the opening `---` is never actually closed (#160)
|
||||
- Fix link conflict between a link to an image definition and heading auto-identifiers (#159)
|
||||
## 0.14.3
|
||||
- Make EmojiExtension.EnableSmiley public
|
||||
## 0.14.2
|
||||
- Fix issue with emphasis preceded/followed by an HTML entity (#157)
|
||||
- Add support for link reference definitions for Normalize renderer (#155)
|
||||
- Add option to disable smiley parsing in EmojiAndSmiley extension
|
||||
## 0.14.1
|
||||
- Fix crash in Markdown.Normalize to handle HtmlBlock correctly
|
||||
- Add better handling of bullet character for lists in Markdown.Normalize
|
||||
## 0.14.0
|
||||
- Add Markdown.ToPlainText, Add option HtmlRenderer.EnableHtmlForBlock.
|
||||
- Add Markdown.Normalize, to allow to normalize a markdown document. Add NormalizeRenderer, to render a MarkdownDocument back to markdown.
|
||||
## 0.13.4
|
||||
- Add support for single table header row without a table body rows (#141)
|
||||
- ADd support for `nomnoml` diagrams
|
||||
## 0.13.3
|
||||
- Add support for Pandoc YAML frontmatter (#138)
|
||||
## 0.13.2
|
||||
- Add support for UAP10.0 (#137)
|
||||
## 0.13.1
|
||||
- Fix indenting issue after a double digit list block using a tab (#134)
|
||||
## 0.13.0
|
||||
- Update to latest CommonMark specs 0.28
|
||||
## 0.12.3
|
||||
- Fix issue with HTML blocks for heading h2,h3,h4,h5,h6 that were not correctly identified as HTML blocks as per CommonMark spec
|
||||
## 0.12.2
|
||||
- Fix issue with generic attributes used just before a pipe table (issue #121)
|
||||
## 0.12.1
|
||||
- Fix issue with media links extension when a URL to video is used, an unexpected closing `</iframe>` was inserted (issue #119)
|
||||
## 0.12.0
|
||||
- Add new extension JiraLink support (thanks to @clarkd)
|
||||
- Fix issue in html attributes not parsing correctly properties (thanks to @meziantou)
|
||||
- Fix issues detected by an automatic static code analysis tool
|
||||
## 0.11.0
|
||||
- Fix issue with math extension and $$ block parsing not handling correctly beginning of a $$ as a inline math instead (issue #107)
|
||||
- Fix issue with custom attributes for emphasis
|
||||
- Add support for new special custom arrows emoji (`->` `<-` `<->` `<=` `=>` `<==>`)
|
||||
## 0.10.7
|
||||
- Fix issue when an url ends by a dot `.`
|
||||
## 0.10.6
|
||||
- Fix emphasis with HTML entities
|
||||
## 0.10.5
|
||||
- Several minor fixes
|
||||
## 0.10.4
|
||||
- Fix issue with autolinks
|
||||
- Normalize number of columns for tables
|
||||
## 0.10.3
|
||||
- Fix issue with pipetables shifting a cell to a new column (issue #73)
|
||||
## 0.10.2
|
||||
- Fix exception when trying to urlize an url with an unicode character outside the supported range by NormD (issue #75)
|
||||
## 0.10.1
|
||||
- Update to latest CommonMark specs
|
||||
- Fix source span for LinkReferenceDefinition
|
||||
## 0.10.0
|
||||
- Breaking change of the IMarkdownExtension to allow to receive the MarkdownPipeline for the renderers setup
|
||||
## 0.9.1
|
||||
- Fix regression bug with conflicts between autolink extension and html inline/regular links
|
||||
## 0.9.0
|
||||
- Add new Autolink extension
|
||||
## 0.8.5
|
||||
- Allow to force table column alignment to left
|
||||
## 0.8.4
|
||||
- Fix issue when calculating the span of an indented code block within a list. Make sure to include first whitespace on the line
|
||||
## 0.8.3
|
||||
- fix NullReferenceException with Gridtables extension when a single `+` is entered on a line
|
||||
## 0.8.2
|
||||
- fix potential cast exception with Abreviation extension and empty literals
|
||||
## 0.8.1
|
||||
- new extension to disable URI escaping for non-US-ASCII characters to workaround a bug in Edge/IE
|
||||
- Fix an issue with abbreviations with left/right multiple non-punctuation/space characters
|
||||
## 0.8.0
|
||||
- Update to latest CommonMark specs
|
||||
- Fix empty literal
|
||||
- Add YAML frontmatter extension
|
||||
## 0.7.5
|
||||
- several bug fixes (pipe tables, disable HTML, special attributes, inline maths, abbreviations...)
|
||||
- add support for rowspan in grid tables
|
||||
## 0.7.4
|
||||
- Fix bug with strong emphasis starting at the beginning of a line
|
||||
## 0.7.3
|
||||
- Fix threading issue with pipeline
|
||||
## 0.7.2
|
||||
- Fix rendering of table colspan with non english locale
|
||||
- Fix grid table colspan parsing
|
||||
- Add nofollow extension for links
|
||||
## 0.7.1
|
||||
- Fix issue in smarty pants which could lead to an InvalidCastException
|
||||
- Update parsers to latest CommonMark specs
|
||||
## 0.7.0
|
||||
- Update to latest NETStandard.Library 1.6.0
|
||||
- Fix issue with digits in auto-identifier extension
|
||||
- Fix incorrect start of span calculated for code indented blocks
|
||||
## 0.6.2
|
||||
- Handle latest CommonMark specs for corner cases for emphasis (See https://talk.commonmark.org/t/emphasis-strong-emphasis-corner-cases/2123/1 )
|
||||
## 0.6.1:
|
||||
- Fix issue with autoidentifier extension overriding manual HTML attributes id on headings
|
||||
## 0.6.0
|
||||
- Fix conflicts between PipeTables and SmartyPants extensions
|
||||
- Add SelfPipeline extension
|
||||
# Changelog
|
||||
|
||||
## 0.15.5 (11 Dec 2018)
|
||||
- Empty image alt text for link reference definitions ([(PR #254)](https://github.com/lunet-io/markdig/pull/254))
|
||||
- Fix AutoLink Match links without slash after domain ([(PR #260)](https://github.com/lunet-io/markdig/pull/260))
|
||||
- Make AutoLink ValidPreviousCharacters configurable ([(PR #264)](https://github.com/lunet-io/markdig/pull/264))
|
||||
- Ensuring line breaks when renderer does not have html enabled ([(PR #270)](https://github.com/lunet-io/markdig/pull/270))
|
||||
|
||||
## 0.15.4 (07 Oct 2018)
|
||||
- Add autolink domain GFM validation ([(PR #239)](https://github.com/lunet-io/markdig/pull/253))
|
||||
|
||||
## 0.15.3 (15 Sep 2018)
|
||||
- Add support for RTL ([(PR #239)](https://github.com/lunet-io/markdig/pull/239))
|
||||
- Add MarkdownDocument.LineCount ([(PR #241)](https://github.com/lunet-io/markdig/pull/241))
|
||||
- Fix source positions for link definitions ([(PR #243)](https://github.com/lunet-io/markdig/pull/243))
|
||||
- Add ListItemBlock.Order ([(PR #244)](https://github.com/lunet-io/markdig/pull/244))
|
||||
- Add MarkdownDocument.LineStartIndexes ([(PR #247)](https://github.com/lunet-io/markdig/pull/247))
|
||||
|
||||
## 0.15.2 (21 Aug 2018)
|
||||
- Fix footnotes parsing when they are defined after a container that has been closed in the meantime (#223)
|
||||
|
||||
## 0.15.1 (10 July 2018)
|
||||
- Add support for `netstandard2.0`
|
||||
- Make AutoIdentifierExtension thread safe
|
||||
|
||||
## 0.15.0 (4 Apr 2018)
|
||||
- Add `ConfigureNewLine` extension method to `MarkdownPipelineBuilder` ([(PR #214)](https://github.com/lunet-io/markdig/pull/214))
|
||||
- Add alternative `Use` extension method to `MarkdownPipelineBuilder` that receives an object instance ([(PR #213)](https://github.com/lunet-io/markdig/pull/213))
|
||||
- Added class attribute to media link extension ([(PR #203)](https://github.com/lunet-io/markdig/pull/203))
|
||||
- Optional link rewriter func for HtmlRenderer #143 ([(PR #201)](https://github.com/lunet-io/markdig/pull/201))
|
||||
- Upgrade NUnit3TestAdapter from 3.2 to 3.9 to address Resharper test runner problems ([(PR #199)](https://github.com/lunet-io/markdig/pull/199))
|
||||
- HTML renderer supports converting relative URLs on links and images to absolute #143 ([(PR #197)](https://github.com/lunet-io/markdig/pull/197))
|
||||
|
||||
## 0.14.9 (15 Jan 2018)
|
||||
- AutoLinkParser should to remove mailto: in outputted text ([(PR #195)](https://github.com/lunet-io/markdig/pull/195))
|
||||
- Add support for `music.yandex.ru` and `ok.ru` for MediaLinks extension ([(PR #193)](https://github.com/lunet-io/markdig/pull/193))
|
||||
## 0.14.8 (05 Dec 2017)
|
||||
- Fix potential StackOverflow exception when processing deep nested `|` delimiters (#179)
|
||||
## 0.14.7 (25 Nov 2017)
|
||||
- Fix autolink attached attributes not being displayed properly (#175)
|
||||
## 0.14.6 (21 Nov 2017)
|
||||
- Fix yaml frontmatter issue when ending with a empty line (#170)
|
||||
## 0.14.5 (18 Nov 2017)
|
||||
- Fix changelog link from nuget package
|
||||
## 0.14.4 (18 Nov 2017)
|
||||
- Add changelog.md
|
||||
- Fix bug when a thematic break is inside a fenced code block inside a pending list (#164)
|
||||
- Add support for GFM autolinks (#165, #169)
|
||||
- Better handle YAML frontmatter in case the opening `---` is never actually closed (#160)
|
||||
- Fix link conflict between a link to an image definition and heading auto-identifiers (#159)
|
||||
## 0.14.3
|
||||
- Make EmojiExtension.EnableSmiley public
|
||||
## 0.14.2
|
||||
- Fix issue with emphasis preceded/followed by an HTML entity (#157)
|
||||
- Add support for link reference definitions for Normalize renderer (#155)
|
||||
- Add option to disable smiley parsing in EmojiAndSmiley extension
|
||||
## 0.14.1
|
||||
- Fix crash in Markdown.Normalize to handle HtmlBlock correctly
|
||||
- Add better handling of bullet character for lists in Markdown.Normalize
|
||||
## 0.14.0
|
||||
- Add Markdown.ToPlainText, Add option HtmlRenderer.EnableHtmlForBlock.
|
||||
- Add Markdown.Normalize, to allow to normalize a markdown document. Add NormalizeRenderer, to render a MarkdownDocument back to markdown.
|
||||
## 0.13.4
|
||||
- Add support for single table header row without a table body rows (#141)
|
||||
- ADd support for `nomnoml` diagrams
|
||||
## 0.13.3
|
||||
- Add support for Pandoc YAML frontmatter (#138)
|
||||
## 0.13.2
|
||||
- Add support for UAP10.0 (#137)
|
||||
## 0.13.1
|
||||
- Fix indenting issue after a double digit list block using a tab (#134)
|
||||
## 0.13.0
|
||||
- Update to latest CommonMark specs 0.28
|
||||
## 0.12.3
|
||||
- Fix issue with HTML blocks for heading h2,h3,h4,h5,h6 that were not correctly identified as HTML blocks as per CommonMark spec
|
||||
## 0.12.2
|
||||
- Fix issue with generic attributes used just before a pipe table (issue #121)
|
||||
## 0.12.1
|
||||
- Fix issue with media links extension when a URL to video is used, an unexpected closing `</iframe>` was inserted (issue #119)
|
||||
## 0.12.0
|
||||
- Add new extension JiraLink support (thanks to @clarkd)
|
||||
- Fix issue in html attributes not parsing correctly properties (thanks to @meziantou)
|
||||
- Fix issues detected by an automatic static code analysis tool
|
||||
## 0.11.0
|
||||
- Fix issue with math extension and $$ block parsing not handling correctly beginning of a $$ as a inline math instead (issue #107)
|
||||
- Fix issue with custom attributes for emphasis
|
||||
- Add support for new special custom arrows emoji (`->` `<-` `<->` `<=` `=>` `<==>`)
|
||||
## 0.10.7
|
||||
- Fix issue when an url ends by a dot `.`
|
||||
## 0.10.6
|
||||
- Fix emphasis with HTML entities
|
||||
## 0.10.5
|
||||
- Several minor fixes
|
||||
## 0.10.4
|
||||
- Fix issue with autolinks
|
||||
- Normalize number of columns for tables
|
||||
## 0.10.3
|
||||
- Fix issue with pipetables shifting a cell to a new column (issue #73)
|
||||
## 0.10.2
|
||||
- Fix exception when trying to urlize an url with an unicode character outside the supported range by NormD (issue #75)
|
||||
## 0.10.1
|
||||
- Update to latest CommonMark specs
|
||||
- Fix source span for LinkReferenceDefinition
|
||||
## 0.10.0
|
||||
- Breaking change of the IMarkdownExtension to allow to receive the MarkdownPipeline for the renderers setup
|
||||
## 0.9.1
|
||||
- Fix regression bug with conflicts between autolink extension and html inline/regular links
|
||||
## 0.9.0
|
||||
- Add new Autolink extension
|
||||
## 0.8.5
|
||||
- Allow to force table column alignment to left
|
||||
## 0.8.4
|
||||
- Fix issue when calculating the span of an indented code block within a list. Make sure to include first whitespace on the line
|
||||
## 0.8.3
|
||||
- fix NullReferenceException with Gridtables extension when a single `+` is entered on a line
|
||||
## 0.8.2
|
||||
- fix potential cast exception with Abreviation extension and empty literals
|
||||
## 0.8.1
|
||||
- new extension to disable URI escaping for non-US-ASCII characters to workaround a bug in Edge/IE
|
||||
- Fix an issue with abbreviations with left/right multiple non-punctuation/space characters
|
||||
## 0.8.0
|
||||
- Update to latest CommonMark specs
|
||||
- Fix empty literal
|
||||
- Add YAML frontmatter extension
|
||||
## 0.7.5
|
||||
- several bug fixes (pipe tables, disable HTML, special attributes, inline maths, abbreviations...)
|
||||
- add support for rowspan in grid tables
|
||||
## 0.7.4
|
||||
- Fix bug with strong emphasis starting at the beginning of a line
|
||||
## 0.7.3
|
||||
- Fix threading issue with pipeline
|
||||
## 0.7.2
|
||||
- Fix rendering of table colspan with non english locale
|
||||
- Fix grid table colspan parsing
|
||||
- Add nofollow extension for links
|
||||
## 0.7.1
|
||||
- Fix issue in smarty pants which could lead to an InvalidCastException
|
||||
- Update parsers to latest CommonMark specs
|
||||
## 0.7.0
|
||||
- Update to latest NETStandard.Library 1.6.0
|
||||
- Fix issue with digits in auto-identifier extension
|
||||
- Fix incorrect start of span calculated for code indented blocks
|
||||
## 0.6.2
|
||||
- Handle latest CommonMark specs for corner cases for emphasis (See https://talk.commonmark.org/t/emphasis-strong-emphasis-corner-cases/2123/1 )
|
||||
## 0.6.1:
|
||||
- Fix issue with autoidentifier extension overriding manual HTML attributes id on headings
|
||||
## 0.6.0
|
||||
- Fix conflicts between PipeTables and SmartyPants extensions
|
||||
- Add SelfPipeline extension
|
||||
|
||||
@@ -77,6 +77,7 @@
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="project.json" />
|
||||
<None Include="Specs\GlobalizationSpecs.md" />
|
||||
<None Include="Specs\JiraLinks.md" />
|
||||
<None Include="Specs\AutoLinks.md" />
|
||||
<None Include="Specs\AutoIdentifierSpecs.md" />
|
||||
|
||||
@@ -77,6 +77,14 @@ Check **http://www.a.com** or __http://www.b.com__
|
||||
<p>Check <strong><a href="http://www.a.com">http://www.a.com</a></strong> or <strong><a href="http://www.b.com">http://www.b.com</a></strong></p>
|
||||
````````````````````````````````
|
||||
|
||||
It is not mentioned by the spec, but empty emails won't be matched (only a subset of [RFC2368](https://tools.ietf.org/html/rfc2368) is supported by auto links):
|
||||
|
||||
```````````````````````````````` example
|
||||
mailto:email@test.com is okay, but mailto:@test.com is not
|
||||
.
|
||||
<p><a href="mailto:email@test.com">email@test.com</a> is okay, but mailto:@test.com is not</p>
|
||||
````````````````````````````````
|
||||
|
||||
### GFM Support
|
||||
|
||||
Extract from [GFM Autolinks extensions specs](https://github.github.com/gfm/#autolinks-extension-)
|
||||
@@ -140,3 +148,95 @@ Anonymous FTP is available at ftp://foo.bar.baz.
|
||||
<p>(Visit <a href="https://encrypted.google.com/search?q=Markup+(business)">https://encrypted.google.com/search?q=Markup+(business)</a>)</p>
|
||||
<p>Anonymous FTP is available at <a href="ftp://foo.bar.baz">ftp://foo.bar.baz</a>.</p>
|
||||
````````````````````````````````
|
||||
|
||||
### Valid Domain Tests
|
||||
|
||||
Domain names that have empty segments won't be matched
|
||||
|
||||
```````````````````````````````` example
|
||||
www..
|
||||
www..com
|
||||
http://test.
|
||||
http://.test
|
||||
http://.
|
||||
http://..
|
||||
ftp://test.
|
||||
ftp://.test
|
||||
mailto:email@test.
|
||||
mailto:email@.test
|
||||
.
|
||||
<p>www..
|
||||
www..com
|
||||
http://test.
|
||||
http://.test
|
||||
http://.
|
||||
http://..
|
||||
ftp://test.
|
||||
ftp://.test
|
||||
mailto:email@test.
|
||||
mailto:email@.test</p>
|
||||
````````````````````````````````
|
||||
|
||||
Domain names with too few segments won't be matched
|
||||
|
||||
```````````````````````````````` example
|
||||
www
|
||||
www.com
|
||||
http://test
|
||||
ftp://test
|
||||
mailto:email@test
|
||||
.
|
||||
<p>www
|
||||
www.com
|
||||
http://test
|
||||
ftp://test
|
||||
mailto:email@test</p>
|
||||
````````````````````````````````
|
||||
|
||||
Domain names that contain an underscores in the last two segments won't be matched
|
||||
|
||||
```````````````````````````````` example
|
||||
www._test.foo.bar is okay, but www._test.foo is not
|
||||
|
||||
http://te_st.foo.bar is okay, as is http://test.foo_.bar.foo
|
||||
|
||||
But http://te_st.foo, http://test.foo_.bar and http://test._foo are not
|
||||
|
||||
ftp://test_.foo.bar is okay, but ftp://test.fo_o is not
|
||||
|
||||
mailto:email@_test.foo.bar is okay, but mailto:email@_test.foo is not
|
||||
.
|
||||
<p><a href="http://www._test.foo.bar">www._test.foo.bar</a> is okay, but www._test.foo is not</p>
|
||||
<p><a href="http://te_st.foo.bar">http://te_st.foo.bar</a> is okay, as is <a href="http://test.foo_.bar.foo">http://test.foo_.bar.foo</a></p>
|
||||
<p>But http://te_st.foo, http://test.foo_.bar and http://test._foo are not</p>
|
||||
<p><a href="ftp://test_.foo.bar">ftp://test_.foo.bar</a> is okay, but ftp://test.fo_o is not</p>
|
||||
<p><a href="mailto:email@_test.foo.bar">email@_test.foo.bar</a> is okay, but mailto:email@_test.foo is not</p>
|
||||
````````````````````````````````
|
||||
|
||||
Domain names that contain invalid characters (not AlphaNumberic, -, _ or .) won't be matched
|
||||
|
||||
```````````````````````````````` example
|
||||
https://[your-domain]/api
|
||||
.
|
||||
<p>https://[your-domain]/api</p>
|
||||
````````````````````````````````
|
||||
|
||||
Domain names followed by ?, : or # instead of / are matched
|
||||
|
||||
```````````````````````````````` example
|
||||
https://github.com?
|
||||
|
||||
https://github.com?a
|
||||
|
||||
https://github.com#a
|
||||
|
||||
https://github.com:
|
||||
|
||||
https://github.com:443
|
||||
.
|
||||
<p><a href="https://github.com">https://github.com</a>?</p>
|
||||
<p><a href="https://github.com?a">https://github.com?a</a></p>
|
||||
<p><a href="https://github.com#a">https://github.com#a</a></p>
|
||||
<p><a href="https://github.com">https://github.com</a>:</p>
|
||||
<p><a href="https://github.com:443">https://github.com:443</a></p>
|
||||
````````````````````````````````
|
||||
@@ -4,7 +4,7 @@ This section describes the different extensions supported:
|
||||
|
||||
## Custom Container
|
||||
|
||||
A custom container is similar to a fenced code block, but it is using the character `:` to declare a block (with at least 3 characters), and instead of generating a `<pre><code>...</code></pre>` it will generate a `<div>...</dib>` block.
|
||||
A custom container is similar to a fenced code block, but it is using the character `:` to declare a block (with at least 3 characters), and instead of generating a `<pre><code>...</code></pre>` it will generate a `<div>...</div>` block.
|
||||
|
||||
```````````````````````````````` example
|
||||
:::spoiler
|
||||
@@ -109,4 +109,4 @@ Attributes can be attached to a inline custom container:
|
||||
This is a text ::with special emphasis::{#myId .myemphasis}
|
||||
.
|
||||
<p>This is a text <span id="myId" class="myemphasis">with special emphasis</span></p>
|
||||
````````````````````````````````
|
||||
````````````````````````````````
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
This section describes the different extensions supported:
|
||||
|
||||
## Footontes
|
||||
## Footnotes
|
||||
|
||||
Allows footnotes using the following syntax (taken from pandoc example):
|
||||
|
||||
@@ -118,3 +118,24 @@ Here is a footnote[^1]. And another one[^2]. And a third one[^3]. And a fourth[^
|
||||
</ol>
|
||||
</div>
|
||||
````````````````````````````````
|
||||
|
||||
A footnote link inside a list should work as well:
|
||||
|
||||
```````````````````````````````` example
|
||||
- abc
|
||||
- def[^1]
|
||||
|
||||
[^1]: Here is the footnote.
|
||||
.
|
||||
<ul>
|
||||
<li>abc</li>
|
||||
<li>def<a id="fnref:1" href="#fn:1" class="footnote-ref"><sup>1</sup></a></li>
|
||||
</ul>
|
||||
<div class="footnotes">
|
||||
<hr />
|
||||
<ol>
|
||||
<li id="fn:1">
|
||||
<p>Here is the footnote.<a href="#fnref:1" class="footnote-back-ref">↩</a></p></li>
|
||||
</ol>
|
||||
</div>
|
||||
````````````````````````````````
|
||||
|
||||
189
src/Markdig.Tests/Specs/GlobalizationSpecs.md
Normal file
189
src/Markdig.Tests/Specs/GlobalizationSpecs.md
Normal file
@@ -0,0 +1,189 @@
|
||||
# Extensions
|
||||
|
||||
This section describes the different extensions supported:
|
||||
|
||||
## Globalization
|
||||
Adds support for RTL content by adding `dir="rtl"` and `align="right` attributes to the appropriate html elements. Left to right text is not affected by this extension.
|
||||
|
||||
Whether a markdown block is marked as RTL or not is determined by the [first strong character](https://en.wikipedia.org/wiki/Bi-directional_text#Strong_characters) of the block.
|
||||
|
||||
**Note**: You might need to add `<meta charset="UTF-8">` to the head of the html file to be able to see the result correctly.
|
||||
|
||||
Headings and block quotes:
|
||||
```````````````````````````````` example
|
||||
# Fruits
|
||||
In botany, a [fruit](https://en.wikipedia.org/wiki/Fruit) is the seed-bearing structure in flowering plants (also known as angiosperms) formed from the ovary after flowering.
|
||||
|
||||
> Fruits are good for health
|
||||
-- Anonymous
|
||||
|
||||
# میوە
|
||||
[میوە](https://ckb.wikipedia.org/wiki/%D9%85%DB%8C%D9%88%DB%95) یان مێوە بەروبوومی ڕوەکیە کە ڕوەکەکان ھەڵیان ئەگرن وەک بەرگێک بۆ تۆوەکانیان، بە زۆری جیادەکرێتەوە بە شیرینی یان ترشی لە تامدا و بە بوونی بڕێکی زۆر ئاو
|
||||
|
||||
> میوە بۆ تەندروستی باشە
|
||||
-- نەزانراو
|
||||
.
|
||||
<h1 id="fruits">Fruits</h1>
|
||||
<p>In botany, a <a href="https://en.wikipedia.org/wiki/Fruit">fruit</a> is the seed-bearing structure in flowering plants (also known as angiosperms) formed from the ovary after flowering.</p>
|
||||
<blockquote>
|
||||
<p>Fruits are good for health
|
||||
-- Anonymous</p>
|
||||
</blockquote>
|
||||
<h1 id="section" dir="rtl">میوە</h1>
|
||||
<p dir="rtl"><a href="https://ckb.wikipedia.org/wiki/%D9%85%DB%8C%D9%88%DB%95" dir="rtl">میوە</a> یان مێوە بەروبوومی ڕوەکیە کە ڕوەکەکان ھەڵیان ئەگرن وەک بەرگێک بۆ تۆوەکانیان، بە زۆری جیادەکرێتەوە بە شیرینی یان ترشی لە تامدا و بە بوونی بڕێکی زۆر ئاو</p>
|
||||
<blockquote dir="rtl">
|
||||
<p dir="rtl">میوە بۆ تەندروستی باشە
|
||||
-- نەزانراو</p>
|
||||
</blockquote>
|
||||
````````````````````````````````
|
||||
|
||||
Lists:
|
||||
```````````````````````````````` example
|
||||
## Types of fruits
|
||||
- Berries
|
||||
- Strawberry
|
||||
- kiwifruit
|
||||
- Citrus
|
||||
- Orange
|
||||
- Lemon
|
||||
|
||||
## Examples of fruits :yum:
|
||||
1. Apple
|
||||
2. Banana
|
||||
3. Orange
|
||||
|
||||
## Grocery List
|
||||
- [X] Watermelon
|
||||
- [X] Apricot
|
||||
- [ ] Fig
|
||||
|
||||
## نموونەی میوە :yum:
|
||||
1. ? سێو
|
||||
2. 5 مۆز
|
||||
3. پرتەقاڵ
|
||||
|
||||
## جۆرەکانی میوە
|
||||
- توو
|
||||
- فڕاولە
|
||||
- کیوی
|
||||
- مزرەمەنی
|
||||
- پڕتەقاڵ
|
||||
- لیمۆ
|
||||
|
||||
## لیستی کڕین
|
||||
- [X] شووتی
|
||||
- [X] قەیسی
|
||||
- [ ] هەنجیر
|
||||
.
|
||||
<h2 id="types-of-fruits">Types of fruits</h2>
|
||||
<ul>
|
||||
<li>Berries
|
||||
<ul>
|
||||
<li>Strawberry</li>
|
||||
<li>kiwifruit</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Citrus
|
||||
<ul>
|
||||
<li>Orange</li>
|
||||
<li>Lemon</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<h2 id="examples-of-fruits">Examples of fruits 😋</h2>
|
||||
<ol>
|
||||
<li>Apple</li>
|
||||
<li>Banana</li>
|
||||
<li>Orange</li>
|
||||
</ol>
|
||||
<h2 id="grocery-list">Grocery List</h2>
|
||||
<ul class="contains-task-list">
|
||||
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> Watermelon</li>
|
||||
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> Apricot</li>
|
||||
<li class="task-list-item"><input disabled="disabled" type="checkbox" /> Fig</li>
|
||||
</ul>
|
||||
<h2 id="section" dir="rtl">نموونەی میوە 😋</h2>
|
||||
<ol dir="rtl">
|
||||
<li>? سێو</li>
|
||||
<li>5 مۆز</li>
|
||||
<li> پرتەقاڵ</li>
|
||||
</ol>
|
||||
<h2 id="section-1" dir="rtl">جۆرەکانی میوە</h2>
|
||||
<ul dir="rtl">
|
||||
<li>توو
|
||||
<ul dir="rtl">
|
||||
<li>فڕاولە</li>
|
||||
<li>کیوی</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>مزرەمەنی
|
||||
<ul dir="rtl">
|
||||
<li>پڕتەقاڵ</li>
|
||||
<li>لیمۆ</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<h2 id="section-2" dir="rtl">لیستی کڕین</h2>
|
||||
<ul class="contains-task-list" dir="rtl">
|
||||
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> شووتی</li>
|
||||
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> قەیسی</li>
|
||||
<li class="task-list-item"><input disabled="disabled" type="checkbox" /> هەنجیر</li>
|
||||
</ul>
|
||||
````````````````````````````````
|
||||
|
||||
Tables:
|
||||
|
||||
```````````````````````````````` example
|
||||
Nuitrion |Apple | Oranges
|
||||
--|-- | --
|
||||
Calories|52|47
|
||||
Sugar|10g|9g
|
||||
|
||||
پێکهاتە |سێو | پڕتەقاڵ
|
||||
--|-- | --
|
||||
کالۆری|٥٢|٤٧
|
||||
شەکر| ١٠گ|٩گ
|
||||
.
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Nuitrion</th>
|
||||
<th>Apple</th>
|
||||
<th>Oranges</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Calories</td>
|
||||
<td>52</td>
|
||||
<td>47</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Sugar</td>
|
||||
<td>10g</td>
|
||||
<td>9g</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table dir="rtl" align="right">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>پێکهاتە</th>
|
||||
<th>سێو</th>
|
||||
<th>پڕتەقاڵ</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>کالۆری</td>
|
||||
<td>٥٢</td>
|
||||
<td>٤٧</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>شەکر</td>
|
||||
<td>١٠گ</td>
|
||||
<td>٩گ</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
````````````````````````````````
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
<#/*
|
||||
Copyright (c) Alexandre Mutel. All rights reserved.
|
||||
This file is licensed under the BSD-Clause 2 license.
|
||||
This file is licensed under the BSD-Clause 2 license.
|
||||
See the license.txt file in the project root for more information.The MIT License (MIT)
|
||||
|
||||
This is a modified version of code released previously with the following license:
|
||||
@@ -63,10 +63,12 @@ SOFTWARE.
|
||||
new KeyValuePair<string, string>(Host.ResolvePath("YamlSpecs.md"), "yaml"),
|
||||
new KeyValuePair<string, string>(Host.ResolvePath("AutoLinks.md"), "autolinks|advanced"),
|
||||
new KeyValuePair<string, string>(Host.ResolvePath("JiraLinks.md"), "jiralinks"),
|
||||
new KeyValuePair<string, string>(Host.ResolvePath("GlobalizationSpecs.md"), "globalization+advanced+emojis"),
|
||||
};
|
||||
var emptyLines = false;
|
||||
var displayEmptyLines = false;
|
||||
#>
|
||||
// Generated the <#= DateTime.Now #>
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ This is a text
|
||||
This is a text</p>
|
||||
````````````````````````````````
|
||||
|
||||
Front matter ends with the first line containing three dots `...` or three dashes `...`:
|
||||
Front matter ends with the first line containing three dots `...` or three dashes `---`:
|
||||
|
||||
```````````````````````````````` example
|
||||
---
|
||||
|
||||
@@ -21,5 +21,22 @@ namespace Markdig.Tests
|
||||
var actual = Markdown.ToHtml(markdownText, pipeline);
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase(/* newLineForWriting: */ "\n", /* markdownText: */ "*1*\n*2*\n", /* expected: */ "1\n2\n")]
|
||||
[TestCase(/* newLineForWriting: */ "\n", /* markdownText: */ "*1*\r\n*2*\r\n", /* expected: */ "1\n2\n")]
|
||||
[TestCase(/* newLineForWriting: */ "\r\n", /* markdownText: */ "*1*\n*2*\n", /* expected: */ "1\r\n2\r\n")]
|
||||
[TestCase(/* newLineForWriting: */ "\r\n", /* markdownText: */ "*1*\r\n*2*\r\n", /* expected: */ "1\r\n2\r\n")]
|
||||
[TestCase(/* newLineForWriting: */ "!!!", /* markdownText: */ "*1*\n*2*\n", /* expected: */ "1!!!2!!!")]
|
||||
[TestCase(/* newLineForWriting: */ "!!!", /* markdownText: */ "*1*\r\n*2*\r\n", /* expected: */ "1!!!2!!!")]
|
||||
public void TestPlainOutputWhenConfiguringNewLine(string newLineForWriting, string markdownText, string expected)
|
||||
{
|
||||
var pipeline = new MarkdownPipelineBuilder()
|
||||
.ConfigureNewLine(newLineForWriting)
|
||||
.Build();
|
||||
|
||||
var actual = Markdown.ToPlainText(markdownText, pipeline);
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
25
src/Markdig.Tests/TestImageAltText.cs
Normal file
25
src/Markdig.Tests/TestImageAltText.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using NUnit.Framework;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Markdig.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestImageAltText
|
||||
{
|
||||
[Test]
|
||||
[TestCase("", "")]
|
||||
[TestCase("", "foo")]
|
||||
[TestCase("![][1]\n\n[1]: image.jpg", "")]
|
||||
[TestCase("![bar][1]\n\n[1]: image.jpg", "bar")]
|
||||
[TestCase("", "")]
|
||||
[TestCase("", "foo")]
|
||||
[TestCase("![][1]\n\n[1]: image.jpg 'title'", "")]
|
||||
[TestCase("![bar][1]\n\n[1]: image.jpg 'title'", "bar")]
|
||||
public void TestImageHtmlAltText(string markdown, string expectedAltText)
|
||||
{
|
||||
string html = Markdown.ToHtml(markdown);
|
||||
string actualAltText = Regex.Match(html, "alt=\"(.*?)\"").Groups[1].Value;
|
||||
Assert.AreEqual(expectedAltText, actualAltText);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,9 +9,30 @@ namespace Markdig.Tests
|
||||
public void TestPlain()
|
||||
{
|
||||
var markdownText = "*Hello*, [world](http://example.com)!";
|
||||
var expected = "Hello, world!";
|
||||
var expected = "Hello, world!\n";
|
||||
var actual = Markdown.ToPlainText(markdownText);
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase(/* markdownText: */ "foo bar", /* expected: */ "foo bar\n")]
|
||||
[TestCase(/* markdownText: */ "foo\nbar", /* expected: */ "foo\nbar\n")]
|
||||
[TestCase(/* markdownText: */ "*foo\nbar*", /* expected: */ "foo\nbar\n")]
|
||||
[TestCase(/* markdownText: */ "[foo\nbar](http://example.com)", /* expected: */ "foo\nbar\n")]
|
||||
[TestCase(/* markdownText: */ "<http://foo.bar.baz>", /* expected: */ "http://foo.bar.baz\n")]
|
||||
[TestCase(/* markdownText: */ "# foo bar", /* expected: */ "foo bar\n")]
|
||||
[TestCase(/* markdownText: */ "# foo\nbar", /* expected: */ "foo\nbar\n")]
|
||||
[TestCase(/* markdownText: */ "> foo", /* expected: */ "foo\n")]
|
||||
[TestCase(/* markdownText: */ "> foo\nbar\n> baz", /* expected: */ "foo\nbar\nbaz\n")]
|
||||
[TestCase(/* markdownText: */ "`foo`", /* expected: */ "foo\n")]
|
||||
[TestCase(/* markdownText: */ "`foo\nbar`", /* expected: */ "foo bar\n")] // new line within codespan is treated as whitespace (Example317)
|
||||
[TestCase(/* markdownText: */ "```\nfoo bar\n```", /* expected: */ "foo bar\n")]
|
||||
[TestCase(/* markdownText: */ "- foo\n- bar\n- baz", /* expected: */ "foo\nbar\nbaz\n")]
|
||||
public void TestPlainEnsureNewLine(string markdownText, string expected)
|
||||
{
|
||||
var actual = Markdown.ToPlainText(markdownText);
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Alexandre Mutel. All rights reserved.
|
||||
// Copyright (c) Alexandre Mutel. All rights reserved.
|
||||
// This file is licensed under the BSD-Clause 2 license.
|
||||
// See the license.txt file in the project root for more information.
|
||||
|
||||
@@ -6,6 +6,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Markdig.Extensions.Footnotes;
|
||||
using Markdig.Helpers;
|
||||
using Markdig.Renderers.Html;
|
||||
using Markdig.Syntax;
|
||||
@@ -140,6 +141,48 @@ literal ( 0, 2) 2-3
|
||||
emphasis ( 0, 4) 4-9
|
||||
literal ( 0, 6) 6-7
|
||||
");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFootnoteLinkReferenceDefinition()
|
||||
{
|
||||
// 01 2 345678
|
||||
var footnote = Markdown.Parse("0\n\n [^1]:", new MarkdownPipelineBuilder().UsePreciseSourceLocation().UseFootnotes().Build()).Descendants().OfType<FootnoteLinkReferenceDefinition>().FirstOrDefault();
|
||||
Assert.NotNull(footnote);
|
||||
|
||||
Assert.AreEqual(2, footnote.Line);
|
||||
Assert.AreEqual(new SourceSpan(4, 7), footnote.Span);
|
||||
Assert.AreEqual(new SourceSpan(5, 6), footnote.LabelSpan);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestLinkReferenceDefinition1()
|
||||
{
|
||||
// 0 1
|
||||
// 0123456789012345
|
||||
var link = Markdown.Parse("[234]: /56 'yo' ", new MarkdownPipelineBuilder().UsePreciseSourceLocation().Build()).Descendants().OfType<LinkReferenceDefinition>().FirstOrDefault();
|
||||
Assert.NotNull(link);
|
||||
|
||||
Assert.AreEqual(0, link.Line);
|
||||
Assert.AreEqual(new SourceSpan(0, 14), link.Span);
|
||||
Assert.AreEqual(new SourceSpan(1, 3), link.LabelSpan);
|
||||
Assert.AreEqual(new SourceSpan(7, 9), link.UrlSpan);
|
||||
Assert.AreEqual(new SourceSpan(11, 14), link.TitleSpan);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestLinkReferenceDefinition2()
|
||||
{
|
||||
// 0 1
|
||||
// 01 2 34567890123456789
|
||||
var link = Markdown.Parse("0\n\n [234]: /56 'yo' ", new MarkdownPipelineBuilder().UsePreciseSourceLocation().Build()).Descendants().OfType<LinkReferenceDefinition>().FirstOrDefault();
|
||||
Assert.NotNull(link);
|
||||
|
||||
Assert.AreEqual(2, link.Line);
|
||||
Assert.AreEqual(new SourceSpan(4, 18), link.Span);
|
||||
Assert.AreEqual(new SourceSpan(5, 7), link.LabelSpan);
|
||||
Assert.AreEqual(new SourceSpan(11, 13), link.UrlSpan);
|
||||
Assert.AreEqual(new SourceSpan(15, 18), link.TitleSpan);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -353,6 +396,42 @@ listitem ( 1, 0) 4-6
|
||||
paragraph ( 1, 2) 6-6
|
||||
literal ( 1, 2) 6-6
|
||||
");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestListBlock2()
|
||||
{
|
||||
string test = @"
|
||||
1. Foo
|
||||
9. Bar
|
||||
5. Foo
|
||||
6. Bar
|
||||
987123. FooBar";
|
||||
test = test.Replace("\r\n", "\n");
|
||||
var list = Markdown.Parse(test, new MarkdownPipelineBuilder().UsePreciseSourceLocation().Build()).Descendants().OfType<ListBlock>().FirstOrDefault();
|
||||
Assert.NotNull(list);
|
||||
|
||||
Assert.AreEqual(1, list.Line);
|
||||
Assert.True(list.IsOrdered);
|
||||
List<ListItemBlock> items = list.Cast<ListItemBlock>().ToList();
|
||||
Assert.AreEqual(5, items.Count);
|
||||
|
||||
// Test orders
|
||||
Assert.AreEqual(1, items[0].Order);
|
||||
Assert.AreEqual(9, items[1].Order);
|
||||
Assert.AreEqual(5, items[2].Order);
|
||||
Assert.AreEqual(6, items[3].Order);
|
||||
Assert.AreEqual(987123, items[4].Order);
|
||||
|
||||
// Test positions
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
Assert.AreEqual(i + 1, items[i].Line);
|
||||
Assert.AreEqual(1 + (i * 7), items[i].Span.Start);
|
||||
Assert.AreEqual(6, items[i].Span.Length);
|
||||
}
|
||||
Assert.AreEqual(5, items[4].Line);
|
||||
Assert.AreEqual(new SourceSpan(29, 42), items[4].Span);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
9
src/Markdig/Directory.Build.props
Normal file
9
src/Markdig/Directory.Build.props
Normal file
@@ -0,0 +1,9 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<PublishRepositoryUrl>true</PublishRepositoryUrl>
|
||||
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-*" PrivateAssets="All"/>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -12,7 +12,7 @@ namespace Markdig.Extensions.AutoIdentifiers
|
||||
public enum AutoIdentifierOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// No options
|
||||
/// No options: does not apply any additional formatting and/or transformations.
|
||||
/// </summary>
|
||||
None = 0,
|
||||
|
||||
@@ -36,4 +36,4 @@ namespace Markdig.Extensions.AutoIdentifiers
|
||||
/// </summary>
|
||||
GitHub = 4,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,12 +14,19 @@ namespace Markdig.Extensions.AutoLinks
|
||||
/// <seealso cref="Markdig.IMarkdownExtension" />
|
||||
public class AutoLinkExtension : IMarkdownExtension
|
||||
{
|
||||
public readonly string ValidPreviousCharacters;
|
||||
|
||||
public AutoLinkExtension(string validPreviousCharacters = AutoLinkParser.DefaultValidPreviousCharacters)
|
||||
{
|
||||
ValidPreviousCharacters = validPreviousCharacters;
|
||||
}
|
||||
|
||||
public void Setup(MarkdownPipelineBuilder pipeline)
|
||||
{
|
||||
if (!pipeline.InlineParsers.Contains<AutoLinkParser>())
|
||||
{
|
||||
// Insert the parser before any other parsers
|
||||
pipeline.InlineParsers.Insert(0, new AutoLinkParser());
|
||||
pipeline.InlineParsers.Insert(0, new AutoLinkParser(ValidPreviousCharacters));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// See the license.txt file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using Markdig.Helpers;
|
||||
using Markdig.Parsers;
|
||||
using Markdig.Syntax.Inlines;
|
||||
@@ -19,7 +19,7 @@ namespace Markdig.Extensions.AutoLinks
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AutoLinkParser"/> class.
|
||||
/// </summary>
|
||||
public AutoLinkParser()
|
||||
public AutoLinkParser(string validPreviousCharacters = DefaultValidPreviousCharacters)
|
||||
{
|
||||
OpeningCharacters = new char[]
|
||||
{
|
||||
@@ -28,20 +28,19 @@ namespace Markdig.Extensions.AutoLinks
|
||||
'm', // for mailto:
|
||||
'w', // for www.
|
||||
};
|
||||
|
||||
ValidPreviousCharacters = validPreviousCharacters;
|
||||
}
|
||||
|
||||
|
||||
private static bool IsValidPreviousCharacter(char c)
|
||||
{
|
||||
// All such recognized autolinks can only come at the beginning of a line, after whitespace, or any of the delimiting characters *, _, ~, and (.
|
||||
return c.IsWhiteSpaceOrZero() || c == '*' || c == '_' || c == '~' || c == '(';
|
||||
}
|
||||
// All such recognized autolinks can only come at the beginning of a line, after whitespace, or any of the delimiting characters *, _, ~, and (.
|
||||
public readonly string ValidPreviousCharacters;
|
||||
public const string DefaultValidPreviousCharacters = "*_~(";
|
||||
|
||||
public override bool Match(InlineProcessor processor, ref StringSlice slice)
|
||||
{
|
||||
// Previous char must be a whitespace or a punctuation
|
||||
var previousChar = slice.PeekCharExtra(-1);
|
||||
if (!IsValidPreviousCharacter(previousChar))
|
||||
if (!previousChar.IsWhiteSpaceOrZero() && ValidPreviousCharacters.IndexOf(previousChar) == -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -54,22 +53,29 @@ namespace Markdig.Extensions.AutoLinks
|
||||
}
|
||||
|
||||
var startPosition = slice.Start;
|
||||
int domainOffset = 0;
|
||||
|
||||
var c = slice.CurrentChar;
|
||||
// Precheck URL
|
||||
switch (c)
|
||||
{
|
||||
case 'h':
|
||||
if (!slice.MatchLowercase("ttp://", 1) && !slice.MatchLowercase("ttps://", 1))
|
||||
{
|
||||
return false;
|
||||
if (slice.MatchLowercase("ttp://", 1))
|
||||
{
|
||||
domainOffset = 7; // http://
|
||||
}
|
||||
else if (slice.MatchLowercase("ttps://", 1))
|
||||
{
|
||||
domainOffset = 8; // https://
|
||||
}
|
||||
else return false;
|
||||
break;
|
||||
case 'f':
|
||||
if (!slice.MatchLowercase("tp://", 1))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
domainOffset = 6; // ftp://
|
||||
break;
|
||||
case 'm':
|
||||
if (!slice.MatchLowercase("ailto:", 1))
|
||||
@@ -83,6 +89,7 @@ namespace Markdig.Extensions.AutoLinks
|
||||
{
|
||||
return false;
|
||||
}
|
||||
domainOffset = 4; // www.
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -131,19 +138,19 @@ namespace Markdig.Extensions.AutoLinks
|
||||
}
|
||||
break;
|
||||
case 'm':
|
||||
if (string.Equals(link, "mailto:", StringComparison.OrdinalIgnoreCase) || !link.Contains("@"))
|
||||
int atIndex = link.IndexOf('@');
|
||||
if (atIndex == -1 ||
|
||||
atIndex == 7) // mailto:@ - no email part
|
||||
{
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
domainOffset = atIndex + 1;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'w':
|
||||
// We require at least two .
|
||||
if (link.Length <= "www.x.y".Length || link.IndexOf(".", 4, StringComparison.Ordinal) < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
if (!LinkHelper.IsValidDomain(link, domainOffset))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int line;
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
using Markdig.Helpers;
|
||||
using Markdig.Parsers;
|
||||
using Markdig.Syntax;
|
||||
using Markdig.Syntax.Inlines;
|
||||
|
||||
using Markdig.Syntax.Inlines;
|
||||
|
||||
namespace Markdig.Extensions.Footnotes
|
||||
{
|
||||
/// <summary>
|
||||
@@ -33,7 +33,8 @@ namespace Markdig.Extensions.Footnotes
|
||||
private BlockState TryOpen(BlockProcessor processor, bool isContinue)
|
||||
{
|
||||
// We expect footnote to appear only at document level and not indented more than a code indent block
|
||||
if (processor.IsCodeIndent || (!isContinue && processor.CurrentContainer.GetType() != typeof(MarkdownDocument)) || (isContinue && !(processor.CurrentContainer is Footnote)))
|
||||
var currentContainer = processor.GetCurrentContainerOpened();
|
||||
if (processor.IsCodeIndent || (!isContinue && currentContainer.GetType() != typeof(MarkdownDocument)) || (isContinue && !(currentContainer is FootnoteGroup)))
|
||||
{
|
||||
return BlockState.None;
|
||||
}
|
||||
@@ -74,7 +75,11 @@ namespace Markdig.Extensions.Footnotes
|
||||
var linkRef = new FootnoteLinkReferenceDefinition()
|
||||
{
|
||||
Footnote = footnote,
|
||||
CreateLinkInline = CreateLinkToFootnote
|
||||
CreateLinkInline = CreateLinkToFootnote,
|
||||
Line = processor.LineIndex,
|
||||
Span = new SourceSpan(start, processor.Start - 2), // account for ]:
|
||||
LabelSpan = labelSpan,
|
||||
Label = label
|
||||
};
|
||||
processor.Document.SetLinkReferenceDefinition(footnote.Label, linkRef);
|
||||
processor.NewBlocks.Push(footnote);
|
||||
|
||||
108
src/Markdig/Extensions/Globalization/GlobalizationExtension.cs
Normal file
108
src/Markdig/Extensions/Globalization/GlobalizationExtension.cs
Normal file
@@ -0,0 +1,108 @@
|
||||
// Copyright (c) Alexandre Mutel. All rights reserved.
|
||||
// This file is licensed under the BSD-Clause 2 license.
|
||||
// See the license.txt file in the project root for more information.
|
||||
|
||||
using Markdig.Extensions.Tables;
|
||||
using Markdig.Extensions.TaskLists;
|
||||
using Markdig.Helpers;
|
||||
using Markdig.Renderers;
|
||||
using Markdig.Renderers.Html;
|
||||
using Markdig.Syntax;
|
||||
using Markdig.Syntax.Inlines;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Markdig.Extensions.Globalization
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension to add support for RTL content.
|
||||
/// </summary>
|
||||
public class GlobalizationExtension : IMarkdownExtension
|
||||
{
|
||||
|
||||
public void Setup(MarkdownPipelineBuilder pipeline)
|
||||
{
|
||||
// Make sure we don't have a delegate twice
|
||||
pipeline.DocumentProcessed -= Pipeline_DocumentProcessed;
|
||||
pipeline.DocumentProcessed += Pipeline_DocumentProcessed;
|
||||
}
|
||||
|
||||
private void Pipeline_DocumentProcessed(MarkdownDocument document)
|
||||
{
|
||||
foreach (var node in document.Descendants())
|
||||
{
|
||||
if (node is TableRow || node is TableCell || node is ListItemBlock)
|
||||
continue;
|
||||
|
||||
if (ShouldBeRightToLeft(node))
|
||||
{
|
||||
var attributes = node.GetAttributes();
|
||||
attributes.AddPropertyIfNotExist("dir", "rtl");
|
||||
|
||||
if (node is Table table)
|
||||
{
|
||||
attributes.AddPropertyIfNotExist("align", "right");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private bool ShouldBeRightToLeft(MarkdownObject item)
|
||||
{
|
||||
if (item is IEnumerable<MarkdownObject> container)
|
||||
{
|
||||
foreach (var child in container)
|
||||
{
|
||||
// TaskList items contain an "X", which will cause
|
||||
// the function to always return false.
|
||||
if (child is TaskList)
|
||||
continue;
|
||||
|
||||
return ShouldBeRightToLeft(child);
|
||||
}
|
||||
}
|
||||
else if (item is LeafBlock leaf)
|
||||
{
|
||||
return ShouldBeRightToLeft(leaf.Inline);
|
||||
}
|
||||
else if (item is LiteralInline literal)
|
||||
{
|
||||
return StartsWithRtlCharacter(literal.ToString());
|
||||
}
|
||||
|
||||
foreach (var descendant in item.Descendants())
|
||||
{
|
||||
if (descendant is ParagraphBlock p)
|
||||
{
|
||||
foreach (var i in p.Inline)
|
||||
{
|
||||
if (i is LiteralInline l)
|
||||
{
|
||||
return StartsWithRtlCharacter(l.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool StartsWithRtlCharacter(string text)
|
||||
{
|
||||
foreach (var c in CharHelper.ToUtf32(text))
|
||||
{
|
||||
if (CharHelper.IsRightToLeft(c))
|
||||
return true;
|
||||
|
||||
else if (CharHelper.IsLeftToRight(c))
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,37 @@
|
||||
// Copyright (c) Alexandre Mutel. All rights reserved.
|
||||
// Copyright (c) Alexandre Mutel. All rights reserved.
|
||||
// This file is licensed under the BSD-Clause 2 license.
|
||||
// See the license.txt file in the project root for more information.
|
||||
|
||||
|
||||
// The IsHighSurrogate, IsLowSurrogate and ConvertToUtf32 methods are copied from
|
||||
// .Net Core source code which is under MIT license. They are copied here because
|
||||
// they don't exist in `portable40-net40+sl5+win8+wp8+wpa81`, We probably should remove them
|
||||
// once we dropped support for that target platform and use the official .Net methods.
|
||||
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) .NET Foundation and Contributors
|
||||
|
||||
//All rights reserved.
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Runtime.CompilerServices;
|
||||
@@ -20,6 +51,14 @@ namespace Markdig.Helpers
|
||||
|
||||
public const string ZeroSafeString = "\uFFFD";
|
||||
|
||||
private const char HighSurrogateStart = '\ud800';
|
||||
private const char HighSurrogateEnd = '\udbff';
|
||||
private const char LowSurrogateStart = '\udc00';
|
||||
private const char LowSurrogateEnd = '\udfff';
|
||||
|
||||
// The starting codepoint for Unicode plane 1. Plane 1 contains 0x010000 ~ 0x01ffff.
|
||||
private const int UnicodePlane01Start = 0x10000;
|
||||
|
||||
// We don't support LCDM
|
||||
private static readonly Dictionary<char, int> romanMap = new Dictionary<char, int> { { 'I', 1 }, { 'V', 5 }, { 'X', 10 } };
|
||||
|
||||
@@ -306,5 +345,419 @@ namespace Markdig.Helpers
|
||||
{
|
||||
return ".!#$%&'*+/=?^_`{|}~-+.~".IndexOf(c) >= 0;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptionPortable.AggressiveInlining)]
|
||||
public static bool IsHighSurrogate(char c)
|
||||
{
|
||||
return ((c >= HighSurrogateStart) && (c <= HighSurrogateEnd));
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptionPortable.AggressiveInlining)]
|
||||
public static bool IsLowSurrogate(char c)
|
||||
{
|
||||
return ((c >= LowSurrogateStart) && (c <= LowSurrogateEnd));
|
||||
}
|
||||
|
||||
public static int ConvertToUtf32(char highSurrogate, char lowSurrogate)
|
||||
{
|
||||
if (!IsHighSurrogate(highSurrogate))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(highSurrogate), "Invalid high surrogate");
|
||||
}
|
||||
if (!IsLowSurrogate(lowSurrogate))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(lowSurrogate), "Invalid low surrogate");
|
||||
}
|
||||
return (((highSurrogate - HighSurrogateStart) * 0x400) + (lowSurrogate - LowSurrogateStart) + UnicodePlane01Start);
|
||||
}
|
||||
|
||||
public static IEnumerable<int> ToUtf32(string text)
|
||||
{
|
||||
for (int i = 0; i < text.Length; i++)
|
||||
{
|
||||
if (IsHighSurrogate(text[i]) && i < text.Length - 1 && IsLowSurrogate(text[i + 1]))
|
||||
{
|
||||
yield return ConvertToUtf32(text[i], text[i + 1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
yield return text[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsRightToLeft(int c)
|
||||
{
|
||||
// Generated from Table D.1 of RFC3454
|
||||
// http://www.ietf.org/rfc/rfc3454.txt
|
||||
|
||||
// Probably should use a binary search approach
|
||||
|
||||
return c >= 0x0005D0 && c <= 0x0005EA ||
|
||||
c >= 0x0005F0 && c <= 0x0005F4 ||
|
||||
c >= 0x000621 && c <= 0x00063A ||
|
||||
c >= 0x000640 && c <= 0x00064A ||
|
||||
c >= 0x00066D && c <= 0x00066F ||
|
||||
c >= 0x000671 && c <= 0x0006D5 ||
|
||||
c >= 0x0006E5 && c <= 0x0006E6 ||
|
||||
c >= 0x0006FA && c <= 0x0006FE ||
|
||||
c >= 0x000700 && c <= 0x00070D ||
|
||||
c >= 0x000712 && c <= 0x00072C ||
|
||||
c >= 0x000780 && c <= 0x0007A5 ||
|
||||
c >= 0x00FB1F && c <= 0x00FB28 ||
|
||||
c >= 0x00FB2A && c <= 0x00FB36 ||
|
||||
c >= 0x00FB38 && c <= 0x00FB3C ||
|
||||
c >= 0x00FB40 && c <= 0x00FB41 ||
|
||||
c >= 0x00FB43 && c <= 0x00FB44 ||
|
||||
c >= 0x00FB46 && c <= 0x00FBB1 ||
|
||||
c >= 0x00FBD3 && c <= 0x00FD3D ||
|
||||
c >= 0x00FD50 && c <= 0x00FD8F ||
|
||||
c >= 0x00FD92 && c <= 0x00FDC7 ||
|
||||
c >= 0x00FDF0 && c <= 0x00FDFC ||
|
||||
c >= 0x00FE70 && c <= 0x00FE74 ||
|
||||
c >= 0x00FE76 && c <= 0x00FEFC ||
|
||||
c == 0x0005BE || c == 0x0005C0 ||
|
||||
c == 0x0005C3 || c == 0x00061B ||
|
||||
c == 0x00061F || c == 0x0006DD ||
|
||||
c == 0x000710 || c == 0x0007B1 ||
|
||||
c == 0x00200F || c == 0x00FB1D ||
|
||||
c == 0x00FB3E;
|
||||
}
|
||||
|
||||
public static bool IsLeftToRight(int c)
|
||||
{
|
||||
// Generated from Table D.2 of RFC3454
|
||||
// http://www.ietf.org/rfc/rfc3454.txt
|
||||
|
||||
// Probably should use a binary search approach
|
||||
|
||||
return c >= 0x000041 && c <= 0x00005A ||
|
||||
c >= 0x000061 && c <= 0x00007A ||
|
||||
c >= 0x0000C0 && c <= 0x0000D6 ||
|
||||
c >= 0x0000D8 && c <= 0x0000F6 ||
|
||||
c >= 0x0000F8 && c <= 0x000220 ||
|
||||
c >= 0x000222 && c <= 0x000233 ||
|
||||
c >= 0x000250 && c <= 0x0002AD ||
|
||||
c >= 0x0002B0 && c <= 0x0002B8 ||
|
||||
c >= 0x0002BB && c <= 0x0002C1 ||
|
||||
c >= 0x0002D0 && c <= 0x0002D1 ||
|
||||
c >= 0x0002E0 && c <= 0x0002E4 ||
|
||||
c >= 0x000388 && c <= 0x00038A ||
|
||||
c >= 0x00038E && c <= 0x0003A1 ||
|
||||
c >= 0x0003A3 && c <= 0x0003CE ||
|
||||
c >= 0x0003D0 && c <= 0x0003F5 ||
|
||||
c >= 0x000400 && c <= 0x000482 ||
|
||||
c >= 0x00048A && c <= 0x0004CE ||
|
||||
c >= 0x0004D0 && c <= 0x0004F5 ||
|
||||
c >= 0x0004F8 && c <= 0x0004F9 ||
|
||||
c >= 0x000500 && c <= 0x00050F ||
|
||||
c >= 0x000531 && c <= 0x000556 ||
|
||||
c >= 0x000559 && c <= 0x00055F ||
|
||||
c >= 0x000561 && c <= 0x000587 ||
|
||||
c >= 0x000905 && c <= 0x000939 ||
|
||||
c >= 0x00093D && c <= 0x000940 ||
|
||||
c >= 0x000949 && c <= 0x00094C ||
|
||||
c >= 0x000958 && c <= 0x000961 ||
|
||||
c >= 0x000964 && c <= 0x000970 ||
|
||||
c >= 0x000982 && c <= 0x000983 ||
|
||||
c >= 0x000985 && c <= 0x00098C ||
|
||||
c >= 0x00098F && c <= 0x000990 ||
|
||||
c >= 0x000993 && c <= 0x0009A8 ||
|
||||
c >= 0x0009AA && c <= 0x0009B0 ||
|
||||
c >= 0x0009B6 && c <= 0x0009B9 ||
|
||||
c >= 0x0009BE && c <= 0x0009C0 ||
|
||||
c >= 0x0009C7 && c <= 0x0009C8 ||
|
||||
c >= 0x0009CB && c <= 0x0009CC ||
|
||||
c >= 0x0009DC && c <= 0x0009DD ||
|
||||
c >= 0x0009DF && c <= 0x0009E1 ||
|
||||
c >= 0x0009E6 && c <= 0x0009F1 ||
|
||||
c >= 0x0009F4 && c <= 0x0009FA ||
|
||||
c >= 0x000A05 && c <= 0x000A0A ||
|
||||
c >= 0x000A0F && c <= 0x000A10 ||
|
||||
c >= 0x000A13 && c <= 0x000A28 ||
|
||||
c >= 0x000A2A && c <= 0x000A30 ||
|
||||
c >= 0x000A32 && c <= 0x000A33 ||
|
||||
c >= 0x000A35 && c <= 0x000A36 ||
|
||||
c >= 0x000A38 && c <= 0x000A39 ||
|
||||
c >= 0x000A3E && c <= 0x000A40 ||
|
||||
c >= 0x000A59 && c <= 0x000A5C ||
|
||||
c >= 0x000A66 && c <= 0x000A6F ||
|
||||
c >= 0x000A72 && c <= 0x000A74 ||
|
||||
c >= 0x000A85 && c <= 0x000A8B ||
|
||||
c >= 0x000A8F && c <= 0x000A91 ||
|
||||
c >= 0x000A93 && c <= 0x000AA8 ||
|
||||
c >= 0x000AAA && c <= 0x000AB0 ||
|
||||
c >= 0x000AB2 && c <= 0x000AB3 ||
|
||||
c >= 0x000AB5 && c <= 0x000AB9 ||
|
||||
c >= 0x000ABD && c <= 0x000AC0 ||
|
||||
c >= 0x000ACB && c <= 0x000ACC ||
|
||||
c >= 0x000AE6 && c <= 0x000AEF ||
|
||||
c >= 0x000B02 && c <= 0x000B03 ||
|
||||
c >= 0x000B05 && c <= 0x000B0C ||
|
||||
c >= 0x000B0F && c <= 0x000B10 ||
|
||||
c >= 0x000B13 && c <= 0x000B28 ||
|
||||
c >= 0x000B2A && c <= 0x000B30 ||
|
||||
c >= 0x000B32 && c <= 0x000B33 ||
|
||||
c >= 0x000B36 && c <= 0x000B39 ||
|
||||
c >= 0x000B3D && c <= 0x000B3E ||
|
||||
c >= 0x000B47 && c <= 0x000B48 ||
|
||||
c >= 0x000B4B && c <= 0x000B4C ||
|
||||
c >= 0x000B5C && c <= 0x000B5D ||
|
||||
c >= 0x000B5F && c <= 0x000B61 ||
|
||||
c >= 0x000B66 && c <= 0x000B70 ||
|
||||
c >= 0x000B85 && c <= 0x000B8A ||
|
||||
c >= 0x000B8E && c <= 0x000B90 ||
|
||||
c >= 0x000B92 && c <= 0x000B95 ||
|
||||
c >= 0x000B99 && c <= 0x000B9A ||
|
||||
c >= 0x000B9E && c <= 0x000B9F ||
|
||||
c >= 0x000BA3 && c <= 0x000BA4 ||
|
||||
c >= 0x000BA8 && c <= 0x000BAA ||
|
||||
c >= 0x000BAE && c <= 0x000BB5 ||
|
||||
c >= 0x000BB7 && c <= 0x000BB9 ||
|
||||
c >= 0x000BBE && c <= 0x000BBF ||
|
||||
c >= 0x000BC1 && c <= 0x000BC2 ||
|
||||
c >= 0x000BC6 && c <= 0x000BC8 ||
|
||||
c >= 0x000BCA && c <= 0x000BCC ||
|
||||
c >= 0x000BE7 && c <= 0x000BF2 ||
|
||||
c >= 0x000C01 && c <= 0x000C03 ||
|
||||
c >= 0x000C05 && c <= 0x000C0C ||
|
||||
c >= 0x000C0E && c <= 0x000C10 ||
|
||||
c >= 0x000C12 && c <= 0x000C28 ||
|
||||
c >= 0x000C2A && c <= 0x000C33 ||
|
||||
c >= 0x000C35 && c <= 0x000C39 ||
|
||||
c >= 0x000C41 && c <= 0x000C44 ||
|
||||
c >= 0x000C60 && c <= 0x000C61 ||
|
||||
c >= 0x000C66 && c <= 0x000C6F ||
|
||||
c >= 0x000C82 && c <= 0x000C83 ||
|
||||
c >= 0x000C85 && c <= 0x000C8C ||
|
||||
c >= 0x000C8E && c <= 0x000C90 ||
|
||||
c >= 0x000C92 && c <= 0x000CA8 ||
|
||||
c >= 0x000CAA && c <= 0x000CB3 ||
|
||||
c >= 0x000CB5 && c <= 0x000CB9 ||
|
||||
c >= 0x000CC0 && c <= 0x000CC4 ||
|
||||
c >= 0x000CC7 && c <= 0x000CC8 ||
|
||||
c >= 0x000CCA && c <= 0x000CCB ||
|
||||
c >= 0x000CD5 && c <= 0x000CD6 ||
|
||||
c >= 0x000CE0 && c <= 0x000CE1 ||
|
||||
c >= 0x000CE6 && c <= 0x000CEF ||
|
||||
c >= 0x000D02 && c <= 0x000D03 ||
|
||||
c >= 0x000D05 && c <= 0x000D0C ||
|
||||
c >= 0x000D0E && c <= 0x000D10 ||
|
||||
c >= 0x000D12 && c <= 0x000D28 ||
|
||||
c >= 0x000D2A && c <= 0x000D39 ||
|
||||
c >= 0x000D3E && c <= 0x000D40 ||
|
||||
c >= 0x000D46 && c <= 0x000D48 ||
|
||||
c >= 0x000D4A && c <= 0x000D4C ||
|
||||
c >= 0x000D60 && c <= 0x000D61 ||
|
||||
c >= 0x000D66 && c <= 0x000D6F ||
|
||||
c >= 0x000D82 && c <= 0x000D83 ||
|
||||
c >= 0x000D85 && c <= 0x000D96 ||
|
||||
c >= 0x000D9A && c <= 0x000DB1 ||
|
||||
c >= 0x000DB3 && c <= 0x000DBB ||
|
||||
c >= 0x000DC0 && c <= 0x000DC6 ||
|
||||
c >= 0x000DCF && c <= 0x000DD1 ||
|
||||
c >= 0x000DD8 && c <= 0x000DDF ||
|
||||
c >= 0x000DF2 && c <= 0x000DF4 ||
|
||||
c >= 0x000E01 && c <= 0x000E30 ||
|
||||
c >= 0x000E32 && c <= 0x000E33 ||
|
||||
c >= 0x000E40 && c <= 0x000E46 ||
|
||||
c >= 0x000E4F && c <= 0x000E5B ||
|
||||
c >= 0x000E81 && c <= 0x000E82 ||
|
||||
c >= 0x000E87 && c <= 0x000E88 ||
|
||||
c >= 0x000E94 && c <= 0x000E97 ||
|
||||
c >= 0x000E99 && c <= 0x000E9F ||
|
||||
c >= 0x000EA1 && c <= 0x000EA3 ||
|
||||
c >= 0x000EAA && c <= 0x000EAB ||
|
||||
c >= 0x000EAD && c <= 0x000EB0 ||
|
||||
c >= 0x000EB2 && c <= 0x000EB3 ||
|
||||
c >= 0x000EC0 && c <= 0x000EC4 ||
|
||||
c >= 0x000ED0 && c <= 0x000ED9 ||
|
||||
c >= 0x000EDC && c <= 0x000EDD ||
|
||||
c >= 0x000F00 && c <= 0x000F17 ||
|
||||
c >= 0x000F1A && c <= 0x000F34 ||
|
||||
c >= 0x000F3E && c <= 0x000F47 ||
|
||||
c >= 0x000F49 && c <= 0x000F6A ||
|
||||
c >= 0x000F88 && c <= 0x000F8B ||
|
||||
c >= 0x000FBE && c <= 0x000FC5 ||
|
||||
c >= 0x000FC7 && c <= 0x000FCC ||
|
||||
c >= 0x001000 && c <= 0x001021 ||
|
||||
c >= 0x001023 && c <= 0x001027 ||
|
||||
c >= 0x001029 && c <= 0x00102A ||
|
||||
c >= 0x001040 && c <= 0x001057 ||
|
||||
c >= 0x0010A0 && c <= 0x0010C5 ||
|
||||
c >= 0x0010D0 && c <= 0x0010F8 ||
|
||||
c >= 0x001100 && c <= 0x001159 ||
|
||||
c >= 0x00115F && c <= 0x0011A2 ||
|
||||
c >= 0x0011A8 && c <= 0x0011F9 ||
|
||||
c >= 0x001200 && c <= 0x001206 ||
|
||||
c >= 0x001208 && c <= 0x001246 ||
|
||||
c >= 0x00124A && c <= 0x00124D ||
|
||||
c >= 0x001250 && c <= 0x001256 ||
|
||||
c >= 0x00125A && c <= 0x00125D ||
|
||||
c >= 0x001260 && c <= 0x001286 ||
|
||||
c >= 0x00128A && c <= 0x00128D ||
|
||||
c >= 0x001290 && c <= 0x0012AE ||
|
||||
c >= 0x0012B2 && c <= 0x0012B5 ||
|
||||
c >= 0x0012B8 && c <= 0x0012BE ||
|
||||
c >= 0x0012C2 && c <= 0x0012C5 ||
|
||||
c >= 0x0012C8 && c <= 0x0012CE ||
|
||||
c >= 0x0012D0 && c <= 0x0012D6 ||
|
||||
c >= 0x0012D8 && c <= 0x0012EE ||
|
||||
c >= 0x0012F0 && c <= 0x00130E ||
|
||||
c >= 0x001312 && c <= 0x001315 ||
|
||||
c >= 0x001318 && c <= 0x00131E ||
|
||||
c >= 0x001320 && c <= 0x001346 ||
|
||||
c >= 0x001348 && c <= 0x00135A ||
|
||||
c >= 0x001361 && c <= 0x00137C ||
|
||||
c >= 0x0013A0 && c <= 0x0013F4 ||
|
||||
c >= 0x001401 && c <= 0x001676 ||
|
||||
c >= 0x001681 && c <= 0x00169A ||
|
||||
c >= 0x0016A0 && c <= 0x0016F0 ||
|
||||
c >= 0x001700 && c <= 0x00170C ||
|
||||
c >= 0x00170E && c <= 0x001711 ||
|
||||
c >= 0x001720 && c <= 0x001731 ||
|
||||
c >= 0x001735 && c <= 0x001736 ||
|
||||
c >= 0x001740 && c <= 0x001751 ||
|
||||
c >= 0x001760 && c <= 0x00176C ||
|
||||
c >= 0x00176E && c <= 0x001770 ||
|
||||
c >= 0x001780 && c <= 0x0017B6 ||
|
||||
c >= 0x0017BE && c <= 0x0017C5 ||
|
||||
c >= 0x0017C7 && c <= 0x0017C8 ||
|
||||
c >= 0x0017D4 && c <= 0x0017DA ||
|
||||
c >= 0x0017E0 && c <= 0x0017E9 ||
|
||||
c >= 0x001810 && c <= 0x001819 ||
|
||||
c >= 0x001820 && c <= 0x001877 ||
|
||||
c >= 0x001880 && c <= 0x0018A8 ||
|
||||
c >= 0x001E00 && c <= 0x001E9B ||
|
||||
c >= 0x001EA0 && c <= 0x001EF9 ||
|
||||
c >= 0x001F00 && c <= 0x001F15 ||
|
||||
c >= 0x001F18 && c <= 0x001F1D ||
|
||||
c >= 0x001F20 && c <= 0x001F45 ||
|
||||
c >= 0x001F48 && c <= 0x001F4D ||
|
||||
c >= 0x001F50 && c <= 0x001F57 ||
|
||||
c >= 0x001F5F && c <= 0x001F7D ||
|
||||
c >= 0x001F80 && c <= 0x001FB4 ||
|
||||
c >= 0x001FB6 && c <= 0x001FBC ||
|
||||
c >= 0x001FC2 && c <= 0x001FC4 ||
|
||||
c >= 0x001FC6 && c <= 0x001FCC ||
|
||||
c >= 0x001FD0 && c <= 0x001FD3 ||
|
||||
c >= 0x001FD6 && c <= 0x001FDB ||
|
||||
c >= 0x001FE0 && c <= 0x001FEC ||
|
||||
c >= 0x001FF2 && c <= 0x001FF4 ||
|
||||
c >= 0x001FF6 && c <= 0x001FFC ||
|
||||
c >= 0x00210A && c <= 0x002113 ||
|
||||
c >= 0x002119 && c <= 0x00211D ||
|
||||
c >= 0x00212A && c <= 0x00212D ||
|
||||
c >= 0x00212F && c <= 0x002131 ||
|
||||
c >= 0x002133 && c <= 0x002139 ||
|
||||
c >= 0x00213D && c <= 0x00213F ||
|
||||
c >= 0x002145 && c <= 0x002149 ||
|
||||
c >= 0x002160 && c <= 0x002183 ||
|
||||
c >= 0x002336 && c <= 0x00237A ||
|
||||
c >= 0x00249C && c <= 0x0024E9 ||
|
||||
c >= 0x003005 && c <= 0x003007 ||
|
||||
c >= 0x003021 && c <= 0x003029 ||
|
||||
c >= 0x003031 && c <= 0x003035 ||
|
||||
c >= 0x003038 && c <= 0x00303C ||
|
||||
c >= 0x003041 && c <= 0x003096 ||
|
||||
c >= 0x00309D && c <= 0x00309F ||
|
||||
c >= 0x0030A1 && c <= 0x0030FA ||
|
||||
c >= 0x0030FC && c <= 0x0030FF ||
|
||||
c >= 0x003105 && c <= 0x00312C ||
|
||||
c >= 0x003131 && c <= 0x00318E ||
|
||||
c >= 0x003190 && c <= 0x0031B7 ||
|
||||
c >= 0x0031F0 && c <= 0x00321C ||
|
||||
c >= 0x003220 && c <= 0x003243 ||
|
||||
c >= 0x003260 && c <= 0x00327B ||
|
||||
c >= 0x00327F && c <= 0x0032B0 ||
|
||||
c >= 0x0032C0 && c <= 0x0032CB ||
|
||||
c >= 0x0032D0 && c <= 0x0032FE ||
|
||||
c >= 0x003300 && c <= 0x003376 ||
|
||||
c >= 0x00337B && c <= 0x0033DD ||
|
||||
c >= 0x0033E0 && c <= 0x0033FE ||
|
||||
c >= 0x003400 && c <= 0x004DB5 ||
|
||||
c >= 0x004E00 && c <= 0x009FA5 ||
|
||||
c >= 0x00A000 && c <= 0x00A48C ||
|
||||
c >= 0x00AC00 && c <= 0x00D7A3 ||
|
||||
c >= 0x00D800 && c <= 0x00FA2D ||
|
||||
c >= 0x00FA30 && c <= 0x00FA6A ||
|
||||
c >= 0x00FB00 && c <= 0x00FB06 ||
|
||||
c >= 0x00FB13 && c <= 0x00FB17 ||
|
||||
c >= 0x00FF21 && c <= 0x00FF3A ||
|
||||
c >= 0x00FF41 && c <= 0x00FF5A ||
|
||||
c >= 0x00FF66 && c <= 0x00FFBE ||
|
||||
c >= 0x00FFC2 && c <= 0x00FFC7 ||
|
||||
c >= 0x00FFCA && c <= 0x00FFCF ||
|
||||
c >= 0x00FFD2 && c <= 0x00FFD7 ||
|
||||
c >= 0x00FFDA && c <= 0x00FFDC ||
|
||||
c >= 0x010300 && c <= 0x01031E ||
|
||||
c >= 0x010320 && c <= 0x010323 ||
|
||||
c >= 0x010330 && c <= 0x01034A ||
|
||||
c >= 0x010400 && c <= 0x010425 ||
|
||||
c >= 0x010428 && c <= 0x01044D ||
|
||||
c >= 0x01D000 && c <= 0x01D0F5 ||
|
||||
c >= 0x01D100 && c <= 0x01D126 ||
|
||||
c >= 0x01D12A && c <= 0x01D166 ||
|
||||
c >= 0x01D16A && c <= 0x01D172 ||
|
||||
c >= 0x01D183 && c <= 0x01D184 ||
|
||||
c >= 0x01D18C && c <= 0x01D1A9 ||
|
||||
c >= 0x01D1AE && c <= 0x01D1DD ||
|
||||
c >= 0x01D400 && c <= 0x01D454 ||
|
||||
c >= 0x01D456 && c <= 0x01D49C ||
|
||||
c >= 0x01D49E && c <= 0x01D49F ||
|
||||
c >= 0x01D4A5 && c <= 0x01D4A6 ||
|
||||
c >= 0x01D4A9 && c <= 0x01D4AC ||
|
||||
c >= 0x01D4AE && c <= 0x01D4B9 ||
|
||||
c >= 0x01D4BD && c <= 0x01D4C0 ||
|
||||
c >= 0x01D4C2 && c <= 0x01D4C3 ||
|
||||
c >= 0x01D4C5 && c <= 0x01D505 ||
|
||||
c >= 0x01D507 && c <= 0x01D50A ||
|
||||
c >= 0x01D50D && c <= 0x01D514 ||
|
||||
c >= 0x01D516 && c <= 0x01D51C ||
|
||||
c >= 0x01D51E && c <= 0x01D539 ||
|
||||
c >= 0x01D53B && c <= 0x01D53E ||
|
||||
c >= 0x01D540 && c <= 0x01D544 ||
|
||||
c >= 0x01D54A && c <= 0x01D550 ||
|
||||
c >= 0x01D552 && c <= 0x01D6A3 ||
|
||||
c >= 0x01D6A8 && c <= 0x01D7C9 ||
|
||||
c >= 0x020000 && c <= 0x02A6D6 ||
|
||||
c >= 0x02F800 && c <= 0x02FA1D ||
|
||||
c >= 0x0F0000 && c <= 0x0FFFFD ||
|
||||
c >= 0x100000 && c <= 0x10FFFD ||
|
||||
c == 0x0000AA || c == 0x0000B5 ||
|
||||
c == 0x0000BA || c == 0x0002EE ||
|
||||
c == 0x00037A || c == 0x000386 ||
|
||||
c == 0x00038C || c == 0x000589 ||
|
||||
c == 0x000903 || c == 0x000950 ||
|
||||
c == 0x0009B2 || c == 0x0009D7 ||
|
||||
c == 0x000A5E || c == 0x000A83 ||
|
||||
c == 0x000A8D || c == 0x000AC9 ||
|
||||
c == 0x000AD0 || c == 0x000AE0 ||
|
||||
c == 0x000B40 || c == 0x000B57 ||
|
||||
c == 0x000B83 || c == 0x000B9C ||
|
||||
c == 0x000BD7 || c == 0x000CBE ||
|
||||
c == 0x000CDE || c == 0x000D57 ||
|
||||
c == 0x000DBD || c == 0x000E84 ||
|
||||
c == 0x000E8A || c == 0x000E8D ||
|
||||
c == 0x000EA5 || c == 0x000EA7 ||
|
||||
c == 0x000EBD || c == 0x000EC6 ||
|
||||
c == 0x000F36 || c == 0x000F38 ||
|
||||
c == 0x000F7F || c == 0x000F85 ||
|
||||
c == 0x000FCF || c == 0x00102C ||
|
||||
c == 0x001031 || c == 0x001038 ||
|
||||
c == 0x0010FB || c == 0x001248 ||
|
||||
c == 0x001258 || c == 0x001288 ||
|
||||
c == 0x0012B0 || c == 0x0012C0 ||
|
||||
c == 0x001310 || c == 0x0017DC ||
|
||||
c == 0x001F59 || c == 0x001F5B ||
|
||||
c == 0x001F5D || c == 0x001FBE ||
|
||||
c == 0x00200E || c == 0x002071 ||
|
||||
c == 0x00207F || c == 0x002102 ||
|
||||
c == 0x002107 || c == 0x002115 ||
|
||||
c == 0x002124 || c == 0x002126 ||
|
||||
c == 0x002128 || c == 0x002395 ||
|
||||
c == 0x01D4A2 || c == 0x01D4BB ||
|
||||
c == 0x01D546;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,6 @@
|
||||
// See the license.txt file in the project root for more information.
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using Markdig.Parsers.Inlines;
|
||||
using Markdig.Syntax;
|
||||
|
||||
namespace Markdig.Helpers
|
||||
@@ -666,6 +664,54 @@ namespace Markdig.Helpers
|
||||
return c == '\0' || c.IsSpaceOrTab() || c.IsControl() || (isAutoLink && c == '<'); // TODO: specs unclear. space is strict or relaxed? (includes tabs?)
|
||||
}
|
||||
|
||||
public static bool IsValidDomain(string link, int prefixLength)
|
||||
{
|
||||
// https://github.github.com/gfm/#extended-www-autolink
|
||||
// A valid domain consists of alphanumeric characters, underscores (_), hyphens (-) and periods (.).
|
||||
// There must be at least one period, and no underscores may be present in the last two segments of the domain.
|
||||
|
||||
int segmentCount = 1;
|
||||
bool segmentHasCharacters = false;
|
||||
int lastUnderscoreSegment = -1;
|
||||
|
||||
for (int i = prefixLength; i < link.Length; i++)
|
||||
{
|
||||
char c = link[i];
|
||||
|
||||
if (c == '.') // New segment
|
||||
{
|
||||
if (!segmentHasCharacters)
|
||||
return false;
|
||||
|
||||
segmentCount++;
|
||||
segmentHasCharacters = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!c.IsAlphaNumeric())
|
||||
{
|
||||
if (c == '/' || c == '?' || c == '#' || c == ':') // End of domain name
|
||||
break;
|
||||
|
||||
if (c == '_')
|
||||
{
|
||||
lastUnderscoreSegment = segmentCount;
|
||||
}
|
||||
else if (c != '-')
|
||||
{
|
||||
// An invalid character has been found
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
segmentHasCharacters = true;
|
||||
}
|
||||
|
||||
return segmentCount != 1 && // At least one dot was present
|
||||
segmentHasCharacters && // Last segment has valid characters
|
||||
segmentCount - lastUnderscoreSegment >= 2; // No underscores are present in the last two segments of the domain
|
||||
}
|
||||
|
||||
public static bool TryParseLinkReferenceDefinition<T>(T text, out string label, out string url,
|
||||
out string title) where T : ICharIterator
|
||||
{
|
||||
@@ -785,7 +831,6 @@ namespace Markdig.Helpers
|
||||
return TryParseLabel(ref lines, false, out label, out labelSpan);
|
||||
}
|
||||
|
||||
|
||||
public static bool TryParseLabel<T>(ref T lines, out string label, out SourceSpan labelSpan) where T : ICharIterator
|
||||
{
|
||||
return TryParseLabel(ref lines, false, out label, out labelSpan);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Alexandre Mutel. All rights reserved.
|
||||
// Copyright (c) Alexandre Mutel. All rights reserved.
|
||||
// This file is licensed under the BSD-Clause 2 license.
|
||||
// See the license.txt file in the project root for more information.
|
||||
using System;
|
||||
@@ -121,5 +121,20 @@ namespace Markdig.Helpers
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replaces <typeparamref name="TElement"/> with <paramref name="newElement"/> or adds <paramref name="newElement"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="TElement">Element type to find in the list</typeparam>
|
||||
/// <param name="newElement">Object to add/replace the found element with</param>
|
||||
/// <returns><c>true</c> if a replacement was made; otherwise <c>false</c>.</returns>
|
||||
public bool ReplaceOrAdd<TElement>(T newElement) where TElement : T
|
||||
{
|
||||
if (Replace<TElement>(newElement))
|
||||
return true;
|
||||
|
||||
Add(newElement);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
<Copyright>Alexandre Mutel</Copyright>
|
||||
<AssemblyTitle>Markdig</AssemblyTitle>
|
||||
<NeutralLanguage>en-US</NeutralLanguage>
|
||||
<VersionPrefix>0.15.1</VersionPrefix>
|
||||
<VersionPrefix>0.15.5</VersionPrefix>
|
||||
<Authors>Alexandre Mutel</Authors>
|
||||
<TargetFrameworks>net35;net40;portable40-net40+sl5+win8+wp8+wpa81;netstandard1.1;netstandard2.0;uap10.0</TargetFrameworks>
|
||||
<AssemblyName>Markdig</AssemblyName>
|
||||
@@ -54,7 +54,7 @@
|
||||
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
|
||||
<DefineConstants>$(DefineConstants);SUPPORT_FIXED_STRING;SUPPORT_UNSAFE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
<PropertyGroup Condition=" '$(TargetFramework)' == 'uap10.0' ">
|
||||
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
|
||||
<TargetPlatformVersion Condition="'$(TargetPlatformVersion)' == ''">10.0.10240.0</TargetPlatformVersion>
|
||||
|
||||
@@ -33,6 +33,7 @@ using Markdig.Extensions.TextRenderer;
|
||||
using Markdig.Extensions.Yaml;
|
||||
using Markdig.Parsers;
|
||||
using Markdig.Parsers.Inlines;
|
||||
using Markdig.Extensions.Globalization;
|
||||
|
||||
namespace Markdig
|
||||
{
|
||||
@@ -98,9 +99,9 @@ namespace Markdig
|
||||
/// </summary>
|
||||
/// <param name="pipeline">The pipeline.</param>
|
||||
/// <returns>The modified pipeline</returns>
|
||||
public static MarkdownPipelineBuilder UseAutoLinks(this MarkdownPipelineBuilder pipeline)
|
||||
public static MarkdownPipelineBuilder UseAutoLinks(this MarkdownPipelineBuilder pipeline, string validPreviousCharacters = AutoLinkParser.DefaultValidPreviousCharacters)
|
||||
{
|
||||
pipeline.Extensions.AddIfNotAlready<AutoLinkExtension>();
|
||||
pipeline.Extensions.ReplaceOrAdd<AutoLinkExtension>(new AutoLinkExtension(validPreviousCharacters));
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
@@ -460,6 +461,17 @@ namespace Markdig
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds support for right-to-left content by adding appropriate html attribtues.
|
||||
/// </summary>
|
||||
/// <param name="pipeline">The pipeline</param>
|
||||
/// <returns>The modified pipeline</returns>
|
||||
public static MarkdownPipelineBuilder UseGlobalization(this MarkdownPipelineBuilder pipeline)
|
||||
{
|
||||
pipeline.Extensions.AddIfNotAlready<GlobalizationExtension>();
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This will disable the HTML support in the markdown processor (for constraint/safe parsing).
|
||||
/// </summary>
|
||||
@@ -583,6 +595,9 @@ namespace Markdig
|
||||
case "autolinks":
|
||||
pipeline.UseAutoLinks();
|
||||
break;
|
||||
case "globalization":
|
||||
pipeline.UseGlobalization();
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException($"Invalid extension `{extension}` from `{extensions}`", nameof(extensions));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Alexandre Mutel. All rights reserved.
|
||||
// Copyright (c) Alexandre Mutel. All rights reserved.
|
||||
// This file is licensed under the BSD-Clause 2 license.
|
||||
// See the license.txt file in the project root for more information.
|
||||
using System;
|
||||
@@ -116,9 +116,16 @@ namespace Markdig
|
||||
extension.Setup(this);
|
||||
}
|
||||
|
||||
pipeline = new MarkdownPipeline(new OrderedList<IMarkdownExtension>(Extensions),
|
||||
new BlockParserList(BlockParsers), new InlineParserList(InlineParsers), StringBuilderCache, DebugLog,
|
||||
GetDocumentProcessed) {PreciseSourceLocation = PreciseSourceLocation};
|
||||
pipeline = new MarkdownPipeline(
|
||||
new OrderedList<IMarkdownExtension>(Extensions),
|
||||
new BlockParserList(BlockParsers),
|
||||
new InlineParserList(InlineParsers),
|
||||
StringBuilderCache,
|
||||
DebugLog,
|
||||
GetDocumentProcessed)
|
||||
{
|
||||
PreciseSourceLocation = PreciseSourceLocation
|
||||
};
|
||||
return pipeline;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Alexandre Mutel. All rights reserved.
|
||||
// Copyright (c) Alexandre Mutel. All rights reserved.
|
||||
// This file is licensed under the BSD-Clause 2 license.
|
||||
// See the license.txt file in the project root for more information.
|
||||
using System;
|
||||
@@ -162,6 +162,21 @@ namespace Markdig.Parsers
|
||||
/// </summary>
|
||||
private bool ContinueProcessingLine { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Get the current Container that is currently opened
|
||||
/// </summary>
|
||||
/// <returns>The current Container that is currently opened</returns>
|
||||
public ContainerBlock GetCurrentContainerOpened()
|
||||
{
|
||||
var container = CurrentContainer;
|
||||
while (container != null && !container.IsOpen)
|
||||
{
|
||||
container = container.Parent;
|
||||
}
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the next character in the line being processed. Update <see cref="Start"/> and <see cref="Column"/>.
|
||||
/// </summary>
|
||||
@@ -429,6 +444,8 @@ namespace Markdig.Parsers
|
||||
{
|
||||
CurrentLineStartPosition = newLine.Start;
|
||||
|
||||
Document.LineStartIndexes?.Add(CurrentLineStartPosition);
|
||||
|
||||
ContinueProcessingLine = true;
|
||||
|
||||
ResetLine(newLine);
|
||||
|
||||
@@ -136,7 +136,7 @@ namespace Markdig.Parsers.Inlines
|
||||
{
|
||||
child = new LiteralInline()
|
||||
{
|
||||
Content = new StringSlice(label),
|
||||
Content = StringSlice.Empty,
|
||||
IsClosed = true,
|
||||
// Not exact but we leave it like this
|
||||
Span = parent.Span,
|
||||
|
||||
@@ -262,10 +262,12 @@ namespace Markdig.Parsers
|
||||
}
|
||||
}
|
||||
|
||||
int.TryParse(listInfo.OrderedStart, out int order);
|
||||
var newListItem = new ListItemBlock(this)
|
||||
{
|
||||
Column = initColumn,
|
||||
ColumnWidth = columnWidth,
|
||||
Order = order,
|
||||
Span = new SourceSpan(sourcePosition, sourceEndPosition)
|
||||
};
|
||||
state.NewBlocks.Push(newListItem);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Alexandre Mutel. All rights reserved.
|
||||
// Copyright (c) Alexandre Mutel. All rights reserved.
|
||||
// This file is licensed under the BSD-Clause 2 license.
|
||||
// See the license.txt file in the project root for more information.
|
||||
|
||||
@@ -85,8 +85,14 @@ namespace Markdig.Parsers
|
||||
/// <returns>A document instance</returns>
|
||||
private MarkdownDocument Parse()
|
||||
{
|
||||
if (preciseSourceLocation)
|
||||
document.LineStartIndexes = new List<int>();
|
||||
|
||||
ProcessBlocks();
|
||||
ProcessInlines();
|
||||
|
||||
// At this point the LineIndex is the same as the number of lines in the document
|
||||
document.LineCount = blockProcessor.LineIndex;
|
||||
|
||||
// Allow to call a hook after processing a document
|
||||
documentProcessed?.Invoke(document);
|
||||
@@ -146,8 +152,7 @@ namespace Markdig.Parsers
|
||||
for (; item.Index < container.Count; item.Index++)
|
||||
{
|
||||
var block = container[item.Index];
|
||||
var leafBlock = block as LeafBlock;
|
||||
if (leafBlock != null)
|
||||
if (block is LeafBlock leafBlock)
|
||||
{
|
||||
leafBlock.OnProcessInlinesBegin(inlineProcessor);
|
||||
if (leafBlock.ProcessInlines)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Alexandre Mutel. All rights reserved.
|
||||
// Copyright (c) Alexandre Mutel. All rights reserved.
|
||||
// This file is licensed under the BSD-Clause 2 license.
|
||||
// See the license.txt file in the project root for more information.
|
||||
using Markdig.Helpers;
|
||||
@@ -9,7 +9,7 @@ namespace Markdig.Parsers
|
||||
/// <summary>
|
||||
/// Block parser for a <see cref="ParagraphBlock"/>.
|
||||
/// </summary>
|
||||
/// <seealso cref="Markdig.Parsers.BlockParser" />
|
||||
/// <seealso cref="BlockParser" />
|
||||
public class ParagraphBlockParser : BlockParser
|
||||
{
|
||||
public override BlockState TryOpen(BlockProcessor processor)
|
||||
@@ -152,15 +152,20 @@ namespace Markdig.Parsers
|
||||
{
|
||||
// If we have found a LinkReferenceDefinition, we can discard the previous paragraph
|
||||
var iterator = lines.ToCharIterator();
|
||||
LinkReferenceDefinition linkReferenceDefinition;
|
||||
if (LinkReferenceDefinition.TryParse(ref iterator, out linkReferenceDefinition))
|
||||
{
|
||||
if (!state.Document.ContainsLinkReferenceDefinition(linkReferenceDefinition.Label))
|
||||
{
|
||||
state.Document.SetLinkReferenceDefinition(linkReferenceDefinition.Label, linkReferenceDefinition);
|
||||
}
|
||||
if (LinkReferenceDefinition.TryParse(ref iterator, out LinkReferenceDefinition linkReferenceDefinition))
|
||||
{
|
||||
state.Document.SetLinkReferenceDefinition(linkReferenceDefinition.Label, linkReferenceDefinition);
|
||||
atLeastOneFound = true;
|
||||
|
||||
// Correct the locations of each field
|
||||
linkReferenceDefinition.Line = lines.Lines[0].Line;
|
||||
int startPosition = lines.Lines[0].Slice.Start;
|
||||
|
||||
linkReferenceDefinition.Span = linkReferenceDefinition.Span .MoveForward(startPosition);
|
||||
linkReferenceDefinition.LabelSpan = linkReferenceDefinition.LabelSpan .MoveForward(startPosition);
|
||||
linkReferenceDefinition.UrlSpan = linkReferenceDefinition.UrlSpan .MoveForward(startPosition);
|
||||
linkReferenceDefinition.TitleSpan = linkReferenceDefinition.TitleSpan .MoveForward(startPosition);
|
||||
|
||||
// Remove lines that have been matched
|
||||
if (iterator.Start > iterator.End)
|
||||
{
|
||||
|
||||
@@ -87,6 +87,8 @@ namespace Markdig.Renderers.Html
|
||||
renderer.WriteLine("</code></pre>");
|
||||
}
|
||||
}
|
||||
|
||||
renderer.EnsureLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,8 @@ namespace Markdig.Renderers.Html
|
||||
{
|
||||
renderer.Write("</").Write(headingText).WriteLine(">");
|
||||
}
|
||||
|
||||
renderer.EnsureLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,15 +24,9 @@ namespace Markdig.Renderers.Html.Inlines
|
||||
{
|
||||
renderer.WriteLine("<br />");
|
||||
}
|
||||
else
|
||||
{
|
||||
renderer.WriteLine();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
renderer.Write(" ");
|
||||
}
|
||||
|
||||
renderer.EnsureLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,6 +59,7 @@ namespace Markdig.Renderers.Html
|
||||
renderer.WriteLine("</li>");
|
||||
}
|
||||
|
||||
renderer.EnsureLine();
|
||||
renderer.ImplicitParagraph = previousImplicit;
|
||||
}
|
||||
|
||||
@@ -66,6 +67,8 @@ namespace Markdig.Renderers.Html
|
||||
{
|
||||
renderer.WriteLine(listBlock.IsOrdered ? "</ol>" : "</ul>");
|
||||
}
|
||||
|
||||
renderer.EnsureLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,9 +23,14 @@ namespace Markdig.Renderers.Html
|
||||
renderer.Write("<p").WriteAttributes(obj).Write(">");
|
||||
}
|
||||
renderer.WriteLeafInline(obj);
|
||||
if (!renderer.ImplicitParagraph && renderer.EnableHtmlForBlock)
|
||||
if (!renderer.ImplicitParagraph)
|
||||
{
|
||||
renderer.WriteLine("</p>");
|
||||
if(renderer.EnableHtmlForBlock)
|
||||
{
|
||||
renderer.WriteLine("</p>");
|
||||
}
|
||||
|
||||
renderer.EnsureLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace Markdig.Renderers.Html
|
||||
{
|
||||
renderer.WriteLine("</blockquote>");
|
||||
}
|
||||
renderer.EnsureLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Alexandre Mutel. All rights reserved.
|
||||
// Copyright (c) Alexandre Mutel. All rights reserved.
|
||||
// This file is licensed under the BSD-Clause 2 license.
|
||||
// See the license.txt file in the project root for more information.
|
||||
|
||||
@@ -28,11 +28,14 @@ namespace Markdig.Syntax
|
||||
|
||||
public void Set(string label, LinkReferenceDefinition link)
|
||||
{
|
||||
if (link == null) throw new ArgumentNullException(nameof(link));
|
||||
Links[label] = link;
|
||||
if (!Contains(link))
|
||||
{
|
||||
Add(link);
|
||||
if (link == null) throw new ArgumentNullException(nameof(link));
|
||||
if (!Contains(link))
|
||||
{
|
||||
Add(link);
|
||||
if (!Links.ContainsKey(label))
|
||||
{
|
||||
Links[label] = link;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Alexandre Mutel. All rights reserved.
|
||||
// Copyright (c) Alexandre Mutel. All rights reserved.
|
||||
// This file is licensed under the BSD-Clause 2 license.
|
||||
// See the license.txt file in the project root for more information.
|
||||
using Markdig.Parsers;
|
||||
@@ -20,5 +20,10 @@ namespace Markdig.Syntax
|
||||
}
|
||||
|
||||
internal int ColumnWidth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The number defined for this <see cref="ListItemBlock"/> in an ordered list
|
||||
/// </summary>
|
||||
public int Order { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright (c) Alexandre Mutel. All rights reserved.
|
||||
// Copyright (c) Alexandre Mutel. All rights reserved.
|
||||
// This file is licensed under the BSD-Clause 2 license.
|
||||
// See the license.txt file in the project root for more information.
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Markdig.Syntax
|
||||
{
|
||||
/// <summary>
|
||||
@@ -15,5 +17,16 @@ namespace Markdig.Syntax
|
||||
public MarkdownDocument() : base(null)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of lines in this <see cref="MarkdownDocument"/>
|
||||
/// </summary>
|
||||
public int LineCount;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of zero-based indexes of line beginnings in the source span
|
||||
/// <para>Available if <see cref="MarkdownPipelineBuilder.PreciseSourceLocation"/> is used, otherwise null</para>
|
||||
/// </summary>
|
||||
public List<int> LineStartIndexes;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Alexandre Mutel. All rights reserved.
|
||||
// Copyright (c) Alexandre Mutel. All rights reserved.
|
||||
// This file is licensed under the BSD-Clause 2 license.
|
||||
// See the license.txt file in the project root for more information.
|
||||
|
||||
@@ -43,6 +43,11 @@ namespace Markdig.Syntax
|
||||
|
||||
public bool IsEmpty => Start > End;
|
||||
|
||||
public SourceSpan MoveForward(int count)
|
||||
{
|
||||
return new SourceSpan(Start + count, End + count);
|
||||
}
|
||||
|
||||
public bool Equals(SourceSpan other)
|
||||
{
|
||||
return Start == other.Start && End == other.End;
|
||||
|
||||
Reference in New Issue
Block a user