Generate Specs

This commit is contained in:
Miha Zupan
2019-01-21 16:10:34 +01:00
parent edbf832e0a
commit ffdfd427ce
29 changed files with 29368 additions and 132 deletions

View File

@@ -1,138 +1,153 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A0C5CB5F-5568-40AB-B945-D6D2664D51B0}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Markdig.Tests</RootNamespace>
<AssemblyName>Markdig.Tests</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<CopyNuGetImplementations>true</CopyNuGetImplementations>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Specs\Specs.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Specs.tt</DependentUpon>
</Compile>
<Compile Include="Specs\TestEmphasisPlus.cs" />
<Compile Include="TestEmphasisExtraOptions.cs" />
<Compile Include="TestDescendantsOrder.cs" />
<Compile Include="TestConfigureNewLine.cs" />
<Compile Include="TestHtmlAttributes.cs" />
<Compile Include="TestHtmlHelper.cs" />
<Compile Include="TestLineReader.cs" />
<Compile Include="TestLinkHelper.cs" />
<Compile Include="TestNormalize.cs" />
<Compile Include="TestOrderedList.cs" />
<Compile Include="TestPlainText.cs" />
<Compile Include="TestPragmaLines.cs" />
<Compile Include="TestLinkRewriter.cs" />
<Compile Include="TestRelativeUrlReplacement.cs" />
<Compile Include="TestSourcePosition.cs" />
<Compile Include="TestStringSliceList.cs" />
<Compile Include="TestPlayParser.cs" />
<Compile Include="TextAssert.cs" />
<Compile Include="TestParser.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<Content Include="ArgumentOutOfRangeException.md">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="hang.md">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="project.json" />
<None Include="Specs\GlobalizationSpecs.md" />
<None Include="Specs\JiraLinks.md" />
<None Include="Specs\AutoLinks.md" />
<None Include="Specs\AutoIdentifierSpecs.md" />
<None Include="Specs\AbbreviationSpecs.md" />
<None Include="Specs\FigureFooterAndCiteSpecs.md" />
<None Include="Specs\ListExtraSpecs.md" />
<None Include="Specs\GenericAttributesSpecs.md" />
<None Include="Specs\CustomContainerSpecs.md" />
<None Include="Specs\DefinitionListSpecs.md" />
<None Include="Specs\EmojiSpecs.md" />
<None Include="Specs\FootnotesSpecs.md" />
<None Include="Specs\GridTableSpecs.md" />
<None Include="Specs\HardlineBreakSpecs.md" />
<None Include="Specs\BootstrapSpecs.md" />
<None Include="Specs\DiagramsSpecs.md" />
<None Include="Specs\NoHtmlSpecs.md" />
<None Include="Specs\readme.md" />
<None Include="Specs\YamlSpecs.md" />
<None Include="Specs\TaskListSpecs.md" />
<None Include="Specs\SmartyPantsSpecs.md" />
<None Include="Specs\MediaSpecs.md" />
<None Include="Specs\MathSpecs.md" />
<None Include="Specs\PipeTableSpecs.md" />
<None Include="Specs\EmphasisExtraSpecs.md" />
</ItemGroup>
<ItemGroup>
<Content Include="Specs\Specs.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>Specs.cs</LastGenOutput>
</Content>
</ItemGroup>
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Markdig\Markdig.csproj">
<Project>{8a58a7e2-627c-4f41-933f-5ac92adfab48}</Project>
<Name>Markdig</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A0C5CB5F-5568-40AB-B945-D6D2664D51B0}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Markdig.Tests</RootNamespace>
<AssemblyName>Markdig.Tests</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<CopyNuGetImplementations>true</CopyNuGetImplementations>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Specs\AbbreviationSpecs.cs" />
<Compile Include="Specs\AutoIdentifierSpecs.cs" />
<Compile Include="Specs\AutoLinks.cs" />
<Compile Include="Specs\BootstrapSpecs.cs" />
<Compile Include="Specs\CommonMark.cs" />
<Compile Include="Specs\CustomContainerSpecs.cs" />
<Compile Include="Specs\DefinitionListSpecs.cs" />
<Compile Include="Specs\DiagramsSpecs.cs" />
<Compile Include="Specs\EmojiSpecs.cs" />
<Compile Include="Specs\EmphasisExtraSpecs.cs" />
<Compile Include="Specs\FigureFooterAndCiteSpecs.cs" />
<Compile Include="Specs\FootnotesSpecs.cs" />
<Compile Include="Specs\GenericAttributesSpecs.cs" />
<Compile Include="Specs\GlobalizationSpecs.cs" />
<Compile Include="Specs\GridTableSpecs.cs" />
<Compile Include="Specs\HardlineBreakSpecs.cs" />
<Compile Include="Specs\JiraLinks.cs" />
<Compile Include="Specs\ListExtraSpecs.cs" />
<Compile Include="Specs\MathSpecs.cs" />
<Compile Include="Specs\MediaSpecs.cs" />
<Compile Include="Specs\NoHtmlSpecs.cs" />
<Compile Include="Specs\PipeTableSpecs.cs" />
<Compile Include="Specs\SmartyPantsSpecs.cs" />
<Compile Include="Specs\TaskListSpecs.cs" />
<Compile Include="Specs\YamlSpecs.cs" />
<Compile Include="TestEmphasisPlus.cs" />
<Compile Include="TestEmphasisExtraOptions.cs" />
<Compile Include="TestDescendantsOrder.cs" />
<Compile Include="TestConfigureNewLine.cs" />
<Compile Include="TestHtmlAttributes.cs" />
<Compile Include="TestHtmlHelper.cs" />
<Compile Include="TestLineReader.cs" />
<Compile Include="TestLinkHelper.cs" />
<Compile Include="TestNormalize.cs" />
<Compile Include="TestOrderedList.cs" />
<Compile Include="TestPlainText.cs" />
<Compile Include="TestPragmaLines.cs" />
<Compile Include="TestLinkRewriter.cs" />
<Compile Include="TestRelativeUrlReplacement.cs" />
<Compile Include="TestSourcePosition.cs" />
<Compile Include="TestStringSliceList.cs" />
<Compile Include="TestPlayParser.cs" />
<Compile Include="TextAssert.cs" />
<Compile Include="TestParser.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<Content Include="ArgumentOutOfRangeException.md">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="hang.md">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="project.json" />
<None Include="Specs\CommonMark.md" />
<None Include="Specs\GlobalizationSpecs.md" />
<None Include="Specs\JiraLinks.md" />
<None Include="Specs\AutoLinks.md" />
<None Include="Specs\AutoIdentifierSpecs.md" />
<None Include="Specs\AbbreviationSpecs.md" />
<None Include="Specs\FigureFooterAndCiteSpecs.md" />
<None Include="Specs\ListExtraSpecs.md" />
<None Include="Specs\GenericAttributesSpecs.md" />
<None Include="Specs\CustomContainerSpecs.md" />
<None Include="Specs\DefinitionListSpecs.md" />
<None Include="Specs\EmojiSpecs.md" />
<None Include="Specs\FootnotesSpecs.md" />
<None Include="Specs\GridTableSpecs.md" />
<None Include="Specs\HardlineBreakSpecs.md" />
<None Include="Specs\BootstrapSpecs.md" />
<None Include="Specs\DiagramsSpecs.md" />
<None Include="Specs\NoHtmlSpecs.md" />
<None Include="Specs\readme.md" />
<None Include="Specs\YamlSpecs.md" />
<None Include="Specs\TaskListSpecs.md" />
<None Include="Specs\SmartyPantsSpecs.md" />
<None Include="Specs\MediaSpecs.md" />
<None Include="Specs\MathSpecs.md" />
<None Include="Specs\PipeTableSpecs.md" />
<None Include="Specs\EmphasisExtraSpecs.md" />
</ItemGroup>
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Markdig\Markdig.csproj">
<Project>{8a58a7e2-627c-4f41-933f-5ac92adfab48}</Project>
<Name>Markdig</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
-->
</Project>

View File

@@ -0,0 +1,197 @@
// Generated: 21. 01. 2019 14:26:34
// --------------------------------
// Abbreviations
// --------------------------------
using System;
using NUnit.Framework;
namespace Markdig.Tests.Specs.Abbreviations
{
[TestFixture]
public class TestExtensionsAbbreviation
{
// # Extensions
//
// This section describes the different extensions supported:
//
// ## Abbreviation
//
// Abbreviation can be declared by using the `*[Abbreviation Label]: Abbreviation description`
//
// Abbreviation definition will be removed from the original document. Any Abbreviation label found in literals will be replaced by the abbreviation description:
[Test]
public void ExtensionsAbbreviation_Example001()
{
// Example 1
// Section: Extensions / Abbreviation
//
// The following Markdown:
// *[HTML]: Hypertext Markup Language
//
// Later in a text we are using HTML and it becomes an abbr tag HTML
//
// Should be rendered as:
// <p>Later in a text we are using <abbr title="Hypertext Markup Language">HTML</abbr> and it becomes an abbr tag <abbr title="Hypertext Markup Language">HTML</abbr></p>
Console.WriteLine("Example 1\nSection Extensions / Abbreviation\n");
TestParser.TestSpec("*[HTML]: Hypertext Markup Language\n\nLater in a text we are using HTML and it becomes an abbr tag HTML", "<p>Later in a text we are using <abbr title=\"Hypertext Markup Language\">HTML</abbr> and it becomes an abbr tag <abbr title=\"Hypertext Markup Language\">HTML</abbr></p>", "abbreviations|advanced");
}
// An abbreviation definition can be indented at most 3 spaces
[Test]
public void ExtensionsAbbreviation_Example002()
{
// Example 2
// Section: Extensions / Abbreviation
//
// The following Markdown:
// *[HTML]: Hypertext Markup Language
// *[This]: is not an abbreviation
//
// Should be rendered as:
// <pre><code>*[This]: is not an abbreviation
// </code></pre>
Console.WriteLine("Example 2\nSection Extensions / Abbreviation\n");
TestParser.TestSpec("*[HTML]: Hypertext Markup Language\n *[This]: is not an abbreviation", "<pre><code>*[This]: is not an abbreviation\n</code></pre>", "abbreviations|advanced");
}
// An abbreviation may contain spaces:
[Test]
public void ExtensionsAbbreviation_Example003()
{
// Example 3
// Section: Extensions / Abbreviation
//
// The following Markdown:
// *[SUPER HTML]: Super Hypertext Markup Language
//
// This is a SUPER HTML document
//
// Should be rendered as:
// <p>This is a <abbr title="Super Hypertext Markup Language">SUPER HTML</abbr> document</p>
Console.WriteLine("Example 3\nSection Extensions / Abbreviation\n");
TestParser.TestSpec("*[SUPER HTML]: Super Hypertext Markup Language\n\nThis is a SUPER HTML document ", "<p>This is a <abbr title=\"Super Hypertext Markup Language\">SUPER HTML</abbr> document</p>", "abbreviations|advanced");
}
// Abbreviation may contain any unicode characters:
[Test]
public void ExtensionsAbbreviation_Example004()
{
// Example 4
// Section: Extensions / Abbreviation
//
// The following Markdown:
// *[😃 HTML]: Hypertext Markup Language
//
// This is a 😃 HTML document
//
// Should be rendered as:
// <p>This is a <abbr title="Hypertext Markup Language">😃 HTML</abbr> document</p>
Console.WriteLine("Example 4\nSection Extensions / Abbreviation\n");
TestParser.TestSpec("*[😃 HTML]: Hypertext Markup Language\n\nThis is a 😃 HTML document ", "<p>This is a <abbr title=\"Hypertext Markup Language\">😃 HTML</abbr> document</p>", "abbreviations|advanced");
}
// Abbreviations may be similar:
[Test]
public void ExtensionsAbbreviation_Example005()
{
// Example 5
// Section: Extensions / Abbreviation
//
// The following Markdown:
// *[1A]: First
// *[1A1]: Second
// *[1A2]: Third
//
// We can abbreviate 1A, 1A1 and 1A2!
//
// Should be rendered as:
// <p>We can abbreviate <abbr title="First">1A</abbr>, <abbr title="Second">1A1</abbr> and <abbr title="Third">1A2</abbr>!</p>
Console.WriteLine("Example 5\nSection Extensions / Abbreviation\n");
TestParser.TestSpec("*[1A]: First\n*[1A1]: Second\n*[1A2]: Third\n\nWe can abbreviate 1A, 1A1 and 1A2!", "<p>We can abbreviate <abbr title=\"First\">1A</abbr>, <abbr title=\"Second\">1A1</abbr> and <abbr title=\"Third\">1A2</abbr>!</p>", "abbreviations|advanced");
}
// Abbreviations should match whole word only:
[Test]
public void ExtensionsAbbreviation_Example006()
{
// Example 6
// Section: Extensions / Abbreviation
//
// The following Markdown:
// *[1A]: First
//
// We should not abbreviate 1.1A or 11A!
//
// Should be rendered as:
// <p>We should not abbreviate 1.1A or 11A!</p>
Console.WriteLine("Example 6\nSection Extensions / Abbreviation\n");
TestParser.TestSpec("*[1A]: First\n\nWe should not abbreviate 1.1A or 11A!", "<p>We should not abbreviate 1.1A or 11A!</p>", "abbreviations|advanced");
}
// Abbreviations should match whole word only, even if the word is the entire content:
[Test]
public void ExtensionsAbbreviation_Example007()
{
// Example 7
// Section: Extensions / Abbreviation
//
// The following Markdown:
// *[1A]: First
//
// 1.1A
//
// Should be rendered as:
// <p>1.1A</p>
Console.WriteLine("Example 7\nSection Extensions / Abbreviation\n");
TestParser.TestSpec("*[1A]: First\n\n1.1A", "<p>1.1A</p>", "abbreviations|advanced");
}
// Abbreviations should match whole word only, even if there is another glossary term:
[Test]
public void ExtensionsAbbreviation_Example008()
{
// Example 8
// Section: Extensions / Abbreviation
//
// The following Markdown:
// *[SCO]: First
// *[SCOM]: Second
//
// SCOM
//
// Should be rendered as:
// <p><abbr title="Second">SCOM</abbr></p>
Console.WriteLine("Example 8\nSection Extensions / Abbreviation\n");
TestParser.TestSpec("*[SCO]: First\n*[SCOM]: Second\n\nSCOM", "<p><abbr title=\"Second\">SCOM</abbr></p>", "abbreviations|advanced");
}
// Abbreviations should only match when surrounded by whitespace:
[Test]
public void ExtensionsAbbreviation_Example009()
{
// Example 9
// Section: Extensions / Abbreviation
//
// The following Markdown:
// *[PR]: Pull Request
//
// PRAA
//
// Should be rendered as:
// <p>PRAA</p>
Console.WriteLine("Example 9\nSection Extensions / Abbreviation\n");
TestParser.TestSpec("*[PR]: Pull Request\n\nPRAA", "<p>PRAA</p>", "abbreviations|advanced");
}
}
}

View File

@@ -0,0 +1,224 @@
// Generated: 21. 01. 2019 14:26:34
// --------------------------------
// Auto Identifiers
// --------------------------------
using System;
using NUnit.Framework;
namespace Markdig.Tests.Specs.AutoIdentifiers
{
[TestFixture]
public class TestExtensionsHeadingAutoIdentifiers
{
// # Extensions
//
// This section describes the auto identifier extension
//
// ## Heading Auto Identifiers
//
// Allows to automatically creates an identifier for a heading:
[Test]
public void ExtensionsHeadingAutoIdentifiers_Example001()
{
// Example 1
// Section: Extensions / Heading Auto Identifiers
//
// The following Markdown:
// # This is a heading
//
// Should be rendered as:
// <h1 id="this-is-a-heading">This is a heading</h1>
Console.WriteLine("Example 1\nSection Extensions / Heading Auto Identifiers\n");
TestParser.TestSpec("# This is a heading", "<h1 id=\"this-is-a-heading\">This is a heading</h1>", "autoidentifiers|advanced");
}
// Only punctuation `-`, `_` and `.` is kept, all other non letter characters are discarded.
// Consecutive same character `-`, `_` or `.` are rendered into a single one
// Characters `-`, `_` and `.` at the end of the string are also discarded.
[Test]
public void ExtensionsHeadingAutoIdentifiers_Example002()
{
// Example 2
// Section: Extensions / Heading Auto Identifiers
//
// The following Markdown:
// # This - is a &@! heading _ with . and ! -
//
// Should be rendered as:
// <h1 id="this-is-a-heading_with.and">This - is a &amp;@! heading _ with . and ! -</h1>
Console.WriteLine("Example 2\nSection Extensions / Heading Auto Identifiers\n");
TestParser.TestSpec("# This - is a &@! heading _ with . and ! -", "<h1 id=\"this-is-a-heading_with.and\">This - is a &amp;@! heading _ with . and ! -</h1>", "autoidentifiers|advanced");
}
// Formatting (emphasis) are also discarded:
[Test]
public void ExtensionsHeadingAutoIdentifiers_Example003()
{
// Example 3
// Section: Extensions / Heading Auto Identifiers
//
// The following Markdown:
// # This is a *heading*
//
// Should be rendered as:
// <h1 id="this-is-a-heading">This is a <em>heading</em></h1>
Console.WriteLine("Example 3\nSection Extensions / Heading Auto Identifiers\n");
TestParser.TestSpec("# This is a *heading*", "<h1 id=\"this-is-a-heading\">This is a <em>heading</em></h1>", "autoidentifiers|advanced");
}
// Links are also removed:
[Test]
public void ExtensionsHeadingAutoIdentifiers_Example004()
{
// Example 4
// Section: Extensions / Heading Auto Identifiers
//
// The following Markdown:
// # This is a [heading](/url)
//
// Should be rendered as:
// <h1 id="this-is-a-heading">This is a <a href="/url">heading</a></h1>
Console.WriteLine("Example 4\nSection Extensions / Heading Auto Identifiers\n");
TestParser.TestSpec("# This is a [heading](/url)", "<h1 id=\"this-is-a-heading\">This is a <a href=\"/url\">heading</a></h1>", "autoidentifiers|advanced");
}
// If multiple heading have the same text, -1, -2...-n will be postfix to the header id.
[Test]
public void ExtensionsHeadingAutoIdentifiers_Example005()
{
// Example 5
// Section: Extensions / Heading Auto Identifiers
//
// The following Markdown:
// # This is a heading
// # This is a heading
//
// Should be rendered as:
// <h1 id="this-is-a-heading">This is a heading</h1>
// <h1 id="this-is-a-heading-1">This is a heading</h1>
Console.WriteLine("Example 5\nSection Extensions / Heading Auto Identifiers\n");
TestParser.TestSpec("# This is a heading\n# This is a heading", "<h1 id=\"this-is-a-heading\">This is a heading</h1>\n<h1 id=\"this-is-a-heading-1\">This is a heading</h1>", "autoidentifiers|advanced");
}
// The heading Id will start on the first letter character of the heading, all previous characters will be discarded:
[Test]
public void ExtensionsHeadingAutoIdentifiers_Example006()
{
// Example 6
// Section: Extensions / Heading Auto Identifiers
//
// The following Markdown:
// # 1.0 This is a heading
//
// Should be rendered as:
// <h1 id="this-is-a-heading">1.0 This is a heading</h1>
Console.WriteLine("Example 6\nSection Extensions / Heading Auto Identifiers\n");
TestParser.TestSpec("# 1.0 This is a heading", "<h1 id=\"this-is-a-heading\">1.0 This is a heading</h1>", "autoidentifiers|advanced");
}
// If the heading is all stripped by the previous rules, the id `section` will be used instead:
[Test]
public void ExtensionsHeadingAutoIdentifiers_Example007()
{
// Example 7
// Section: Extensions / Heading Auto Identifiers
//
// The following Markdown:
// # 1.0 & ^ % *
// # 1.0 & ^ % *
//
// Should be rendered as:
// <h1 id="section">1.0 &amp; ^ % *</h1>
// <h1 id="section-1">1.0 &amp; ^ % *</h1>
Console.WriteLine("Example 7\nSection Extensions / Heading Auto Identifiers\n");
TestParser.TestSpec("# 1.0 & ^ % *\n# 1.0 & ^ % *", "<h1 id=\"section\">1.0 &amp; ^ % *</h1>\n<h1 id=\"section-1\">1.0 &amp; ^ % *</h1>", "autoidentifiers|advanced");
}
// When the options "AutoLink" is setup, it is possible to link to an existing heading by using the
// exact same Label text as the heading:
[Test]
public void ExtensionsHeadingAutoIdentifiers_Example008()
{
// Example 8
// Section: Extensions / Heading Auto Identifiers
//
// The following Markdown:
// # This is a heading
// [This is a heading]
//
// Should be rendered as:
// <h1 id="this-is-a-heading">This is a heading</h1>
// <p><a href="#this-is-a-heading">This is a heading</a></p>
Console.WriteLine("Example 8\nSection Extensions / Heading Auto Identifiers\n");
TestParser.TestSpec("# This is a heading\n[This is a heading]", "<h1 id=\"this-is-a-heading\">This is a heading</h1>\n<p><a href=\"#this-is-a-heading\">This is a heading</a></p>", "autoidentifiers|advanced");
}
// Links before the heading are also working:
[Test]
public void ExtensionsHeadingAutoIdentifiers_Example009()
{
// Example 9
// Section: Extensions / Heading Auto Identifiers
//
// The following Markdown:
// [This is a heading]
// # This is a heading
//
// Should be rendered as:
// <p><a href="#this-is-a-heading">This is a heading</a></p>
// <h1 id="this-is-a-heading">This is a heading</h1>
Console.WriteLine("Example 9\nSection Extensions / Heading Auto Identifiers\n");
TestParser.TestSpec("[This is a heading]\n# This is a heading", "<p><a href=\"#this-is-a-heading\">This is a heading</a></p>\n<h1 id=\"this-is-a-heading\">This is a heading</h1>", "autoidentifiers|advanced");
}
// The text of the link can be changed:
[Test]
public void ExtensionsHeadingAutoIdentifiers_Example010()
{
// Example 10
// Section: Extensions / Heading Auto Identifiers
//
// The following Markdown:
// [With a new text][This is a heading]
// # This is a heading
//
// Should be rendered as:
// <p><a href="#this-is-a-heading">With a new text</a></p>
// <h1 id="this-is-a-heading">This is a heading</h1>
Console.WriteLine("Example 10\nSection Extensions / Heading Auto Identifiers\n");
TestParser.TestSpec("[With a new text][This is a heading]\n# This is a heading", "<p><a href=\"#this-is-a-heading\">With a new text</a></p>\n<h1 id=\"this-is-a-heading\">This is a heading</h1>", "autoidentifiers|advanced");
}
// An autoidentifier should not conflict with an existing link:
[Test]
public void ExtensionsHeadingAutoIdentifiers_Example011()
{
// Example 11
// Section: Extensions / Heading Auto Identifiers
//
// The following Markdown:
// ![scenario image][scenario]
// ## Scenario
// [scenario]: ./scenario.png
//
// Should be rendered as:
// <p><img src="./scenario.png" alt="scenario image" /></p>
// <h2 id="scenario">Scenario</h2>
Console.WriteLine("Example 11\nSection Extensions / Heading Auto Identifiers\n");
TestParser.TestSpec("![scenario image][scenario]\n## Scenario\n[scenario]: ./scenario.png", "<p><img src=\"./scenario.png\" alt=\"scenario image\" /></p>\n<h2 id=\"scenario\">Scenario</h2>", "autoidentifiers|advanced");
}
}
}

View File

@@ -0,0 +1,449 @@
// Generated: 21. 01. 2019 14:26:34
// --------------------------------
// Auto Links
// --------------------------------
using System;
using NUnit.Framework;
namespace Markdig.Tests.Specs.AutoLinks
{
[TestFixture]
public class TestExtensionsAutoLinks
{
// # Extensions
//
// This section describes the different extensions supported:
//
// ## AutoLinks
//
// Autolinks will format as a HTML link any string that starts by:
//
// - `http://` or `https://`
// - `ftp://`
// - `mailto:`
// - `www.`
[Test]
public void ExtensionsAutoLinks_Example001()
{
// Example 1
// Section: Extensions / AutoLinks
//
// The following Markdown:
// This is a http://www.google.com URL and https://www.google.com
// This is a ftp://test.com
// And a mailto:email@toto.com
// And a plain www.google.com
//
// Should be rendered as:
// <p>This is a <a href="http://www.google.com">http://www.google.com</a> URL and <a href="https://www.google.com">https://www.google.com</a>
// This is a <a href="ftp://test.com">ftp://test.com</a>
// And a <a href="mailto:email@toto.com">email@toto.com</a>
// And a plain <a href="http://www.google.com">www.google.com</a></p>
Console.WriteLine("Example 1\nSection Extensions / AutoLinks\n");
TestParser.TestSpec("This is a http://www.google.com URL and https://www.google.com\nThis is a ftp://test.com\nAnd a mailto:email@toto.com\nAnd a plain www.google.com", "<p>This is a <a href=\"http://www.google.com\">http://www.google.com</a> URL and <a href=\"https://www.google.com\">https://www.google.com</a>\nThis is a <a href=\"ftp://test.com\">ftp://test.com</a>\nAnd a <a href=\"mailto:email@toto.com\">email@toto.com</a>\nAnd a plain <a href=\"http://www.google.com\">www.google.com</a></p>", "autolinks|advanced");
}
// But incomplete links will not be matched:
[Test]
public void ExtensionsAutoLinks_Example002()
{
// Example 2
// Section: Extensions / AutoLinks
//
// The following Markdown:
// This is not a http:/www.google.com URL and https:/www.google.com
// This is not a ftp:/test.com
// And not a mailto:emailtoto.com
// And not a plain www. or a www.x
//
// Should be rendered as:
// <p>This is not a http:/www.google.com URL and https:/www.google.com
// This is not a ftp:/test.com
// And not a mailto:emailtoto.com
// And not a plain www. or a www.x</p>
Console.WriteLine("Example 2\nSection Extensions / AutoLinks\n");
TestParser.TestSpec("This is not a http:/www.google.com URL and https:/www.google.com\nThis is not a ftp:/test.com\nAnd not a mailto:emailtoto.com\nAnd not a plain www. or a www.x ", "<p>This is not a http:/www.google.com URL and https:/www.google.com\nThis is not a ftp:/test.com\nAnd not a mailto:emailtoto.com\nAnd not a plain www. or a www.x</p>", "autolinks|advanced");
}
// Previous character must be a punctuation or a valid space (tab, space, new line):
[Test]
public void ExtensionsAutoLinks_Example003()
{
// Example 3
// Section: Extensions / AutoLinks
//
// The following Markdown:
// This is not a nhttp://www.google.com URL but this is (https://www.google.com)
//
// Should be rendered as:
// <p>This is not a nhttp://www.google.com URL but this is (<a href="https://www.google.com">https://www.google.com</a>)</p>
Console.WriteLine("Example 3\nSection Extensions / AutoLinks\n");
TestParser.TestSpec("This is not a nhttp://www.google.com URL but this is (https://www.google.com)", "<p>This is not a nhttp://www.google.com URL but this is (<a href=\"https://www.google.com\">https://www.google.com</a>)</p>", "autolinks|advanced");
}
// An autolink should not interfere with an `<a>` HTML inline:
[Test]
public void ExtensionsAutoLinks_Example004()
{
// Example 4
// Section: Extensions / AutoLinks
//
// The following Markdown:
// This is an HTML <a href="http://www.google.com">http://www.google.com</a> link
//
// Should be rendered as:
// <p>This is an HTML <a href="http://www.google.com">http://www.google.com</a> link</p>
Console.WriteLine("Example 4\nSection Extensions / AutoLinks\n");
TestParser.TestSpec("This is an HTML <a href=\"http://www.google.com\">http://www.google.com</a> link", "<p>This is an HTML <a href=\"http://www.google.com\">http://www.google.com</a> link</p>", "autolinks|advanced");
}
// or even within emphasis:
[Test]
public void ExtensionsAutoLinks_Example005()
{
// Example 5
// Section: Extensions / AutoLinks
//
// The following Markdown:
// This is an HTML <a href="http://www.google.com"> **http://www.google.com** </a> link
//
// Should be rendered as:
// <p>This is an HTML <a href="http://www.google.com"> <strong>http://www.google.com</strong> </a> link</p>
Console.WriteLine("Example 5\nSection Extensions / AutoLinks\n");
TestParser.TestSpec("This is an HTML <a href=\"http://www.google.com\"> **http://www.google.com** </a> link", "<p>This is an HTML <a href=\"http://www.google.com\"> <strong>http://www.google.com</strong> </a> link</p>", "autolinks|advanced");
}
// An autolink should not interfere with a markdown link:
[Test]
public void ExtensionsAutoLinks_Example006()
{
// Example 6
// Section: Extensions / AutoLinks
//
// The following Markdown:
// This is an HTML [http://www.google.com](http://www.google.com) link
//
// Should be rendered as:
// <p>This is an HTML <a href="http://www.google.com">http://www.google.com</a> link</p>
Console.WriteLine("Example 6\nSection Extensions / AutoLinks\n");
TestParser.TestSpec("This is an HTML [http://www.google.com](http://www.google.com) link", "<p>This is an HTML <a href=\"http://www.google.com\">http://www.google.com</a> link</p>", "autolinks|advanced");
}
// A link embraced by pending emphasis should let the emphasis takes precedence if characters are placed at the end of the matched link:
[Test]
public void ExtensionsAutoLinks_Example007()
{
// Example 7
// Section: Extensions / AutoLinks
//
// The following Markdown:
// Check **http://www.a.com** or __http://www.b.com__
//
// Should be rendered as:
// <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>
Console.WriteLine("Example 7\nSection Extensions / AutoLinks\n");
TestParser.TestSpec("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>", "autolinks|advanced");
}
// 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):
[Test]
public void ExtensionsAutoLinks_Example008()
{
// Example 8
// Section: Extensions / AutoLinks
//
// The following Markdown:
// mailto:email@test.com is okay, but mailto:@test.com is not
//
// Should be rendered as:
// <p><a href="mailto:email@test.com">email@test.com</a> is okay, but mailto:@test.com is not</p>
Console.WriteLine("Example 8\nSection Extensions / AutoLinks\n");
TestParser.TestSpec("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>", "autolinks|advanced");
}
}
[TestFixture]
public class TestExtensionsAutoLinksGFMSupport
{
// ### GFM Support
//
// Extract from [GFM Autolinks extensions specs](https://github.github.com/gfm/#autolinks-extension-)
[Test]
public void ExtensionsAutoLinksGFMSupport_Example009()
{
// Example 9
// Section: Extensions / AutoLinks / GFM Support
//
// The following Markdown:
// www.commonmark.org
//
// Should be rendered as:
// <p><a href="http://www.commonmark.org">www.commonmark.org</a></p>
Console.WriteLine("Example 9\nSection Extensions / AutoLinks / GFM Support\n");
TestParser.TestSpec("www.commonmark.org", "<p><a href=\"http://www.commonmark.org\">www.commonmark.org</a></p>", "autolinks|advanced");
}
[Test]
public void ExtensionsAutoLinksGFMSupport_Example010()
{
// Example 10
// Section: Extensions / AutoLinks / GFM Support
//
// The following Markdown:
// Visit www.commonmark.org/help for more information.
//
// Should be rendered as:
// <p>Visit <a href="http://www.commonmark.org/help">www.commonmark.org/help</a> for more information.</p>
Console.WriteLine("Example 10\nSection Extensions / AutoLinks / GFM Support\n");
TestParser.TestSpec("Visit www.commonmark.org/help for more information.", "<p>Visit <a href=\"http://www.commonmark.org/help\">www.commonmark.org/help</a> for more information.</p>", "autolinks|advanced");
}
[Test]
public void ExtensionsAutoLinksGFMSupport_Example011()
{
// Example 11
// Section: Extensions / AutoLinks / GFM Support
//
// The following Markdown:
// Visit www.commonmark.org.
//
// Visit www.commonmark.org/a.b.
//
// Should be rendered as:
// <p>Visit <a href="http://www.commonmark.org">www.commonmark.org</a>.</p>
// <p>Visit <a href="http://www.commonmark.org/a.b">www.commonmark.org/a.b</a>.</p>
Console.WriteLine("Example 11\nSection Extensions / AutoLinks / GFM Support\n");
TestParser.TestSpec("Visit www.commonmark.org.\n\nVisit www.commonmark.org/a.b.", "<p>Visit <a href=\"http://www.commonmark.org\">www.commonmark.org</a>.</p>\n<p>Visit <a href=\"http://www.commonmark.org/a.b\">www.commonmark.org/a.b</a>.</p>", "autolinks|advanced");
}
[Test]
public void ExtensionsAutoLinksGFMSupport_Example012()
{
// Example 12
// Section: Extensions / AutoLinks / GFM Support
//
// The following Markdown:
// www.google.com/search?q=Markup+(business)
//
// (www.google.com/search?q=Markup+(business))
//
// Should be rendered as:
// <p><a href="http://www.google.com/search?q=Markup+(business)">www.google.com/search?q=Markup+(business)</a></p>
// <p>(<a href="http://www.google.com/search?q=Markup+(business)">www.google.com/search?q=Markup+(business)</a>)</p>
Console.WriteLine("Example 12\nSection Extensions / AutoLinks / GFM Support\n");
TestParser.TestSpec("www.google.com/search?q=Markup+(business)\n\n(www.google.com/search?q=Markup+(business))", "<p><a href=\"http://www.google.com/search?q=Markup+(business)\">www.google.com/search?q=Markup+(business)</a></p>\n<p>(<a href=\"http://www.google.com/search?q=Markup+(business)\">www.google.com/search?q=Markup+(business)</a>)</p>", "autolinks|advanced");
}
[Test]
public void ExtensionsAutoLinksGFMSupport_Example013()
{
// Example 13
// Section: Extensions / AutoLinks / GFM Support
//
// The following Markdown:
// www.google.com/search?q=commonmark&hl=en
//
// www.google.com/search?q=commonmark&hl;
//
// Should be rendered as:
// <p><a href="http://www.google.com/search?q=commonmark&amp;hl=en">www.google.com/search?q=commonmark&amp;hl=en</a></p>
// <p><a href="http://www.google.com/search?q=commonmark">www.google.com/search?q=commonmark</a>&amp;hl;</p>
Console.WriteLine("Example 13\nSection Extensions / AutoLinks / GFM Support\n");
TestParser.TestSpec("www.google.com/search?q=commonmark&hl=en\n\nwww.google.com/search?q=commonmark&hl;", "<p><a href=\"http://www.google.com/search?q=commonmark&amp;hl=en\">www.google.com/search?q=commonmark&amp;hl=en</a></p>\n<p><a href=\"http://www.google.com/search?q=commonmark\">www.google.com/search?q=commonmark</a>&amp;hl;</p>", "autolinks|advanced");
}
[Test]
public void ExtensionsAutoLinksGFMSupport_Example014()
{
// Example 14
// Section: Extensions / AutoLinks / GFM Support
//
// The following Markdown:
// www.commonmark.org/he<lp
//
// Should be rendered as:
// <p><a href="http://www.commonmark.org/he">www.commonmark.org/he</a>&lt;lp</p>
Console.WriteLine("Example 14\nSection Extensions / AutoLinks / GFM Support\n");
TestParser.TestSpec("www.commonmark.org/he<lp", "<p><a href=\"http://www.commonmark.org/he\">www.commonmark.org/he</a>&lt;lp</p>", "autolinks|advanced");
}
[Test]
public void ExtensionsAutoLinksGFMSupport_Example015()
{
// Example 15
// Section: Extensions / AutoLinks / GFM Support
//
// The following Markdown:
// http://commonmark.org
//
// (Visit https://encrypted.google.com/search?q=Markup+(business))
//
// Anonymous FTP is available at ftp://foo.bar.baz.
//
// Should be rendered as:
// <p><a href="http://commonmark.org">http://commonmark.org</a></p>
// <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>
Console.WriteLine("Example 15\nSection Extensions / AutoLinks / GFM Support\n");
TestParser.TestSpec("http://commonmark.org\n\n(Visit https://encrypted.google.com/search?q=Markup+(business))\n\nAnonymous FTP is available at ftp://foo.bar.baz.", "<p><a href=\"http://commonmark.org\">http://commonmark.org</a></p>\n<p>(Visit <a href=\"https://encrypted.google.com/search?q=Markup+(business)\">https://encrypted.google.com/search?q=Markup+(business)</a>)</p>\n<p>Anonymous FTP is available at <a href=\"ftp://foo.bar.baz\">ftp://foo.bar.baz</a>.</p>", "autolinks|advanced");
}
}
[TestFixture]
public class TestExtensionsAutoLinksValidDomainTests
{
// ### Valid Domain Tests
//
// Domain names that have empty segments won't be matched
[Test]
public void ExtensionsAutoLinksValidDomainTests_Example016()
{
// Example 16
// Section: Extensions / AutoLinks / Valid Domain Tests
//
// The following Markdown:
// www..
// www..com
// http://test.
// http://.test
// http://.
// http://..
// ftp://test.
// ftp://.test
// mailto:email@test.
// mailto:email@.test
//
// Should be rendered as:
// <p>www..
// www..com
// http://test.
// http://.test
// http://.
// http://..
// ftp://test.
// ftp://.test
// mailto:email@test.
// mailto:email@.test</p>
Console.WriteLine("Example 16\nSection Extensions / AutoLinks / Valid Domain Tests\n");
TestParser.TestSpec("www..\nwww..com\nhttp://test.\nhttp://.test\nhttp://.\nhttp://..\nftp://test.\nftp://.test\nmailto:email@test.\nmailto:email@.test", "<p>www..\nwww..com\nhttp://test.\nhttp://.test\nhttp://.\nhttp://..\nftp://test.\nftp://.test\nmailto:email@test.\nmailto:email@.test</p>", "autolinks|advanced");
}
// Domain names with too few segments won't be matched
[Test]
public void ExtensionsAutoLinksValidDomainTests_Example017()
{
// Example 17
// Section: Extensions / AutoLinks / Valid Domain Tests
//
// The following Markdown:
// www
// www.com
// http://test
// ftp://test
// mailto:email@test
//
// Should be rendered as:
// <p>www
// www.com
// http://test
// ftp://test
// mailto:email@test</p>
Console.WriteLine("Example 17\nSection Extensions / AutoLinks / Valid Domain Tests\n");
TestParser.TestSpec("www\nwww.com\nhttp://test\nftp://test\nmailto:email@test", "<p>www\nwww.com\nhttp://test\nftp://test\nmailto:email@test</p>", "autolinks|advanced");
}
// Domain names that contain an underscores in the last two segments won't be matched
[Test]
public void ExtensionsAutoLinksValidDomainTests_Example018()
{
// Example 18
// Section: Extensions / AutoLinks / Valid Domain Tests
//
// The following Markdown:
// 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
//
// Should be rendered as:
// <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>
Console.WriteLine("Example 18\nSection Extensions / AutoLinks / Valid Domain Tests\n");
TestParser.TestSpec("www._test.foo.bar is okay, but www._test.foo is not\n\nhttp://te_st.foo.bar is okay, as is http://test.foo_.bar.foo\n\nBut http://te_st.foo, http://test.foo_.bar and http://test._foo are not\n\nftp://test_.foo.bar is okay, but ftp://test.fo_o is not\n\nmailto: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>\n<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>\n<p>But http://te_st.foo, http://test.foo_.bar and http://test._foo are not</p>\n<p><a href=\"ftp://test_.foo.bar\">ftp://test_.foo.bar</a> is okay, but ftp://test.fo_o is not</p>\n<p><a href=\"mailto:email@_test.foo.bar\">email@_test.foo.bar</a> is okay, but mailto:email@_test.foo is not</p>", "autolinks|advanced");
}
// Domain names that contain invalid characters (not AlphaNumberic, -, _ or .) won't be matched
[Test]
public void ExtensionsAutoLinksValidDomainTests_Example019()
{
// Example 19
// Section: Extensions / AutoLinks / Valid Domain Tests
//
// The following Markdown:
// https://[your-domain]/api
//
// Should be rendered as:
// <p>https://[your-domain]/api</p>
Console.WriteLine("Example 19\nSection Extensions / AutoLinks / Valid Domain Tests\n");
TestParser.TestSpec("https://[your-domain]/api", "<p>https://[your-domain]/api</p>", "autolinks|advanced");
}
// Domain names followed by ?, : or # instead of / are matched
[Test]
public void ExtensionsAutoLinksValidDomainTests_Example020()
{
// Example 20
// Section: Extensions / AutoLinks / Valid Domain Tests
//
// The following Markdown:
// https://github.com?
//
// https://github.com?a
//
// https://github.com#a
//
// https://github.com:
//
// https://github.com:443
//
// Should be rendered as:
// <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>
Console.WriteLine("Example 20\nSection Extensions / AutoLinks / Valid Domain Tests\n");
TestParser.TestSpec("https://github.com?\n\nhttps://github.com?a\n\nhttps://github.com#a\n\nhttps://github.com:\n\nhttps://github.com:443", "<p><a href=\"https://github.com\">https://github.com</a>?</p>\n<p><a href=\"https://github.com?a\">https://github.com?a</a></p>\n<p><a href=\"https://github.com#a\">https://github.com#a</a></p>\n<p><a href=\"https://github.com\">https://github.com</a>:</p>\n<p><a href=\"https://github.com:443\">https://github.com:443</a></p>", "autolinks|advanced");
}
}
}

View File

@@ -0,0 +1,111 @@
// Generated: 21. 01. 2019 14:26:34
// --------------------------------
// Bootstrap
// --------------------------------
using System;
using NUnit.Framework;
namespace Markdig.Tests.Specs.Bootstrap
{
[TestFixture]
public class TestExtensionsBootstrap
{
// # Extensions
//
// Adds support for outputing bootstrap ready tags:
//
// ## Bootstrap
//
// Adds bootstrap `.table` class to `<table>`:
[Test]
public void ExtensionsBootstrap_Example001()
{
// Example 1
// Section: Extensions / Bootstrap
//
// The following Markdown:
// Name | Value
// -----| -----
// Abc | 16
//
// Should be rendered as:
// <table class="table">
// <thead>
// <tr>
// <th>Name</th>
// <th>Value</th>
// </tr>
// </thead>
// <tbody>
// <tr>
// <td>Abc</td>
// <td>16</td>
// </tr>
// </tbody>
// </table>
Console.WriteLine("Example 1\nSection Extensions / Bootstrap\n");
TestParser.TestSpec("Name | Value\n-----| -----\nAbc | 16", "<table class=\"table\">\n<thead>\n<tr>\n<th>Name</th>\n<th>Value</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Abc</td>\n<td>16</td>\n</tr>\n</tbody>\n</table>", "bootstrap+pipetables+figures+attributes");
}
// Adds bootstrap `.blockquote` class to `<blockquote>`:
[Test]
public void ExtensionsBootstrap_Example002()
{
// Example 2
// Section: Extensions / Bootstrap
//
// The following Markdown:
// > This is a blockquote
//
// Should be rendered as:
// <blockquote class="blockquote">
// <p>This is a blockquote</p>
// </blockquote>
Console.WriteLine("Example 2\nSection Extensions / Bootstrap\n");
TestParser.TestSpec("> This is a blockquote", "<blockquote class=\"blockquote\">\n<p>This is a blockquote</p>\n</blockquote>", "bootstrap+pipetables+figures+attributes");
}
// Adds bootstrap `.figure` class to `<figure>` and `.figure-caption` to `<figcaption>`
[Test]
public void ExtensionsBootstrap_Example003()
{
// Example 3
// Section: Extensions / Bootstrap
//
// The following Markdown:
// ^^^
// This is a text in a caption
// ^^^ This is the caption
//
// Should be rendered as:
// <figure class="figure">
// <p>This is a text in a caption</p>
// <figcaption class="figure-caption">This is the caption</figcaption>
// </figure>
Console.WriteLine("Example 3\nSection Extensions / Bootstrap\n");
TestParser.TestSpec("^^^\nThis is a text in a caption\n^^^ This is the caption", "<figure class=\"figure\">\n<p>This is a text in a caption</p>\n<figcaption class=\"figure-caption\">This is the caption</figcaption>\n</figure>", "bootstrap+pipetables+figures+attributes");
}
// Adds the `.img-fluid` class to all image links `<img>`
[Test]
public void ExtensionsBootstrap_Example004()
{
// Example 4
// Section: Extensions / Bootstrap
//
// The following Markdown:
// ![Image Link](/url)
//
// Should be rendered as:
// <p><img src="/url" class="img-fluid" alt="Image Link" /></p>
Console.WriteLine("Example 4\nSection Extensions / Bootstrap\n");
TestParser.TestSpec("![Image Link](/url)", "<p><img src=\"/url\" class=\"img-fluid\" alt=\"Image Link\" /></p>", "bootstrap+pipetables+figures+attributes");
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,211 @@
// Generated: 21. 01. 2019 14:26:34
// --------------------------------
// Custom Containers
// --------------------------------
using System;
using NUnit.Framework;
namespace Markdig.Tests.Specs.CustomContainers
{
[TestFixture]
public class TestExtensionsCustomContainer
{
// # Extensions
//
// 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>...</div>` block.
[Test]
public void ExtensionsCustomContainer_Example001()
{
// Example 1
// Section: Extensions / Custom Container
//
// The following Markdown:
// :::spoiler
// This is a *spoiler*
// :::
//
// Should be rendered as:
// <div class="spoiler"><p>This is a <em>spoiler</em></p>
// </div>
Console.WriteLine("Example 1\nSection Extensions / Custom Container\n");
TestParser.TestSpec(":::spoiler\nThis is a *spoiler*\n:::", "<div class=\"spoiler\"><p>This is a <em>spoiler</em></p>\n</div>", "customcontainers+attributes|advanced");
}
// The text following the opened custom container is optional:
[Test]
public void ExtensionsCustomContainer_Example002()
{
// Example 2
// Section: Extensions / Custom Container
//
// The following Markdown:
// :::
// This is a regular div
// :::
//
// Should be rendered as:
// <div><p>This is a regular div</p>
// </div>
Console.WriteLine("Example 2\nSection Extensions / Custom Container\n");
TestParser.TestSpec(":::\nThis is a regular div\n:::", "<div><p>This is a regular div</p>\n</div>", "customcontainers+attributes|advanced");
}
// Like for fenced code block, you can use more than 3 `:` characters as long as the closing has the same number of characters:
[Test]
public void ExtensionsCustomContainer_Example003()
{
// Example 3
// Section: Extensions / Custom Container
//
// The following Markdown:
// ::::::::::::spoiler
// This is a spoiler
// ::::::::::::
//
// Should be rendered as:
// <div class="spoiler"><p>This is a spoiler</p>
// </div>
Console.WriteLine("Example 3\nSection Extensions / Custom Container\n");
TestParser.TestSpec("::::::::::::spoiler\nThis is a spoiler\n::::::::::::", "<div class=\"spoiler\"><p>This is a spoiler</p>\n</div>", "customcontainers+attributes|advanced");
}
// Like for fenced code block, a custom container can span over multiple empty lines in a list block:
[Test]
public void ExtensionsCustomContainer_Example004()
{
// Example 4
// Section: Extensions / Custom Container
//
// The following Markdown:
// - This is a list
// :::spoiler
// This is a spoiler
// - item1
// - item2
// :::
// - A second item in the list
//
// Should be rendered as:
// <ul>
// <li>This is a list
// <div class="spoiler">This is a spoiler
// <ul>
// <li>item1</li>
// <li>item2</li>
// </ul>
// </div>
// </li>
// <li>A second item in the list</li>
// </ul>
Console.WriteLine("Example 4\nSection Extensions / Custom Container\n");
TestParser.TestSpec("- This is a list\n :::spoiler\n This is a spoiler\n - item1\n - item2\n :::\n- A second item in the list", "<ul>\n<li>This is a list\n<div class=\"spoiler\">This is a spoiler\n<ul>\n<li>item1</li>\n<li>item2</li>\n</ul>\n</div>\n</li>\n<li>A second item in the list</li>\n</ul>", "customcontainers+attributes|advanced");
}
// Attributes extension is also supported for Custom Container, as long as the Attributes extension is activated after the CustomContainer extension (`.UseCustomContainer().UseAttributes()`)
[Test]
public void ExtensionsCustomContainer_Example005()
{
// Example 5
// Section: Extensions / Custom Container
//
// The following Markdown:
// :::spoiler {#myspoiler myprop=yes}
// This is a spoiler
// :::
//
// Should be rendered as:
// <div id="myspoiler" class="spoiler" myprop="yes"><p>This is a spoiler</p>
// </div>
Console.WriteLine("Example 5\nSection Extensions / Custom Container\n");
TestParser.TestSpec(":::spoiler {#myspoiler myprop=yes}\nThis is a spoiler\n:::", "<div id=\"myspoiler\" class=\"spoiler\" myprop=\"yes\"><p>This is a spoiler</p>\n</div>", "customcontainers+attributes|advanced");
}
// The content of a custom container can contain any blocks:
[Test]
public void ExtensionsCustomContainer_Example006()
{
// Example 6
// Section: Extensions / Custom Container
//
// The following Markdown:
// :::mycontainer
// <p>This is a raw spoiler</p>
// :::
//
// Should be rendered as:
// <div class="mycontainer"><p>This is a raw spoiler</p>
// </div>
Console.WriteLine("Example 6\nSection Extensions / Custom Container\n");
TestParser.TestSpec(":::mycontainer\n<p>This is a raw spoiler</p>\n:::", "<div class=\"mycontainer\"><p>This is a raw spoiler</p>\n</div>", "customcontainers+attributes|advanced");
}
}
[TestFixture]
public class TestExtensionsInlineCustomContainer
{
// ## Inline Custom Container
//
// A custom container can also be used within an inline container (e.g: paragraph, heading...) by enclosing a text by a new emphasis `::`
[Test]
public void ExtensionsInlineCustomContainer_Example007()
{
// Example 7
// Section: Extensions / Inline Custom Container
//
// The following Markdown:
// This is a text ::with special emphasis::
//
// Should be rendered as:
// <p>This is a text <span>with special emphasis</span></p>
Console.WriteLine("Example 7\nSection Extensions / Inline Custom Container \n");
TestParser.TestSpec("This is a text ::with special emphasis::", "<p>This is a text <span>with special emphasis</span></p>", "customcontainers+attributes|advanced");
}
// Any other emphasis inline can be used within this emphasis inline container:
[Test]
public void ExtensionsInlineCustomContainer_Example008()
{
// Example 8
// Section: Extensions / Inline Custom Container
//
// The following Markdown:
// This is a text ::with special *emphasis*::
//
// Should be rendered as:
// <p>This is a text <span>with special <em>emphasis</em></span></p>
Console.WriteLine("Example 8\nSection Extensions / Inline Custom Container \n");
TestParser.TestSpec("This is a text ::with special *emphasis*::", "<p>This is a text <span>with special <em>emphasis</em></span></p>", "customcontainers+attributes|advanced");
}
// Attributes can be attached to a inline custom container:
[Test]
public void ExtensionsInlineCustomContainer_Example009()
{
// Example 9
// Section: Extensions / Inline Custom Container
//
// The following Markdown:
// This is a text ::with special emphasis::{#myId .myemphasis}
//
// Should be rendered as:
// <p>This is a text <span id="myId" class="myemphasis">with special emphasis</span></p>
Console.WriteLine("Example 9\nSection Extensions / Inline Custom Container \n");
TestParser.TestSpec("This is a text ::with special emphasis::{#myId .myemphasis}", "<p>This is a text <span id=\"myId\" class=\"myemphasis\">with special emphasis</span></p>", "customcontainers+attributes|advanced");
}
}
}

View File

@@ -0,0 +1,202 @@
// Generated: 21. 01. 2019 14:26:34
// --------------------------------
// Definition Lists
// --------------------------------
using System;
using NUnit.Framework;
namespace Markdig.Tests.Specs.DefinitionLists
{
[TestFixture]
public class TestExtensionsDefinitionLists
{
// # Extensions
//
// This section describes the different extensions supported:
//
// ## Definition lists
//
// 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.
[Test]
public void ExtensionsDefinitionLists_Example001()
{
// Example 1
// Section: Extensions / Definition lists
//
// The following Markdown:
//
// Term 1
// : This is a definition item
// With a paragraph
// > This is a block quote
//
// - This is a list
// - with an item2
//
// ```java
// Test
//
//
// ```
//
// And a last line
// : This ia another definition item
//
// Term2
// Term3 *with some inline*
// : This is another definition for term2
//
// Should be rendered as:
// <dl>
// <dt>Term 1</dt>
// <dd><p>This is a definition item
// With a paragraph</p>
// <blockquote>
// <p>This is a block quote</p>
// </blockquote>
// <ul>
// <li>This is a list</li>
// <li>with an item2</li>
// </ul>
// <pre><code class="language-java">Test
//
//
// </code></pre>
// <p>And a last line</p>
// </dd>
// <dd>This ia another definition item</dd>
// <dt>Term2</dt>
// <dt>Term3 <em>with some inline</em></dt>
// <dd>This is another definition for term2</dd>
// </dl>
Console.WriteLine("Example 1\nSection Extensions / Definition lists\n");
TestParser.TestSpec("\nTerm 1\n: This is a definition item\n With a paragraph\n > This is a block quote\n\n - This is a list\n - with an item2\n\n ```java\n Test\n\n\n ```\n\n And a last line\n: This ia another definition item\n\nTerm2\nTerm3 *with some inline*\n: This is another definition for term2", "<dl>\n<dt>Term 1</dt>\n<dd><p>This is a definition item\nWith a paragraph</p>\n<blockquote>\n<p>This is a block quote</p>\n</blockquote>\n<ul>\n<li>This is a list</li>\n<li>with an item2</li>\n</ul>\n<pre><code class=\"language-java\">Test\n\n\n</code></pre>\n<p>And a last line</p>\n</dd>\n<dd>This ia another definition item</dd>\n<dt>Term2</dt>\n<dt>Term3 <em>with some inline</em></dt>\n<dd>This is another definition for term2</dd>\n</dl>", "definitionlists+attributes|advanced");
}
// A definition term can be followed at most by one blank line. Lazy continuations are supported for definitions:
[Test]
public void ExtensionsDefinitionLists_Example002()
{
// Example 2
// Section: Extensions / Definition lists
//
// The following Markdown:
// Term 1
//
// : Definition
// with lazy continuation.
//
// Second paragraph of the definition.
//
// Should be rendered as:
// <dl>
// <dt>Term 1</dt>
// <dd><p>Definition
// with lazy continuation.</p>
// <p>Second paragraph of the definition.</p>
// </dd>
// </dl>
Console.WriteLine("Example 2\nSection Extensions / Definition lists\n");
TestParser.TestSpec("Term 1\n\n: Definition\nwith lazy continuation.\n\n Second paragraph of the definition.", "<dl>\n<dt>Term 1</dt>\n<dd><p>Definition\nwith lazy continuation.</p>\n<p>Second paragraph of the definition.</p>\n</dd>\n</dl>", "definitionlists+attributes|advanced");
}
// The definition must be indented to 4 characters including the `:`.
[Test]
public void ExtensionsDefinitionLists_Example003()
{
// Example 3
// Section: Extensions / Definition lists
//
// The following Markdown:
// Term 1
// : Invalid with less than 3 characters
//
// Should be rendered as:
// <p>Term 1
// : Invalid with less than 3 characters</p>
Console.WriteLine("Example 3\nSection Extensions / Definition lists\n");
TestParser.TestSpec("Term 1\n: Invalid with less than 3 characters", "<p>Term 1\n: Invalid with less than 3 characters</p>", "definitionlists+attributes|advanced");
}
// The `:` can be indented up to 3 spaces:
[Test]
public void ExtensionsDefinitionLists_Example004()
{
// Example 4
// Section: Extensions / Definition lists
//
// The following Markdown:
// Term 1
// : Valid even if `:` starts at most 3 spaces
//
// Should be rendered as:
// <dl>
// <dt>Term 1</dt>
// <dd>Valid even if <code>:</code> starts at most 3 spaces</dd>
// </dl>
Console.WriteLine("Example 4\nSection Extensions / Definition lists\n");
TestParser.TestSpec("Term 1\n : Valid even if `:` starts at most 3 spaces", "<dl>\n<dt>Term 1</dt>\n<dd>Valid even if <code>:</code> starts at most 3 spaces</dd>\n</dl>", "definitionlists+attributes|advanced");
}
// But more than 3 spaces before `:` will trigger an indented code block:
[Test]
public void ExtensionsDefinitionLists_Example005()
{
// Example 5
// Section: Extensions / Definition lists
//
// The following Markdown:
// Term 1
//
// : Not valid
//
// Should be rendered as:
// <p>Term 1</p>
// <pre><code>: Not valid
// </code></pre>
Console.WriteLine("Example 5\nSection Extensions / Definition lists\n");
TestParser.TestSpec("Term 1\n\n : Not valid", "<p>Term 1</p>\n<pre><code>: Not valid\n</code></pre>", "definitionlists+attributes|advanced");
}
// Definition lists can be nested inside list items
[Test]
public void ExtensionsDefinitionLists_Example006()
{
// Example 6
// Section: Extensions / Definition lists
//
// The following Markdown:
// 1. First
//
// 2. Second
//
// Term 1
// : Definition
//
// Term 2
// : Second Definition
//
// Should be rendered as:
// <ol>
// <li><p>First</p></li>
// <li><p>Second</p>
// <dl>
// <dt>Term 1</dt>
// <dd>Definition</dd>
// <dt>Term 2</dt>
// <dd>Second Definition</dd>
// </dl></li>
// </ol>
Console.WriteLine("Example 6\nSection Extensions / Definition lists\n");
TestParser.TestSpec("1. First\n \n2. Second\n \n Term 1\n : Definition\n \n Term 2\n : Second Definition", "<ol>\n<li><p>First</p></li>\n<li><p>Second</p>\n<dl>\n<dt>Term 1</dt>\n<dd>Definition</dd>\n<dt>Term 2</dt>\n<dd>Second Definition</dd>\n</dl></li>\n</ol>", "definitionlists+attributes|advanced");
}
}
}

View File

@@ -0,0 +1,94 @@
// Generated: 21. 01. 2019 14:26:34
// --------------------------------
// Diagrams
// --------------------------------
using System;
using NUnit.Framework;
namespace Markdig.Tests.Specs.Diagrams
{
[TestFixture]
public class TestExtensionsMermaidDiagrams
{
// # Extensions
//
// Adds support for diagrams extension:
//
// ## Mermaid diagrams
//
// Using a fenced code block with the `mermaid` language info will output a `<div class='mermaid'>` instead of a `pre/code` block:
[Test]
public void ExtensionsMermaidDiagrams_Example001()
{
// Example 1
// Section: Extensions / Mermaid diagrams
//
// The following Markdown:
// ```mermaid
// graph TD;
// A-->B;
// A-->C;
// B-->D;
// C-->D;
// ```
//
// Should be rendered as:
// <div class="mermaid">graph TD;
// A-->B;
// A-->C;
// B-->D;
// C-->D;
// </div>
Console.WriteLine("Example 1\nSection Extensions / Mermaid diagrams\n");
TestParser.TestSpec("```mermaid\ngraph TD;\n A-->B;\n A-->C;\n B-->D;\n C-->D;\n```", "<div class=\"mermaid\">graph TD;\n A-->B;\n A-->C;\n B-->D;\n C-->D;\n</div>", "diagrams|advanced");
}
}
[TestFixture]
public class TestExtensionsNomnomlDiagrams
{
// ## nomnoml diagrams
//
// Using a fenced code block with the `nomnoml` language info will output a `<div class='nomnoml'>` instead of a `pre/code` block:
[Test]
public void ExtensionsNomnomlDiagrams_Example002()
{
// Example 2
// Section: Extensions / nomnoml diagrams
//
// The following Markdown:
// ```nomnoml
// [example|
// propertyA: Int
// propertyB: string
// |
// methodA()
// methodB()
// |
// [subA]--[subB]
// [subA]-:>[sub C]
// ]
// ```
//
// Should be rendered as:
// <div class="nomnoml">[example|
// propertyA: Int
// propertyB: string
// |
// methodA()
// methodB()
// |
// [subA]--[subB]
// [subA]-:>[sub C]
// ]
// </div>
Console.WriteLine("Example 2\nSection Extensions / nomnoml diagrams\n");
TestParser.TestSpec("```nomnoml\n[example|\n propertyA: Int\n propertyB: string\n|\n methodA()\n methodB()\n|\n [subA]--[subB]\n [subA]-:>[sub C]\n]\n```", "<div class=\"nomnoml\">[example|\n propertyA: Int\n propertyB: string\n|\n methodA()\n methodB()\n|\n [subA]--[subB]\n [subA]-:>[sub C]\n]\n</div>", "diagrams|advanced");
}
// TODO: Add other text diagram languages
}
}

View File

@@ -0,0 +1,91 @@
// Generated: 21. 01. 2019 14:26:34
// --------------------------------
// Emoji
// --------------------------------
using System;
using NUnit.Framework;
namespace Markdig.Tests.Specs.Emoji
{
[TestFixture]
public class TestExtensionsEmoji
{
// # Extensions
//
// This section describes the different extensions supported:
//
// ## Emoji
//
// Emoji and smiley can be converted to their respective unicode characters:
[Test]
public void ExtensionsEmoji_Example001()
{
// Example 1
// Section: Extensions / Emoji
//
// The following Markdown:
// This is a test with a :) and a :angry: smiley
//
// Should be rendered as:
// <p>This is a test with a 😃 and a 😠 smiley</p>
Console.WriteLine("Example 1\nSection Extensions / Emoji\n");
TestParser.TestSpec("This is a test with a :) and a :angry: smiley", "<p>This is a test with a 😃 and a 😠 smiley</p>", "emojis|advanced+emojis");
}
// An emoji needs to be preceded by a space:
[Test]
public void ExtensionsEmoji_Example002()
{
// Example 2
// Section: Extensions / Emoji
//
// The following Markdown:
// These are not:) an emoji with a:) x:angry:x
//
// Should be rendered as:
// <p>These are not:) an emoji with a:) x:angry:x</p>
Console.WriteLine("Example 2\nSection Extensions / Emoji\n");
TestParser.TestSpec("These are not:) an emoji with a:) x:angry:x", "<p>These are not:) an emoji with a:) x:angry:x</p>", "emojis|advanced+emojis");
}
// Emoji can be followed by close ponctuation (or any other characters):
[Test]
public void ExtensionsEmoji_Example003()
{
// Example 3
// Section: Extensions / Emoji
//
// The following Markdown:
// We all need :), it makes us :muscle:. (and :ok_hand:).
//
// Should be rendered as:
// <p>We all need 😃, it makes us 💪. (and 👌).</p>
Console.WriteLine("Example 3\nSection Extensions / Emoji\n");
TestParser.TestSpec("We all need :), it makes us :muscle:. (and :ok_hand:).", "<p>We all need 😃, it makes us 💪. (and 👌).</p>", "emojis|advanced+emojis");
}
// Sentences can end with Emoji:
[Test]
public void ExtensionsEmoji_Example004()
{
// Example 4
// Section: Extensions / Emoji
//
// The following Markdown:
// This is a sentence :ok_hand:
// and keeps going to the next line :)
//
// Should be rendered as:
// <p>This is a sentence 👌
// and keeps going to the next line 😃</p>
Console.WriteLine("Example 4\nSection Extensions / Emoji\n");
TestParser.TestSpec("This is a sentence :ok_hand:\nand keeps going to the next line :)", "<p>This is a sentence 👌\nand keeps going to the next line 😃</p>", "emojis|advanced+emojis");
}
}
}

View File

@@ -0,0 +1,152 @@
// Generated: 21. 01. 2019 14:26:34
// --------------------------------
// Emphasis Extra
// --------------------------------
using System;
using NUnit.Framework;
namespace Markdig.Tests.Specs.EmphasisExtra
{
[TestFixture]
public class TestExtensionsStrikethrough
{
// # Extensions
//
// The following additional emphasis are supported:
//
// ## Strikethrough
//
// Allows to strikethrough a span of text by surrounding it by `~~`. The semantic used for the generated HTML is the tag `<del>`.
[Test]
public void ExtensionsStrikethrough_Example001()
{
// Example 1
// Section: Extensions / Strikethrough
//
// The following Markdown:
// The following text ~~is deleted~~
//
// Should be rendered as:
// <p>The following text <del>is deleted</del></p>
Console.WriteLine("Example 1\nSection Extensions / Strikethrough\n");
TestParser.TestSpec("The following text ~~is deleted~~", "<p>The following text <del>is deleted</del></p>", "emphasisextras|advanced");
}
}
[TestFixture]
public class TestExtensionsSuperscriptAndSubscript
{
// ## Superscript and Subscript
//
// Superscripts can be written by surrounding a text by ^ characters; subscripts can be written by surrounding the subscripted text by ~ characters
[Test]
public void ExtensionsSuperscriptAndSubscript_Example002()
{
// Example 2
// Section: Extensions / Superscript and Subscript
//
// The following Markdown:
// H~2~O is a liquid. 2^10^ is 1024
//
// Should be rendered as:
// <p>H<sub>2</sub>O is a liquid. 2<sup>10</sup> is 1024</p>
Console.WriteLine("Example 2\nSection Extensions / Superscript and Subscript\n");
TestParser.TestSpec("H~2~O is a liquid. 2^10^ is 1024", "<p>H<sub>2</sub>O is a liquid. 2<sup>10</sup> is 1024</p>", "emphasisextras|advanced");
}
// Certain punctuation characters are exempted from the rule forbidding them within inline delimiters
[Test]
public void ExtensionsSuperscriptAndSubscript_Example003()
{
// Example 3
// Section: Extensions / Superscript and Subscript
//
// The following Markdown:
// One quintillionth can be expressed as 10^-18^
//
// Daggers^†^ and double-daggers^‡^ can be used to denote notes.
//
// Should be rendered as:
// <p>One quintillionth can be expressed as 10<sup>-18</sup></p>
// <p>Daggers<sup>†</sup> and double-daggers<sup>‡</sup> can be used to denote notes.</p>
Console.WriteLine("Example 3\nSection Extensions / Superscript and Subscript\n");
TestParser.TestSpec("One quintillionth can be expressed as 10^-18^\n\nDaggers^†^ and double-daggers^‡^ can be used to denote notes.", "<p>One quintillionth can be expressed as 10<sup>-18</sup></p>\n<p>Daggers<sup>†</sup> and double-daggers<sup>‡</sup> can be used to denote notes.</p>", "emphasisextras|advanced");
}
}
[TestFixture]
public class TestExtensionsInserted
{
// ## Inserted
//
// Inserted text can be used to specify that a text has been added to a document. The semantic used for the generated HTML is the tag `<ins>`.
[Test]
public void ExtensionsInserted_Example004()
{
// Example 4
// Section: Extensions / Inserted
//
// The following Markdown:
// ++Inserted text++
//
// Should be rendered as:
// <p><ins>Inserted text</ins></p>
Console.WriteLine("Example 4\nSection Extensions / Inserted\n");
TestParser.TestSpec("++Inserted text++", "<p><ins>Inserted text</ins></p>", "emphasisextras|advanced");
}
}
[TestFixture]
public class TestExtensionsMarked
{
// ## Marked
//
// Marked text can be used to specify that a text has been marked in a document. The semantic used for the generated HTML is the tag `<mark>`.
[Test]
public void ExtensionsMarked_Example005()
{
// Example 5
// Section: Extensions / Marked
//
// The following Markdown:
// ==Marked text==
//
// Should be rendered as:
// <p><mark>Marked text</mark></p>
Console.WriteLine("Example 5\nSection Extensions / Marked\n");
TestParser.TestSpec("==Marked text==", "<p><mark>Marked text</mark></p>", "emphasisextras|advanced");
}
}
[TestFixture]
public class TestExtensionsEmphasisOnHtmlEntities
{
// ## Emphasis on Html Entities
[Test]
public void ExtensionsEmphasisOnHtmlEntities_Example006()
{
// Example 6
// Section: Extensions / Emphasis on Html Entities
//
// The following Markdown:
// This is text MyBrand ^&reg;^ and MyTrademark ^&trade;^
// This is text MyBrand^&reg;^ and MyTrademark^&trade;^
// This is text MyBrand~&reg;~ and MyCopyright^&copy;^
//
// Should be rendered as:
// <p>This is text MyBrand <sup>®</sup> and MyTrademark <sup>TM</sup>
// This is text MyBrand<sup>®</sup> and MyTrademark<sup>TM</sup>
// This is text MyBrand<sub>®</sub> and MyCopyright<sup>©</sup></p>
Console.WriteLine("Example 6\nSection Extensions / Emphasis on Html Entities\n");
TestParser.TestSpec("This is text MyBrand ^&reg;^ and MyTrademark ^&trade;^\nThis is text MyBrand^&reg;^ and MyTrademark^&trade;^\nThis is text MyBrand~&reg;~ and MyCopyright^&copy;^", "<p>This is text MyBrand <sup>®</sup> and MyTrademark <sup>TM</sup>\nThis is text MyBrand<sup>®</sup> and MyTrademark<sup>TM</sup>\nThis is text MyBrand<sub>®</sub> and MyCopyright<sup>©</sup></p>", "emphasisextras|advanced");
}
}
}

View File

@@ -0,0 +1,91 @@
// Generated: 21. 01. 2019 14:42:25
// --------------------------------
// Figures, Footers and Cites
// --------------------------------
using System;
using NUnit.Framework;
namespace Markdig.Tests.Specs.FiguresFootersAndCites
{
[TestFixture]
public class TestExtensionsFigures
{
// # Extensions
//
// The following the figure extension:
//
// ## Figures
//
// A figure can be defined by using a pattern equivalent to a fenced code block but with the character `^`
[Test]
public void ExtensionsFigures_Example001()
{
// Example 1
// Section: Extensions / Figures
//
// The following Markdown:
// ^^^
// This is a figure
// ^^^ This is a *caption*
//
// Should be rendered as:
// <figure>
// <p>This is a figure</p>
// <figcaption>This is a <em>caption</em></figcaption>
// </figure>
Console.WriteLine("Example 1\nSection Extensions / Figures\n");
TestParser.TestSpec("^^^\nThis is a figure\n^^^ This is a *caption*", "<figure>\n<p>This is a figure</p>\n<figcaption>This is a <em>caption</em></figcaption>\n</figure>", "figures+footers+citations|advanced");
}
}
[TestFixture]
public class TestExtensionsFooters
{
// ## Footers
//
// A footer equivalent to a block quote parsing but starts with double character ^^
[Test]
public void ExtensionsFooters_Example002()
{
// Example 2
// Section: Extensions / Footers
//
// The following Markdown:
// ^^ This is a footer
// ^^ multi-line
//
// Should be rendered as:
// <footer>This is a footer
// multi-line</footer>
Console.WriteLine("Example 2\nSection Extensions / Footers\n");
TestParser.TestSpec("^^ This is a footer\n^^ multi-line", "<footer>This is a footer\nmulti-line</footer>", "figures+footers+citations|advanced");
}
}
[TestFixture]
public class TestExtensionsCite
{
// ## Cite
//
// A cite is working like an emphasis but using the double character ""
[Test]
public void ExtensionsCite_Example003()
{
// Example 3
// Section: Extensions / Cite
//
// The following Markdown:
// This is a ""citation of someone""
//
// Should be rendered as:
// <p>This is a <cite>citation of someone</cite></p>
Console.WriteLine("Example 3\nSection Extensions / Cite\n");
TestParser.TestSpec("This is a \"\"citation of someone\"\"", "<p>This is a <cite>citation of someone</cite></p>", "figures+footers+citations|advanced");
}
}
}

View File

@@ -0,0 +1,193 @@
// Generated: 21. 01. 2019 14:26:34
// --------------------------------
// Footnotes
// --------------------------------
using System;
using NUnit.Framework;
namespace Markdig.Tests.Specs.Footnotes
{
[TestFixture]
public class TestExtensionsFootnotes
{
// # Extensions
//
// This section describes the different extensions supported:
//
// ## Footnotes
//
// Allows footnotes using the following syntax (taken from pandoc example):
[Test]
public void ExtensionsFootnotes_Example001()
{
// Example 1
// Section: Extensions / Footnotes
//
// The following Markdown:
// Here is a footnote reference,[^1] and another.[^longnote]
//
// This is another reference to [^1]
//
// [^1]: Here is the footnote.
//
// And another reference to [^longnote]
//
// [^longnote]: Here's one with multiple blocks.
//
// Subsequent paragraphs are indented to show that they
// belong to the previous footnote.
//
// > This is a block quote
// > Inside a footnote
//
// { some.code }
//
// The whole paragraph can be indented, or just the first
// line. In this way, multi-paragraph footnotes work like
// multi-paragraph list items.
//
// This paragraph won't be part of the note, because it
// isn't indented.
//
// Should be rendered as:
// <p>Here is a footnote reference,<a id="fnref:1" href="#fn:1" class="footnote-ref"><sup>1</sup></a> and another.<a id="fnref:3" href="#fn:2" class="footnote-ref"><sup>2</sup></a></p>
// <p>This is another reference to <a id="fnref:2" href="#fn:1" class="footnote-ref"><sup>1</sup></a></p>
// <p>And another reference to <a id="fnref:4" href="#fn:2" class="footnote-ref"><sup>2</sup></a></p>
// <p>This paragraph won't be part of the note, because it
// isn't indented.</p>
// <div class="footnotes">
// <hr />
// <ol>
// <li id="fn:1">
// <p>Here is the footnote.<a href="#fnref:1" class="footnote-back-ref">&#8617;</a><a href="#fnref:2" class="footnote-back-ref">&#8617;</a></p>
// </li>
// <li id="fn:2">
// <p>Here's one with multiple blocks.</p>
// <p>Subsequent paragraphs are indented to show that they
// belong to the previous footnote.</p>
// <blockquote>
// <p>This is a block quote
// Inside a footnote</p>
// </blockquote>
// <pre><code>{ some.code }
// </code></pre>
// <p>The whole paragraph can be indented, or just the first
// line. In this way, multi-paragraph footnotes work like
// multi-paragraph list items.<a href="#fnref:3" class="footnote-back-ref">&#8617;</a><a href="#fnref:4" class="footnote-back-ref">&#8617;</a></p>
// </li>
// </ol>
// </div>
Console.WriteLine("Example 1\nSection Extensions / Footnotes\n");
TestParser.TestSpec("Here is a footnote reference,[^1] and another.[^longnote]\n\nThis is another reference to [^1]\n\n[^1]: Here is the footnote.\n\nAnd another reference to [^longnote]\n\n[^longnote]: Here's one with multiple blocks.\n\n Subsequent paragraphs are indented to show that they\nbelong to the previous footnote.\n\n > This is a block quote\n > Inside a footnote\n\n { some.code }\n\n The whole paragraph can be indented, or just the first\n line. In this way, multi-paragraph footnotes work like\n multi-paragraph list items.\n\nThis paragraph won't be part of the note, because it\nisn't indented.", "<p>Here is a footnote reference,<a id=\"fnref:1\" href=\"#fn:1\" class=\"footnote-ref\"><sup>1</sup></a> and another.<a id=\"fnref:3\" href=\"#fn:2\" class=\"footnote-ref\"><sup>2</sup></a></p>\n<p>This is another reference to <a id=\"fnref:2\" href=\"#fn:1\" class=\"footnote-ref\"><sup>1</sup></a></p>\n<p>And another reference to <a id=\"fnref:4\" href=\"#fn:2\" class=\"footnote-ref\"><sup>2</sup></a></p>\n<p>This paragraph won't be part of the note, because it\nisn't indented.</p>\n<div class=\"footnotes\">\n<hr />\n<ol>\n<li id=\"fn:1\">\n<p>Here is the footnote.<a href=\"#fnref:1\" class=\"footnote-back-ref\">&#8617;</a><a href=\"#fnref:2\" class=\"footnote-back-ref\">&#8617;</a></p>\n</li>\n<li id=\"fn:2\">\n<p>Here's one with multiple blocks.</p>\n<p>Subsequent paragraphs are indented to show that they\nbelong to the previous footnote.</p>\n<blockquote>\n<p>This is a block quote\nInside a footnote</p>\n</blockquote>\n<pre><code>{ some.code }\n</code></pre>\n<p>The whole paragraph can be indented, or just the first\nline. In this way, multi-paragraph footnotes work like\nmulti-paragraph list items.<a href=\"#fnref:3\" class=\"footnote-back-ref\">&#8617;</a><a href=\"#fnref:4\" class=\"footnote-back-ref\">&#8617;</a></p>\n</li>\n</ol>\n</div>", "footnotes|advanced");
}
// Check with mulitple consecutive footnotes:
[Test]
public void ExtensionsFootnotes_Example002()
{
// Example 2
// Section: Extensions / Footnotes
//
// The following Markdown:
// Here is a footnote[^1]. And another one[^2]. And a third one[^3]. And a fourth[^4].
//
// [^1]: Footnote 1 text
//
// [^2]: Footnote 2 text
//
// a
//
// [^3]: Footnote 3 text
//
// [^4]: Footnote 4 text
//
// Should be rendered as:
// <p>Here is a footnote<a id="fnref:1" href="#fn:1" class="footnote-ref"><sup>1</sup></a>. And another one<a id="fnref:2" href="#fn:2" class="footnote-ref"><sup>2</sup></a>. And a third one<a id="fnref:3" href="#fn:3" class="footnote-ref"><sup>3</sup></a>. And a fourth<a id="fnref:4" href="#fn:4" class="footnote-ref"><sup>4</sup></a>.</p>
// <p>a</p>
// <div class="footnotes">
// <hr />
// <ol>
// <li id="fn:1">
// <p>Footnote 1 text<a href="#fnref:1" class="footnote-back-ref">&#8617;</a></p></li>
// <li id="fn:2">
// <p>Footnote 2 text<a href="#fnref:2" class="footnote-back-ref">&#8617;</a></p></li>
// <li id="fn:3">
// <p>Footnote 3 text<a href="#fnref:3" class="footnote-back-ref">&#8617;</a></p></li>
// <li id="fn:4">
// <p>Footnote 4 text<a href="#fnref:4" class="footnote-back-ref">&#8617;</a></p></li>
// </ol>
// </div>
Console.WriteLine("Example 2\nSection Extensions / Footnotes\n");
TestParser.TestSpec("Here is a footnote[^1]. And another one[^2]. And a third one[^3]. And a fourth[^4].\n\n[^1]: Footnote 1 text\n\n[^2]: Footnote 2 text\n\na\n\n[^3]: Footnote 3 text\n\n[^4]: Footnote 4 text", "<p>Here is a footnote<a id=\"fnref:1\" href=\"#fn:1\" class=\"footnote-ref\"><sup>1</sup></a>. And another one<a id=\"fnref:2\" href=\"#fn:2\" class=\"footnote-ref\"><sup>2</sup></a>. And a third one<a id=\"fnref:3\" href=\"#fn:3\" class=\"footnote-ref\"><sup>3</sup></a>. And a fourth<a id=\"fnref:4\" href=\"#fn:4\" class=\"footnote-ref\"><sup>4</sup></a>.</p>\n<p>a</p>\n<div class=\"footnotes\">\n<hr />\n<ol>\n<li id=\"fn:1\">\n<p>Footnote 1 text<a href=\"#fnref:1\" class=\"footnote-back-ref\">&#8617;</a></p></li>\n<li id=\"fn:2\">\n<p>Footnote 2 text<a href=\"#fnref:2\" class=\"footnote-back-ref\">&#8617;</a></p></li>\n<li id=\"fn:3\">\n<p>Footnote 3 text<a href=\"#fnref:3\" class=\"footnote-back-ref\">&#8617;</a></p></li>\n<li id=\"fn:4\">\n<p>Footnote 4 text<a href=\"#fnref:4\" class=\"footnote-back-ref\">&#8617;</a></p></li>\n</ol>\n</div>", "footnotes|advanced");
}
// Another test with consecutive footnotes without a blank line separator:
[Test]
public void ExtensionsFootnotes_Example003()
{
// Example 3
// Section: Extensions / Footnotes
//
// The following Markdown:
// Here is a footnote[^1]. And another one[^2]. And a third one[^3]. And a fourth[^4].
//
// [^1]: Footnote 1 text
// [^2]: Footnote 2 text
// [^3]: Footnote 3 text
// [^4]: Footnote 4 text
//
// Should be rendered as:
// <p>Here is a footnote<a id="fnref:1" href="#fn:1" class="footnote-ref"><sup>1</sup></a>. And another one<a id="fnref:2" href="#fn:2" class="footnote-ref"><sup>2</sup></a>. And a third one<a id="fnref:3" href="#fn:3" class="footnote-ref"><sup>3</sup></a>. And a fourth<a id="fnref:4" href="#fn:4" class="footnote-ref"><sup>4</sup></a>.</p>
// <div class="footnotes">
// <hr />
// <ol>
// <li id="fn:1">
// <p>Footnote 1 text<a href="#fnref:1" class="footnote-back-ref">&#8617;</a></p></li>
// <li id="fn:2">
// <p>Footnote 2 text<a href="#fnref:2" class="footnote-back-ref">&#8617;</a></p></li>
// <li id="fn:3">
// <p>Footnote 3 text<a href="#fnref:3" class="footnote-back-ref">&#8617;</a></p></li>
// <li id="fn:4">
// <p>Footnote 4 text<a href="#fnref:4" class="footnote-back-ref">&#8617;</a></p></li>
// </ol>
// </div>
Console.WriteLine("Example 3\nSection Extensions / Footnotes\n");
TestParser.TestSpec("Here is a footnote[^1]. And another one[^2]. And a third one[^3]. And a fourth[^4].\n\n[^1]: Footnote 1 text\n[^2]: Footnote 2 text\n[^3]: Footnote 3 text\n[^4]: Footnote 4 text", "<p>Here is a footnote<a id=\"fnref:1\" href=\"#fn:1\" class=\"footnote-ref\"><sup>1</sup></a>. And another one<a id=\"fnref:2\" href=\"#fn:2\" class=\"footnote-ref\"><sup>2</sup></a>. And a third one<a id=\"fnref:3\" href=\"#fn:3\" class=\"footnote-ref\"><sup>3</sup></a>. And a fourth<a id=\"fnref:4\" href=\"#fn:4\" class=\"footnote-ref\"><sup>4</sup></a>.</p>\n<div class=\"footnotes\">\n<hr />\n<ol>\n<li id=\"fn:1\">\n<p>Footnote 1 text<a href=\"#fnref:1\" class=\"footnote-back-ref\">&#8617;</a></p></li>\n<li id=\"fn:2\">\n<p>Footnote 2 text<a href=\"#fnref:2\" class=\"footnote-back-ref\">&#8617;</a></p></li>\n<li id=\"fn:3\">\n<p>Footnote 3 text<a href=\"#fnref:3\" class=\"footnote-back-ref\">&#8617;</a></p></li>\n<li id=\"fn:4\">\n<p>Footnote 4 text<a href=\"#fnref:4\" class=\"footnote-back-ref\">&#8617;</a></p></li>\n</ol>\n</div>", "footnotes|advanced");
}
// A footnote link inside a list should work as well:
[Test]
public void ExtensionsFootnotes_Example004()
{
// Example 4
// Section: Extensions / Footnotes
//
// The following Markdown:
// - abc
// - def[^1]
//
// [^1]: Here is the footnote.
//
// Should be rendered as:
// <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">&#8617;</a></p></li>
// </ol>
// </div>
Console.WriteLine("Example 4\nSection Extensions / Footnotes\n");
TestParser.TestSpec("- abc\n- def[^1]\n\n[^1]: Here is the footnote.", "<ul>\n<li>abc</li>\n<li>def<a id=\"fnref:1\" href=\"#fn:1\" class=\"footnote-ref\"><sup>1</sup></a></li>\n</ul>\n<div class=\"footnotes\">\n<hr />\n<ol>\n<li id=\"fn:1\">\n<p>Here is the footnote.<a href=\"#fnref:1\" class=\"footnote-back-ref\">&#8617;</a></p></li>\n</ol>\n</div>", "footnotes|advanced");
}
}
}

View File

@@ -0,0 +1,83 @@
// Generated: 21. 01. 2019 15:02:43
// --------------------------------
// Generic Attributes
// --------------------------------
using System;
using NUnit.Framework;
namespace Markdig.Tests.Specs.GenericAttributes
{
[TestFixture]
public class TestExtensionsGenericAttributes
{
// # Extensions
//
// This section describes the different extensions supported:
//
// ## Generic Attributes
//
// Attributes can be attached to:
// - The previous inline element if the previous element is not a literal
// - The next block if the current block is a paragraph and the attributes is the only inline present in the paragraph
// - Or the current block
//
// Attributes can be of 3 kinds:
//
// - An id element, starting by `#` that will be used to set the `id` property of the HTML element
// - A class element, starting by `.` that will be appended to the CSS class property of the HTML element
// - a `name=value` or `name="value"` that will be appended as an attribute of the HTML element
//
// The following shows that attributes is attached to the current block or the previous inline:
[Test]
public void ExtensionsGenericAttributes_Example001()
{
// Example 1
// Section: Extensions / Generic Attributes
//
// The following Markdown:
// # This is a heading with an an attribute{#heading-link}
//
// # This is a heading # {#heading-link2}
//
// [This is a link](http://google.com){#a-link .myclass data-lang=fr data-value="This is a value"}
//
// This is a heading{#heading-link2}
// -----------------
//
// This is a paragraph with an attached attributes {#myparagraph attached-bool-property attached-bool-property2}
//
// Should be rendered as:
// <h1 id="heading-link">This is a heading with an an attribute</h1>
// <h1 id="heading-link2">This is a heading</h1>
// <p><a href="http://google.com" id="a-link" class="myclass" data-lang="fr" data-value="This is a value">This is a link</a></p>
// <h2 id="heading-link2">This is a heading</h2>
// <p id="myparagraph" attached-bool-property="" attached-bool-property2="">This is a paragraph with an attached attributes </p>
Console.WriteLine("Example 1\nSection Extensions / Generic Attributes\n");
TestParser.TestSpec("# This is a heading with an an attribute{#heading-link}\n\n# This is a heading # {#heading-link2}\n\n[This is a link](http://google.com){#a-link .myclass data-lang=fr data-value=\"This is a value\"}\n\nThis is a heading{#heading-link2}\n-----------------\n\nThis is a paragraph with an attached attributes {#myparagraph attached-bool-property attached-bool-property2}", "<h1 id=\"heading-link\">This is a heading with an an attribute</h1>\n<h1 id=\"heading-link2\">This is a heading</h1>\n<p><a href=\"http://google.com\" id=\"a-link\" class=\"myclass\" data-lang=\"fr\" data-value=\"This is a value\">This is a link</a></p>\n<h2 id=\"heading-link2\">This is a heading</h2>\n<p id=\"myparagraph\" attached-bool-property=\"\" attached-bool-property2=\"\">This is a paragraph with an attached attributes </p>", "attributes|advanced");
}
// The following shows that attributes can be attached to the next block if they are used inside a single line just preceding the block (and preceded by a blank line or beginning of a block container):
[Test]
public void ExtensionsGenericAttributes_Example002()
{
// Example 2
// Section: Extensions / Generic Attributes
//
// The following Markdown:
// {#fenced-id .fenced-class}
// ~~~
// This is a fenced with attached attributes
// ~~~
//
// Should be rendered as:
// <pre><code id="fenced-id" class="fenced-class">This is a fenced with attached attributes
// </code></pre>
Console.WriteLine("Example 2\nSection Extensions / Generic Attributes\n");
TestParser.TestSpec("{#fenced-id .fenced-class}\n~~~\nThis is a fenced with attached attributes\n~~~ ", "<pre><code id=\"fenced-id\" class=\"fenced-class\">This is a fenced with attached attributes\n</code></pre>", "attributes|advanced");
}
}
}

View File

@@ -33,7 +33,7 @@ This is a paragraph with an attached attributes {#myparagraph attached-bool-prop
<h1 id="heading-link2">This is a heading</h1>
<p><a href="http://google.com" id="a-link" class="myclass" data-lang="fr" data-value="This is a value">This is a link</a></p>
<h2 id="heading-link2">This is a heading</h2>
<p id="myparagraph" attached-bool-property attached-bool-property2>This is a paragraph with an attached attributes </p>
<p id="myparagraph" attached-bool-property="" attached-bool-property2="">This is a paragraph with an attached attributes </p>
````````````````````````````````
The following shows that attributes can be attached to the next block if they are used inside a single line just preceding the block (and preceded by a blank line or beginning of a block container):

View File

@@ -0,0 +1,234 @@
// Generated: 21. 01. 2019 14:26:34
// --------------------------------
// Globalization
// --------------------------------
using System;
using NUnit.Framework;
namespace Markdig.Tests.Specs.Globalization
{
[TestFixture]
public class TestExtensionsGlobalization
{
// # 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:
[Test]
public void ExtensionsGlobalization_Example001()
{
// Example 1
// Section: Extensions / Globalization
//
// The following Markdown:
// # 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) یان مێوە بەروبوومی ڕوەکیە کە ڕوەکەکان ھەڵیان ئەگرن وەک بەرگێک بۆ تۆوەکانیان، بە زۆری جیادەکرێتەوە بە شیرینی یان ترشی لە تامدا و بە بوونی بڕێکی زۆر ئاو
//
// > میوە بۆ تەندروستی باشە
// -- نەزانراو
//
// Should be rendered as:
// <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>
Console.WriteLine("Example 1\nSection Extensions / Globalization\n");
TestParser.TestSpec("# Fruits\nIn 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.\n\n> Fruits are good for health\n-- Anonymous\n\n# میوە\n[میوە](https://ckb.wikipedia.org/wiki/%D9%85%DB%8C%D9%88%DB%95) یان مێوە بەروبوومی ڕوەکیە کە ڕوەکەکان ھەڵیان ئەگرن وەک بەرگێک بۆ تۆوەکانیان، بە زۆری جیادەکرێتەوە بە شیرینی یان ترشی لە تامدا و بە بوونی بڕێکی زۆر ئاو\n\n> میوە بۆ تەندروستی باشە\n-- نەزانراو", "<h1 id=\"fruits\">Fruits</h1>\n<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>\n<blockquote>\n<p>Fruits are good for health\n-- Anonymous</p>\n</blockquote>\n<h1 id=\"section\" dir=\"rtl\">میوە</h1>\n<p dir=\"rtl\"><a href=\"https://ckb.wikipedia.org/wiki/%D9%85%DB%8C%D9%88%DB%95\" dir=\"rtl\">میوە</a> یان مێوە بەروبوومی ڕوەکیە کە ڕوەکەکان ھەڵیان ئەگرن وەک بەرگێک بۆ تۆوەکانیان، بە زۆری جیادەکرێتەوە بە شیرینی یان ترشی لە تامدا و بە بوونی بڕێکی زۆر ئاو</p>\n<blockquote dir=\"rtl\">\n<p dir=\"rtl\">میوە بۆ تەندروستی باشە\n-- نەزانراو</p>\n</blockquote>", "globalization+advanced+emojis");
}
// Lists:
[Test]
public void ExtensionsGlobalization_Example002()
{
// Example 2
// Section: Extensions / Globalization
//
// The following Markdown:
// ## 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] قەیسی
// - [ ] هەنجیر
//
// Should be rendered as:
// <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>
Console.WriteLine("Example 2\nSection Extensions / Globalization\n");
TestParser.TestSpec("## Types of fruits\n- Berries\n - Strawberry\n - kiwifruit\n- Citrus\n - Orange\n - Lemon\n\n## Examples of fruits :yum:\n1. Apple\n2. Banana\n3. Orange\n\n## Grocery List\n- [X] 􏿽 Watermelon\n- [X] Apricot\n- [ ] Fig \n\n## نموونەی میوە :yum:\n1. ? سێو\n2. 5 مۆز \n3. 􏿽 پرتەقاڵ\n\n## جۆرەکانی میوە\n- توو\n - فڕاولە\n - کیوی\n- مزرەمەنی\n - پڕتەقاڵ\n - لیمۆ\n\n## لیستی کڕین\n- [X] شووتی\n- [X] قەیسی\n- [ ] هەنجیر", "<h2 id=\"types-of-fruits\">Types of fruits</h2>\n<ul>\n<li>Berries\n<ul>\n<li>Strawberry</li>\n<li>kiwifruit</li>\n</ul>\n</li>\n<li>Citrus\n<ul>\n<li>Orange</li>\n<li>Lemon</li>\n</ul>\n</li>\n</ul>\n<h2 id=\"examples-of-fruits\">Examples of fruits 😋</h2>\n<ol>\n<li>Apple</li>\n<li>Banana</li>\n<li>Orange</li>\n</ol>\n<h2 id=\"grocery-list\">Grocery List</h2>\n<ul class=\"contains-task-list\">\n<li class=\"task-list-item\"><input disabled=\"disabled\" type=\"checkbox\" checked=\"checked\" /> 􏿽 Watermelon</li>\n<li class=\"task-list-item\"><input disabled=\"disabled\" type=\"checkbox\" checked=\"checked\" /> Apricot</li>\n<li class=\"task-list-item\"><input disabled=\"disabled\" type=\"checkbox\" /> Fig</li>\n</ul>\n<h2 id=\"section\" dir=\"rtl\">نموونەی میوە 😋</h2>\n<ol dir=\"rtl\">\n<li>? سێو</li>\n<li>5 مۆز</li>\n<li>􏿽 پرتەقاڵ</li>\n</ol>\n<h2 id=\"section-1\" dir=\"rtl\">جۆرەکانی میوە</h2>\n<ul dir=\"rtl\">\n<li>توو\n<ul dir=\"rtl\">\n<li>فڕاولە</li>\n<li>کیوی</li>\n</ul>\n</li>\n<li>مزرەمەنی\n<ul dir=\"rtl\">\n<li>پڕتەقاڵ</li>\n<li>لیمۆ</li>\n</ul>\n</li>\n</ul>\n<h2 id=\"section-2\" dir=\"rtl\">لیستی کڕین</h2>\n<ul class=\"contains-task-list\" dir=\"rtl\">\n<li class=\"task-list-item\"><input disabled=\"disabled\" type=\"checkbox\" checked=\"checked\" /> شووتی</li>\n<li class=\"task-list-item\"><input disabled=\"disabled\" type=\"checkbox\" checked=\"checked\" /> قەیسی</li>\n<li class=\"task-list-item\"><input disabled=\"disabled\" type=\"checkbox\" /> هەنجیر</li>\n</ul>", "globalization+advanced+emojis");
}
// Tables:
[Test]
public void ExtensionsGlobalization_Example003()
{
// Example 3
// Section: Extensions / Globalization
//
// The following Markdown:
// Nuitrion |Apple | Oranges
// --|-- | --
// Calories|52|47
// Sugar|10g|9g
//
// پێکهاتە |سێو | پڕتەقاڵ
// --|-- | --
// کالۆری|٥٢|٤٧
// شەکر| ١٠گ|٩گ
//
// Should be rendered as:
// <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>
Console.WriteLine("Example 3\nSection Extensions / Globalization\n");
TestParser.TestSpec("Nuitrion |Apple | Oranges\n--|-- | --\nCalories|52|47\nSugar|10g|9g\n\n پێکهاتە |سێو | پڕتەقاڵ\n--|-- | --\nکالۆری|٥٢|٤٧\nشەکر| ١٠گ|٩گ", "<table>\n<thead>\n<tr>\n<th>Nuitrion</th>\n<th>Apple</th>\n<th>Oranges</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Calories</td>\n<td>52</td>\n<td>47</td>\n</tr>\n<tr>\n<td>Sugar</td>\n<td>10g</td>\n<td>9g</td>\n</tr>\n</tbody>\n</table>\n<table dir=\"rtl\" align=\"right\">\n<thead>\n<tr>\n<th>پێکهاتە</th>\n<th>سێو</th>\n<th>پڕتەقاڵ</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>کالۆری</td>\n<td>٥٢</td>\n<td>٤٧</td>\n</tr>\n<tr>\n<td>شەکر</td>\n<td>١٠گ</td>\n<td>٩گ</td>\n</tr>\n</tbody>\n</table>", "globalization+advanced+emojis");
}
}
}

View File

@@ -0,0 +1,399 @@
// Generated: 21. 01. 2019 14:26:34
// --------------------------------
// Grid Tables
// --------------------------------
using System;
using NUnit.Framework;
namespace Markdig.Tests.Specs.GridTables
{
[TestFixture]
public class TestExtensionsGridTable
{
// # Extensions
//
// This section describes the different extensions supported:
//
// ## Grid Table
//
// A grid table allows to have multiple lines per cells and allows to span cells over multiple columns. The following shows a simple grid table
//
// ```
// +---------+---------+
// | Header | Header |
// | Column1 | Column2 |
// +=========+=========+
// | 1. ab | > This is a quote
// | 2. cde | > For the second column
// | 3. f |
// +---------+---------+
// | Second row spanning
// | on two columns
// +---------+---------+
// | Back | |
// | to | |
// | one | |
// | column | |
// ```
//
// **Rule #1**
// The first line of a grid table must a **row separator**. It must start with the column separator character `+` used to separate columns in a row separator. Each column separator is:
// - starting by optional spaces
// - followed by an optional `:` to specify left align, followed by optional spaces
// - followed by a sequence of at least one `-` character, followed by optional spaces
// - followed by an optional `:` to specify right align (or center align if left align is also defined)
// - ending by optional spaces
//
// The first row separator must be followed by a *regular row*. A regular row must start with the character `|` that is starting at the same position than the column separator `+` of the first row separator.
//
//
// The following is a valid row separator
[Test]
public void ExtensionsGridTable_Example001()
{
// Example 1
// Section: Extensions / Grid Table
//
// The following Markdown:
// +---------+---------+
// | This is | a table |
//
// Should be rendered as:
// <table>
// <col style="width:50%">
// <col style="width:50%">
// <tbody>
// <tr>
// <td>This is</td>
// <td>a table</td>
// </tr>
// </tbody>
// </table>
Console.WriteLine("Example 1\nSection Extensions / Grid Table\n");
TestParser.TestSpec("+---------+---------+\n| This is | a table |", "<table>\n<col style=\"width:50%\">\n<col style=\"width:50%\">\n<tbody>\n<tr>\n<td>This is</td>\n<td>a table</td>\n</tr>\n</tbody>\n</table>", "gridtables|advanced");
}
// The following is not a valid row separator
[Test]
public void ExtensionsGridTable_Example002()
{
// Example 2
// Section: Extensions / Grid Table
//
// The following Markdown:
// |-----xxx----+---------+
// | This is | not a table
//
// Should be rendered as:
// <p>|-----xxx----+---------+
// | This is | not a table</p>
Console.WriteLine("Example 2\nSection Extensions / Grid Table\n");
TestParser.TestSpec("|-----xxx----+---------+\n| This is | not a table", "<p>|-----xxx----+---------+\n| This is | not a table</p>", "gridtables|advanced");
}
// **Rule #2**
// A regular row can continue a previous regular row when column separator `|` are positioned at the same position than the previous line. If they are positioned at the same location, the column may span over multiple columns:
[Test]
public void ExtensionsGridTable_Example003()
{
// Example 3
// Section: Extensions / Grid Table
//
// The following Markdown:
// +---------+---------+---------+
// | Col1 | Col2 | Col3 |
// | Col1a | Col2a | Col3a |
// | Col1b | Col3b |
// | Col1c |
//
// Should be rendered as:
// <table>
// <col style="width:33.33%">
// <col style="width:33.33%">
// <col style="width:33.33%">
// <tbody>
// <tr>
// <td>Col1
// Col1a</td>
// <td>Col2
// Col2a</td>
// <td>Col3
// Col3a</td>
// </tr>
// <tr>
// <td colspan="2">Col1b</td>
// <td>Col3b</td>
// </tr>
// <tr>
// <td colspan="3">Col1c</td>
// </tr>
// </tbody>
// </table>
Console.WriteLine("Example 3\nSection Extensions / Grid Table\n");
TestParser.TestSpec("+---------+---------+---------+\n| Col1 | Col2 | Col3 |\n| Col1a | Col2a | Col3a |\n| Col1b | Col3b |\n| Col1c |", "<table>\n<col style=\"width:33.33%\">\n<col style=\"width:33.33%\">\n<col style=\"width:33.33%\">\n<tbody>\n<tr>\n<td>Col1\nCol1a</td>\n<td>Col2\nCol2a</td>\n<td>Col3\nCol3a</td>\n</tr>\n<tr>\n<td colspan=\"2\">Col1b</td>\n<td>Col3b</td>\n</tr>\n<tr>\n<td colspan=\"3\">Col1c</td>\n</tr>\n</tbody>\n</table>", "gridtables|advanced");
}
// A row header is separated using `+========+` instead of `+---------+`:
[Test]
public void ExtensionsGridTable_Example004()
{
// Example 4
// Section: Extensions / Grid Table
//
// The following Markdown:
// +---------+---------+
// | This is | a table |
// +=========+=========+
//
// Should be rendered as:
// <table>
// <col style="width:50%">
// <col style="width:50%">
// <thead>
// <tr>
// <th>This is</th>
// <th>a table</th>
// </tr>
// </thead>
// </table>
Console.WriteLine("Example 4\nSection Extensions / Grid Table\n");
TestParser.TestSpec("+---------+---------+\n| This is | a table |\n+=========+=========+", "<table>\n<col style=\"width:50%\">\n<col style=\"width:50%\">\n<thead>\n<tr>\n<th>This is</th>\n<th>a table</th>\n</tr>\n</thead>\n</table>", "gridtables|advanced");
}
// The last column separator `|` may be omitted:
[Test]
public void ExtensionsGridTable_Example005()
{
// Example 5
// Section: Extensions / Grid Table
//
// The following Markdown:
// +---------+---------+
// | This is | a table with a longer text in the second column
//
// Should be rendered as:
// <table>
// <col style="width:50%">
// <col style="width:50%">
// <tbody>
// <tr>
// <td>This is</td>
// <td>a table with a longer text in the second column</td>
// </tr>
// </tbody>
// </table>
Console.WriteLine("Example 5\nSection Extensions / Grid Table\n");
TestParser.TestSpec("+---------+---------+\n| This is | a table with a longer text in the second column", "<table>\n<col style=\"width:50%\">\n<col style=\"width:50%\">\n<tbody>\n<tr>\n<td>This is</td>\n<td>a table with a longer text in the second column</td>\n</tr>\n</tbody>\n</table>", "gridtables|advanced");
}
// The respective width of the columns are calculated from the ratio between the total size of the first table row without counting the `+`: `+----+--------+----+` would be divided between:
//
// Total size is : 16
//
// - `----` -> 4
// - `--------` -> 8
// - `----` -> 4
//
// So the width would be 4/16 = 25%, 8/16 = 50%, 4/16 = 25%
[Test]
public void ExtensionsGridTable_Example006()
{
// Example 6
// Section: Extensions / Grid Table
//
// The following Markdown:
// +----+--------+----+
// | A | B C D | E |
// +----+--------+----+
//
// Should be rendered as:
// <table>
// <col style="width:25%">
// <col style="width:50%">
// <col style="width:25%">
// <tbody>
// <tr>
// <td>A</td>
// <td>B C D</td>
// <td>E</td>
// </tr>
// </tbody>
// </table>
Console.WriteLine("Example 6\nSection Extensions / Grid Table\n");
TestParser.TestSpec("+----+--------+----+\n| A | B C D | E |\n+----+--------+----+", "<table>\n<col style=\"width:25%\">\n<col style=\"width:50%\">\n<col style=\"width:25%\">\n<tbody>\n<tr>\n<td>A</td>\n<td>B C D</td>\n<td>E</td>\n</tr>\n</tbody>\n</table>", "gridtables|advanced");
}
// Alignment might be specified on the first row using the character `:`:
[Test]
public void ExtensionsGridTable_Example007()
{
// Example 7
// Section: Extensions / Grid Table
//
// The following Markdown:
// +-----+:---:+-----+
// | A | B | C |
// +-----+-----+-----+
//
// Should be rendered as:
// <table>
// <col style="width:33.33%">
// <col style="width:33.33%">
// <col style="width:33.33%">
// <tbody>
// <tr>
// <td>A</td>
// <td style="text-align: center;">B</td>
// <td>C</td>
// </tr>
// </tbody>
// </table>
Console.WriteLine("Example 7\nSection Extensions / Grid Table\n");
TestParser.TestSpec("+-----+:---:+-----+\n| A | B | C |\n+-----+-----+-----+", "<table>\n<col style=\"width:33.33%\">\n<col style=\"width:33.33%\">\n<col style=\"width:33.33%\">\n<tbody>\n<tr>\n<td>A</td>\n<td style=\"text-align: center;\">B</td>\n<td>C</td>\n</tr>\n</tbody>\n</table>", "gridtables|advanced");
}
// A grid table may have cells spanning both columns and rows:
[Test]
public void ExtensionsGridTable_Example008()
{
// Example 8
// Section: Extensions / Grid Table
//
// The following Markdown:
// +---+---+---+
// | AAAAA | B |
// +---+---+ B +
// | D | E | B |
// + D +---+---+
// | D | CCCCC |
// +---+---+---+
//
// Should be rendered as:
// <table>
// <col style="width:33.33%">
// <col style="width:33.33%">
// <col style="width:33.33%">
// <tbody>
// <tr>
// <td colspan="2">AAAAA</td>
// <td rowspan="2">B
// B
// B</td>
// </tr>
// <tr>
// <td rowspan="2">D
// D
// D</td>
// <td>E</td>
// </tr>
// <tr>
// <td colspan="2">CCCCC</td>
// </tr>
// </tbody>
// </table>
Console.WriteLine("Example 8\nSection Extensions / Grid Table\n");
TestParser.TestSpec("+---+---+---+\n| AAAAA | B |\n+---+---+ B +\n| D | E | B |\n+ D +---+---+\n| D | CCCCC |\n+---+---+---+", "<table>\n<col style=\"width:33.33%\">\n<col style=\"width:33.33%\">\n<col style=\"width:33.33%\">\n<tbody>\n<tr>\n<td colspan=\"2\">AAAAA</td>\n<td rowspan=\"2\">B\nB\nB</td>\n</tr>\n<tr>\n<td rowspan=\"2\">D\nD\nD</td>\n<td>E</td>\n</tr>\n<tr>\n<td colspan=\"2\">CCCCC</td>\n</tr>\n</tbody>\n</table>", "gridtables|advanced");
}
// A grid table may have cells with both colspan and rowspan:
[Test]
public void ExtensionsGridTable_Example009()
{
// Example 9
// Section: Extensions / Grid Table
//
// The following Markdown:
// +---+---+---+
// | AAAAA | B |
// + AAAAA +---+
// | AAAAA | C |
// +---+---+---+
// | D | E | F |
// +---+---+---+
//
// Should be rendered as:
// <table>
// <col style="width:33.33%">
// <col style="width:33.33%">
// <col style="width:33.33%">
// <tbody>
// <tr>
// <td colspan="2" rowspan="2">AAAAA
// AAAAA
// AAAAA</td>
// <td>B</td>
// </tr>
// <tr>
// <td>C</td>
// </tr>
// <tr>
// <td>D</td>
// <td>E</td>
// <td>F</td>
// </tr>
// </tbody>
// </table>
Console.WriteLine("Example 9\nSection Extensions / Grid Table\n");
TestParser.TestSpec("+---+---+---+\n| AAAAA | B |\n+ AAAAA +---+\n| AAAAA | C |\n+---+---+---+\n| D | E | F |\n+---+---+---+", "<table>\n<col style=\"width:33.33%\">\n<col style=\"width:33.33%\">\n<col style=\"width:33.33%\">\n<tbody>\n<tr>\n<td colspan=\"2\" rowspan=\"2\">AAAAA\nAAAAA\nAAAAA</td>\n<td>B</td>\n</tr>\n<tr>\n<td>C</td>\n</tr>\n<tr>\n<td>D</td>\n<td>E</td>\n<td>F</td>\n</tr>\n</tbody>\n</table>", "gridtables|advanced");
}
// A grid table may not have irregularly shaped cells:
[Test]
public void ExtensionsGridTable_Example010()
{
// Example 10
// Section: Extensions / Grid Table
//
// The following Markdown:
// +---+---+---+
// | AAAAA | B |
// + A +---+ B +
// | A | C | B |
// +---+---+---+
// | DDDDD | E |
// +---+---+---+
//
// Should be rendered as:
// <p>+---+---+---+
// | AAAAA | B |
// + A +---+ B +
// | A | C | B |
// +---+---+---+
// | DDDDD | E |
// +---+---+---+</p>
Console.WriteLine("Example 10\nSection Extensions / Grid Table\n");
TestParser.TestSpec("+---+---+---+\n| AAAAA | B |\n+ A +---+ B +\n| A | C | B |\n+---+---+---+\n| DDDDD | E |\n+---+---+---+", "<p>+---+---+---+\n| AAAAA | B |\n+ A +---+ B +\n| A | C | B |\n+---+---+---+\n| DDDDD | E |\n+---+---+---+</p>", "gridtables|advanced");
}
// An empty `+` on a line should result in a simple empty list output:
[Test]
public void ExtensionsGridTable_Example011()
{
// Example 11
// Section: Extensions / Grid Table
//
// The following Markdown:
// +
//
// Should be rendered as:
// <ul>
// <li></li>
// </ul>
Console.WriteLine("Example 11\nSection Extensions / Grid Table\n");
TestParser.TestSpec("+", "<ul>\n<li></li>\n</ul>", "gridtables|advanced");
}
}
}

View File

@@ -0,0 +1,40 @@
// Generated: 21. 01. 2019 14:26:34
// --------------------------------
// Hardline Breaks
// --------------------------------
using System;
using NUnit.Framework;
namespace Markdig.Tests.Specs.HardlineBreaks
{
[TestFixture]
public class TestExtensionsHardlineBreak
{
// # Extensions
//
// This section describes the different extensions supported:
//
// ## Hardline break
//
// When this extension is used, a new line in a paragraph block will result in a hardline break `<br>`:
[Test]
public void ExtensionsHardlineBreak_Example001()
{
// Example 1
// Section: Extensions / Hardline break
//
// The following Markdown:
// This is a paragraph
// with a break inside
//
// Should be rendered as:
// <p>This is a paragraph<br />
// with a break inside</p>
Console.WriteLine("Example 1\nSection Extensions / Hardline break\n");
TestParser.TestSpec("This is a paragraph\nwith a break inside", "<p>This is a paragraph<br />\nwith a break inside</p>", "hardlinebreak|advanced+hardlinebreak");
}
}
}

View File

@@ -0,0 +1,180 @@
// Generated: 21. 01. 2019 14:22:45
// --------------------------------
// Jira Links
// --------------------------------
using System;
using NUnit.Framework;
namespace Markdig.Tests.Specs.JiraLinks
{
[TestFixture]
public class TestJiraLinks
{
// ## Jira Links
//
// The JiraLinks extension will automatically add links to JIRA issue items within your markdown, e.g. XX-1234. For this to happen, you must configure the extension when adding to the pipeline, e.g.
//
// ```
// var pipeline = new MarkdownPipelineBuilder()
// .UseJiraLinks(new JiraLinkOptions("http://your.company.abc"))
// .Build();
// ```
//
// The rules for detecting a link are:
//
// - The project key must be composed of onre or more capitalised ASCII letter `[A-Z]+`
// - A single hypen `-` must separate the project key and issue number.
// - The issue number is composed of 1 or more digits `[0, 9]+`
// - The reference must be preceeded by either `(` or whitespace or EOF.
// - The reference must be followed by either `)` or whitespace or EOF.
//
// The following are valid examples:
[Test]
public void JiraLinks_Example001()
{
// Example 1
// Section: Jira Links
//
// The following Markdown:
// This is a ABCD-123 issue
//
// Should be rendered as:
// <p>This is a <a href="http://your.company.abc/browse/ABCD-123" target="blank">ABCD-123</a> issue</p>
Console.WriteLine("Example 1\nSection Jira Links\n");
TestParser.TestSpec("This is a ABCD-123 issue", "<p>This is a <a href=\"http://your.company.abc/browse/ABCD-123\" target=\"blank\">ABCD-123</a> issue</p>", "jiralinks");
}
[Test]
public void JiraLinks_Example002()
{
// Example 2
// Section: Jira Links
//
// The following Markdown:
// This is a KIRA-1 issue
//
// Should be rendered as:
// <p>This is a <a href="http://your.company.abc/browse/KIRA-1" target="blank">KIRA-1</a> issue</p>
Console.WriteLine("Example 2\nSection Jira Links\n");
TestParser.TestSpec("This is a KIRA-1 issue", "<p>This is a <a href=\"http://your.company.abc/browse/KIRA-1\" target=\"blank\">KIRA-1</a> issue</p>", "jiralinks");
}
[Test]
public void JiraLinks_Example003()
{
// Example 3
// Section: Jira Links
//
// The following Markdown:
// This is a Z-1 issue
//
// Should be rendered as:
// <p>This is a <a href="http://your.company.abc/browse/Z-1" target="blank">Z-1</a> issue</p>
Console.WriteLine("Example 3\nSection Jira Links\n");
TestParser.TestSpec("This is a Z-1 issue", "<p>This is a <a href=\"http://your.company.abc/browse/Z-1\" target=\"blank\">Z-1</a> issue</p>", "jiralinks");
}
// These are also valid links with `(` and `)`:
[Test]
public void JiraLinks_Example004()
{
// Example 4
// Section: Jira Links
//
// The following Markdown:
// This is a (ABCD-123) issue
//
// Should be rendered as:
// <p>This is a (<a href="http://your.company.abc/browse/ABCD-123" target="blank">ABCD-123</a>) issue</p>
Console.WriteLine("Example 4\nSection Jira Links\n");
TestParser.TestSpec("This is a (ABCD-123) issue", "<p>This is a (<a href=\"http://your.company.abc/browse/ABCD-123\" target=\"blank\">ABCD-123</a>) issue</p>", "jiralinks");
}
[Test]
public void JiraLinks_Example005()
{
// Example 5
// Section: Jira Links
//
// The following Markdown:
// This is a (KIRA-1) issue
//
// Should be rendered as:
// <p>This is a (<a href="http://your.company.abc/browse/KIRA-1" target="blank">KIRA-1</a>) issue</p>
Console.WriteLine("Example 5\nSection Jira Links\n");
TestParser.TestSpec("This is a (KIRA-1) issue", "<p>This is a (<a href=\"http://your.company.abc/browse/KIRA-1\" target=\"blank\">KIRA-1</a>) issue</p>", "jiralinks");
}
[Test]
public void JiraLinks_Example006()
{
// Example 6
// Section: Jira Links
//
// The following Markdown:
// This is a (Z-1) issue
//
// Should be rendered as:
// <p>This is a (<a href="http://your.company.abc/browse/Z-1" target="blank">Z-1</a>) issue</p>
Console.WriteLine("Example 6\nSection Jira Links\n");
TestParser.TestSpec("This is a (Z-1) issue", "<p>This is a (<a href=\"http://your.company.abc/browse/Z-1\" target=\"blank\">Z-1</a>) issue</p>", "jiralinks");
}
// These are not valid links:
[Test]
public void JiraLinks_Example007()
{
// Example 7
// Section: Jira Links
//
// The following Markdown:
// This is not aJIRA-123 issue
//
// Should be rendered as:
// <p>This is not aJIRA-123 issue</p>
Console.WriteLine("Example 7\nSection Jira Links\n");
TestParser.TestSpec("This is not aJIRA-123 issue", "<p>This is not aJIRA-123 issue</p>", "jiralinks");
}
[Test]
public void JiraLinks_Example008()
{
// Example 8
// Section: Jira Links
//
// The following Markdown:
// This is not JIRA-123a issue
//
// Should be rendered as:
// <p>This is not JIRA-123a issue</p>
Console.WriteLine("Example 8\nSection Jira Links\n");
TestParser.TestSpec("This is not JIRA-123a issue", "<p>This is not JIRA-123a issue</p>", "jiralinks");
}
[Test]
public void JiraLinks_Example009()
{
// Example 9
// Section: Jira Links
//
// The following Markdown:
// This is not JIRA- issue
//
// Should be rendered as:
// <p>This is not JIRA- issue</p>
Console.WriteLine("Example 9\nSection Jira Links\n");
TestParser.TestSpec("This is not JIRA- issue", "<p>This is not JIRA- issue</p>", "jiralinks");
}
}
}

View File

@@ -0,0 +1,217 @@
// Generated: 21. 01. 2019 14:26:34
// --------------------------------
// List Extras
// --------------------------------
using System;
using NUnit.Framework;
namespace Markdig.Tests.Specs.ListExtras
{
[TestFixture]
public class TestExtensionsOrderedListWithAlphaLetter
{
// # Extensions
//
// The following additional list items are supported:
//
// ## Ordered list with alpha letter
//
// Allows to use a list using an alpha letter instead of a number
[Test]
public void ExtensionsOrderedListWithAlphaLetter_Example001()
{
// Example 1
// Section: Extensions / Ordered list with alpha letter
//
// The following Markdown:
// a. First item
// b. Second item
// c. Last item
//
// Should be rendered as:
// <ol type="a">
// <li>First item</li>
// <li>Second item</li>
// <li>Last item</li>
// </ol>
Console.WriteLine("Example 1\nSection Extensions / Ordered list with alpha letter\n");
TestParser.TestSpec("a. First item\nb. Second item\nc. Last item", "<ol type=\"a\">\n<li>First item</li>\n<li>Second item</li>\n<li>Last item</li>\n</ol>", "listextras|advanced");
}
// It works also for uppercase alpha:
[Test]
public void ExtensionsOrderedListWithAlphaLetter_Example002()
{
// Example 2
// Section: Extensions / Ordered list with alpha letter
//
// The following Markdown:
// A. First item
// B. Second item
// C. Last item
//
// Should be rendered as:
// <ol type="A">
// <li>First item</li>
// <li>Second item</li>
// <li>Last item</li>
// </ol>
Console.WriteLine("Example 2\nSection Extensions / Ordered list with alpha letter\n");
TestParser.TestSpec("A. First item\nB. Second item\nC. Last item", "<ol type=\"A\">\n<li>First item</li>\n<li>Second item</li>\n<li>Last item</li>\n</ol>", "listextras|advanced");
}
// Like for numbered list, a list can start with a different letter
[Test]
public void ExtensionsOrderedListWithAlphaLetter_Example003()
{
// Example 3
// Section: Extensions / Ordered list with alpha letter
//
// The following Markdown:
// b. First item
// c. Second item
//
// Should be rendered as:
// <ol type="a" start="2">
// <li>First item</li>
// <li>Second item</li>
// </ol>
Console.WriteLine("Example 3\nSection Extensions / Ordered list with alpha letter\n");
TestParser.TestSpec("b. First item\nc. Second item", "<ol type=\"a\" start=\"2\">\n<li>First item</li>\n<li>Second item</li>\n</ol>", "listextras|advanced");
}
// A different type of list will break the existing list:
[Test]
public void ExtensionsOrderedListWithAlphaLetter_Example004()
{
// Example 4
// Section: Extensions / Ordered list with alpha letter
//
// The following Markdown:
// a. First item1
// b. Second item
// A. First item2
//
// Should be rendered as:
// <ol type="a">
// <li>First item1</li>
// <li>Second item</li>
// </ol>
// <ol type="A">
// <li>First item2</li>
// </ol>
Console.WriteLine("Example 4\nSection Extensions / Ordered list with alpha letter\n");
TestParser.TestSpec("a. First item1\nb. Second item\nA. First item2", "<ol type=\"a\">\n<li>First item1</li>\n<li>Second item</li>\n</ol>\n<ol type=\"A\">\n<li>First item2</li>\n</ol>", "listextras|advanced");
}
}
[TestFixture]
public class TestExtensionsOrderedListWithRomanLetter
{
// ## Ordered list with roman letter
//
// Allows to use a list using a roman number instead of a number.
[Test]
public void ExtensionsOrderedListWithRomanLetter_Example005()
{
// Example 5
// Section: Extensions / Ordered list with roman letter
//
// The following Markdown:
// i. First item
// ii. Second item
// iii. Third item
// iv. Last item
//
// Should be rendered as:
// <ol type="i">
// <li>First item</li>
// <li>Second item</li>
// <li>Third item</li>
// <li>Last item</li>
// </ol>
Console.WriteLine("Example 5\nSection Extensions / Ordered list with roman letter\n");
TestParser.TestSpec("i. First item\nii. Second item\niii. Third item\niv. Last item", "<ol type=\"i\">\n<li>First item</li>\n<li>Second item</li>\n<li>Third item</li>\n<li>Last item</li>\n</ol>", "listextras|advanced");
}
// It works also for uppercase alpha:
[Test]
public void ExtensionsOrderedListWithRomanLetter_Example006()
{
// Example 6
// Section: Extensions / Ordered list with roman letter
//
// The following Markdown:
// I. First item
// II. Second item
// III. Third item
// IV. Last item
//
// Should be rendered as:
// <ol type="I">
// <li>First item</li>
// <li>Second item</li>
// <li>Third item</li>
// <li>Last item</li>
// </ol>
Console.WriteLine("Example 6\nSection Extensions / Ordered list with roman letter\n");
TestParser.TestSpec("I. First item\nII. Second item\nIII. Third item\nIV. Last item", "<ol type=\"I\">\n<li>First item</li>\n<li>Second item</li>\n<li>Third item</li>\n<li>Last item</li>\n</ol>", "listextras|advanced");
}
// Like for numbered list, a list can start with a different letter
[Test]
public void ExtensionsOrderedListWithRomanLetter_Example007()
{
// Example 7
// Section: Extensions / Ordered list with roman letter
//
// The following Markdown:
// ii. First item
// iii. Second item
//
// Should be rendered as:
// <ol type="i" start="2">
// <li>First item</li>
// <li>Second item</li>
// </ol>
Console.WriteLine("Example 7\nSection Extensions / Ordered list with roman letter\n");
TestParser.TestSpec("ii. First item\niii. Second item", "<ol type=\"i\" start=\"2\">\n<li>First item</li>\n<li>Second item</li>\n</ol>", "listextras|advanced");
}
// Lists can be restarted, specifying the start point.
[Test]
public void ExtensionsOrderedListWithRomanLetter_Example008()
{
// Example 8
// Section: Extensions / Ordered list with roman letter
//
// The following Markdown:
// 1. First item
//
// Some text
//
// 2. Second item
//
// Should be rendered as:
// <ol>
// <li>First item</li>
// </ol>
// <p>Some text</p>
// <ol start="2">
// <li>Second item</li>
// </ol>
Console.WriteLine("Example 8\nSection Extensions / Ordered list with roman letter\n");
TestParser.TestSpec("1. First item\n\nSome text\n\n2. Second item", "<ol>\n<li>First item</li>\n</ol>\n<p>Some text</p>\n<ol start=\"2\">\n<li>Second item</li>\n</ol>", "listextras|advanced");
}
}
}

View File

@@ -0,0 +1,326 @@
// Generated: 21. 01. 2019 14:26:34
// --------------------------------
// Math
// --------------------------------
using System;
using NUnit.Framework;
namespace Markdig.Tests.Specs.Math
{
[TestFixture]
public class TestExtensionsMathInline
{
// # Extensions
//
// Adds support for mathematics spans:
//
// ## Math Inline
//
// Allows to define a mathematic block embraced by `$...$`
[Test]
public void ExtensionsMathInline_Example001()
{
// Example 1
// Section: Extensions / Math Inline
//
// The following Markdown:
// This is a $math block$
//
// Should be rendered as:
// <p>This is a <span class="math">math block</span></p>
Console.WriteLine("Example 1\nSection Extensions / Math Inline\n");
TestParser.TestSpec("This is a $math block$", "<p>This is a <span class=\"math\">math block</span></p>", "mathematics|advanced");
}
// Or by `$$...$$` embracing it by:
[Test]
public void ExtensionsMathInline_Example002()
{
// Example 2
// Section: Extensions / Math Inline
//
// The following Markdown:
// This is a $$math block$$
//
// Should be rendered as:
// <p>This is a <span class="math">math block</span></p>
Console.WriteLine("Example 2\nSection Extensions / Math Inline\n");
TestParser.TestSpec("This is a $$math block$$", "<p>This is a <span class=\"math\">math block</span></p>", "mathematics|advanced");
}
// Newlines inside an inline math are not allowed:
[Test]
public void ExtensionsMathInline_Example003()
{
// Example 3
// Section: Extensions / Math Inline
//
// The following Markdown:
// This is not a $$math
// block$$ and? this is a $$math block$$
//
// Should be rendered as:
// <p>This is not a $$math
// block$$ and? this is a <span class="math">math block</span></p>
Console.WriteLine("Example 3\nSection Extensions / Math Inline\n");
TestParser.TestSpec("This is not a $$math \nblock$$ and? this is a $$math block$$", "<p>This is not a $$math\nblock$$ and? this is a <span class=\"math\">math block</span></p>", "mathematics|advanced");
}
[Test]
public void ExtensionsMathInline_Example004()
{
// Example 4
// Section: Extensions / Math Inline
//
// The following Markdown:
// This is not a $math
// block$ and? this is a $math block$
//
// Should be rendered as:
// <p>This is not a $math
// block$ and? this is a <span class="math">math block</span></p>
Console.WriteLine("Example 4\nSection Extensions / Math Inline\n");
TestParser.TestSpec("This is not a $math \nblock$ and? this is a $math block$", "<p>This is not a $math\nblock$ and? this is a <span class=\"math\">math block</span></p>", "mathematics|advanced");
}
// An opening `$` can be followed by a space if the closing is also preceded by a space `$`:
[Test]
public void ExtensionsMathInline_Example005()
{
// Example 5
// Section: Extensions / Math Inline
//
// The following Markdown:
// This is a $ math block $
//
// Should be rendered as:
// <p>This is a <span class="math">math block</span></p>
Console.WriteLine("Example 5\nSection Extensions / Math Inline\n");
TestParser.TestSpec("This is a $ math block $", "<p>This is a <span class=\"math\">math block</span></p>", "mathematics|advanced");
}
[Test]
public void ExtensionsMathInline_Example006()
{
// Example 6
// Section: Extensions / Math Inline
//
// The following Markdown:
// This is a $ math block $ after
//
// Should be rendered as:
// <p>This is a <span class="math">math block</span> after</p>
Console.WriteLine("Example 6\nSection Extensions / Math Inline\n");
TestParser.TestSpec("This is a $ math block $ after", "<p>This is a <span class=\"math\">math block</span> after</p>", "mathematics|advanced");
}
[Test]
public void ExtensionsMathInline_Example007()
{
// Example 7
// Section: Extensions / Math Inline
//
// The following Markdown:
// This is a $$ math block $$ after
//
// Should be rendered as:
// <p>This is a <span class="math">math block</span> after</p>
Console.WriteLine("Example 7\nSection Extensions / Math Inline\n");
TestParser.TestSpec("This is a $$ math block $$ after", "<p>This is a <span class=\"math\">math block</span> after</p>", "mathematics|advanced");
}
[Test]
public void ExtensionsMathInline_Example008()
{
// Example 8
// Section: Extensions / Math Inline
//
// The following Markdown:
// This is a not $ math block$ because there is not a whitespace before the closing
//
// Should be rendered as:
// <p>This is a not $ math block$ because there is not a whitespace before the closing</p>
Console.WriteLine("Example 8\nSection Extensions / Math Inline\n");
TestParser.TestSpec("This is a not $ math block$ because there is not a whitespace before the closing", "<p>This is a not $ math block$ because there is not a whitespace before the closing</p>", "mathematics|advanced");
}
// For the opening `$` it requires a space or a punctuation before (but cannot be used within a word):
[Test]
public void ExtensionsMathInline_Example009()
{
// Example 9
// Section: Extensions / Math Inline
//
// The following Markdown:
// This is not a m$ath block$
//
// Should be rendered as:
// <p>This is not a m$ath block$</p>
Console.WriteLine("Example 9\nSection Extensions / Math Inline\n");
TestParser.TestSpec("This is not a m$ath block$", "<p>This is not a m$ath block$</p>", "mathematics|advanced");
}
// For the closing `$` it requires a space after or a punctuation (but cannot be preceded by a space and cannot be used within a word):
[Test]
public void ExtensionsMathInline_Example010()
{
// Example 10
// Section: Extensions / Math Inline
//
// The following Markdown:
// This is not a $math bloc$k
//
// Should be rendered as:
// <p>This is not a $math bloc$k</p>
Console.WriteLine("Example 10\nSection Extensions / Math Inline\n");
TestParser.TestSpec("This is not a $math bloc$k", "<p>This is not a $math bloc$k</p>", "mathematics|advanced");
}
// For the closing `$` it requires a space after or a punctuation (but cannot be preceded by a space and cannot be used within a word):
[Test]
public void ExtensionsMathInline_Example011()
{
// Example 11
// Section: Extensions / Math Inline
//
// The following Markdown:
// This is should not match a 16$ or a $15
//
// Should be rendered as:
// <p>This is should not match a 16$ or a $15</p>
Console.WriteLine("Example 11\nSection Extensions / Math Inline\n");
TestParser.TestSpec("This is should not match a 16$ or a $15", "<p>This is should not match a 16$ or a $15</p>", "mathematics|advanced");
}
// A `$` can be escaped between a math inline block by using the escape `\\`
[Test]
public void ExtensionsMathInline_Example012()
{
// Example 12
// Section: Extensions / Math Inline
//
// The following Markdown:
// This is a $math \$ block$
//
// Should be rendered as:
// <p>This is a <span class="math">math \$ block</span></p>
Console.WriteLine("Example 12\nSection Extensions / Math Inline\n");
TestParser.TestSpec("This is a $math \\$ block$", "<p>This is a <span class=\"math\">math \\$ block</span></p>", "mathematics|advanced");
}
// At most, two `$` will be matched for the opening and closing:
[Test]
public void ExtensionsMathInline_Example013()
{
// Example 13
// Section: Extensions / Math Inline
//
// The following Markdown:
// This is a $$$math block$$$
//
// Should be rendered as:
// <p>This is a <span class="math">$math block$</span></p>
Console.WriteLine("Example 13\nSection Extensions / Math Inline\n");
TestParser.TestSpec("This is a $$$math block$$$", "<p>This is a <span class=\"math\">$math block$</span></p>", "mathematics|advanced");
}
// Regular text can come both before and after the math inline
[Test]
public void ExtensionsMathInline_Example014()
{
// Example 14
// Section: Extensions / Math Inline
//
// The following Markdown:
// This is a $math block$ with text on both sides.
//
// Should be rendered as:
// <p>This is a <span class="math">math block</span> with text on both sides.</p>
Console.WriteLine("Example 14\nSection Extensions / Math Inline\n");
TestParser.TestSpec("This is a $math block$ with text on both sides.", "<p>This is a <span class=\"math\">math block</span> with text on both sides.</p>", "mathematics|advanced");
}
// A mathematic block takes precedence over standard emphasis `*` `_`:
[Test]
public void ExtensionsMathInline_Example015()
{
// Example 15
// Section: Extensions / Math Inline
//
// The following Markdown:
// This is *a $math* block$
//
// Should be rendered as:
// <p>This is *a <span class="math">math* block</span></p>
Console.WriteLine("Example 15\nSection Extensions / Math Inline\n");
TestParser.TestSpec("This is *a $math* block$", "<p>This is *a <span class=\"math\">math* block</span></p>", "mathematics|advanced");
}
// An opening $$ at the beginning of a line should not be interpreted as a Math block:
[Test]
public void ExtensionsMathInline_Example016()
{
// Example 16
// Section: Extensions / Math Inline
//
// The following Markdown:
// $$ math $$ starting at a line
//
// Should be rendered as:
// <p><span class="math">math</span> starting at a line</p>
Console.WriteLine("Example 16\nSection Extensions / Math Inline\n");
TestParser.TestSpec("$$ math $$ starting at a line", "<p><span class=\"math\">math</span> starting at a line</p>", "mathematics|advanced");
}
}
[TestFixture]
public class TestExtensionsMathBlock
{
// ## Math Block
//
// The match block can spawn on multiple lines by having a $$ starting on a line.
// It is working as a fenced code block.
[Test]
public void ExtensionsMathBlock_Example017()
{
// Example 17
// Section: Extensions / Math Block
//
// The following Markdown:
// $$
// \begin{equation}
// \int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15}
// \label{eq:sample}
// \end{equation}
// $$
//
// Should be rendered as:
// <div class="math">\begin{equation}
// \int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15}
// \label{eq:sample}
// \end{equation}
// </div>
Console.WriteLine("Example 17\nSection Extensions / Math Block\n");
TestParser.TestSpec("$$\n\\begin{equation}\n \\int_0^\\infty \\frac{x^3}{e^x-1}\\,dx = \\frac{\\pi^4}{15}\n \\label{eq:sample}\n\\end{equation}\n$$", "<div class=\"math\">\\begin{equation}\n \\int_0^\\infty \\frac{x^3}{e^x-1}\\,dx = \\frac{\\pi^4}{15}\n \\label{eq:sample}\n\\end{equation}\n</div>", "mathematics|advanced");
}
}
}

View File

@@ -0,0 +1,50 @@
// Generated: 21. 01. 2019 14:26:34
// --------------------------------
// Media
// --------------------------------
using System;
using NUnit.Framework;
namespace Markdig.Tests.Specs.Media
{
[TestFixture]
public class TestExtensionsMediaLinks
{
// # Extensions
//
// Adds support for media links:
//
// ## Media links
//
// Allows to embed audio/video links to popular website:
[Test]
public void ExtensionsMediaLinks_Example001()
{
// Example 1
// Section: Extensions / Media links
//
// The following Markdown:
// ![Video1](https://www.youtube.com/watch?v=mswPy5bt3TQ)
//
// ![Video2](https://vimeo.com/8607834)
//
// ![Video3](https://sample.com/video.mp4)
//
// ![Audio4](https://music.yandex.ru/album/411845/track/4402274)
//
// ![Video5](https://ok.ru/video/26870090463)
//
// Should be rendered as:
// <p><iframe src="https://www.youtube.com/embed/mswPy5bt3TQ" width="500" height="281" frameborder="0" allowfullscreen=""></iframe></p>
// <p><iframe src="https://player.vimeo.com/video/8607834" width="500" height="281" frameborder="0" allowfullscreen=""></iframe></p>
// <p><video width="500" height="281" controls=""><source type="video/mp4" src="https://sample.com/video.mp4"></source></video></p>
// <p><iframe src="https://music.yandex.ru/iframe/#track/4402274/411845/" width="500" height="281" frameborder="0"></iframe></p>
// <p><iframe src="https://ok.ru/videoembed/26870090463" width="500" height="281" frameborder="0" allowfullscreen=""></iframe></p>
Console.WriteLine("Example 1\nSection Extensions / Media links\n");
TestParser.TestSpec("![Video1](https://www.youtube.com/watch?v=mswPy5bt3TQ)\n\n![Video2](https://vimeo.com/8607834)\n\n![Video3](https://sample.com/video.mp4)\n\n![Audio4](https://music.yandex.ru/album/411845/track/4402274)\n\n![Video5](https://ok.ru/video/26870090463)", "<p><iframe src=\"https://www.youtube.com/embed/mswPy5bt3TQ\" width=\"500\" height=\"281\" frameborder=\"0\" allowfullscreen=\"\"></iframe></p>\n<p><iframe src=\"https://player.vimeo.com/video/8607834\" width=\"500\" height=\"281\" frameborder=\"0\" allowfullscreen=\"\"></iframe></p>\n<p><video width=\"500\" height=\"281\" controls=\"\"><source type=\"video/mp4\" src=\"https://sample.com/video.mp4\"></source></video></p>\n<p><iframe src=\"https://music.yandex.ru/iframe/#track/4402274/411845/\" width=\"500\" height=\"281\" frameborder=\"0\"></iframe></p>\n<p><iframe src=\"https://ok.ru/videoembed/26870090463\" width=\"500\" height=\"281\" frameborder=\"0\" allowfullscreen=\"\"></iframe></p>", "medialinks|advanced+medialinks");
}
}
}

View File

@@ -0,0 +1,59 @@
// Generated: 21. 01. 2019 14:26:34
// --------------------------------
// No Html
// --------------------------------
using System;
using NUnit.Framework;
namespace Markdig.Tests.Specs.NoHtml
{
[TestFixture]
public class TestExtensionsNoHTML
{
// # Extensions
//
// ## NoHTML
//
// The extension DisableHtml allows to disable the parsing of HTML:
//
// For inline HTML:
[Test]
public void ExtensionsNoHTML_Example001()
{
// Example 1
// Section: Extensions / NoHTML
//
// The following Markdown:
// this is some text</td></tr>
//
// Should be rendered as:
// <p>this is some text&lt;/td&gt;&lt;/tr&gt;</p>
Console.WriteLine("Example 1\nSection Extensions / NoHTML\n");
TestParser.TestSpec("this is some text</td></tr>", "<p>this is some text&lt;/td&gt;&lt;/tr&gt;</p>", "nohtml");
}
// For Block HTML:
[Test]
public void ExtensionsNoHTML_Example002()
{
// Example 2
// Section: Extensions / NoHTML
//
// The following Markdown:
// <div>
// this is some text
// </div>
//
// Should be rendered as:
// <p>&lt;div&gt;
// this is some text
// &lt;/div&gt;</p>
Console.WriteLine("Example 2\nSection Extensions / NoHTML\n");
TestParser.TestSpec("<div>\nthis is some text\n</div>", "<p>&lt;div&gt;\nthis is some text\n&lt;/div&gt;</p>", "nohtml");
}
}
}

View File

@@ -0,0 +1,855 @@
// Generated: 21. 01. 2019 14:26:34
// --------------------------------
// Pipe Tables
// --------------------------------
using System;
using NUnit.Framework;
namespace Markdig.Tests.Specs.PipeTables
{
[TestFixture]
public class TestExtensionsPipeTable
{
// # Extensions
//
// This section describes the different extensions supported:
//
// ## Pipe Table
//
// A pipe table is detected when:
//
// **Rule #1**
// - Each line of a paragraph block have to contain at least a **column delimiter** `|` that is not embedded by either a code inline (backstick \`) or a HTML inline.
// - The second row must separate the first header row from sub-sequent rows by containing a **header column separator** for each column separated by a column delimiter. A header column separator is:
// - starting by optional spaces
// - followed by an optional `:` to specify left align
// - followed by a sequence of at least one `-` character
// - followed by an optional `:` to specify right align (or center align if left align is also defined)
// - ending by optional spaces
//
// Because a list has a higher precedence than a pipe table, a table header row separator requires at least 2 dashes `--` to start a header row:
[Test]
public void ExtensionsPipeTable_Example001()
{
// Example 1
// Section: Extensions / Pipe Table
//
// The following Markdown:
// a | b
// -- | -
// 0 | 1
//
// Should be rendered as:
// <table>
// <thead>
// <tr>
// <th>a</th>
// <th>b</th>
// </tr>
// </thead>
// <tbody>
// <tr>
// <td>0</td>
// <td>1</td>
// </tr>
// </tbody>
// </table>
Console.WriteLine("Example 1\nSection Extensions / Pipe Table\n");
TestParser.TestSpec("a | b\n-- | -\n0 | 1", "<table>\n<thead>\n<tr>\n<th>a</th>\n<th>b</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>0</td>\n<td>1</td>\n</tr>\n</tbody>\n</table>", "pipetables|advanced");
}
// The following is also considered as a table, even if the second line starts like a list:
[Test]
public void ExtensionsPipeTable_Example002()
{
// Example 2
// Section: Extensions / Pipe Table
//
// The following Markdown:
// a | b
// - | -
// 0 | 1
//
// Should be rendered as:
// <table>
// <thead>
// <tr>
// <th>a</th>
// <th>b</th>
// </tr>
// </thead>
// <tbody>
// <tr>
// <td>0</td>
// <td>1</td>
// </tr>
// </tbody>
// </table>
Console.WriteLine("Example 2\nSection Extensions / Pipe Table\n");
TestParser.TestSpec("a | b\n- | -\n0 | 1", "<table>\n<thead>\n<tr>\n<th>a</th>\n<th>b</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>0</td>\n<td>1</td>\n</tr>\n</tbody>\n</table>", "pipetables|advanced");
}
// A pipe table with only one header row is allowed:
[Test]
public void ExtensionsPipeTable_Example003()
{
// Example 3
// Section: Extensions / Pipe Table
//
// The following Markdown:
// a | b
// -- | --
//
// Should be rendered as:
// <table>
// <thead>
// <tr>
// <th>a</th>
// <th>b</th>
// </tr>
// </thead>
// </table>
Console.WriteLine("Example 3\nSection Extensions / Pipe Table\n");
TestParser.TestSpec("a | b\n-- | --", "<table>\n<thead>\n<tr>\n<th>a</th>\n<th>b</th>\n</tr>\n</thead>\n</table>", "pipetables|advanced");
}
// After a row separator header, they will be interpreted as plain column:
[Test]
public void ExtensionsPipeTable_Example004()
{
// Example 4
// Section: Extensions / Pipe Table
//
// The following Markdown:
// a | b
// -- | --
// -- | --
//
// Should be rendered as:
// <table>
// <thead>
// <tr>
// <th>a</th>
// <th>b</th>
// </tr>
// </thead>
// <tbody>
// <tr>
// <td>--</td>
// <td>--</td>
// </tr>
// </tbody>
// </table>
Console.WriteLine("Example 4\nSection Extensions / Pipe Table\n");
TestParser.TestSpec("a | b\n-- | --\n-- | --", "<table>\n<thead>\n<tr>\n<th>a</th>\n<th>b</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>--</td>\n<td>--</td>\n</tr>\n</tbody>\n</table>", "pipetables|advanced");
}
// But if a table doesn't start with a column delimiter, it is not interpreted as a table, even if following lines have a column delimiter
[Test]
public void ExtensionsPipeTable_Example005()
{
// Example 5
// Section: Extensions / Pipe Table
//
// The following Markdown:
// a b
// c | d
// e | f
//
// Should be rendered as:
// <p>a b
// c | d
// e | f</p>
Console.WriteLine("Example 5\nSection Extensions / Pipe Table\n");
TestParser.TestSpec("a b\nc | d\ne | f", "<p>a b\nc | d\ne | f</p>", "pipetables|advanced");
}
// If a line doesn't have a column delimiter `|` the table is not detected
[Test]
public void ExtensionsPipeTable_Example006()
{
// Example 6
// Section: Extensions / Pipe Table
//
// The following Markdown:
// a | b
// c no d
//
// Should be rendered as:
// <p>a | b
// c no d</p>
Console.WriteLine("Example 6\nSection Extensions / Pipe Table\n");
TestParser.TestSpec("a | b\nc no d", "<p>a | b\nc no d</p>", "pipetables|advanced");
}
// If a row contains more column than the header row, it will still be added as a column:
[Test]
public void ExtensionsPipeTable_Example007()
{
// Example 7
// Section: Extensions / Pipe Table
//
// The following Markdown:
// a | b
// -- | --
// 0 | 1 | 2
// 3 | 4
// 5 |
//
// Should be rendered as:
// <table>
// <thead>
// <tr>
// <th>a</th>
// <th>b</th>
// <th></th>
// </tr>
// </thead>
// <tbody>
// <tr>
// <td>0</td>
// <td>1</td>
// <td>2</td>
// </tr>
// <tr>
// <td>3</td>
// <td>4</td>
// <td></td>
// </tr>
// <tr>
// <td>5</td>
// <td></td>
// <td></td>
// </tr>
// </tbody>
// </table>
Console.WriteLine("Example 7\nSection Extensions / Pipe Table\n");
TestParser.TestSpec("a | b \n-- | --\n0 | 1 | 2\n3 | 4\n5 |", "<table>\n<thead>\n<tr>\n<th>a</th>\n<th>b</th>\n<th></th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>0</td>\n<td>1</td>\n<td>2</td>\n</tr>\n<tr>\n<td>3</td>\n<td>4</td>\n<td></td>\n</tr>\n<tr>\n<td>5</td>\n<td></td>\n<td></td>\n</tr>\n</tbody>\n</table>", "pipetables|advanced");
}
// **Rule #2**
// A pipe table ends after a blank line or the end of the file.
//
// **Rule #3**
// A cell content is trimmed (start and end) from white-spaces.
[Test]
public void ExtensionsPipeTable_Example008()
{
// Example 8
// Section: Extensions / Pipe Table
//
// The following Markdown:
// a | b |
// -- | --
// 0 | 1 |
//
// Should be rendered as:
// <table>
// <thead>
// <tr>
// <th>a</th>
// <th>b</th>
// </tr>
// </thead>
// <tbody>
// <tr>
// <td>0</td>
// <td>1</td>
// </tr>
// </tbody>
// </table>
Console.WriteLine("Example 8\nSection Extensions / Pipe Table\n");
TestParser.TestSpec("a | b |\n-- | --\n0 | 1 |", "<table>\n<thead>\n<tr>\n<th>a</th>\n<th>b</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>0</td>\n<td>1</td>\n</tr>\n</tbody>\n</table>", "pipetables|advanced");
}
// **Rule #4**
// Column delimiters `|` at the very beginning of a line or just before a line ending with only spaces and/or terminated by a newline can be omitted
[Test]
public void ExtensionsPipeTable_Example009()
{
// Example 9
// Section: Extensions / Pipe Table
//
// The following Markdown:
// a | b |
// -- | --
// | 0 | 1
// | 2 | 3 |
// 4 | 5
//
// Should be rendered as:
// <table>
// <thead>
// <tr>
// <th>a</th>
// <th>b</th>
// </tr>
// </thead>
// <tbody>
// <tr>
// <td>0</td>
// <td>1</td>
// </tr>
// <tr>
// <td>2</td>
// <td>3</td>
// </tr>
// <tr>
// <td>4</td>
// <td>5</td>
// </tr>
// </tbody>
// </table>
Console.WriteLine("Example 9\nSection Extensions / Pipe Table\n");
TestParser.TestSpec(" a | b |\n-- | --\n| 0 | 1\n| 2 | 3 |\n 4 | 5 ", "<table>\n<thead>\n<tr>\n<th>a</th>\n<th>b</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>0</td>\n<td>1</td>\n</tr>\n<tr>\n<td>2</td>\n<td>3</td>\n</tr>\n<tr>\n<td>4</td>\n<td>5</td>\n</tr>\n</tbody>\n</table>", "pipetables|advanced");
}
// A pipe may be present at both the beginning/ending of each line:
[Test]
public void ExtensionsPipeTable_Example010()
{
// Example 10
// Section: Extensions / Pipe Table
//
// The following Markdown:
// |a|b|
// |-|-|
// |0|1|
//
// Should be rendered as:
// <table>
// <thead>
// <tr>
// <th>a</th>
// <th>b</th>
// </tr>
// </thead>
// <tbody>
// <tr>
// <td>0</td>
// <td>1</td>
// </tr>
// </tbody>
// </table>
Console.WriteLine("Example 10\nSection Extensions / Pipe Table\n");
TestParser.TestSpec("|a|b|\n|-|-|\n|0|1|", "<table>\n<thead>\n<tr>\n<th>a</th>\n<th>b</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>0</td>\n<td>1</td>\n</tr>\n</tbody>\n</table>", "pipetables|advanced");
}
// Or may be ommitted on one side:
[Test]
public void ExtensionsPipeTable_Example011()
{
// Example 11
// Section: Extensions / Pipe Table
//
// The following Markdown:
// a|b|
// -|-|
// 0|1|
//
// Should be rendered as:
// <table>
// <thead>
// <tr>
// <th>a</th>
// <th>b</th>
// </tr>
// </thead>
// <tbody>
// <tr>
// <td>0</td>
// <td>1</td>
// </tr>
// </tbody>
// </table>
Console.WriteLine("Example 11\nSection Extensions / Pipe Table\n");
TestParser.TestSpec("a|b|\n-|-|\n0|1|", "<table>\n<thead>\n<tr>\n<th>a</th>\n<th>b</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>0</td>\n<td>1</td>\n</tr>\n</tbody>\n</table>", "pipetables|advanced");
}
[Test]
public void ExtensionsPipeTable_Example012()
{
// Example 12
// Section: Extensions / Pipe Table
//
// The following Markdown:
// |a|b
// |-|-
// |0|1
//
// Should be rendered as:
// <table>
// <thead>
// <tr>
// <th>a</th>
// <th>b</th>
// </tr>
// </thead>
// <tbody>
// <tr>
// <td>0</td>
// <td>1</td>
// </tr>
// </tbody>
// </table>
Console.WriteLine("Example 12\nSection Extensions / Pipe Table\n");
TestParser.TestSpec("|a|b\n|-|-\n|0|1", "<table>\n<thead>\n<tr>\n<th>a</th>\n<th>b</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>0</td>\n<td>1</td>\n</tr>\n</tbody>\n</table>", "pipetables|advanced");
}
// Single column table can be declared with lines starting only by a column delimiter:
[Test]
public void ExtensionsPipeTable_Example013()
{
// Example 13
// Section: Extensions / Pipe Table
//
// The following Markdown:
// | a
// | --
// | b
// | c
//
// Should be rendered as:
// <table>
// <thead>
// <tr>
// <th>a</th>
// </tr>
// </thead>
// <tbody>
// <tr>
// <td>b</td>
// </tr>
// <tr>
// <td>c</td>
// </tr>
// </tbody>
// </table>
Console.WriteLine("Example 13\nSection Extensions / Pipe Table\n");
TestParser.TestSpec("| a\n| --\n| b\n| c ", "<table>\n<thead>\n<tr>\n<th>a</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>b</td>\n</tr>\n<tr>\n<td>c</td>\n</tr>\n</tbody>\n</table>", "pipetables|advanced");
}
// **Rule #5**
//
// The first row is considered as a **header row** if it is separated from the regular rows by a row containing a **header column separator** for each column. A header column separator is:
//
// - starting by optional spaces
// - followed by an optional `:` to specify left align
// - followed by a sequence of at least one `-` character
// - followed by an optional `:` to specify right align (or center align if left align is also defined)
// - ending by optional spaces
[Test]
public void ExtensionsPipeTable_Example014()
{
// Example 14
// Section: Extensions / Pipe Table
//
// The following Markdown:
// a | b
// -------|-------
// 0 | 1
// 2 | 3
//
// Should be rendered as:
// <table>
// <thead>
// <tr>
// <th>a</th>
// <th>b</th>
// </tr>
// </thead>
// <tbody>
// <tr>
// <td>0</td>
// <td>1</td>
// </tr>
// <tr>
// <td>2</td>
// <td>3</td>
// </tr>
// </tbody>
// </table>
Console.WriteLine("Example 14\nSection Extensions / Pipe Table\n");
TestParser.TestSpec(" a | b \n-------|-------\n 0 | 1 \n 2 | 3 ", "<table>\n<thead>\n<tr>\n<th>a</th>\n<th>b</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>0</td>\n<td>1</td>\n</tr>\n<tr>\n<td>2</td>\n<td>3</td>\n</tr>\n</tbody>\n</table>", "pipetables|advanced");
}
// The text alignment is defined by default to be center for header and left for cells. If the left alignment is applied, it will force the column heading to be left aligned.
// There is no way to define a different alignment for heading and cells (apart from the default).
// The text alignment can be changed by using the character `:` with the header column separator:
[Test]
public void ExtensionsPipeTable_Example015()
{
// Example 15
// Section: Extensions / Pipe Table
//
// The following Markdown:
// a | b | c
// :------|:-------:| ----:
// 0 | 1 | 2
// 3 | 4 | 5
//
// Should be rendered as:
// <table>
// <thead>
// <tr>
// <th style="text-align: left;">a</th>
// <th style="text-align: center;">b</th>
// <th style="text-align: right;">c</th>
// </tr>
// </thead>
// <tbody>
// <tr>
// <td style="text-align: left;">0</td>
// <td style="text-align: center;">1</td>
// <td style="text-align: right;">2</td>
// </tr>
// <tr>
// <td style="text-align: left;">3</td>
// <td style="text-align: center;">4</td>
// <td style="text-align: right;">5</td>
// </tr>
// </tbody>
// </table>
Console.WriteLine("Example 15\nSection Extensions / Pipe Table\n");
TestParser.TestSpec(" a | b | c \n:------|:-------:| ----:\n 0 | 1 | 2 \n 3 | 4 | 5 ", "<table>\n<thead>\n<tr>\n<th style=\"text-align: left;\">a</th>\n<th style=\"text-align: center;\">b</th>\n<th style=\"text-align: right;\">c</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td style=\"text-align: left;\">0</td>\n<td style=\"text-align: center;\">1</td>\n<td style=\"text-align: right;\">2</td>\n</tr>\n<tr>\n<td style=\"text-align: left;\">3</td>\n<td style=\"text-align: center;\">4</td>\n<td style=\"text-align: right;\">5</td>\n</tr>\n</tbody>\n</table>", "pipetables|advanced");
}
// Test alignment with starting and ending pipes:
[Test]
public void ExtensionsPipeTable_Example016()
{
// Example 16
// Section: Extensions / Pipe Table
//
// The following Markdown:
// | abc | def | ghi |
// |:---:|-----|----:|
// | 1 | 2 | 3 |
//
// Should be rendered as:
// <table>
// <thead>
// <tr>
// <th style="text-align: center;">abc</th>
// <th>def</th>
// <th style="text-align: right;">ghi</th>
// </tr>
// </thead>
// <tbody>
// <tr>
// <td style="text-align: center;">1</td>
// <td>2</td>
// <td style="text-align: right;">3</td>
// </tr>
// </tbody>
// </table>
Console.WriteLine("Example 16\nSection Extensions / Pipe Table\n");
TestParser.TestSpec("| abc | def | ghi |\n|:---:|-----|----:|\n| 1 | 2 | 3 |", "<table>\n<thead>\n<tr>\n<th style=\"text-align: center;\">abc</th>\n<th>def</th>\n<th style=\"text-align: right;\">ghi</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td style=\"text-align: center;\">1</td>\n<td>2</td>\n<td style=\"text-align: right;\">3</td>\n</tr>\n</tbody>\n</table>", "pipetables|advanced");
}
// The following example shows a non matching header column separator:
[Test]
public void ExtensionsPipeTable_Example017()
{
// Example 17
// Section: Extensions / Pipe Table
//
// The following Markdown:
// a | b
// -------|---x---
// 0 | 1
// 2 | 3
//
// Should be rendered as:
// <p>a | b
// -------|---x---
// 0 | 1
// 2 | 3</p>
Console.WriteLine("Example 17\nSection Extensions / Pipe Table\n");
TestParser.TestSpec(" a | b\n-------|---x---\n 0 | 1\n 2 | 3 ", "<p>a | b\n-------|---x---\n0 | 1\n2 | 3</p> ", "pipetables|advanced");
}
// **Rule #6**
//
// A column delimiter has a higher priority than emphasis delimiter
[Test]
public void ExtensionsPipeTable_Example018()
{
// Example 18
// Section: Extensions / Pipe Table
//
// The following Markdown:
// *a* | b
// ----- |-----
// 0 | _1_
// _2 | 3*
//
// Should be rendered as:
// <table>
// <thead>
// <tr>
// <th><em>a</em></th>
// <th>b</th>
// </tr>
// </thead>
// <tbody>
// <tr>
// <td>0</td>
// <td><em>1</em></td>
// </tr>
// <tr>
// <td>_2</td>
// <td>3*</td>
// </tr>
// </tbody>
// </table>
Console.WriteLine("Example 18\nSection Extensions / Pipe Table\n");
TestParser.TestSpec(" *a* | b\n----- |-----\n 0 | _1_\n _2 | 3* ", "<table>\n<thead>\n<tr>\n<th><em>a</em></th>\n<th>b</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>0</td>\n<td><em>1</em></td>\n</tr>\n<tr>\n<td>_2</td>\n<td>3*</td>\n</tr>\n</tbody>\n</table>", "pipetables|advanced");
}
// **Rule #7**
//
// A backstick/code delimiter has a higher precedence than a column delimiter `|`:
[Test]
public void ExtensionsPipeTable_Example019()
{
// Example 19
// Section: Extensions / Pipe Table
//
// The following Markdown:
// a | b `
// 0 | `
//
// Should be rendered as:
// <p>a | b <code>0 |</code></p>
Console.WriteLine("Example 19\nSection Extensions / Pipe Table\n");
TestParser.TestSpec("a | b `\n0 | ` ", "<p>a | b <code>0 |</code></p> ", "pipetables|advanced");
}
// **Rule #7**
//
// A HTML inline has a higher precedence than a column delimiter `|`:
[Test]
public void ExtensionsPipeTable_Example020()
{
// Example 20
// Section: Extensions / Pipe Table
//
// The following Markdown:
// a <a href="" title="|"></a> | b
// -- | --
// 0 | 1
//
// Should be rendered as:
// <table>
// <thead>
// <tr>
// <th>a <a href="" title="|"></a></th>
// <th>b</th>
// </tr>
// </thead>
// <tbody>
// <tr>
// <td>0</td>
// <td>1</td>
// </tr>
// </tbody>
// </table>
Console.WriteLine("Example 20\nSection Extensions / Pipe Table\n");
TestParser.TestSpec("a <a href=\"\" title=\"|\"></a> | b\n-- | --\n0 | 1", "<table>\n<thead>\n<tr>\n<th>a <a href=\"\" title=\"|\"></a></th>\n<th>b</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>0</td>\n<td>1</td>\n</tr>\n</tbody>\n</table>", "pipetables|advanced");
}
// **Rule #8**
//
// Links have a higher precedence than the column delimiter character `|`:
[Test]
public void ExtensionsPipeTable_Example021()
{
// Example 21
// Section: Extensions / Pipe Table
//
// The following Markdown:
// a | b
// -- | --
// [This is a link with a | inside the label](http://google.com) | 1
//
// Should be rendered as:
// <table>
// <thead>
// <tr>
// <th>a</th>
// <th>b</th>
// </tr>
// </thead>
// <tbody>
// <tr>
// <td><a href="http://google.com">This is a link with a | inside the label</a></td>
// <td>1</td>
// </tr>
// </tbody>
// </table>
Console.WriteLine("Example 21\nSection Extensions / Pipe Table\n");
TestParser.TestSpec("a | b\n-- | --\n[This is a link with a | inside the label](http://google.com) | 1", "<table>\n<thead>\n<tr>\n<th>a</th>\n<th>b</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><a href=\"http://google.com\">This is a link with a | inside the label</a></td>\n<td>1</td>\n</tr>\n</tbody>\n</table>", "pipetables|advanced");
}
// ** Rule #9**
//
// It is possible to have a single row header only:
[Test]
public void ExtensionsPipeTable_Example022()
{
// Example 22
// Section: Extensions / Pipe Table
//
// The following Markdown:
// a | b
// -- | --
//
// Should be rendered as:
// <table>
// <thead>
// <tr>
// <th>a</th>
// <th>b</th>
// </tr>
// </thead>
// </table>
Console.WriteLine("Example 22\nSection Extensions / Pipe Table\n");
TestParser.TestSpec("a | b\n-- | --", "<table>\n<thead>\n<tr>\n<th>a</th>\n<th>b</th>\n</tr>\n</thead>\n</table>", "pipetables|advanced");
}
[Test]
public void ExtensionsPipeTable_Example023()
{
// Example 23
// Section: Extensions / Pipe Table
//
// The following Markdown:
// |a|b|c
// |---|---|---|
//
// Should be rendered as:
// <table>
// <thead>
// <tr>
// <th>a</th>
// <th>b</th>
// <th>c</th>
// </tr>
// </thead>
// </table>
Console.WriteLine("Example 23\nSection Extensions / Pipe Table\n");
TestParser.TestSpec("|a|b|c\n|---|---|---|", "<table>\n<thead>\n<tr>\n<th>a</th>\n<th>b</th>\n<th>c</th>\n</tr>\n</thead>\n</table>", "pipetables|advanced");
}
// ** Tests **
//
// Tests trailing spaces after pipes
[Test]
public void ExtensionsPipeTable_Example024()
{
// Example 24
// Section: Extensions / Pipe Table
//
// The following Markdown:
// | abc | def |
// |---|---|
// | cde| ddd|
// | eee| fff|
// | fff | fffff |
// |gggg | ffff |
//
// Should be rendered as:
// <table>
// <thead>
// <tr>
// <th>abc</th>
// <th>def</th>
// </tr>
// </thead>
// <tbody>
// <tr>
// <td>cde</td>
// <td>ddd</td>
// </tr>
// <tr>
// <td>eee</td>
// <td>fff</td>
// </tr>
// <tr>
// <td>fff</td>
// <td>fffff</td>
// </tr>
// <tr>
// <td>gggg</td>
// <td>ffff</td>
// </tr>
// </tbody>
// </table>
Console.WriteLine("Example 24\nSection Extensions / Pipe Table\n");
TestParser.TestSpec("| abc | def | \n|---|---|\n| cde| ddd| \n| eee| fff|\n| fff | fffff | \n|gggg | ffff | ", "<table>\n<thead>\n<tr>\n<th>abc</th>\n<th>def</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>cde</td>\n<td>ddd</td>\n</tr>\n<tr>\n<td>eee</td>\n<td>fff</td>\n</tr>\n<tr>\n<td>fff</td>\n<td>fffff</td>\n</tr>\n<tr>\n<td>gggg</td>\n<td>ffff</td>\n</tr>\n</tbody>\n</table>", "pipetables|advanced");
}
// ** Normalized columns count **
//
// The tables are normalized to the maximum number of columns found in a table
[Test]
public void ExtensionsPipeTable_Example025()
{
// Example 25
// Section: Extensions / Pipe Table
//
// The following Markdown:
// a | b
// -- | -
// 0 | 1 | 2
//
// Should be rendered as:
// <table>
// <thead>
// <tr>
// <th>a</th>
// <th>b</th>
// <th></th>
// </tr>
// </thead>
// <tbody>
// <tr>
// <td>0</td>
// <td>1</td>
// <td>2</td>
// </tr>
// </tbody>
// </table>
Console.WriteLine("Example 25\nSection Extensions / Pipe Table\n");
TestParser.TestSpec("a | b\n-- | - \n0 | 1 | 2", "<table>\n<thead>\n<tr>\n<th>a</th>\n<th>b</th>\n<th></th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>0</td>\n<td>1</td>\n<td>2</td>\n</tr>\n</tbody>\n</table>", "pipetables|advanced");
}
}
}

View File

@@ -0,0 +1,336 @@
// Generated: 21. 01. 2019 14:26:34
// --------------------------------
// Smarty Pants
// --------------------------------
using System;
using NUnit.Framework;
namespace Markdig.Tests.Specs.SmartyPants
{
[TestFixture]
public class TestExtensionsSmartyPantsQuotes
{
// # Extensions
//
// Adds support for smarty pants:
//
// ## SmartyPants Quotes
//
// Converts the following character to smarty pants:
[Test]
public void ExtensionsSmartyPantsQuotes_Example001()
{
// Example 1
// Section: Extensions / SmartyPants Quotes
//
// The following Markdown:
// This is a "text"
//
// Should be rendered as:
// <p>This is a &ldquo;text&rdquo;</p>
Console.WriteLine("Example 1\nSection Extensions / SmartyPants Quotes\n");
TestParser.TestSpec("This is a \"text\"", "<p>This is a &ldquo;text&rdquo;</p>", "pipetables+smartypants|advanced+smartypants");
}
[Test]
public void ExtensionsSmartyPantsQuotes_Example002()
{
// Example 2
// Section: Extensions / SmartyPants Quotes
//
// The following Markdown:
// This is a 'text'
//
// Should be rendered as:
// <p>This is a &lsquo;text&rsquo;</p>
Console.WriteLine("Example 2\nSection Extensions / SmartyPants Quotes\n");
TestParser.TestSpec("This is a 'text'", "<p>This is a &lsquo;text&rsquo;</p>", "pipetables+smartypants|advanced+smartypants");
}
[Test]
public void ExtensionsSmartyPantsQuotes_Example003()
{
// Example 3
// Section: Extensions / SmartyPants Quotes
//
// The following Markdown:
// This is a <<text>>
//
// Should be rendered as:
// <p>This is a &laquo;text&raquo;</p>
Console.WriteLine("Example 3\nSection Extensions / SmartyPants Quotes\n");
TestParser.TestSpec("This is a <<text>>", "<p>This is a &laquo;text&raquo;</p>", "pipetables+smartypants|advanced+smartypants");
}
// Unbalanced quotes are not changed:
[Test]
public void ExtensionsSmartyPantsQuotes_Example004()
{
// Example 4
// Section: Extensions / SmartyPants Quotes
//
// The following Markdown:
// This is a "text
//
// Should be rendered as:
// <p>This is a &quot;text</p>
Console.WriteLine("Example 4\nSection Extensions / SmartyPants Quotes\n");
TestParser.TestSpec("This is a \"text", "<p>This is a &quot;text</p>", "pipetables+smartypants|advanced+smartypants");
}
[Test]
public void ExtensionsSmartyPantsQuotes_Example005()
{
// Example 5
// Section: Extensions / SmartyPants Quotes
//
// The following Markdown:
// This is a 'text
//
// Should be rendered as:
// <p>This is a 'text</p>
Console.WriteLine("Example 5\nSection Extensions / SmartyPants Quotes\n");
TestParser.TestSpec("This is a 'text", "<p>This is a 'text</p>", "pipetables+smartypants|advanced+smartypants");
}
[Test]
public void ExtensionsSmartyPantsQuotes_Example006()
{
// Example 6
// Section: Extensions / SmartyPants Quotes
//
// The following Markdown:
// This is a <<text
//
// Should be rendered as:
// <p>This is a &lt;&lt;text</p>
Console.WriteLine("Example 6\nSection Extensions / SmartyPants Quotes\n");
TestParser.TestSpec("This is a <<text", "<p>This is a &lt;&lt;text</p>", "pipetables+smartypants|advanced+smartypants");
}
// Unbalanced quotes inside other quotes are not changed:
[Test]
public void ExtensionsSmartyPantsQuotes_Example007()
{
// Example 7
// Section: Extensions / SmartyPants Quotes
//
// The following Markdown:
// This is a "text 'with" a another text'
//
// Should be rendered as:
// <p>This is a &ldquo;text 'with&rdquo; a another text'</p>
Console.WriteLine("Example 7\nSection Extensions / SmartyPants Quotes\n");
TestParser.TestSpec("This is a \"text 'with\" a another text'", "<p>This is a &ldquo;text 'with&rdquo; a another text'</p>", "pipetables+smartypants|advanced+smartypants");
}
[Test]
public void ExtensionsSmartyPantsQuotes_Example008()
{
// Example 8
// Section: Extensions / SmartyPants Quotes
//
// The following Markdown:
// This is a 'text <<with' a another text>>
//
// Should be rendered as:
// <p>This is a &lsquo;text &lt;&lt;with&rsquo; a another text&gt;&gt;</p>
Console.WriteLine("Example 8\nSection Extensions / SmartyPants Quotes\n");
TestParser.TestSpec("This is a 'text <<with' a another text>>", "<p>This is a &lsquo;text &lt;&lt;with&rsquo; a another text&gt;&gt;</p>", "pipetables+smartypants|advanced+smartypants");
}
[Test]
public void ExtensionsSmartyPantsQuotes_Example009()
{
// Example 9
// Section: Extensions / SmartyPants Quotes
//
// The following Markdown:
// This is a <<text 'with>> a another text'
//
// Should be rendered as:
// <p>This is a &laquo;text 'with&raquo; a another text'</p>
Console.WriteLine("Example 9\nSection Extensions / SmartyPants Quotes\n");
TestParser.TestSpec("This is a <<text 'with>> a another text'", "<p>This is a &laquo;text 'with&raquo; a another text'</p>", "pipetables+smartypants|advanced+smartypants");
}
// Quotes requires to have the same rules than emphasis `_` regarding left/right frankling rules:
[Test]
public void ExtensionsSmartyPantsQuotes_Example010()
{
// Example 10
// Section: Extensions / SmartyPants Quotes
//
// The following Markdown:
// It's not quotes'
//
// Should be rendered as:
// <p>It's not quotes'</p>
Console.WriteLine("Example 10\nSection Extensions / SmartyPants Quotes\n");
TestParser.TestSpec("It's not quotes'", "<p>It's not quotes'</p>", "pipetables+smartypants|advanced+smartypants");
}
[Test]
public void ExtensionsSmartyPantsQuotes_Example011()
{
// Example 11
// Section: Extensions / SmartyPants Quotes
//
// The following Markdown:
// They are ' not matching quotes '
//
// Should be rendered as:
// <p>They are ' not matching quotes '</p>
Console.WriteLine("Example 11\nSection Extensions / SmartyPants Quotes\n");
TestParser.TestSpec("They are ' not matching quotes '", "<p>They are ' not matching quotes '</p>", "pipetables+smartypants|advanced+smartypants");
}
[Test]
public void ExtensionsSmartyPantsQuotes_Example012()
{
// Example 12
// Section: Extensions / SmartyPants Quotes
//
// The following Markdown:
// They are' not matching 'quotes
//
// Should be rendered as:
// <p>They are' not matching 'quotes</p>
Console.WriteLine("Example 12\nSection Extensions / SmartyPants Quotes\n");
TestParser.TestSpec("They are' not matching 'quotes", "<p>They are' not matching 'quotes</p>", "pipetables+smartypants|advanced+smartypants");
}
// An emphasis starting inside left/right quotes will span over the right quote:
[Test]
public void ExtensionsSmartyPantsQuotes_Example013()
{
// Example 13
// Section: Extensions / SmartyPants Quotes
//
// The following Markdown:
// This is "a *text" with an emphasis*
//
// Should be rendered as:
// <p>This is &ldquo;a <em>text&rdquo; with an emphasis</em></p>
Console.WriteLine("Example 13\nSection Extensions / SmartyPants Quotes\n");
TestParser.TestSpec("This is \"a *text\" with an emphasis*", "<p>This is &ldquo;a <em>text&rdquo; with an emphasis</em></p>", "pipetables+smartypants|advanced+smartypants");
}
}
[TestFixture]
public class TestExtensionsSmartyPantsSeparators
{
// ## SmartyPants Separators
[Test]
public void ExtensionsSmartyPantsSeparators_Example014()
{
// Example 14
// Section: Extensions / SmartyPants Separators
//
// The following Markdown:
// This is a -- text
//
// Should be rendered as:
// <p>This is a &ndash; text</p>
Console.WriteLine("Example 14\nSection Extensions / SmartyPants Separators\n");
TestParser.TestSpec("This is a -- text", "<p>This is a &ndash; text</p>", "pipetables+smartypants|advanced+smartypants");
}
[Test]
public void ExtensionsSmartyPantsSeparators_Example015()
{
// Example 15
// Section: Extensions / SmartyPants Separators
//
// The following Markdown:
// This is a --- text
//
// Should be rendered as:
// <p>This is a &mdash; text</p>
Console.WriteLine("Example 15\nSection Extensions / SmartyPants Separators\n");
TestParser.TestSpec("This is a --- text", "<p>This is a &mdash; text</p>", "pipetables+smartypants|advanced+smartypants");
}
[Test]
public void ExtensionsSmartyPantsSeparators_Example016()
{
// Example 16
// Section: Extensions / SmartyPants Separators
//
// The following Markdown:
// This is a en ellipsis...
//
// Should be rendered as:
// <p>This is a en ellipsis&hellip;</p>
Console.WriteLine("Example 16\nSection Extensions / SmartyPants Separators\n");
TestParser.TestSpec("This is a en ellipsis...", "<p>This is a en ellipsis&hellip;</p>", "pipetables+smartypants|advanced+smartypants");
}
// Check that a smartypants are not breaking pipetable parsing:
[Test]
public void ExtensionsSmartyPantsSeparators_Example017()
{
// Example 17
// Section: Extensions / SmartyPants Separators
//
// The following Markdown:
// a | b
// -- | --
// 0 | 1
//
// Should be rendered as:
// <table>
// <thead>
// <tr>
// <th>a</th>
// <th>b</th>
// </tr>
// </thead>
// <tbody>
// <tr>
// <td>0</td>
// <td>1</td>
// </tr>
// </tbody>
// </table>
Console.WriteLine("Example 17\nSection Extensions / SmartyPants Separators\n");
TestParser.TestSpec("a | b\n-- | --\n0 | 1", "<table>\n<thead>\n<tr>\n<th>a</th>\n<th>b</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>0</td>\n<td>1</td>\n</tr>\n</tbody>\n</table>", "pipetables+smartypants|advanced+smartypants");
}
// Check quotes and dash:
[Test]
public void ExtensionsSmartyPantsSeparators_Example018()
{
// Example 18
// Section: Extensions / SmartyPants Separators
//
// The following Markdown:
// A "quote" with a ---
//
// Should be rendered as:
// <p>A &ldquo;quote&rdquo; with a &mdash;</p>
Console.WriteLine("Example 18\nSection Extensions / SmartyPants Separators\n");
TestParser.TestSpec("A \"quote\" with a ---", "<p>A &ldquo;quote&rdquo; with a &mdash;</p>", "pipetables+smartypants|advanced+smartypants");
}
}
}

View File

@@ -0,0 +1,63 @@
// Generated: 21. 01. 2019 14:26:34
// --------------------------------
// Task Lists
// --------------------------------
using System;
using NUnit.Framework;
namespace Markdig.Tests.Specs.TaskLists
{
[TestFixture]
public class TestExtensionsTaskLists
{
// # Extensions
//
// Adds support for task lists:
//
// ## TaskLists
//
// A task list item consist of `[ ]` or `[x]` or `[X]` inside a list item (ordered or unordered)
[Test]
public void ExtensionsTaskLists_Example001()
{
// Example 1
// Section: Extensions / TaskLists
//
// The following Markdown:
// - [ ] Item1
// - [x] Item2
// - [ ] Item3
// - Item4
//
// Should be rendered as:
// <ul class="contains-task-list">
// <li class="task-list-item"><input disabled="disabled" type="checkbox" /> Item1</li>
// <li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> Item2</li>
// <li class="task-list-item"><input disabled="disabled" type="checkbox" /> Item3</li>
// <li>Item4</li>
// </ul>
Console.WriteLine("Example 1\nSection Extensions / TaskLists\n");
TestParser.TestSpec("- [ ] Item1\n- [x] Item2\n- [ ] Item3\n- Item4", "<ul class=\"contains-task-list\">\n<li class=\"task-list-item\"><input disabled=\"disabled\" type=\"checkbox\" /> Item1</li>\n<li class=\"task-list-item\"><input disabled=\"disabled\" type=\"checkbox\" checked=\"checked\" /> Item2</li>\n<li class=\"task-list-item\"><input disabled=\"disabled\" type=\"checkbox\" /> Item3</li>\n<li>Item4</li>\n</ul>", "tasklists|advanced");
}
// A task is not recognized outside a list item:
[Test]
public void ExtensionsTaskLists_Example002()
{
// Example 2
// Section: Extensions / TaskLists
//
// The following Markdown:
// [ ] This is not a task list
//
// Should be rendered as:
// <p>[ ] This is not a task list</p>
Console.WriteLine("Example 2\nSection Extensions / TaskLists\n");
TestParser.TestSpec("[ ] This is not a task list", "<p>[ ] This is not a task list</p>", "tasklists|advanced");
}
}
}

View File

@@ -0,0 +1,214 @@
// Generated: 21. 01. 2019 14:26:34
// --------------------------------
// Yaml
// --------------------------------
using System;
using NUnit.Framework;
namespace Markdig.Tests.Specs.Yaml
{
[TestFixture]
public class TestExtensionsYAMLFrontmatterDiscard
{
// # Extensions
//
// Adds support for YAML frontmatter parsing:
//
// ## YAML frontmatter discard
//
// If a frontmatter is present, it will not be rendered:
[Test]
public void ExtensionsYAMLFrontmatterDiscard_Example001()
{
// Example 1
// Section: Extensions / YAML frontmatter discard
//
// The following Markdown:
// ---
// this: is a frontmatter
// ---
// This is a text
//
// Should be rendered as:
// <p>This is a text</p>
Console.WriteLine("Example 1\nSection Extensions / YAML frontmatter discard\n");
TestParser.TestSpec("---\nthis: is a frontmatter\n---\nThis is a text", "<p>This is a text</p>", "yaml");
}
// But if a frontmatter doesn't happen on the first line, it will be parse as regular Markdown content
[Test]
public void ExtensionsYAMLFrontmatterDiscard_Example002()
{
// Example 2
// Section: Extensions / YAML frontmatter discard
//
// The following Markdown:
// This is a text1
// ---
// this: is a frontmatter
// ---
// This is a text2
//
// Should be rendered as:
// <h2>This is a text1</h2>
// <h2>this: is a frontmatter</h2>
// <p>This is a text2</p>
Console.WriteLine("Example 2\nSection Extensions / YAML frontmatter discard\n");
TestParser.TestSpec("This is a text1\n---\nthis: is a frontmatter\n---\nThis is a text2", "<h2>This is a text1</h2>\n<h2>this: is a frontmatter</h2>\n<p>This is a text2</p>", "yaml");
}
// It expects an exact 3 dashes `---`:
[Test]
public void ExtensionsYAMLFrontmatterDiscard_Example003()
{
// Example 3
// Section: Extensions / YAML frontmatter discard
//
// The following Markdown:
// ----
// this: is a frontmatter
// ----
// This is a text
//
// Should be rendered as:
// <hr />
// <h2>this: is a frontmatter</h2>
// <p>This is a text</p>
Console.WriteLine("Example 3\nSection Extensions / YAML frontmatter discard\n");
TestParser.TestSpec("----\nthis: is a frontmatter\n----\nThis is a text", "<hr />\n<h2>this: is a frontmatter</h2>\n<p>This is a text</p>", "yaml");
}
// It can end with three dots `...`:
[Test]
public void ExtensionsYAMLFrontmatterDiscard_Example004()
{
// Example 4
// Section: Extensions / YAML frontmatter discard
//
// The following Markdown:
// ---
// this: is a frontmatter
//
// ...
// This is a text
//
// Should be rendered as:
// <p>This is a text</p>
Console.WriteLine("Example 4\nSection Extensions / YAML frontmatter discard\n");
TestParser.TestSpec("---\nthis: is a frontmatter\n\n...\nThis is a text", "<p>This is a text</p>", "yaml");
}
// If the end front matter marker (`...` or `---`) is not present, it will render the `---` has a `<hr>`:
[Test]
public void ExtensionsYAMLFrontmatterDiscard_Example005()
{
// Example 5
// Section: Extensions / YAML frontmatter discard
//
// The following Markdown:
// ---
// this: is a frontmatter
// This is a text
//
// Should be rendered as:
// <hr />
// <p>this: is a frontmatter
// This is a text</p>
Console.WriteLine("Example 5\nSection Extensions / YAML frontmatter discard\n");
TestParser.TestSpec("---\nthis: is a frontmatter\nThis is a text", "<hr />\n<p>this: is a frontmatter\nThis is a text</p>", "yaml");
}
// It expects exactly three dots `...`:
[Test]
public void ExtensionsYAMLFrontmatterDiscard_Example006()
{
// Example 6
// Section: Extensions / YAML frontmatter discard
//
// The following Markdown:
// ---
// this: is a frontmatter
// ....
// This is a text
//
// Should be rendered as:
// <hr />
// <p>this: is a frontmatter
// ....
// This is a text</p>
Console.WriteLine("Example 6\nSection Extensions / YAML frontmatter discard\n");
TestParser.TestSpec("---\nthis: is a frontmatter\n....\nThis is a text", "<hr />\n<p>this: is a frontmatter\n....\nThis is a text</p>", "yaml");
}
// Front matter ends with the first line containing three dots `...` or three dashes `---`:
[Test]
public void ExtensionsYAMLFrontmatterDiscard_Example007()
{
// Example 7
// Section: Extensions / YAML frontmatter discard
//
// The following Markdown:
// ---
// this: is a frontmatter
// ....
//
// Hello
// ---
// This is a text
//
// Should be rendered as:
// <p>This is a text</p>
Console.WriteLine("Example 7\nSection Extensions / YAML frontmatter discard\n");
TestParser.TestSpec("---\nthis: is a frontmatter\n....\n\nHello\n---\nThis is a text", "<p>This is a text</p>", "yaml");
}
// It expects whitespace can exist after the leading characters
[Test]
public void ExtensionsYAMLFrontmatterDiscard_Example008()
{
// Example 8
// Section: Extensions / YAML frontmatter discard
//
// The following Markdown:
// ---
// this: is a frontmatter
// ...
// This is a text
//
// Should be rendered as:
// <p>This is a text</p>
Console.WriteLine("Example 8\nSection Extensions / YAML frontmatter discard\n");
TestParser.TestSpec("--- \nthis: is a frontmatter\n...\nThis is a text", "<p>This is a text</p>", "yaml");
}
// It expects whitespace can exist after the trailing characters
[Test]
public void ExtensionsYAMLFrontmatterDiscard_Example009()
{
// Example 9
// Section: Extensions / YAML frontmatter discard
//
// The following Markdown:
// ---
// this: is a frontmatter
// ...
// This is a text
//
// Should be rendered as:
// <p>This is a text</p>
Console.WriteLine("Example 9\nSection Extensions / YAML frontmatter discard\n");
TestParser.TestSpec("---\nthis: is a frontmatter\n... \nThis is a text", "<p>This is a text</p>", "yaml");
}
}
}