mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-09 21:42:15 +00:00
Fix extension DisableHtml not working properly with inline HTML (issue #46)
This commit is contained in:
@@ -88,6 +88,7 @@
|
||||
<None Include="Specs\HardlineBreakSpecs.md" />
|
||||
<None Include="Specs\BootstrapSpecs.md" />
|
||||
<None Include="Specs\DiagramsSpecs.md" />
|
||||
<None Include="Specs\NoHtmlSpecs.md" />
|
||||
<None Include="Specs\TaskListSpecs.md" />
|
||||
<None Include="Specs\SmartyPantsSpecs.md" />
|
||||
<None Include="Specs\MediaSpecs.md" />
|
||||
|
||||
27
src/Markdig.Tests/Specs/NoHtmlSpecs.md
Normal file
27
src/Markdig.Tests/Specs/NoHtmlSpecs.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# Extensions
|
||||
|
||||
## NoHTML
|
||||
|
||||
The extension DisableHtml allows to disable the parsing of HTML:
|
||||
|
||||
For inline HTML:
|
||||
|
||||
```````````````````````````````` example
|
||||
this is some text</td></tr>
|
||||
.
|
||||
<p>this is some text</td></tr></p>
|
||||
````````````````````````````````
|
||||
|
||||
For Block HTML:
|
||||
|
||||
```````````````````````````````` example
|
||||
<div>
|
||||
this is some text
|
||||
</div>
|
||||
.
|
||||
<p><div>
|
||||
this is some text
|
||||
</div></p>
|
||||
````````````````````````````````
|
||||
|
||||
|
||||
@@ -19845,4 +19845,54 @@ namespace Markdig.Tests
|
||||
}
|
||||
}
|
||||
// TODO: Add other text diagram languages
|
||||
// # Extensions
|
||||
//
|
||||
// ## NoHTML
|
||||
//
|
||||
// The extension DisableHtml allows to disable the parsing of HTML:
|
||||
//
|
||||
// For inline HTML:
|
||||
[TestFixture]
|
||||
public partial class TestExtensionsNoHTML
|
||||
{
|
||||
[Test]
|
||||
public void Example001()
|
||||
{
|
||||
// Example 1
|
||||
// Section: Extensions NoHTML
|
||||
//
|
||||
// The following CommonMark:
|
||||
// this is some text</td></tr>
|
||||
//
|
||||
// Should be rendered as:
|
||||
// <p>this is some text</td></tr></p>
|
||||
|
||||
Console.WriteLine("Example {0}" + Environment.NewLine + "Section: {0}" + Environment.NewLine, 1, "Extensions NoHTML");
|
||||
TestParser.TestSpec("this is some text</td></tr>", "<p>this is some text</td></tr></p>", "nohtml");
|
||||
}
|
||||
}
|
||||
// For Block HTML:
|
||||
[TestFixture]
|
||||
public partial class TestExtensionsNoHTML
|
||||
{
|
||||
[Test]
|
||||
public void Example002()
|
||||
{
|
||||
// Example 2
|
||||
// Section: Extensions NoHTML
|
||||
//
|
||||
// The following CommonMark:
|
||||
// <div>
|
||||
// this is some text
|
||||
// </div>
|
||||
//
|
||||
// Should be rendered as:
|
||||
// <p><div>
|
||||
// this is some text
|
||||
// </div></p>
|
||||
|
||||
Console.WriteLine("Example {0}" + Environment.NewLine + "Section: {0}" + Environment.NewLine, 2, "Extensions NoHTML");
|
||||
TestParser.TestSpec("<div>\nthis is some text\n</div>", "<p><div>\nthis is some text\n</div></p>", "nohtml");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ SOFTWARE.
|
||||
new KeyValuePair<string, string>(Host.ResolvePath("AutoIdentifierSpecs.md"), "autoidentifiers|advanced"),
|
||||
new KeyValuePair<string, string>(Host.ResolvePath("TaskListSpecs.md"), "tasklists|advanced"),
|
||||
new KeyValuePair<string, string>(Host.ResolvePath("DiagramsSpecs.md"), "diagrams|advanced"),
|
||||
new KeyValuePair<string, string>(Host.ResolvePath("NoHtmlSpecs.md"), "nohtml"),
|
||||
};
|
||||
var emptyLines = false;
|
||||
var displayEmptyLines = false;
|
||||
|
||||
@@ -487,6 +487,9 @@ namespace Markdig
|
||||
case "nofollowlinks":
|
||||
pipeline.UseNoFollowLinks();
|
||||
break;
|
||||
case "nohtml":
|
||||
pipeline.DisableHtml();
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException($"Invalid extension `{extension}` from `{extensions}`", nameof(extensions));
|
||||
}
|
||||
|
||||
@@ -62,6 +62,10 @@ namespace Markdig.Parsers.Inlines
|
||||
Column = column
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user