-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue where HTML was allowed in headings
Fixes #114
- Loading branch information
Showing
8 changed files
with
365 additions
and
140 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
.idea/.idea.Html2Markdown/.idea/inspectionProfiles/Project_Default.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,16 @@ | ||
namespace Html2Markdown.Replacement | ||
namespace Html2Markdown.Replacement; | ||
|
||
/// <summary> | ||
/// Replaces an anchor tag with the link text and the link URL in Markdown format. | ||
/// </summary> | ||
public class AnchorTagReplacer : CustomReplacer | ||
{ | ||
/// <summary> | ||
/// Replaces an anchor tag with the link text and the link URL in Markdown format. | ||
/// Initializes a new instance of the <see cref="AnchorTagReplacer"/> class. | ||
/// Sets the custom action to replace anchor tags with Markdown formatted links. | ||
/// </summary> | ||
public class AnchorTagReplacer : CustomReplacer | ||
public AnchorTagReplacer() | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="AnchorTagReplacer"/> class. | ||
/// Sets the custom action to replace anchor tags with Markdown formatted links. | ||
/// </summary> | ||
public AnchorTagReplacer() | ||
{ | ||
CustomAction = HtmlParser.ReplaceAnchor; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
test/Html2Markdown.Test/CommonMarkSchemeConverterTest.Convert_Bug_114.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
## Support | ||
|
||
This project will currently convert the following HTML tags:- | ||
|
||
* `<a>` | ||
* `<strong>` | ||
* `<b>` | ||
* `<em>` | ||
* `<i>` | ||
* `<br>` | ||
* `<code>` | ||
* `<h1>` | ||
* `<h2>` | ||
* `<h3>` | ||
* `<h4>` | ||
* `<h5>` | ||
* `<h6>` | ||
* `<blockquote>` | ||
* `<img>` | ||
* `<hr>` | ||
* `<p>` | ||
* `<pre>` | ||
* `<ul>` | ||
* `<ol>` | ||
|
||
## [](https://github.com/baynezy/Html2Markdown#installing-via-nuget)Installing via NuGet | ||
|
||
[![NuGet version](https://camo.githubusercontent.com/2ee778ef534fdd413d5055d3202813398f39235a3d60b13974d43bc1bf1523a1/68747470733a2f2f62616467652e667572792e696f2f6e752f48746d6c324d61726b646f776e2e737667)](http://badge.fury.io/nu/Html2Markdown) | ||
<div class="highlight highlight-source-powershell position-relative" style="box-sizing: border-box; position: relative !important; margin-bottom: 16px; color: rgb(201, 209, 217); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(13, 17, 23); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"> | ||
|
||
<span class="pl-c1" style="box-sizing: border-box; color: var(--color-prettylights-syntax-constant);">Install-Package</span> Html2Markdown | ||
</div> | ||
|
||
## [](https://github.com/baynezy/Html2Markdown#usage)Usage | ||
|
||
### [](https://github.com/baynezy/Html2Markdown#strings)Strings | ||
|
||
<div class="highlight highlight-source-cs position-relative" style="box-sizing: border-box; position: relative !important; margin-bottom: 16px; color: rgb(201, 209, 217); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(13, 17, 23); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"> | ||
|
||
<span class="pl-k" style="box-sizing: border-box; color: var(--color-prettylights-syntax-keyword);">var</span> <span class="pl-en" style="box-sizing: border-box; color: var(--color-prettylights-syntax-entity);">html</span> <span class="pl-k" style="box-sizing: border-box; color: var(--color-prettylights-syntax-keyword);">=</span> <span class="pl-s" style="box-sizing: border-box; color: var(--color-prettylights-syntax-string);"><span class="pl-pds" style="box-sizing: border-box; color: var(--color-prettylights-syntax-string);">"</span>Something to <strong>convert</strong><span class="pl-pds" style="box-sizing: border-box; color: var(--color-prettylights-syntax-string);">"</span></span>; | ||
<span class="pl-k" style="box-sizing: border-box; color: var(--color-prettylights-syntax-keyword);">var</span> <span class="pl-en" style="box-sizing: border-box; color: var(--color-prettylights-syntax-entity);">converter</span> <span class="pl-k" style="box-sizing: border-box; color: var(--color-prettylights-syntax-keyword);">=</span> <span class="pl-k" style="box-sizing: border-box; color: var(--color-prettylights-syntax-keyword);">new</span> <span class="pl-k" style="box-sizing: border-box; color: var(--color-prettylights-syntax-keyword);">Converter</span>(); | ||
<span class="pl-k" style="box-sizing: border-box; color: var(--color-prettylights-syntax-keyword);">var</span> <span class="pl-en" style="box-sizing: border-box; color: var(--color-prettylights-syntax-entity);">markdown</span> <span class="pl-k" style="box-sizing: border-box; color: var(--color-prettylights-syntax-keyword);">=</span> <span class="pl-smi" style="box-sizing: border-box; color: var(--color-prettylights-syntax-storage-modifier-import);">converter</span>.<span class="pl-en" style="box-sizing: border-box; color: var(--color-prettylights-syntax-entity);">Convert</span>(<span class="pl-smi" style="box-sizing: border-box; color: var(--color-prettylights-syntax-storage-modifier-import);">html</span>); | ||
</div> |
43 changes: 43 additions & 0 deletions
43
test/Html2Markdown.Test/MarkdownSchemeConverterTest.Convert_Bug_114.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
## Support | ||
|
||
This project will currently convert the following HTML tags:- | ||
|
||
* `<a>` | ||
* `<strong>` | ||
* `<b>` | ||
* `<em>` | ||
* `<i>` | ||
* `<br>` | ||
* `<code>` | ||
* `<h1>` | ||
* `<h2>` | ||
* `<h3>` | ||
* `<h4>` | ||
* `<h5>` | ||
* `<h6>` | ||
* `<blockquote>` | ||
* `<img>` | ||
* `<hr>` | ||
* `<p>` | ||
* `<pre>` | ||
* `<ul>` | ||
* `<ol>` | ||
|
||
## [](https://github.com/baynezy/Html2Markdown#installing-via-nuget)Installing via NuGet | ||
|
||
[![NuGet version](https://camo.githubusercontent.com/2ee778ef534fdd413d5055d3202813398f39235a3d60b13974d43bc1bf1523a1/68747470733a2f2f62616467652e667572792e696f2f6e752f48746d6c324d61726b646f776e2e737667)](http://badge.fury.io/nu/Html2Markdown) | ||
<div class="highlight highlight-source-powershell position-relative" style="box-sizing: border-box; position: relative !important; margin-bottom: 16px; color: rgb(201, 209, 217); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(13, 17, 23); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"> | ||
|
||
<span class="pl-c1" style="box-sizing: border-box; color: var(--color-prettylights-syntax-constant);">Install-Package</span> Html2Markdown | ||
</div> | ||
|
||
## [](https://github.com/baynezy/Html2Markdown#usage)Usage | ||
|
||
### [](https://github.com/baynezy/Html2Markdown#strings)Strings | ||
|
||
<div class="highlight highlight-source-cs position-relative" style="box-sizing: border-box; position: relative !important; margin-bottom: 16px; color: rgb(201, 209, 217); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(13, 17, 23); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"> | ||
|
||
<span class="pl-k" style="box-sizing: border-box; color: var(--color-prettylights-syntax-keyword);">var</span> <span class="pl-en" style="box-sizing: border-box; color: var(--color-prettylights-syntax-entity);">html</span> <span class="pl-k" style="box-sizing: border-box; color: var(--color-prettylights-syntax-keyword);">=</span> <span class="pl-s" style="box-sizing: border-box; color: var(--color-prettylights-syntax-string);"><span class="pl-pds" style="box-sizing: border-box; color: var(--color-prettylights-syntax-string);">"</span>Something to <strong>convert</strong><span class="pl-pds" style="box-sizing: border-box; color: var(--color-prettylights-syntax-string);">"</span></span>; | ||
<span class="pl-k" style="box-sizing: border-box; color: var(--color-prettylights-syntax-keyword);">var</span> <span class="pl-en" style="box-sizing: border-box; color: var(--color-prettylights-syntax-entity);">converter</span> <span class="pl-k" style="box-sizing: border-box; color: var(--color-prettylights-syntax-keyword);">=</span> <span class="pl-k" style="box-sizing: border-box; color: var(--color-prettylights-syntax-keyword);">new</span> <span class="pl-k" style="box-sizing: border-box; color: var(--color-prettylights-syntax-keyword);">Converter</span>(); | ||
<span class="pl-k" style="box-sizing: border-box; color: var(--color-prettylights-syntax-keyword);">var</span> <span class="pl-en" style="box-sizing: border-box; color: var(--color-prettylights-syntax-entity);">markdown</span> <span class="pl-k" style="box-sizing: border-box; color: var(--color-prettylights-syntax-keyword);">=</span> <span class="pl-smi" style="box-sizing: border-box; color: var(--color-prettylights-syntax-storage-modifier-import);">converter</span>.<span class="pl-en" style="box-sizing: border-box; color: var(--color-prettylights-syntax-entity);">Convert</span>(<span class="pl-smi" style="box-sizing: border-box; color: var(--color-prettylights-syntax-storage-modifier-import);">html</span>); | ||
</div> |
Oops, something went wrong.