From 1f03f9f5da70ebc6179520f0501af50506852fae Mon Sep 17 00:00:00 2001 From: VinsWorldcom Date: Wed, 17 Nov 2021 11:15:27 -0500 Subject: [PATCH 1/3] drop "Npp" from output filename => MarkdownPanel.dll --- NppMarkdownPanel/Main.cs | 2 +- NppMarkdownPanel/NppMarkdownPanel.csproj | 2 +- makerelease.ps1 | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/NppMarkdownPanel/Main.cs b/NppMarkdownPanel/Main.cs index 4c63ceb..ffa65c2 100644 --- a/NppMarkdownPanel/Main.cs +++ b/NppMarkdownPanel/Main.cs @@ -4,7 +4,7 @@ namespace NppMarkdownPanel { class Main { - public const string PluginName = "NppMarkdownPanel"; + public const string PluginName = "MarkdownPanel"; public const string PluginTitle = "Markdown Panel"; private static MarkdownPanelController mdpanel = new MarkdownPanelController(); diff --git a/NppMarkdownPanel/NppMarkdownPanel.csproj b/NppMarkdownPanel/NppMarkdownPanel.csproj index f2fe75c..8c00193 100644 --- a/NppMarkdownPanel/NppMarkdownPanel.csproj +++ b/NppMarkdownPanel/NppMarkdownPanel.csproj @@ -7,7 +7,7 @@ Library Properties NppMarkdownPanel - NppMarkdownPanel + MarkdownPanel bin\Debug\ v4.5 diff --git a/makerelease.ps1 b/makerelease.ps1 index 7fc2a27..7a11839 100644 --- a/makerelease.ps1 +++ b/makerelease.ps1 @@ -4,5 +4,5 @@ function makeReleaseZip($filename, $targetPlattform) Compress-Archive -LiteralPath $filename, 'README.md', 'License.txt', "NppMarkdownPanel\style.css" -DestinationPath $zipName -Force } -makeReleaseZip "NppMarkdownPanel\bin\Release\NppMarkdownPanel.dll" "x86" -makeReleaseZip "NppMarkdownPanel\bin\Release-x64\NppMarkdownPanel.dll" "x64" \ No newline at end of file +makeReleaseZip "NppMarkdownPanel\bin\Release\MarkdownPanel.dll" "x86" +makeReleaseZip "NppMarkdownPanel\bin\Release-x64\MarkdownPanel.dll" "x64" \ No newline at end of file From 7c32287ec5dd69c1edc9d3c03322e5ee8eb1d9cf Mon Sep 17 00:00:00 2001 From: VinsWorldcom Date: Thu, 18 Nov 2021 13:35:24 -0500 Subject: [PATCH 2/3] version bump --- NppMarkdownPanel/Forms/MainResources.resx | 2 +- NppMarkdownPanel/Properties/AssemblyInfo.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/NppMarkdownPanel/Forms/MainResources.resx b/NppMarkdownPanel/Forms/MainResources.resx index 3079dc7..25ae18c 100644 --- a/NppMarkdownPanel/Forms/MainResources.resx +++ b/NppMarkdownPanel/Forms/MainResources.resx @@ -123,7 +123,7 @@ NppMarkdownPanel for Notepad++ -Version 0.6.3.1 +Version 0.6.5.1 Created by Mohzy 2019 Github: https://github.com/mohzy83/NppMarkdownPanel diff --git a/NppMarkdownPanel/Properties/AssemblyInfo.cs b/NppMarkdownPanel/Properties/AssemblyInfo.cs index 644cfc1..cc6b351 100644 --- a/NppMarkdownPanel/Properties/AssemblyInfo.cs +++ b/NppMarkdownPanel/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.6.4.*")] -[assembly: AssemblyFileVersion("0.6.4.1")] +[assembly: AssemblyVersion("0.6.5.*")] +[assembly: AssemblyFileVersion("0.6.5.1")] From c49c5f0eef267a6052468b8eda49dbf269efc1ae Mon Sep 17 00:00:00 2001 From: VinsWorldcom Date: Mon, 17 Jan 2022 19:06:00 -0500 Subject: [PATCH 3/3] Use markdig in nuget, use Fody to package - Thanks @kilbyjmichael --- NppMarkdownPanel/FodyWeavers.xml | 3 + NppMarkdownPanel/FodyWeavers.xsd | 141 ++ NppMarkdownPanel/Forms/MainResources.resx | 6 +- .../Extensions/Abbreviations/Abbreviation.cs | 42 - .../Abbreviations/AbbreviationExtension.cs | 30 - .../Abbreviations/AbbreviationHelper.cs | 42 - .../Abbreviations/AbbreviationInline.cs | 35 - .../Abbreviations/AbbreviationParser.cs | 225 -- .../Abbreviations/HtmlAbbreviationRenderer.cs | 30 - .../AutoIdentifierExtension.cs | 199 -- .../AutoIdentifiers/AutoIdentifierOptions.cs | 39 - .../HeadingLinkReferenceDefinition.cs | 19 - .../Extensions/AutoLinks/AutoLinkExtension.cs | 42 - .../Extensions/AutoLinks/AutoLinkParser.cs | 257 -- .../AutoLinks/NormalizeAutoLinkRenderer.cs | 29 - .../Bootstrap/BootstrapExtension.cs | 63 - .../Extensions/Citations/CitationExtension.cs | 49 - .../CustomContainers/CustomContainer.cs | 32 - .../CustomContainerExtension.cs | 58 - .../CustomContainers/CustomContainerInline.cs | 16 - .../CustomContainers/CustomContainerParser.cs | 30 - .../HtmlCustomContainerInlineRenderer.cs | 22 - .../HtmlCustomContainerRenderer.cs | 24 - .../DefinitionLists/DefinitionItem.cs | 26 - .../DefinitionLists/DefinitionList.cs | 23 - .../DefinitionListExtension.cs | 35 - .../DefinitionLists/DefinitionListParser.cs | 197 -- .../DefinitionLists/DefinitionTerm.cs | 24 - .../HtmlDefinitionListRenderer.cs | 85 - .../Extensions/Diagrams/DiagramExtension.cs | 32 - .../Extensions/Emoji/EmojiExtension.cs | 35 - .../Markdig/Extensions/Emoji/EmojiInline.cs | 39 - .../Markdig/Extensions/Emoji/EmojiParser.cs | 1074 -------- .../EmphasisExtras/EmphasisExtraExtension.cs | 124 - .../EmphasisExtras/EmphasisExtraOptions.cs | 45 - .../Markdig/Extensions/Figures/Figure.cs | 33 - .../Extensions/Figures/FigureBlockParser.cs | 131 - .../Extensions/Figures/FigureCaption.cs | 24 - .../Extensions/Figures/FigureExtension.cs | 42 - .../Figures/HtmlFigureCaptionRenderer.cs | 23 - .../Extensions/Figures/HtmlFigureRenderer.cs | 23 - .../Markdig/Extensions/Footers/FooterBlock.cs | 29 - .../Extensions/Footers/FooterBlockParser.cs | 88 - .../Extensions/Footers/FooterExtension.cs | 41 - .../Extensions/Footers/HtmlFooterRenderer.cs | 26 - .../Markdig/Extensions/Footnotes/Footnote.cs | 44 - .../Extensions/Footnotes/FootnoteExtension.cs | 33 - .../Extensions/Footnotes/FootnoteGroup.cs | 25 - .../Extensions/Footnotes/FootnoteLink.cs | 29 - .../FootnoteLinkReferenceDefinition.cs | 19 - .../Extensions/Footnotes/FootnoteParser.cs | 212 -- .../Footnotes/HtmlFootnoteGroupRenderer.cs | 46 - .../Footnotes/HtmlFootnoteLinkRenderer.cs | 36 - .../GenericAttributesExtension.cs | 76 - .../GenericAttributesParser.cs | 278 --- .../Globalization/GlobalizationExtension.cs | 108 - .../SoftlineBreakAsHardlineExtension.cs | 31 - .../Markdig/Extensions/JiraLinks/JiraLink.cs | 31 - .../Extensions/JiraLinks/JiraLinkExtension.cs | 45 - .../JiraLinks/JiraLinkInlineParser.cs | 115 - .../Extensions/JiraLinks/JiraLinkOptions.cs | 57 - .../JiraLinks/NormalizeJiraLinksRenderer.cs | 18 - .../ListExtras/ListExtraExtension.cs | 29 - .../ListExtras/ListExtraItemParser.cs | 82 - .../Mathematics/HtmlMathBlockRenderer.cs | 25 - .../Mathematics/HtmlMathInlineRenderer.cs | 22 - .../Extensions/Mathematics/MathBlock.cs | 23 - .../Extensions/Mathematics/MathBlockParser.cs | 62 - .../Extensions/Mathematics/MathExtension.cs | 48 - .../Extensions/Mathematics/MathInline.cs | 31 - .../Mathematics/MathInlineParser.cs | 193 -- .../MediaLinks/MediaLinkExtension.cs | 226 -- .../Extensions/MediaLinks/MediaOptions.cs | 95 - .../NoRefLinks/NoFollowLinksExtension.cs | 34 - .../NonAsciiNoEscapeExtension.cs | 27 - .../PragmaLines/PragmaLineExtension.cs | 79 - .../SelfPipeline/SelfPipelineExtension.cs | 99 - .../SmartyPants/HtmlSmartyPantRenderer.cs | 41 - .../Extensions/SmartyPants/SmartyPant.cs | 49 - .../SmartyPants/SmartyPantOptions.cs | 40 - .../Extensions/SmartyPants/SmartyPantType.cs | 66 - .../SmartyPants/SmartyPantsExtension.cs | 50 - .../SmartyPants/SmartyPantsInlineParser.cs | 380 --- .../Extensions/Tables/GridTableExtension.cs | 31 - .../Extensions/Tables/GridTableParser.cs | 366 --- .../Extensions/Tables/GridTableState.cs | 74 - .../Extensions/Tables/HtmlTableRenderer.cs | 138 - .../Extensions/Tables/PipeTableBlockParser.cs | 69 - .../Tables/PipeTableDelimiterInline.cs | 29 - .../Extensions/Tables/PipeTableExtension.cs | 53 - .../Extensions/Tables/PipeTableOptions.cs | 24 - .../Extensions/Tables/PipeTableParser.cs | 653 ----- .../Markdig/Extensions/Tables/Table.cs | 101 - .../Markdig/Extensions/Tables/TableCell.cs | 55 - .../Extensions/Tables/TableColumnAlign.cs | 26 - .../Tables/TableColumnDefinition.cs | 22 - .../Markdig/Extensions/Tables/TableHelper.cs | 113 - .../Markdig/Extensions/Tables/TableRow.cs | 26 - .../TaskLists/HtmlTaskListRenderer.cs | 35 - .../TaskLists/NormalizeTaskListRenderer.cs | 14 - .../Markdig/Extensions/TaskLists/TaskList.cs | 17 - .../Extensions/TaskLists/TaskListExtension.cs | 40 - .../TaskLists/TaskListInlineParser.cs | 90 - .../TextRenderer/ConfigureNewLineExtension.cs | 34 - .../Extensions/Yaml/YamlFrontMatterBlock.cs | 23 - .../Yaml/YamlFrontMatterExtension.cs | 33 - .../Extensions/Yaml/YamlFrontMatterParser.cs | 166 -- .../Yaml/YamlFrontMatterRenderer.cs | 19 - .../Markdig/Helpers/ArrayHelper.cs | 17 - .../Markdig/Helpers/CharHelper.cs | 759 ------ .../Markdig/Helpers/CharNormalizer.cs | 1304 ---------- .../Markdig/Helpers/CharacterMap.cs | 163 -- .../Markdig/Helpers/CompactPrefixTree.cs | 1221 --------- .../Markdig/Helpers/DefaultObjectCache.cs | 22 - .../Markdig/Helpers/EntityHelper.cs | 2212 ----------------- .../Markdig/Helpers/HtmlHelper.cs | 650 ----- .../Markdig/Helpers/ICharIterator.cs | 52 - .../Markdig/Helpers/LineReader.cs | 71 - .../Markdig/Helpers/LinkHelper.cs | 954 ------- .../Helpers/MethodImplOptionPortable.cs | 15 - .../Markdig/Helpers/ObjectCache.cs | 80 - .../Markdig/Helpers/OrderedList.cs | 140 -- .../Markdig/Helpers/StringBuilderCache.cs | 43 - .../Helpers/StringBuilderExtensions.cs | 23 - .../Markdig/Helpers/StringLine.cs | 85 - .../Markdig/Helpers/StringLineGroup.cs | 333 --- .../Markdig/Helpers/StringSlice.cs | 375 --- .../Markdig/Helpers/ThrowHelper.cs | 90 - .../Markdig/IMarkdownExtension.cs | 27 - NppMarkdownPanel/Markdig/Markdown.cs | 214 -- .../Markdig/MarkdownExtensions.cs | 620 ----- .../Markdig/MarkdownParserContext.cs | 23 - NppMarkdownPanel/Markdig/MarkdownPipeline.cs | 67 - .../Markdig/MarkdownPipelineBuilder.cs | 132 - .../Markdig/Parsers/BlockParser.cs | 90 - .../Markdig/Parsers/BlockParserList.cs | 23 - .../Markdig/Parsers/BlockProcessor.cs | 896 ------- .../Markdig/Parsers/BlockState.cs | 42 - .../Markdig/Parsers/BlockStateExtensions.cs | 47 - .../Markdig/Parsers/FencedBlockParserBase.cs | 231 -- .../Markdig/Parsers/FencedCodeBlockParser.cs | 50 - .../Markdig/Parsers/HeadingBlockParser.cs | 146 -- .../Markdig/Parsers/HtmlBlockParser.cs | 352 --- .../Markdig/Parsers/IAttributesParseable.cs | 30 - .../Markdig/Parsers/IBlockParser.cs | 46 - .../Markdig/Parsers/IInlineParser.cs | 23 - .../Markdig/Parsers/IMarkdownParser.cs | 27 - .../Markdig/Parsers/IPostInlineProcessor.cs | 25 - .../Parsers/IndentedCodeBlockParser.cs | 85 - .../Markdig/Parsers/InlineParser.cs | 23 - .../Markdig/Parsers/InlineParserList.cs | 34 - .../Markdig/Parsers/InlineProcessor.cs | 333 --- .../Parsers/Inlines/AutolineInlineParser.cs | 73 - .../Parsers/Inlines/CodeInlineParser.cs | 122 - .../Parsers/Inlines/EmphasisDescriptor.cs | 53 - .../Parsers/Inlines/EmphasisInlineParser.cs | 415 ---- .../Parsers/Inlines/EscapeInlineParser.cs | 60 - .../Parsers/Inlines/HtmlEntityParser.cs | 82 - .../Parsers/Inlines/LineBreakInlineParser.cs | 54 - .../Parsers/Inlines/LinkInlineParser.cs | 345 --- .../Parsers/Inlines/LiteralInlineParser.cs | 103 - .../Markdig/Parsers/ListBlockParser.cs | 374 --- NppMarkdownPanel/Markdig/Parsers/ListInfo.cs | 59 - .../Markdig/Parsers/ListItemParser.cs | 26 - .../Markdig/Parsers/MarkdownParser.cs | 220 -- .../Markdig/Parsers/NumberedListItemParser.cs | 64 - .../Markdig/Parsers/OrderedListItemParser.cs | 47 - .../Markdig/Parsers/ParagraphBlockParser.cs | 180 -- .../Markdig/Parsers/ParserBase.cs | 31 - .../Markdig/Parsers/ParserList.cs | 133 - .../Markdig/Parsers/QuoteBlockParser.cs | 77 - .../Markdig/Parsers/ThematicBreakParser.cs | 98 - .../Parsers/UnorderedListItemParser.cs | 27 - .../Renderers/Html/CodeBlockRenderer.cs | 94 - .../Markdig/Renderers/Html/HeadingRenderer.cs | 45 - .../Markdig/Renderers/Html/HtmlAttributes.cs | 192 -- .../Renderers/Html/HtmlBlockRenderer.cs | 19 - .../Renderers/Html/HtmlObjectRenderer.cs | 16 - .../Html/Inlines/AutolinkInlineRenderer.cs | 48 - .../Html/Inlines/CodeInlineRenderer.cs | 27 - .../Html/Inlines/DelimiterInlineRenderer.cs | 20 - .../Html/Inlines/EmphasisInlineRenderer.cs | 65 - .../Html/Inlines/HtmlEntityInlineRenderer.cs | 19 - .../Html/Inlines/HtmlInlineRenderer.cs | 22 - .../Html/Inlines/LineBreakInlineRenderer.cs | 32 - .../Html/Inlines/LinkInlineRenderer.cs | 76 - .../Html/Inlines/LiteralInlineRenderer.cs | 19 - .../Markdig/Renderers/Html/ListRenderer.cs | 74 - .../Renderers/Html/ParagraphRenderer.cs | 37 - .../Renderers/Html/QuoteBlockRenderer.cs | 32 - .../Renderers/Html/ThematicBreakRenderer.cs | 22 - .../Markdig/Renderers/HtmlRenderer.cs | 364 --- .../Renderers/IMarkdownObjectRenderer.cs | 29 - .../Markdig/Renderers/IMarkdownRenderer.cs | 38 - .../Renderers/MarkdownObjectRenderer.cs | 59 - .../Renderers/Normalize/CodeBlockRenderer.cs | 55 - .../Renderers/Normalize/HeadingRenderer.cs | 36 - .../Renderers/Normalize/HtmlBlockRenderer.cs | 16 - .../Inlines/AutolinkInlineRenderer.cs | 19 - .../Normalize/Inlines/CodeInlineRenderer.cs | 23 - .../Inlines/DelimiterInlineRenderer.cs | 20 - .../Inlines/EmphasisInlineRenderer.cs | 22 - .../Inlines/LineBreakInlineRenderer.cs | 28 - .../Normalize/Inlines/LinkInlineRenderer.cs | 60 - .../Inlines/LiteralInlineRenderer.cs | 25 - .../NormalizeHtmlEntityInlineRenderer.cs | 18 - .../Inlines/NormalizeHtmlInlineRenderer.cs | 18 - .../LinkReferenceDefinitionGroupRenderer.cs | 18 - .../LinkReferenceDefinitionRenderer.cs | 28 - .../Renderers/Normalize/ListRenderer.cs | 93 - .../Normalize/NormalizeObjectRenderer.cs | 16 - .../Renderers/Normalize/NormalizeOptions.cs | 54 - .../Renderers/Normalize/NormalizeRenderer.cs | 161 -- .../Renderers/Normalize/ParagraphRenderer.cs | 20 - .../Renderers/Normalize/QuoteBlockRenderer.cs | 24 - .../Normalize/ThematicBreakRenderer.cs | 21 - .../Renderers/ObjectRendererCollection.cs | 15 - .../Markdig/Renderers/RendererBase.cs | 165 -- .../Markdig/Renderers/TextRendererBase.cs | 264 -- .../Markdig/Syntax/BlankLineBlock.cs | 21 - NppMarkdownPanel/Markdig/Syntax/Block.cs | 93 - .../Markdig/Syntax/BlockExtensions.cs | 138 - .../Markdig/Syntax/CharIteratorHelper.cs | 27 - NppMarkdownPanel/Markdig/Syntax/CodeBlock.cs | 24 - .../Markdig/Syntax/ContainerBlock.cs | 279 --- .../Markdig/Syntax/FencedCodeBlock.cs | 57 - .../Markdig/Syntax/HeadingBlock.cs | 34 - NppMarkdownPanel/Markdig/Syntax/HtmlBlock.cs | 27 - .../Markdig/Syntax/HtmlBlockType.cs | 46 - NppMarkdownPanel/Markdig/Syntax/IBlock.cs | 60 - .../Markdig/Syntax/IFencedBlock.cs | 34 - .../Markdig/Syntax/IMarkdownObject.cs | 43 - .../Markdig/Syntax/Inlines/AutolinkInline.cs | 31 - .../Markdig/Syntax/Inlines/CodeInline.cs | 26 - .../Markdig/Syntax/Inlines/ContainerInline.cs | 275 -- .../Markdig/Syntax/Inlines/DelimiterInline.cs | 59 - .../Markdig/Syntax/Inlines/DelimiterType.cs | 29 - .../Syntax/Inlines/EmphasisDelimiterInline.cs | 62 - .../Markdig/Syntax/Inlines/EmphasisInline.cs | 38 - .../Syntax/Inlines/HtmlEntityInline.cs | 26 - .../Markdig/Syntax/Inlines/HtmlInline.cs | 21 - .../Markdig/Syntax/Inlines/IInline.cs | 32 - .../Markdig/Syntax/Inlines/Inline.cs | 293 --- .../Markdig/Syntax/Inlines/LeafInline.cs | 13 - .../Markdig/Syntax/Inlines/LineBreakInline.cs | 16 - .../Syntax/Inlines/LinkDelimiterInline.cs | 38 - .../Markdig/Syntax/Inlines/LinkInline.cs | 97 - .../Markdig/Syntax/Inlines/LiteralInline.cs | 61 - NppMarkdownPanel/Markdig/Syntax/LeafBlock.cs | 77 - .../Markdig/Syntax/LinkReferenceDefinition.cs | 119 - .../LinkReferenceDefinitionExtensions.cs | 58 - .../Syntax/LinkReferenceDefinitionGroup.cs | 47 - NppMarkdownPanel/Markdig/Syntax/ListBlock.cs | 56 - .../Markdig/Syntax/ListItemBlock.cs | 29 - .../Markdig/Syntax/MarkdownDocument.cs | 32 - .../Markdig/Syntax/MarkdownObject.cs | 177 -- .../Syntax/MarkdownObjectExtensions.cs | 119 - .../Markdig/Syntax/ParagraphBlock.cs | 35 - NppMarkdownPanel/Markdig/Syntax/QuoteBlock.cs | 27 - NppMarkdownPanel/Markdig/Syntax/SourceSpan.cs | 85 - .../Markdig/Syntax/ThematicBreakBlock.cs | 25 - NppMarkdownPanel/MarkdigMarkdownGenerator.cs | 4 +- NppMarkdownPanel/NppMarkdownPanel.csproj | 402 ++- NppMarkdownPanel/Properties/AssemblyInfo.cs | 2 +- NppMarkdownPanel/app.config | 11 + NppMarkdownPanel/packages.config | 56 + 266 files changed, 362 insertions(+), 29192 deletions(-) create mode 100644 NppMarkdownPanel/FodyWeavers.xml create mode 100644 NppMarkdownPanel/FodyWeavers.xsd delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Abbreviations/Abbreviation.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Abbreviations/AbbreviationExtension.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Abbreviations/AbbreviationHelper.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Abbreviations/AbbreviationInline.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Abbreviations/AbbreviationParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Abbreviations/HtmlAbbreviationRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/AutoIdentifiers/AutoIdentifierExtension.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/AutoIdentifiers/AutoIdentifierOptions.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/AutoIdentifiers/HeadingLinkReferenceDefinition.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/AutoLinks/AutoLinkExtension.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/AutoLinks/AutoLinkParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/AutoLinks/NormalizeAutoLinkRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Bootstrap/BootstrapExtension.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Citations/CitationExtension.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/CustomContainers/CustomContainer.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/CustomContainers/CustomContainerExtension.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/CustomContainers/CustomContainerInline.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/CustomContainers/CustomContainerParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/CustomContainers/HtmlCustomContainerInlineRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/CustomContainers/HtmlCustomContainerRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/DefinitionLists/DefinitionItem.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/DefinitionLists/DefinitionList.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/DefinitionLists/DefinitionListExtension.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/DefinitionLists/DefinitionListParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/DefinitionLists/DefinitionTerm.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/DefinitionLists/HtmlDefinitionListRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Diagrams/DiagramExtension.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Emoji/EmojiExtension.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Emoji/EmojiInline.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Emoji/EmojiParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/EmphasisExtras/EmphasisExtraExtension.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/EmphasisExtras/EmphasisExtraOptions.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Figures/Figure.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Figures/FigureBlockParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Figures/FigureCaption.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Figures/FigureExtension.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Figures/HtmlFigureCaptionRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Figures/HtmlFigureRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Footers/FooterBlock.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Footers/FooterBlockParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Footers/FooterExtension.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Footers/HtmlFooterRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Footnotes/Footnote.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Footnotes/FootnoteExtension.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Footnotes/FootnoteGroup.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Footnotes/FootnoteLink.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Footnotes/FootnoteLinkReferenceDefinition.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Footnotes/FootnoteParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Footnotes/HtmlFootnoteGroupRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Footnotes/HtmlFootnoteLinkRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/GenericAttributes/GenericAttributesExtension.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/GenericAttributes/GenericAttributesParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Globalization/GlobalizationExtension.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Hardlines/SoftlineBreakAsHardlineExtension.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/JiraLinks/JiraLink.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/JiraLinks/JiraLinkExtension.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/JiraLinks/JiraLinkInlineParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/JiraLinks/JiraLinkOptions.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/JiraLinks/NormalizeJiraLinksRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/ListExtras/ListExtraExtension.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/ListExtras/ListExtraItemParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Mathematics/HtmlMathBlockRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Mathematics/HtmlMathInlineRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Mathematics/MathBlock.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Mathematics/MathBlockParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Mathematics/MathExtension.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Mathematics/MathInline.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Mathematics/MathInlineParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/MediaLinks/MediaLinkExtension.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/MediaLinks/MediaOptions.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/NoRefLinks/NoFollowLinksExtension.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/NonAsciiNoEscape/NonAsciiNoEscapeExtension.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/PragmaLines/PragmaLineExtension.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/SelfPipeline/SelfPipelineExtension.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/SmartyPants/HtmlSmartyPantRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/SmartyPants/SmartyPant.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/SmartyPants/SmartyPantOptions.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/SmartyPants/SmartyPantType.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/SmartyPants/SmartyPantsExtension.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/SmartyPants/SmartyPantsInlineParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Tables/GridTableExtension.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Tables/GridTableParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Tables/GridTableState.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Tables/HtmlTableRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Tables/PipeTableBlockParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Tables/PipeTableDelimiterInline.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Tables/PipeTableExtension.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Tables/PipeTableOptions.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Tables/PipeTableParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Tables/Table.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Tables/TableCell.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Tables/TableColumnAlign.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Tables/TableColumnDefinition.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Tables/TableHelper.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Tables/TableRow.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/TaskLists/HtmlTaskListRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/TaskLists/NormalizeTaskListRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/TaskLists/TaskList.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/TaskLists/TaskListExtension.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/TaskLists/TaskListInlineParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/TextRenderer/ConfigureNewLineExtension.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Yaml/YamlFrontMatterBlock.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Yaml/YamlFrontMatterExtension.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Yaml/YamlFrontMatterParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Extensions/Yaml/YamlFrontMatterRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Helpers/ArrayHelper.cs delete mode 100644 NppMarkdownPanel/Markdig/Helpers/CharHelper.cs delete mode 100644 NppMarkdownPanel/Markdig/Helpers/CharNormalizer.cs delete mode 100644 NppMarkdownPanel/Markdig/Helpers/CharacterMap.cs delete mode 100644 NppMarkdownPanel/Markdig/Helpers/CompactPrefixTree.cs delete mode 100644 NppMarkdownPanel/Markdig/Helpers/DefaultObjectCache.cs delete mode 100644 NppMarkdownPanel/Markdig/Helpers/EntityHelper.cs delete mode 100644 NppMarkdownPanel/Markdig/Helpers/HtmlHelper.cs delete mode 100644 NppMarkdownPanel/Markdig/Helpers/ICharIterator.cs delete mode 100644 NppMarkdownPanel/Markdig/Helpers/LineReader.cs delete mode 100644 NppMarkdownPanel/Markdig/Helpers/LinkHelper.cs delete mode 100644 NppMarkdownPanel/Markdig/Helpers/MethodImplOptionPortable.cs delete mode 100644 NppMarkdownPanel/Markdig/Helpers/ObjectCache.cs delete mode 100644 NppMarkdownPanel/Markdig/Helpers/OrderedList.cs delete mode 100644 NppMarkdownPanel/Markdig/Helpers/StringBuilderCache.cs delete mode 100644 NppMarkdownPanel/Markdig/Helpers/StringBuilderExtensions.cs delete mode 100644 NppMarkdownPanel/Markdig/Helpers/StringLine.cs delete mode 100644 NppMarkdownPanel/Markdig/Helpers/StringLineGroup.cs delete mode 100644 NppMarkdownPanel/Markdig/Helpers/StringSlice.cs delete mode 100644 NppMarkdownPanel/Markdig/Helpers/ThrowHelper.cs delete mode 100644 NppMarkdownPanel/Markdig/IMarkdownExtension.cs delete mode 100644 NppMarkdownPanel/Markdig/Markdown.cs delete mode 100644 NppMarkdownPanel/Markdig/MarkdownExtensions.cs delete mode 100644 NppMarkdownPanel/Markdig/MarkdownParserContext.cs delete mode 100644 NppMarkdownPanel/Markdig/MarkdownPipeline.cs delete mode 100644 NppMarkdownPanel/Markdig/MarkdownPipelineBuilder.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/BlockParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/BlockParserList.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/BlockProcessor.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/BlockState.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/BlockStateExtensions.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/FencedBlockParserBase.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/FencedCodeBlockParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/HeadingBlockParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/HtmlBlockParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/IAttributesParseable.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/IBlockParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/IInlineParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/IMarkdownParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/IPostInlineProcessor.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/IndentedCodeBlockParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/InlineParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/InlineParserList.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/InlineProcessor.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/Inlines/AutolineInlineParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/Inlines/CodeInlineParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/Inlines/EmphasisDescriptor.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/Inlines/EmphasisInlineParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/Inlines/EscapeInlineParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/Inlines/HtmlEntityParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/Inlines/LineBreakInlineParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/Inlines/LinkInlineParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/Inlines/LiteralInlineParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/ListBlockParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/ListInfo.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/ListItemParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/MarkdownParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/NumberedListItemParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/OrderedListItemParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/ParagraphBlockParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/ParserBase.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/ParserList.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/QuoteBlockParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/ThematicBreakParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Parsers/UnorderedListItemParser.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Html/CodeBlockRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Html/HeadingRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Html/HtmlAttributes.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Html/HtmlBlockRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Html/HtmlObjectRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Html/Inlines/AutolinkInlineRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Html/Inlines/CodeInlineRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Html/Inlines/DelimiterInlineRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Html/Inlines/EmphasisInlineRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Html/Inlines/HtmlEntityInlineRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Html/Inlines/HtmlInlineRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Html/Inlines/LineBreakInlineRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Html/Inlines/LinkInlineRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Html/Inlines/LiteralInlineRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Html/ListRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Html/ParagraphRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Html/QuoteBlockRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Html/ThematicBreakRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/HtmlRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/IMarkdownObjectRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/IMarkdownRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/MarkdownObjectRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Normalize/CodeBlockRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Normalize/HeadingRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Normalize/HtmlBlockRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/AutolinkInlineRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/CodeInlineRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/DelimiterInlineRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/EmphasisInlineRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/LineBreakInlineRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/LinkInlineRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/LiteralInlineRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/NormalizeHtmlEntityInlineRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/NormalizeHtmlInlineRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Normalize/LinkReferenceDefinitionGroupRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Normalize/LinkReferenceDefinitionRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Normalize/ListRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Normalize/NormalizeObjectRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Normalize/NormalizeOptions.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Normalize/NormalizeRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Normalize/ParagraphRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Normalize/QuoteBlockRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/Normalize/ThematicBreakRenderer.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/ObjectRendererCollection.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/RendererBase.cs delete mode 100644 NppMarkdownPanel/Markdig/Renderers/TextRendererBase.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/BlankLineBlock.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/Block.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/BlockExtensions.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/CharIteratorHelper.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/CodeBlock.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/ContainerBlock.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/FencedCodeBlock.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/HeadingBlock.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/HtmlBlock.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/HtmlBlockType.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/IBlock.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/IFencedBlock.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/IMarkdownObject.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/Inlines/AutolinkInline.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/Inlines/CodeInline.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/Inlines/ContainerInline.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/Inlines/DelimiterInline.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/Inlines/DelimiterType.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/Inlines/EmphasisDelimiterInline.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/Inlines/EmphasisInline.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/Inlines/HtmlEntityInline.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/Inlines/HtmlInline.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/Inlines/IInline.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/Inlines/Inline.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/Inlines/LeafInline.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/Inlines/LineBreakInline.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/Inlines/LinkDelimiterInline.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/Inlines/LinkInline.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/Inlines/LiteralInline.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/LeafBlock.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/LinkReferenceDefinition.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/LinkReferenceDefinitionExtensions.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/LinkReferenceDefinitionGroup.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/ListBlock.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/ListItemBlock.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/MarkdownDocument.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/MarkdownObject.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/MarkdownObjectExtensions.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/ParagraphBlock.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/QuoteBlock.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/SourceSpan.cs delete mode 100644 NppMarkdownPanel/Markdig/Syntax/ThematicBreakBlock.cs create mode 100644 NppMarkdownPanel/app.config create mode 100644 NppMarkdownPanel/packages.config diff --git a/NppMarkdownPanel/FodyWeavers.xml b/NppMarkdownPanel/FodyWeavers.xml new file mode 100644 index 0000000..5029e70 --- /dev/null +++ b/NppMarkdownPanel/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/NppMarkdownPanel/FodyWeavers.xsd b/NppMarkdownPanel/FodyWeavers.xsd new file mode 100644 index 0000000..05e92c1 --- /dev/null +++ b/NppMarkdownPanel/FodyWeavers.xsd @@ -0,0 +1,141 @@ + + + + + + + + + + + + A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks + + + + + A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks. + + + + + A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks + + + + + A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks. + + + + + A list of unmanaged 32 bit assembly names to include, delimited with line breaks. + + + + + A list of unmanaged 64 bit assembly names to include, delimited with line breaks. + + + + + The order of preloaded assemblies, delimited with line breaks. + + + + + + This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file. + + + + + Controls if .pdbs for reference assemblies are also embedded. + + + + + Controls if runtime assemblies are also embedded. + + + + + Controls whether the runtime assemblies are embedded with their full path or only with their assembly name. + + + + + Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option. + + + + + As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off. + + + + + Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code. + + + + + Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior. + + + + + A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with | + + + + + A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |. + + + + + A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with | + + + + + A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with |. + + + + + A list of unmanaged 32 bit assembly names to include, delimited with |. + + + + + A list of unmanaged 64 bit assembly names to include, delimited with |. + + + + + The order of preloaded assemblies, delimited with |. + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/NppMarkdownPanel/Forms/MainResources.resx b/NppMarkdownPanel/Forms/MainResources.resx index 25ae18c..29fe21a 100644 --- a/NppMarkdownPanel/Forms/MainResources.resx +++ b/NppMarkdownPanel/Forms/MainResources.resx @@ -121,7 +121,7 @@ style.css - NppMarkdownPanel for Notepad++ + MarkdownPanel for Notepad++ Version 0.6.5.1 @@ -134,6 +134,10 @@ Github: https://github.com/UrsineRaven/NppMarkdownPanel Updated by VinsWorldcom 2020 Github: https://github.com/VinsWorldcom/NppMarkdownPanel +Updated by kilbyjmichael 2022 +Github: https://github.com/kilbyjmichael/NppMarkdownPanel +Moved markdig to use nuget, package as one dll + Using Markdig by xoofx - https://github.com/lunet-io/markdig Using NotepadPlusPlusPluginPack.Net by kbilsted - https://github.com/kbilsted/NotepadPlusPlusPluginPack.Net diff --git a/NppMarkdownPanel/Markdig/Extensions/Abbreviations/Abbreviation.cs b/NppMarkdownPanel/Markdig/Extensions/Abbreviations/Abbreviation.cs deleted file mode 100644 index 8a40218..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Abbreviations/Abbreviation.cs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.Diagnostics; -using Markdig.Helpers; -using Markdig.Parsers; -using Markdig.Syntax; - -namespace Markdig.Extensions.Abbreviations -{ - /// - /// An abbreviation object stored at the document level. See extension methods in . - /// - /// - [DebuggerDisplay("Abbr {Label} => {Text}")] - public class Abbreviation : LeafBlock - { - /// - /// Initializes a new instance of the class. - /// - /// The parser used to create this block. - public Abbreviation(BlockParser parser) : base(parser) - { - } - - /// - /// Gets or sets the label. - /// - public string Label { get; set; } - - /// - /// The text associated to this label. - /// - public StringSlice Text; - - /// - /// The label span - /// - public SourceSpan LabelSpan; - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Abbreviations/AbbreviationExtension.cs b/NppMarkdownPanel/Markdig/Extensions/Abbreviations/AbbreviationExtension.cs deleted file mode 100644 index 268e756..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Abbreviations/AbbreviationExtension.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Renderers; - -namespace Markdig.Extensions.Abbreviations -{ - /// - /// Extension to allow abbreviations. - /// - /// - public class AbbreviationExtension : IMarkdownExtension - { - public void Setup(MarkdownPipelineBuilder pipeline) - { - pipeline.BlockParsers.AddIfNotAlready(); - } - - public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer) - { - var htmlRenderer = renderer as HtmlRenderer; - if (htmlRenderer != null && !htmlRenderer.ObjectRenderers.Contains()) - { - // Must be inserted before CodeBlockRenderer - htmlRenderer.ObjectRenderers.Insert(0, new HtmlAbbreviationRenderer()); - } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Abbreviations/AbbreviationHelper.cs b/NppMarkdownPanel/Markdig/Extensions/Abbreviations/AbbreviationHelper.cs deleted file mode 100644 index faed08a..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Abbreviations/AbbreviationHelper.cs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System; -using System.Collections.Generic; -using Markdig.Syntax; - -namespace Markdig.Extensions.Abbreviations -{ - /// - /// Extension methods for . - /// - public static class AbbreviationHelper - { - private static readonly object DocumentKey = typeof (Abbreviation); - - public static bool HasAbbreviations(this MarkdownDocument document) - { - return document.GetAbbreviations() != null; - } - - public static void AddAbbreviation(this MarkdownDocument document, string label, Abbreviation abbr) - { - if (document == null) throw new ArgumentNullException(nameof(document)); - if (label == null) throw new ArgumentNullException(nameof(label)); - if (abbr == null) throw new ArgumentNullException(nameof(abbr)); - - var map = document.GetAbbreviations(); - if (map == null) - { - map = new Dictionary(); - document.SetData(DocumentKey, map); - } - map[label] = abbr; - } - - public static Dictionary GetAbbreviations(this MarkdownDocument document) - { - return document.GetData(DocumentKey) as Dictionary; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Abbreviations/AbbreviationInline.cs b/NppMarkdownPanel/Markdig/Extensions/Abbreviations/AbbreviationInline.cs deleted file mode 100644 index 140cc92..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Abbreviations/AbbreviationInline.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.Diagnostics; -using Markdig.Syntax.Inlines; - -namespace Markdig.Extensions.Abbreviations -{ - /// - /// The inline abbreviation. - /// - /// - [DebuggerDisplay("{Abbreviation}")] - public class AbbreviationInline : LeafInline - { - /// - /// Initializes a new instance of the class. - /// - public AbbreviationInline() - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The abbreviation. - public AbbreviationInline(Abbreviation abbreviation) - { - Abbreviation = abbreviation; - } - - public Abbreviation Abbreviation { get; set; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Abbreviations/AbbreviationParser.cs b/NppMarkdownPanel/Markdig/Extensions/Abbreviations/AbbreviationParser.cs deleted file mode 100644 index d46042f..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Abbreviations/AbbreviationParser.cs +++ /dev/null @@ -1,225 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System.Collections.Generic; -using Markdig.Helpers; -using Markdig.Parsers; -using Markdig.Syntax; -using Markdig.Syntax.Inlines; - -namespace Markdig.Extensions.Abbreviations -{ - /// - /// A block parser for abbreviations. - /// - /// - public class AbbreviationParser : BlockParser - { - /// - /// Initializes a new instance of the class. - /// - public AbbreviationParser() - { - OpeningCharacters = new[] { '*' }; - } - - public override BlockState TryOpen(BlockProcessor processor) - { - if (processor.IsCodeIndent) - { - return BlockState.None; - } - - // A link must be of the form *[Some Text]: An abbreviation - var slice = processor.Line; - var startPosition = slice.Start; - var c = slice.NextChar(); - if (c != '[') - { - return BlockState.None; - } - - SourceSpan labelSpan; - if (!LinkHelper.TryParseLabel(ref slice, out string label, out labelSpan)) - { - return BlockState.None; - } - - c = slice.CurrentChar; - if (c != ':') - { - return BlockState.None; - } - slice.NextChar(); - - slice.Trim(); - - var abbr = new Abbreviation(this) - { - Label = label, - Text = slice, - Span = new SourceSpan(startPosition, slice.End), - Line = processor.LineIndex, - Column = processor.Column, - LabelSpan = labelSpan, - }; - if (!processor.Document.HasAbbreviations()) - { - processor.Document.ProcessInlinesBegin += DocumentOnProcessInlinesBegin; - } - processor.Document.AddAbbreviation(abbr.Label, abbr); - - return BlockState.BreakDiscard; - } - - private void DocumentOnProcessInlinesBegin(InlineProcessor inlineProcessor, Inline inline) - { - inlineProcessor.Document.ProcessInlinesBegin -= DocumentOnProcessInlinesBegin; - - var abbreviations = inlineProcessor.Document.GetAbbreviations(); - // Should not happen, but another extension could decide to remove them, so... - if (abbreviations == null) - { - return; - } - - // Build a text matcher from the abbreviations labels - var prefixTree = new CompactPrefixTree(abbreviations); - - inlineProcessor.LiteralInlineParser.PostMatch += (InlineProcessor processor, ref StringSlice slice) => - { - var literal = (LiteralInline)processor.Inline; - var originalLiteral = literal; - - ContainerInline container = null; - - // This is slow, but we don't have much the choice - var content = literal.Content; - var text = content.Text; - - for (int i = content.Start; i <= content.End; i++) - { - // Abbreviation must be a whole word == start at the start of a line or after a whitespace - if (i != 0) - { - for (i = i - 1; i <= content.End; i++) - { - if (text[i].IsWhitespace()) - { - i++; - goto ValidAbbreviationStart; - } - } - break; - } - - ValidAbbreviationStart:; - - if (prefixTree.TryMatchLongest(text, i, content.End - i + 1, out KeyValuePair abbreviationMatch)) - { - var match = abbreviationMatch.Key; - if (!IsValidAbbreviationEnding(match, content, i)) - { - continue; - } - - var indexAfterMatch = i + match.Length; - - // If we don't have a container, create a new one - if (container == null) - { - container = literal.Parent ?? - new ContainerInline - { - Span = originalLiteral.Span, - Line = originalLiteral.Line, - Column = originalLiteral.Column, - }; - } - - var abbrInline = new AbbreviationInline(abbreviationMatch.Value) - { - Span = - { - Start = processor.GetSourcePosition(i, out int line, out int column), - }, - Line = line, - Column = column - }; - abbrInline.Span.End = abbrInline.Span.Start + match.Length - 1; - - // Append the previous literal - if (i > content.Start && literal.Parent == null) - { - container.AppendChild(literal); - } - - literal.Span.End = abbrInline.Span.Start - 1; - // Truncate it before the abbreviation - literal.Content.End = i - 1; - - - // Append the abbreviation - container.AppendChild(abbrInline); - - // If this is the end of the string, clear the literal and exit - if (content.End == indexAfterMatch - 1) - { - literal = null; - break; - } - - // Process the remaining literal - literal = new LiteralInline() - { - Span = new SourceSpan(abbrInline.Span.End + 1, literal.Span.End), - Line = line, - Column = column + match.Length, - }; - content.Start = indexAfterMatch; - literal.Content = content; - - i = indexAfterMatch - 1; - } - } - - if (container != null) - { - if (literal != null) - { - container.AppendChild(literal); - } - processor.Inline = container; - } - }; - } - - private static bool IsValidAbbreviationEnding(string match, StringSlice content, int matchIndex) - { - // This will check if the next char at the end of the StringSlice is whitespace, punctuation or \0. - var contentNew = content; - contentNew.End = content.End + 1; - int index = matchIndex + match.Length; - while (index <= contentNew.End) - { - var c = contentNew.PeekCharAbsolute(index); - if (!(c == '\0' || c.IsWhitespace() || c.IsAsciiPunctuation())) - { - return false; - } - - if (c.IsAlphaNumeric()) - { - return false; - } - - if (c.IsWhitespace()) - { - break; - } - index++; - } - return true; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Abbreviations/HtmlAbbreviationRenderer.cs b/NppMarkdownPanel/Markdig/Extensions/Abbreviations/HtmlAbbreviationRenderer.cs deleted file mode 100644 index ec28752..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Abbreviations/HtmlAbbreviationRenderer.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Renderers; -using Markdig.Renderers.Html; - -namespace Markdig.Extensions.Abbreviations -{ - /// - /// A HTML renderer for a . - /// - /// - public class HtmlAbbreviationRenderer : HtmlObjectRenderer - { - protected override void Write(HtmlRenderer renderer, AbbreviationInline obj) - { - // HTML - var abbr = obj.Abbreviation; - if (renderer.EnableHtmlForInline) - { - renderer.Write(""); - } - renderer.Write(abbr.Label); - if (renderer.EnableHtmlForInline) - { - renderer.Write(""); - } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/AutoIdentifiers/AutoIdentifierExtension.cs b/NppMarkdownPanel/Markdig/Extensions/AutoIdentifiers/AutoIdentifierExtension.cs deleted file mode 100644 index d35e2f0..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/AutoIdentifiers/AutoIdentifierExtension.cs +++ /dev/null @@ -1,199 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.IO; -using Markdig.Helpers; -using Markdig.Parsers; -using Markdig.Renderers; -using Markdig.Renderers.Html; -using Markdig.Syntax; -using Markdig.Syntax.Inlines; - -namespace Markdig.Extensions.AutoIdentifiers -{ - /// - /// The auto-identifier extension - /// - /// - public class AutoIdentifierExtension : IMarkdownExtension - { - private const string AutoIdentifierKey = "AutoIdentifier"; - private readonly AutoIdentifierOptions options; - - /// - /// Initializes a new instance of the class. - /// - /// The options. - public AutoIdentifierExtension(AutoIdentifierOptions options) - { - this.options = options; - } - - public void Setup(MarkdownPipelineBuilder pipeline) - { - var headingBlockParser = pipeline.BlockParsers.Find(); - if (headingBlockParser != null) - { - // Install a hook on the HeadingBlockParser when a HeadingBlock is actually processed - headingBlockParser.Closed -= HeadingBlockParser_Closed; - headingBlockParser.Closed += HeadingBlockParser_Closed; - } - var paragraphBlockParser = pipeline.BlockParsers.FindExact(); - if (paragraphBlockParser != null) - { - // Install a hook on the ParagraphBlockParser when a HeadingBlock is actually processed as a Setex heading - paragraphBlockParser.Closed -= HeadingBlockParser_Closed; - paragraphBlockParser.Closed += HeadingBlockParser_Closed; - } - } - - public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer) - { - } - - /// - /// Process on a new - /// - /// The processor. - /// The heading block. - private void HeadingBlockParser_Closed(BlockProcessor processor, Block block) - { - // We may have a ParagraphBlock here as we have a hook on the ParagraphBlockParser - var headingBlock = block as HeadingBlock; - if (headingBlock == null) - { - return; - } - - // If the AutoLink options is set, we register a LinkReferenceDefinition at the document level - if ((options & AutoIdentifierOptions.AutoLink) != 0) - { - var headingLine = headingBlock.Lines.Lines[0]; - - var text = headingLine.ToString(); - - var linkRef = new HeadingLinkReferenceDefinition() - { - Heading = headingBlock, - CreateLinkInline = CreateLinkInlineForHeading - }; - - var doc = processor.Document; - var dictionary = doc.GetData(this) as Dictionary; - if (dictionary == null) - { - dictionary = new Dictionary(); - doc.SetData(this, dictionary); - doc.ProcessInlinesBegin += DocumentOnProcessInlinesBegin; - } - dictionary[text] = linkRef; - } - - // Then we register after inline have been processed to actually generate the proper #id - headingBlock.ProcessInlinesEnd += HeadingBlock_ProcessInlinesEnd; - } - - private void DocumentOnProcessInlinesBegin(InlineProcessor processor, Inline inline) - { - var doc = processor.Document; - doc.ProcessInlinesBegin -= DocumentOnProcessInlinesBegin; - var dictionary = (Dictionary)doc.GetData(this); - foreach (var keyPair in dictionary) - { - // Here we make sure that auto-identifiers will not override an existing link definition - // defined in the document - // If it is the case, we skip the auto identifier for the Heading - if (!doc.TryGetLinkReferenceDefinition(keyPair.Key, out var linkDef)) - { - doc.SetLinkReferenceDefinition(keyPair.Key, keyPair.Value); - } - } - // Once we are done, we don't need to keep the intermediate dictionary arround - doc.RemoveData(this); - } - - /// - /// Callback when there is a reference to found to a heading. - /// Note that reference are only working if they are declared after. - /// - private Inline CreateLinkInlineForHeading(InlineProcessor inlineState, LinkReferenceDefinition linkRef, Inline child) - { - var headingRef = (HeadingLinkReferenceDefinition) linkRef; - return new LinkInline() - { - // Use GetDynamicUrl to allow late binding of the Url (as a link may occur before the heading is declared and - // the inlines of the heading are actually processed by HeadingBlock_ProcessInlinesEnd) - GetDynamicUrl = () => HtmlHelper.Unescape("#" + headingRef.Heading.GetAttributes().Id), - Title = HtmlHelper.Unescape(linkRef.Title), - }; - } - - /// - /// Process the inlines of the heading to create a unique identifier - /// - /// The processor. - /// The inline. - private void HeadingBlock_ProcessInlinesEnd(InlineProcessor processor, Inline inline) - { - var identifiers = processor.Document.GetData(AutoIdentifierKey) as HashSet; - if (identifiers == null) - { - identifiers = new HashSet(); - processor.Document.SetData(AutoIdentifierKey, identifiers); - } - - var headingBlock = (HeadingBlock) processor.Block; - if (headingBlock.Inline == null) - { - return; - } - - // If id is already set, don't try to modify it - var attributes = processor.Block.GetAttributes(); - if (attributes.Id != null) - { - return; - } - - // Use internally a HtmlRenderer to strip links from a heading - var headingWriter = new StringWriter(); - var stripRenderer = new HtmlRenderer(headingWriter) - { - // Set to false both to avoid having any HTML tags in the output - EnableHtmlForInline = false, - EnableHtmlEscape = false - }; - - stripRenderer.Render(headingBlock.Inline); - var headingText = headingWriter.ToString(); - headingWriter.GetStringBuilder().Length = 0; - - // Urilize the link - headingText = (options & AutoIdentifierOptions.GitHub) != 0 - ? LinkHelper.UrilizeAsGfm(headingText) - : LinkHelper.Urilize(headingText, (options & AutoIdentifierOptions.AllowOnlyAscii) != 0); - - // If the heading is empty, use the word "section" instead - var baseHeadingId = string.IsNullOrEmpty(headingText) ? "section" : headingText; - - // Add a trailing -1, -2, -3...etc. in case of collision - int index = 0; - var headingId = baseHeadingId; - var headingBuffer = StringBuilderCache.Local(); - while (!identifiers.Add(headingId)) - { - index++; - headingBuffer.Append(baseHeadingId); - headingBuffer.Append('-'); - headingBuffer.Append(index); - headingId = headingBuffer.ToString(); - headingBuffer.Length = 0; - } - - attributes.Id = headingId; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/AutoIdentifiers/AutoIdentifierOptions.cs b/NppMarkdownPanel/Markdig/Extensions/AutoIdentifiers/AutoIdentifierOptions.cs deleted file mode 100644 index 1e5b89f..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/AutoIdentifiers/AutoIdentifierOptions.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System; - -namespace Markdig.Extensions.AutoIdentifiers -{ - /// - /// Options for the . - /// - [Flags] - public enum AutoIdentifierOptions - { - /// - /// No options: does not apply any additional formatting and/or transformations. - /// - None = 0, - - /// - /// Default () - /// - Default = AutoLink | AllowOnlyAscii, - - /// - /// Allows to link to a header by using the same text as the header for the link label. Default is true - /// - AutoLink = 1, - - /// - /// Allows only ASCII characters in the url (HTML 5 allows to have UTF8 characters). Default is true - /// - AllowOnlyAscii = 2, - - /// - /// Renders auto identifiers like GitHub. - /// - GitHub = 4, - } -} diff --git a/NppMarkdownPanel/Markdig/Extensions/AutoIdentifiers/HeadingLinkReferenceDefinition.cs b/NppMarkdownPanel/Markdig/Extensions/AutoIdentifiers/HeadingLinkReferenceDefinition.cs deleted file mode 100644 index ba6c757..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/AutoIdentifiers/HeadingLinkReferenceDefinition.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax; - -namespace Markdig.Extensions.AutoIdentifiers -{ - /// - /// A link reference definition to a stored at the level. - /// - /// - public class HeadingLinkReferenceDefinition : LinkReferenceDefinition - { - /// - /// Gets or sets the heading related to this link reference definition. - /// - public HeadingBlock Heading { get; set; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/AutoLinks/AutoLinkExtension.cs b/NppMarkdownPanel/Markdig/Extensions/AutoLinks/AutoLinkExtension.cs deleted file mode 100644 index 6fc61e7..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/AutoLinks/AutoLinkExtension.cs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Renderers; -using Markdig.Renderers.Normalize; -using Markdig.Renderers.Normalize.Inlines; - -namespace Markdig.Extensions.AutoLinks -{ - /// - /// Extension to automatically create when a link url http: or mailto: is found. - /// - /// - public class AutoLinkExtension : IMarkdownExtension - { - public readonly string ValidPreviousCharacters; - - public AutoLinkExtension(string validPreviousCharacters = AutoLinkParser.DefaultValidPreviousCharacters) - { - ValidPreviousCharacters = validPreviousCharacters; - } - - public void Setup(MarkdownPipelineBuilder pipeline) - { - if (!pipeline.InlineParsers.Contains()) - { - // Insert the parser before any other parsers - pipeline.InlineParsers.Insert(0, new AutoLinkParser(ValidPreviousCharacters)); - } - } - - public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer) - { - var normalizeRenderer = renderer as NormalizeRenderer; - if (normalizeRenderer != null && !normalizeRenderer.ObjectRenderers.Contains()) - { - normalizeRenderer.ObjectRenderers.InsertBefore(new NormalizeAutoLinkRenderer()); - } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/AutoLinks/AutoLinkParser.cs b/NppMarkdownPanel/Markdig/Extensions/AutoLinks/AutoLinkParser.cs deleted file mode 100644 index 4e5707e..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/AutoLinks/AutoLinkParser.cs +++ /dev/null @@ -1,257 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Collections.Generic; -using Markdig.Helpers; -using Markdig.Parsers; -using Markdig.Syntax.Inlines; - -namespace Markdig.Extensions.AutoLinks -{ - /// - /// The inline parser used to for autolinks. - /// - /// - public class AutoLinkParser : InlineParser - { - /// - /// Initializes a new instance of the class. - /// - public AutoLinkParser(string validPreviousCharacters = DefaultValidPreviousCharacters) - { - OpeningCharacters = new char[] - { - 'h', // for http:// and https:// - 'f', // for ftp:// - 'm', // for mailto: - 'w', // for www. - }; - - ValidPreviousCharacters = validPreviousCharacters; - } - - // All such recognized autolinks can only come at the beginning of a line, after whitespace, or any of the delimiting characters *, _, ~, and (. - public readonly string ValidPreviousCharacters; - public const string DefaultValidPreviousCharacters = "*_~("; - - public override bool Match(InlineProcessor processor, ref StringSlice slice) - { - // Previous char must be a whitespace or a punctuation - var previousChar = slice.PeekCharExtra(-1); - if (!previousChar.IsWhiteSpaceOrZero() && ValidPreviousCharacters.IndexOf(previousChar) == -1) - { - return false; - } - - List pendingEmphasis; - // Check that an autolink is possible in the current context - if (!IsAutoLinkValidInCurrentContext(processor, out pendingEmphasis)) - { - return false; - } - - var startPosition = slice.Start; - int domainOffset = 0; - - var c = slice.CurrentChar; - // Precheck URL - switch (c) - { - case 'h': - if (slice.MatchLowercase("ttp://", 1)) - { - domainOffset = 7; // http:// - } - else if (slice.MatchLowercase("ttps://", 1)) - { - domainOffset = 8; // https:// - } - else return false; - break; - case 'f': - if (!slice.MatchLowercase("tp://", 1)) - { - return false; - } - domainOffset = 6; // ftp:// - break; - case 'm': - if (!slice.MatchLowercase("ailto:", 1)) - { - return false; - } - break; - - case 'w': - if (!slice.MatchLowercase("ww.", 1)) // We won't match http:/www. or /www.xxx - { - return false; - } - domainOffset = 4; // www. - break; - } - - // Parse URL - string link; - if (!LinkHelper.TryParseUrl(ref slice, out link, true)) - { - return false; - } - - - // If we have any pending emphasis, remove any pending emphasis characters from the end of the link - if (pendingEmphasis != null) - { - for (int i = link.Length - 1; i >= 0; i--) - { - if (pendingEmphasis.Contains(link[i])) - { - slice.Start--; - } - else - { - if (i < link.Length - 1) - { - link = link.Substring(0, i + 1); - } - break; - } - } - } - - // Post-check URL - switch (c) - { - case 'h': - if (string.Equals(link, "http://", StringComparison.OrdinalIgnoreCase) || - string.Equals(link, "https://", StringComparison.OrdinalIgnoreCase)) - { - return false; - } - break; - case 'f': - if (string.Equals(link, "ftp://", StringComparison.OrdinalIgnoreCase)) - { - return false; - } - break; - case 'm': - int atIndex = link.IndexOf('@'); - if (atIndex == -1 || - atIndex == 7) // mailto:@ - no email part - { - return false; - } - domainOffset = atIndex + 1; - break; - } - - if (!LinkHelper.IsValidDomain(link, domainOffset)) - { - return false; - } - - int line; - int column; - var inline = new LinkInline() - { - Span = - { - Start = processor.GetSourcePosition(startPosition, out line, out column), - }, - Line = line, - Column = column, - Url = c == 'w' ? "http://" + link : link, - IsClosed = true, - IsAutoLink = true, - }; - - var skipFromBeginning = c == 'm' ? 7 : 0; // For mailto: skip "mailto:" for content - - inline.Span.End = inline.Span.Start + link.Length - 1; - inline.UrlSpan = inline.Span; - inline.AppendChild(new LiteralInline() - { - Span = inline.Span, - Line = line, - Column = column, - Content = new StringSlice(slice.Text, startPosition + skipFromBeginning, startPosition + link.Length - 1), - IsClosed = true - }); - processor.Inline = inline; - - return true; - } - - private bool IsAutoLinkValidInCurrentContext(InlineProcessor processor, out List pendingEmphasis) - { - pendingEmphasis = null; - - // Case where there is a pending HtmlInline - var currentInline = processor.Inline; - while (currentInline != null) - { - var htmlInline = currentInline as HtmlInline; - if (htmlInline != null) - { - // If we have a we don't expect nested - if (htmlInline.Tag.StartsWith(", we can't allow a link - if (htmlInline.Tag.StartsWith("(); - } - if (!pendingEmphasis.Contains(emphasisDelimiter.DelimiterChar)) - { - pendingEmphasis.Add(emphasisDelimiter.DelimiterChar); - } - } - } - currentInline = currentInline.Parent; - } - - return countBrackets <= 0; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/AutoLinks/NormalizeAutoLinkRenderer.cs b/NppMarkdownPanel/Markdig/Extensions/AutoLinks/NormalizeAutoLinkRenderer.cs deleted file mode 100644 index 39d1630..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/AutoLinks/NormalizeAutoLinkRenderer.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Markdig.Renderers; -using Markdig.Renderers.Normalize; -using Markdig.Syntax; -using Markdig.Syntax.Inlines; - -namespace Markdig.Extensions.AutoLinks -{ - public class NormalizeAutoLinkRenderer : NormalizeObjectRenderer - { - public override bool Accept(RendererBase renderer, MarkdownObject obj) - { - if (base.Accept(renderer, obj)) - { - var normalizeRenderer = renderer as NormalizeRenderer; - var link = obj as LinkInline; - - return normalizeRenderer != null && link != null && !normalizeRenderer.Options.ExpandAutoLinks && link.IsAutoLink; - } - else - { - return false; - } - } - protected override void Write(NormalizeRenderer renderer, LinkInline obj) - { - renderer.Write(obj.Url); - } - } -} diff --git a/NppMarkdownPanel/Markdig/Extensions/Bootstrap/BootstrapExtension.cs b/NppMarkdownPanel/Markdig/Extensions/Bootstrap/BootstrapExtension.cs deleted file mode 100644 index a3e827d..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Bootstrap/BootstrapExtension.cs +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Renderers; -using Markdig.Renderers.Html; -using Markdig.Syntax; -using Markdig.Syntax.Inlines; - -namespace Markdig.Extensions.Bootstrap -{ - /// - /// Extension for tagging some HTML elements with bootstrap classes. - /// - /// - public class BootstrapExtension : IMarkdownExtension - { - public void Setup(MarkdownPipelineBuilder pipeline) - { - // Make sure we don't have a delegate twice - pipeline.DocumentProcessed -= PipelineOnDocumentProcessed; - pipeline.DocumentProcessed += PipelineOnDocumentProcessed; - } - - public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer) - { - } - - private static void PipelineOnDocumentProcessed(MarkdownDocument document) - { - foreach(var node in document.Descendants()) - { - if (node is Block) - { - if (node is Tables.Table) - { - node.GetAttributes().AddClass("table"); - } - else if (node is QuoteBlock) - { - node.GetAttributes().AddClass("blockquote"); - } - else if (node is Figures.Figure) - { - node.GetAttributes().AddClass("figure"); - } - else if (node is Figures.FigureCaption) - { - node.GetAttributes().AddClass("figure-caption"); - } - } - else if (node is Inline) - { - var link = node as LinkInline; - if (link != null && link.IsImage) - { - link.GetAttributes().AddClass("img-fluid"); - } - } - } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Citations/CitationExtension.cs b/NppMarkdownPanel/Markdig/Extensions/Citations/CitationExtension.cs deleted file mode 100644 index 0537744..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Citations/CitationExtension.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Parsers.Inlines; -using Markdig.Renderers; -using Markdig.Renderers.Html.Inlines; -using Markdig.Syntax.Inlines; -using System.Diagnostics; - -namespace Markdig.Extensions.Citations -{ - /// - /// Extension for cite ""..."" - /// - /// - public class CitationExtension : IMarkdownExtension - { - public void Setup(MarkdownPipelineBuilder pipeline) - { - var parser = pipeline.InlineParsers.FindExact(); - if (parser != null && !parser.HasEmphasisChar('"')) - { - parser.EmphasisDescriptors.Add(new EmphasisDescriptor('"', 2, 2, false)); - } - } - - public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer) - { - if (renderer is HtmlRenderer htmlRenderer) - { - // Extend the rendering here. - var emphasisRenderer = renderer.ObjectRenderers.FindExact(); - if (emphasisRenderer != null) - { - // TODO: Use an ordered list instead as we don't know if this specific GetTag has been already added - var previousTag = emphasisRenderer.GetTag; - emphasisRenderer.GetTag = inline => GetTag(inline) ?? previousTag(inline); - } - } - } - - private static string GetTag(EmphasisInline emphasisInline) - { - Debug.Assert(emphasisInline.DelimiterCount <= 2); - return emphasisInline.DelimiterCount == 2 && emphasisInline.DelimiterChar == '"' ? "cite" : null; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/CustomContainers/CustomContainer.cs b/NppMarkdownPanel/Markdig/Extensions/CustomContainers/CustomContainer.cs deleted file mode 100644 index 8b9d41a..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/CustomContainers/CustomContainer.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Parsers; -using Markdig.Syntax; - -namespace Markdig.Extensions.CustomContainers -{ - /// - /// A block custom container. - /// - /// - /// - public class CustomContainer : ContainerBlock, IFencedBlock - { - /// - /// Initializes a new instance of the class. - /// - /// The parser used to create this block. - public CustomContainer(BlockParser parser) : base(parser) - { - } - - public string Info { get; set; } - - public string Arguments { get; set; } - - public int FencedCharCount { get; set; } - - public char FencedChar { get; set; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/CustomContainers/CustomContainerExtension.cs b/NppMarkdownPanel/Markdig/Extensions/CustomContainers/CustomContainerExtension.cs deleted file mode 100644 index 3f30fd6..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/CustomContainers/CustomContainerExtension.cs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Parsers.Inlines; -using Markdig.Renderers; - -namespace Markdig.Extensions.CustomContainers -{ - /// - /// Extension to allow custom containers. - /// - /// - public class CustomContainerExtension : IMarkdownExtension - { - public void Setup(MarkdownPipelineBuilder pipeline) - { - if (!pipeline.BlockParsers.Contains()) - { - // Insert the parser before any other parsers - pipeline.BlockParsers.Insert(0, new CustomContainerParser()); - } - - // Plug the inline parser for CustomContainerInline - var inlineParser = pipeline.InlineParsers.Find(); - if (inlineParser != null && !inlineParser.HasEmphasisChar(':')) - { - inlineParser.EmphasisDescriptors.Add(new EmphasisDescriptor(':', 2, 2, true)); - inlineParser.TryCreateEmphasisInlineList.Add((emphasisChar, delimiterCount) => - { - if (delimiterCount == 2 && emphasisChar == ':') - { - return new CustomContainerInline(); - } - return null; - }); - } - } - - public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer) - { - if (renderer is HtmlRenderer htmlRenderer) - { - if (!htmlRenderer.ObjectRenderers.Contains()) - { - // Must be inserted before CodeBlockRenderer - htmlRenderer.ObjectRenderers.Insert(0, new HtmlCustomContainerRenderer()); - } - if (!htmlRenderer.ObjectRenderers.Contains()) - { - // Must be inserted before EmphasisRenderer - htmlRenderer.ObjectRenderers.Insert(0, new HtmlCustomContainerInlineRenderer()); - } - } - - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/CustomContainers/CustomContainerInline.cs b/NppMarkdownPanel/Markdig/Extensions/CustomContainers/CustomContainerInline.cs deleted file mode 100644 index 0ea1b6f..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/CustomContainers/CustomContainerInline.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax.Inlines; - -namespace Markdig.Extensions.CustomContainers -{ - /// - /// An inline custom container - /// - /// - /// - public class CustomContainerInline : EmphasisInline - { - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/CustomContainers/CustomContainerParser.cs b/NppMarkdownPanel/Markdig/Extensions/CustomContainers/CustomContainerParser.cs deleted file mode 100644 index 879cc7c..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/CustomContainers/CustomContainerParser.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Parsers; - -namespace Markdig.Extensions.CustomContainers -{ - /// - /// The block parser for a . - /// - /// - public class CustomContainerParser : FencedBlockParserBase - { - /// - /// Initializes a new instance of the class. - /// - public CustomContainerParser() - { - OpeningCharacters = new [] {':'}; - - // We don't need a prefix - InfoPrefix = null; - } - - protected override CustomContainer CreateFencedBlock(BlockProcessor processor) - { - return new CustomContainer(this); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/CustomContainers/HtmlCustomContainerInlineRenderer.cs b/NppMarkdownPanel/Markdig/Extensions/CustomContainers/HtmlCustomContainerInlineRenderer.cs deleted file mode 100644 index e659f20..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/CustomContainers/HtmlCustomContainerInlineRenderer.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Renderers; -using Markdig.Renderers.Html; - -namespace Markdig.Extensions.CustomContainers -{ - /// - /// A HTML renderer for a . - /// - /// - public class HtmlCustomContainerInlineRenderer : HtmlObjectRenderer - { - protected override void Write(HtmlRenderer renderer, CustomContainerInline obj) - { - renderer.Write(""); - renderer.WriteChildren(obj); - renderer.Write(""); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/CustomContainers/HtmlCustomContainerRenderer.cs b/NppMarkdownPanel/Markdig/Extensions/CustomContainers/HtmlCustomContainerRenderer.cs deleted file mode 100644 index cadf633..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/CustomContainers/HtmlCustomContainerRenderer.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Renderers; -using Markdig.Renderers.Html; - -namespace Markdig.Extensions.CustomContainers -{ - /// - /// A HTML renderer for a . - /// - /// - public class HtmlCustomContainerRenderer : HtmlObjectRenderer - { - protected override void Write(HtmlRenderer renderer, CustomContainer obj) - { - renderer.EnsureLine(); - renderer.Write(""); - // We don't escape a CustomContainer - renderer.WriteChildren(obj); - renderer.WriteLine(""); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/DefinitionLists/DefinitionItem.cs b/NppMarkdownPanel/Markdig/Extensions/DefinitionLists/DefinitionItem.cs deleted file mode 100644 index ae2c79e..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/DefinitionLists/DefinitionItem.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Markdig.Parsers; -using Markdig.Syntax; - -namespace Markdig.Extensions.DefinitionLists -{ - /// - /// A definition item contains zero to multiple - /// and definitions (any ) - /// - /// - public class DefinitionItem : ContainerBlock - { - /// - /// Initializes a new instance of the class. - /// - /// The parser used to create this block. - public DefinitionItem(BlockParser parser) : base(parser) - { - } - - /// - /// Gets or sets the opening character for this definition item (either `:` or `~`) - /// - public char OpeningCharacter { get; set; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/DefinitionLists/DefinitionList.cs b/NppMarkdownPanel/Markdig/Extensions/DefinitionLists/DefinitionList.cs deleted file mode 100644 index cfaf251..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/DefinitionLists/DefinitionList.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Parsers; -using Markdig.Syntax; - -namespace Markdig.Extensions.DefinitionLists -{ - /// - /// A definition list contains children. - /// - /// - public class DefinitionList : ContainerBlock - { - /// - /// Initializes a new instance of the class. - /// - /// The parser used to create this block. - public DefinitionList(BlockParser parser) : base(parser) - { - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/DefinitionLists/DefinitionListExtension.cs b/NppMarkdownPanel/Markdig/Extensions/DefinitionLists/DefinitionListExtension.cs deleted file mode 100644 index a402234..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/DefinitionLists/DefinitionListExtension.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Renderers; - -namespace Markdig.Extensions.DefinitionLists -{ - /// - /// Extension to allow definition lists - /// - /// - public class DefinitionListExtension : IMarkdownExtension - { - public void Setup(MarkdownPipelineBuilder pipeline) - { - if (!pipeline.BlockParsers.Contains()) - { - // Insert the parser before any other parsers - pipeline.BlockParsers.Insert(0, new DefinitionListParser()); - } - } - - public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer) - { - var htmlRenderer = renderer as HtmlRenderer; - if (htmlRenderer != null) - { - if (!htmlRenderer.ObjectRenderers.Contains()) - { - htmlRenderer.ObjectRenderers.Insert(0, new HtmlDefinitionListRenderer()); - } - } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/DefinitionLists/DefinitionListParser.cs b/NppMarkdownPanel/Markdig/Extensions/DefinitionLists/DefinitionListParser.cs deleted file mode 100644 index fc8e262..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/DefinitionLists/DefinitionListParser.cs +++ /dev/null @@ -1,197 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using Markdig.Parsers; -using Markdig.Syntax; - -namespace Markdig.Extensions.DefinitionLists -{ - /// - /// The block parser for a . - /// - /// - public class DefinitionListParser : BlockParser - { - /// - /// Initializes a new instance of the class. - /// - public DefinitionListParser() - { - OpeningCharacters = new [] {':', '~'}; - } - - public override BlockState TryOpen(BlockProcessor processor) - { - var paragraphBlock = processor.LastBlock as ParagraphBlock; - if (processor.IsCodeIndent || paragraphBlock == null || paragraphBlock.LastLine - processor.LineIndex > 1) - { - return BlockState.None; - } - - var startPosition = processor.Start; - - var column = processor.ColumnBeforeIndent; - processor.NextChar(); - processor.ParseIndent(); - var delta = processor.Column - column; - - // We expect to have a least - if (delta < 4) - { - // Return back to original position - processor.GoToColumn(column); - return BlockState.None; - } - - if (delta > 4) - { - processor.GoToColumn(column + 4); - } - - var previousParent = paragraphBlock.Parent; - var currentDefinitionList = GetCurrentDefinitionList(paragraphBlock, previousParent); - - processor.Discard(paragraphBlock); - - // If the paragraph block was not part of the opened blocks, we need to remove it manually from its parent container - if (paragraphBlock.Parent != null) - { - paragraphBlock.Parent.Remove(paragraphBlock); - } - - if (currentDefinitionList == null) - { - currentDefinitionList = new DefinitionList(this) - { - Span = new SourceSpan(paragraphBlock.Span.Start, processor.Line.End), - Column = paragraphBlock.Column, - Line = paragraphBlock.Line, - }; - previousParent.Add(currentDefinitionList); - } - - var definitionItem = new DefinitionItem(this) - { - Line = processor.LineIndex, - Column = column, - Span = new SourceSpan(startPosition, processor.Line.End), - OpeningCharacter = processor.CurrentChar, - }; - - for (int i = 0; i < paragraphBlock.Lines.Count; i++) - { - var line = paragraphBlock.Lines.Lines[i]; - var term = new DefinitionTerm(this) - { - Column = paragraphBlock.Column, - Line = line.Line, - Span = new SourceSpan(paragraphBlock.Span.Start, paragraphBlock.Span.End), - IsOpen = false - }; - term.AppendLine(ref line.Slice, line.Column, line.Line, line.Position); - definitionItem.Add(term); - } - currentDefinitionList.Add(definitionItem); - processor.Open(definitionItem); - - // Update the end position - currentDefinitionList.UpdateSpanEnd(processor.Line.End); - - return BlockState.Continue; - } - - private static DefinitionList GetCurrentDefinitionList(ParagraphBlock paragraphBlock, ContainerBlock previousParent) - { - var index = previousParent.IndexOf(paragraphBlock) - 1; - if (index < 0) return null; - var lastBlock = previousParent[index]; - if (lastBlock is BlankLineBlock) - { - lastBlock = previousParent[index - 1]; - previousParent.RemoveAt(index); - } - return lastBlock as DefinitionList; - } - - public override BlockState TryContinue(BlockProcessor processor, Block block) - { - var definitionItem = (DefinitionItem)block; - if (processor.IsCodeIndent) - { - processor.GoToCodeIndent(); - return BlockState.Continue; - } - - var list = (DefinitionList)definitionItem.Parent; - var lastBlankLine = definitionItem.LastChild as BlankLineBlock; - - // Check if we have another definition list - if (Array.IndexOf(OpeningCharacters, processor.CurrentChar) >= 0) - { - var startPosition = processor.Start; - var column = processor.ColumnBeforeIndent; - processor.NextChar(); - processor.ParseIndent(); - var delta = processor.Column - column; - - // We expect to have a least - if (delta < 4) - { - // Remove the blankline before breaking this definition item - if (lastBlankLine != null) - { - definitionItem.RemoveAt(definitionItem.Count - 1); - } - - list.Span.End = list.LastChild.Span.End; - return BlockState.None; - } - - if (delta > 4) - { - processor.GoToColumn(column + 4); - } - - processor.Close(definitionItem); - var nextDefinitionItem = new DefinitionItem(this) - { - Span = new SourceSpan(startPosition, processor.Line.End), - Line = processor.LineIndex, - Column = processor.Column, - OpeningCharacter = processor.CurrentChar, - }; - list.Add(nextDefinitionItem); - processor.Open(nextDefinitionItem); - - return BlockState.Continue; - } - - var isBreakable = definitionItem.LastChild?.IsBreakable ?? true; - if (processor.IsBlankLine) - { - if (lastBlankLine == null && isBreakable) - { - definitionItem.Add(new BlankLineBlock()); - } - return isBreakable ? BlockState.ContinueDiscard : BlockState.Continue; - } - - var paragraphBlock = definitionItem.LastChild as ParagraphBlock; - if (lastBlankLine == null && paragraphBlock != null) - { - return BlockState.Continue; - } - - // Remove the blankline before breaking this definition item - if (lastBlankLine != null) - { - definitionItem.RemoveAt(definitionItem.Count - 1); - } - - list.Span.End = list.LastChild.Span.End; - return BlockState.Break; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/DefinitionLists/DefinitionTerm.cs b/NppMarkdownPanel/Markdig/Extensions/DefinitionLists/DefinitionTerm.cs deleted file mode 100644 index c837c94..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/DefinitionLists/DefinitionTerm.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Parsers; -using Markdig.Syntax; - -namespace Markdig.Extensions.DefinitionLists -{ - /// - /// A definition term contains a single line with the term to define. - /// - /// - public class DefinitionTerm : LeafBlock - { - /// - /// Initializes a new instance of the class. - /// - /// The parser used to create this block. - public DefinitionTerm(BlockParser parser) : base(parser) - { - ProcessInlines = true; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/DefinitionLists/HtmlDefinitionListRenderer.cs b/NppMarkdownPanel/Markdig/Extensions/DefinitionLists/HtmlDefinitionListRenderer.cs deleted file mode 100644 index 06b7765..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/DefinitionLists/HtmlDefinitionListRenderer.cs +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Renderers; -using Markdig.Renderers.Html; -using Markdig.Syntax; - -namespace Markdig.Extensions.DefinitionLists -{ - /// - /// A HTML renderer for , and . - /// - /// - public class HtmlDefinitionListRenderer : HtmlObjectRenderer - { - protected override void Write(HtmlRenderer renderer, DefinitionList list) - { - renderer.EnsureLine(); - renderer.Write(""); - foreach (var item in list) - { - bool hasOpendd = false; - var definitionItem = (DefinitionItem) item; - int countdd = 0; - bool lastWasSimpleParagraph = false; - for (int i = 0; i < definitionItem.Count; i++) - { - var definitionTermOrContent = definitionItem[i]; - var definitionTerm = definitionTermOrContent as DefinitionTerm; - if (definitionTerm != null) - { - if (hasOpendd) - { - if (!lastWasSimpleParagraph) - { - renderer.EnsureLine(); - } - renderer.WriteLine(""); - lastWasSimpleParagraph = false; - hasOpendd = false; - countdd = 0; - } - renderer.Write(""); - renderer.WriteLeafInline(definitionTerm); - renderer.WriteLine(""); - } - else - { - if (!hasOpendd) - { - renderer.Write(""); - countdd = 0; - hasOpendd = true; - } - - var nextTerm = i + 1 < definitionItem.Count ? definitionItem[i + 1] : null; - bool isSimpleParagraph = (nextTerm == null || nextTerm is DefinitionItem) && countdd == 0 && - definitionTermOrContent is ParagraphBlock; - - var saveImplicitParagraph = renderer.ImplicitParagraph; - if (isSimpleParagraph) - { - renderer.ImplicitParagraph = true; - lastWasSimpleParagraph = true; - } - renderer.Write(definitionTermOrContent); - renderer.ImplicitParagraph = saveImplicitParagraph; - countdd++; - } - } - if (hasOpendd) - { - if (!lastWasSimpleParagraph) - { - renderer.EnsureLine(); - } - renderer.WriteLine(""); - } - } - renderer.EnsureLine(); - renderer.WriteLine(""); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Diagrams/DiagramExtension.cs b/NppMarkdownPanel/Markdig/Extensions/Diagrams/DiagramExtension.cs deleted file mode 100644 index 484f034..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Diagrams/DiagramExtension.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Renderers; -using Markdig.Renderers.Html; - -namespace Markdig.Extensions.Diagrams -{ - /// - /// Extension to allow diagrams. - /// - /// - public class DiagramExtension : IMarkdownExtension - { - public void Setup(MarkdownPipelineBuilder pipeline) - { - } - - public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer) - { - var htmlRenderer = renderer as HtmlRenderer; - if (htmlRenderer != null) - { - var codeRenderer = htmlRenderer.ObjectRenderers.FindExact(); - // TODO: Add other well known diagram languages - codeRenderer.BlocksAsDiv.Add("mermaid"); - codeRenderer.BlocksAsDiv.Add("nomnoml"); - } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Emoji/EmojiExtension.cs b/NppMarkdownPanel/Markdig/Extensions/Emoji/EmojiExtension.cs deleted file mode 100644 index e4255d2..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Emoji/EmojiExtension.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Renderers; - -namespace Markdig.Extensions.Emoji -{ - /// - /// Extension to allow emoji and smiley replacement. - /// - /// - public class EmojiExtension : IMarkdownExtension - { - public EmojiExtension(bool enableSmiley = true) - { - EnableSmiley = enableSmiley; - } - - public bool EnableSmiley { get; set; } - - public void Setup(MarkdownPipelineBuilder pipeline) - { - if (!pipeline.InlineParsers.Contains()) - { - // Insert the parser before any other parsers - pipeline.InlineParsers.Insert(0, new EmojiParser(EnableSmiley)); - } - } - - public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer) - { - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Emoji/EmojiInline.cs b/NppMarkdownPanel/Markdig/Extensions/Emoji/EmojiInline.cs deleted file mode 100644 index 4a7a8ff..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Emoji/EmojiInline.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Helpers; -using Markdig.Syntax.Inlines; - -namespace Markdig.Extensions.Emoji -{ - /// - /// An emoji inline - /// - /// - public class EmojiInline : LiteralInline - { - // Inherit from LiteralInline so that rendering is already handled by default - - /// - /// Initializes a new instance of the class. - /// - public EmojiInline() - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The content. - public EmojiInline(string content) - { - Content = new StringSlice(content); - } - - /// - /// Gets or sets the original match string (either an emoji or a text smiley) - /// - public string Match { get; set; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Emoji/EmojiParser.cs b/NppMarkdownPanel/Markdig/Extensions/Emoji/EmojiParser.cs deleted file mode 100644 index 161d52a..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Emoji/EmojiParser.cs +++ /dev/null @@ -1,1074 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Collections.Generic; -using Markdig.Helpers; -using Markdig.Parsers; - -namespace Markdig.Extensions.Emoji -{ - /// - /// The inline parser used to for emoji. - /// - /// - public class EmojiParser : InlineParser - { - private static readonly Dictionary EmojiToUnicodeDefault; - private static readonly Dictionary SmileyToEmojiDefault; - private static readonly CompactPrefixTree EmojiPrefixTreeDefault; - private static readonly CompactPrefixTree EmojiSmileyPrefixTreeDefault; - private static readonly char[] EmojiOpeningCharactersDefault; - private static readonly char[] EmojiSmileyOpeningCharactersDefault; - - private CompactPrefixTree _emojiPrefixTree; - - /// - /// Initializes a new instance of the class. - /// - public EmojiParser(bool enableSmiley = true) - { - EnableSmiley = enableSmiley; - OpeningCharacters = null; - } - - /// - /// Gets or sets a boolean indicating whether to process smiley. - /// - public bool EnableSmiley { get; set; } - - public override void Initialize() - { - OpeningCharacters = EnableSmiley ? EmojiSmileyOpeningCharactersDefault : EmojiOpeningCharactersDefault; - _emojiPrefixTree = EnableSmiley ? EmojiSmileyPrefixTreeDefault : EmojiPrefixTreeDefault; - } - - public override bool Match(InlineProcessor processor, ref StringSlice slice) - { - // Previous char must be a space - if (!slice.PeekCharExtra(-1).IsWhiteSpaceOrZero()) - { - return false; - } - - // Try to match an emoji - if (!_emojiPrefixTree.TryMatchLongest(slice.Text, slice.Start, slice.Length, out KeyValuePair match)) - { - return false; - } - - // Push the EmojiInline - processor.Inline = new EmojiInline(match.Value) - { - Span = - { - Start = processor.GetSourcePosition(slice.Start, out int line, out int column), - }, - Line = line, - Column = column, - Match = match.Key - }; - processor.Inline.Span.End = processor.Inline.Span.Start + match.Key.Length - 1; - - // Move the cursor to the character after the matched string - slice.Start += match.Key.Length; - - return true; - } - - #region Emojis and Smileys - static EmojiParser() - { - EmojiToUnicodeDefault = new Dictionary() - { - {":100:", "💯"}, - {":1234:", "🔢"}, - {":smile:", "😄"}, - {":smiley:", "😃"}, - {":grinning:", "😀"}, - {":blush:", "😊"}, - {":relaxed:", "☺️"}, - {":wink:", "😉"}, - {":heart_eyes:", "😍"}, - {":kissing_heart:", "😘"}, - {":kissing_closed_eyes:", "😚"}, - {":kissing:", "😗"}, - {":kissing_smiling_eyes:", "😙"}, - {":stuck_out_tongue_winking_eye:", "😜"}, - {":stuck_out_tongue_closed_eyes:", "😝"}, - {":stuck_out_tongue:", "😛"}, - {":flushed:", "😳"}, - {":grin:", "😁"}, - {":pensive:", "😔"}, - {":relieved:", "😌"}, - {":unamused:", "😒"}, - {":disappointed:", "😞"}, - {":persevere:", "😣"}, - {":cry:", "😢"}, - {":joy:", "😂"}, - {":sob:", "😭"}, - {":sleepy:", "😪"}, - {":disappointed_relieved:", "😥"}, - {":cold_sweat:", "😰"}, - {":sweat_smile:", "😅"}, - {":sweat:", "😓"}, - {":weary:", "😩"}, - {":tired_face:", "😫"}, - {":fearful:", "😨"}, - {":scream:", "😱"}, - {":angry:", "😠"}, - {":rage:", "😡"}, - {":triumph:", "😤"}, - {":confounded:", "😖"}, - {":laughing:", "😆"}, - {":satisfied:", "😆"}, - {":yum:", "😋"}, - {":mask:", "😷"}, - {":sunglasses:", "😎"}, - {":sleeping:", "😴"}, - {":dizzy_face:", "😵"}, - {":astonished:", "😲"}, - {":worried:", "😟"}, - {":frowning:", "😦"}, - {":anguished:", "😧"}, - {":smiling_imp:", "😈"}, - {":imp:", "👿"}, - {":open_mouth:", "😮"}, - {":grimacing:", "😬"}, - {":neutral_face:", "😐"}, - {":confused:", "😕"}, - {":hushed:", "😯"}, - {":no_mouth:", "😶"}, - {":innocent:", "😇"}, - {":smirk:", "😏"}, - {":expressionless:", "😑"}, - {":man_with_gua_pi_mao:", "👲"}, - {":man_with_turban:", "👳"}, - {":cop:", "👮"}, - {":construction_worker:", "👷"}, - {":guardsman:", "💂"}, - {":baby:", "👶"}, - {":boy:", "👦"}, - {":girl:", "👧"}, - {":man:", "👨"}, - {":woman:", "👩"}, - {":older_man:", "👴"}, - {":older_woman:", "👵"}, - {":person_with_blond_hair:", "👱"}, - {":angel:", "👼"}, - {":princess:", "👸"}, - {":smiley_cat:", "😺"}, - {":smile_cat:", "😸"}, - {":heart_eyes_cat:", "😻"}, - {":kissing_cat:", "😽"}, - {":smirk_cat:", "😼"}, - {":scream_cat:", "🙀"}, - {":crying_cat_face:", "😿"}, - {":joy_cat:", "😹"}, - {":pouting_cat:", "😾"}, - {":japanese_ogre:", "👹"}, - {":japanese_goblin:", "👺"}, - {":see_no_evil:", "🙈"}, - {":hear_no_evil:", "🙉"}, - {":speak_no_evil:", "🙊"}, - {":skull:", "💀"}, - {":alien:", "👽"}, - {":hankey:", "💩"}, - {":poop:", "💩"}, - {":shit:", "💩"}, - {":fire:", "🔥"}, - {":sparkles:", "✨"}, - {":star2:", "🌟"}, - {":dizzy:", "💫"}, - {":boom:", "💥"}, - {":collision:", "💥"}, - {":anger:", "💢"}, - {":sweat_drops:", "💦"}, - {":droplet:", "💧"}, - {":zzz:", "💤"}, - {":dash:", "💨"}, - {":ear:", "👂"}, - {":eyes:", "👀"}, - {":nose:", "👃"}, - {":tongue:", "👅"}, - {":lips:", "👄"}, - {":+1:", "👍"}, - {":thumbsup:", "👍"}, - {":-1:", "👎"}, - {":thumbsdown:", "👎"}, - {":ok_hand:", "👌"}, - {":facepunch:", "👊"}, - {":punch:", "👊"}, - {":fist:", "✊"}, - {":v:", "✌️"}, - {":wave:", "👋"}, - {":hand:", "✋"}, - {":raised_hand:", "✋"}, - {":open_hands:", "👐"}, - {":point_up_2:", "👆"}, - {":point_down:", "👇"}, - {":point_right:", "👉"}, - {":point_left:", "👈"}, - {":raised_hands:", "🙌"}, - {":pray:", "🙏"}, - {":point_up:", "☝️"}, - {":clap:", "👏"}, - {":muscle:", "💪"}, - {":walking:", "🚶"}, - {":runner:", "🏃"}, - {":running:", "🏃"}, - {":dancer:", "💃"}, - {":couple:", "👫"}, - {":family:", "👪"}, - {":two_men_holding_hands:", "👬"}, - {":two_women_holding_hands:", "👭"}, - {":couplekiss:", "💏"}, - {":couple_with_heart:", "💑"}, - {":dancers:", "👯"}, - {":ok_woman:", "🙆"}, - {":no_good:", "🙅"}, - {":information_desk_person:", "💁"}, - {":raising_hand:", "🙋"}, - {":massage:", "💆"}, - {":haircut:", "💇"}, - {":nail_care:", "💅"}, - {":bride_with_veil:", "👰"}, - {":person_with_pouting_face:", "🙎"}, - {":person_frowning:", "🙍"}, - {":bow:", "🙇"}, - {":tophat:", "🎩"}, - {":crown:", "👑"}, - {":womans_hat:", "👒"}, - {":athletic_shoe:", "👟"}, - {":mans_shoe:", "👞"}, - {":shoe:", "👞"}, - {":sandal:", "👡"}, - {":high_heel:", "👠"}, - {":boot:", "👢"}, - {":shirt:", "👕"}, - {":tshirt:", "👕"}, - {":necktie:", "👔"}, - {":womans_clothes:", "👚"}, - {":dress:", "👗"}, - {":running_shirt_with_sash:", "🎽"}, - {":jeans:", "👖"}, - {":kimono:", "👘"}, - {":bikini:", "👙"}, - {":briefcase:", "💼"}, - {":handbag:", "👜"}, - {":pouch:", "👝"}, - {":purse:", "👛"}, - {":eyeglasses:", "👓"}, - {":ribbon:", "🎀"}, - {":closed_umbrella:", "🌂"}, - {":lipstick:", "💄"}, - {":yellow_heart:", "💛"}, - {":blue_heart:", "💙"}, - {":purple_heart:", "💜"}, - {":green_heart:", "💚"}, - {":heart:", "❤️"}, - {":broken_heart:", "💔"}, - {":heartpulse:", "💗"}, - {":heartbeat:", "💓"}, - {":two_hearts:", "💕"}, - {":sparkling_heart:", "💖"}, - {":revolving_hearts:", "💞"}, - {":cupid:", "💘"}, - {":love_letter:", "💌"}, - {":kiss:", "💋"}, - {":ring:", "💍"}, - {":gem:", "💎"}, - {":bust_in_silhouette:", "👤"}, - {":busts_in_silhouette:", "👥"}, - {":speech_balloon:", "💬"}, - {":footprints:", "👣"}, - {":thought_balloon:", "💭"}, - {":dog:", "🐶"}, - {":wolf:", "🐺"}, - {":cat:", "🐱"}, - {":mouse:", "🐭"}, - {":hamster:", "🐹"}, - {":rabbit:", "🐰"}, - {":frog:", "🐸"}, - {":tiger:", "🐯"}, - {":koala:", "🐨"}, - {":bear:", "🐻"}, - {":pig:", "🐷"}, - {":pig_nose:", "🐽"}, - {":cow:", "🐮"}, - {":boar:", "🐗"}, - {":monkey_face:", "🐵"}, - {":monkey:", "🐒"}, - {":horse:", "🐴"}, - {":sheep:", "🐑"}, - {":elephant:", "🐘"}, - {":panda_face:", "🐼"}, - {":penguin:", "🐧"}, - {":bird:", "🐦"}, - {":baby_chick:", "🐤"}, - {":hatched_chick:", "🐥"}, - {":hatching_chick:", "🐣"}, - {":chicken:", "🐔"}, - {":snake:", "🐍"}, - {":turtle:", "🐢"}, - {":bug:", "🐛"}, - {":bee:", "🐝"}, - {":honeybee:", "🐝"}, - {":ant:", "🐜"}, - {":beetle:", "🐞"}, - {":snail:", "🐌"}, - {":octopus:", "🐙"}, - {":shell:", "🐚"}, - {":tropical_fish:", "🐠"}, - {":fish:", "🐟"}, - {":dolphin:", "🐬"}, - {":flipper:", "🐬"}, - {":whale:", "🐳"}, - {":whale2:", "🐋"}, - {":cow2:", "🐄"}, - {":ram:", "🐏"}, - {":rat:", "🐀"}, - {":water_buffalo:", "🐃"}, - {":tiger2:", "🐅"}, - {":rabbit2:", "🐇"}, - {":dragon:", "🐉"}, - {":racehorse:", "🐎"}, - {":goat:", "🐐"}, - {":rooster:", "🐓"}, - {":dog2:", "🐕"}, - {":pig2:", "🐖"}, - {":mouse2:", "🐁"}, - {":ox:", "🐂"}, - {":dragon_face:", "🐲"}, - {":blowfish:", "🐡"}, - {":crocodile:", "🐊"}, - {":camel:", "🐫"}, - {":dromedary_camel:", "🐪"}, - {":leopard:", "🐆"}, - {":cat2:", "🐈"}, - {":poodle:", "🐩"}, - {":feet:", "🐾"}, - {":paw_prints:", "🐾"}, - {":bouquet:", "💐"}, - {":cherry_blossom:", "🌸"}, - {":tulip:", "🌷"}, - {":four_leaf_clover:", "🍀"}, - {":rose:", "🌹"}, - {":sunflower:", "🌻"}, - {":hibiscus:", "🌺"}, - {":maple_leaf:", "🍁"}, - {":leaves:", "🍃"}, - {":fallen_leaf:", "🍂"}, - {":herb:", "🌿"}, - {":ear_of_rice:", "🌾"}, - {":mushroom:", "🍄"}, - {":cactus:", "🌵"}, - {":palm_tree:", "🌴"}, - {":evergreen_tree:", "🌲"}, - {":deciduous_tree:", "🌳"}, - {":chestnut:", "🌰"}, - {":seedling:", "🌱"}, - {":blossom:", "🌼"}, - {":globe_with_meridians:", "🌐"}, - {":sun_with_face:", "🌞"}, - {":full_moon_with_face:", "🌝"}, - {":new_moon_with_face:", "🌚"}, - {":new_moon:", "🌑"}, - {":waxing_crescent_moon:", "🌒"}, - {":first_quarter_moon:", "🌓"}, - {":moon:", "🌔"}, - {":waxing_gibbous_moon:", "🌔"}, - {":full_moon:", "🌕"}, - {":waning_gibbous_moon:", "🌖"}, - {":last_quarter_moon:", "🌗"}, - {":waning_crescent_moon:", "🌘"}, - {":last_quarter_moon_with_face:", "🌜"}, - {":first_quarter_moon_with_face:", "🌛"}, - {":crescent_moon:", "🌙"}, - {":earth_africa:", "🌍"}, - {":earth_americas:", "🌎"}, - {":earth_asia:", "🌏"}, - {":volcano:", "🌋"}, - {":milky_way:", "🌌"}, - {":stars:", "🌠"}, - {":star:", "⭐"}, - {":sunny:", "☀️"}, - {":partly_sunny:", "⛅"}, - {":cloud:", "☁️"}, - {":zap:", "⚡"}, - {":umbrella:", "☔"}, - {":snowflake:", "❄️"}, - {":snowman:", "⛄"}, - {":cyclone:", "🌀"}, - {":foggy:", "🌁"}, - {":rainbow:", "🌈"}, - {":ocean:", "🌊"}, - {":bamboo:", "🎍"}, - {":gift_heart:", "💝"}, - {":dolls:", "🎎"}, - {":school_satchel:", "🎒"}, - {":mortar_board:", "🎓"}, - {":flags:", "🎏"}, - {":fireworks:", "🎆"}, - {":sparkler:", "🎇"}, - {":wind_chime:", "🎐"}, - {":rice_scene:", "🎑"}, - {":jack_o_lantern:", "🎃"}, - {":ghost:", "👻"}, - {":santa:", "🎅"}, - {":christmas_tree:", "🎄"}, - {":gift:", "🎁"}, - {":tanabata_tree:", "🎋"}, - {":tada:", "🎉"}, - {":confetti_ball:", "🎊"}, - {":balloon:", "🎈"}, - {":crossed_flags:", "🎌"}, - {":crystal_ball:", "🔮"}, - {":movie_camera:", "🎥"}, - {":camera:", "📷"}, - {":video_camera:", "📹"}, - {":vhs:", "📼"}, - {":cd:", "💿"}, - {":dvd:", "📀"}, - {":minidisc:", "💽"}, - {":floppy_disk:", "💾"}, - {":computer:", "💻"}, - {":iphone:", "📱"}, - {":phone:", "☎️"}, - {":telephone:", "☎️"}, - {":telephone_receiver:", "📞"}, - {":pager:", "📟"}, - {":fax:", "📠"}, - {":satellite:", "📡"}, - {":tv:", "📺"}, - {":radio:", "📻"}, - {":loud_sound:", "🔊"}, - {":sound:", "🔉"}, - {":speaker:", "🔈"}, - {":mute:", "🔇"}, - {":bell:", "🔔"}, - {":no_bell:", "🔕"}, - {":loudspeaker:", "📢"}, - {":mega:", "📣"}, - {":hourglass_flowing_sand:", "⏳"}, - {":hourglass:", "⌛"}, - {":alarm_clock:", "⏰"}, - {":watch:", "⌚"}, - {":unlock:", "🔓"}, - {":lock:", "🔒"}, - {":lock_with_ink_pen:", "🔏"}, - {":closed_lock_with_key:", "🔐"}, - {":key:", "🔑"}, - {":mag_right:", "🔎"}, - {":bulb:", "💡"}, - {":flashlight:", "🔦"}, - {":high_brightness:", "🔆"}, - {":low_brightness:", "🔅"}, - {":electric_plug:", "🔌"}, - {":battery:", "🔋"}, - {":mag:", "🔍"}, - {":bathtub:", "🛁"}, - {":bath:", "🛀"}, - {":shower:", "🚿"}, - {":toilet:", "🚽"}, - {":wrench:", "🔧"}, - {":nut_and_bolt:", "🔩"}, - {":hammer:", "🔨"}, - {":door:", "🚪"}, - {":smoking:", "🚬"}, - {":bomb:", "💣"}, - {":gun:", "🔫"}, - {":hocho:", "🔪"}, - {":knife:", "🔪"}, - {":pill:", "💊"}, - {":syringe:", "💉"}, - {":moneybag:", "💰"}, - {":yen:", "💴"}, - {":dollar:", "💵"}, - {":pound:", "💷"}, - {":euro:", "💶"}, - {":credit_card:", "💳"}, - {":money_with_wings:", "💸"}, - {":calling:", "📲"}, - {":e-mail:", "📧"}, - {":inbox_tray:", "📥"}, - {":outbox_tray:", "📤"}, - {":email:", "✉️"}, - {":envelope:", "✉️"}, - {":envelope_with_arrow:", "📩"}, - {":incoming_envelope:", "📨"}, - {":postal_horn:", "📯"}, - {":mailbox:", "📫"}, - {":mailbox_closed:", "📪"}, - {":mailbox_with_mail:", "📬"}, - {":mailbox_with_no_mail:", "📭"}, - {":postbox:", "📮"}, - {":package:", "📦"}, - {":memo:", "📝"}, - {":pencil:", "📝"}, - {":page_facing_up:", "📄"}, - {":page_with_curl:", "📃"}, - {":bookmark_tabs:", "📑"}, - {":bar_chart:", "📊"}, - {":chart_with_upwards_trend:", "📈"}, - {":chart_with_downwards_trend:", "📉"}, - {":scroll:", "📜"}, - {":clipboard:", "📋"}, - {":date:", "📅"}, - {":calendar:", "📆"}, - {":card_index:", "📇"}, - {":file_folder:", "📁"}, - {":open_file_folder:", "📂"}, - {":scissors:", "✂️"}, - {":pushpin:", "📌"}, - {":paperclip:", "📎"}, - {":black_nib:", "✒️"}, - {":pencil2:", "✏️"}, - {":straight_ruler:", "📏"}, - {":triangular_ruler:", "📐"}, - {":closed_book:", "📕"}, - {":green_book:", "📗"}, - {":blue_book:", "📘"}, - {":orange_book:", "📙"}, - {":notebook:", "📓"}, - {":notebook_with_decorative_cover:", "📔"}, - {":ledger:", "📒"}, - {":books:", "📚"}, - {":book:", "📖"}, - {":open_book:", "📖"}, - {":bookmark:", "🔖"}, - {":name_badge:", "📛"}, - {":microscope:", "🔬"}, - {":telescope:", "🔭"}, - {":newspaper:", "📰"}, - {":art:", "🎨"}, - {":clapper:", "🎬"}, - {":microphone:", "🎤"}, - {":headphones:", "🎧"}, - {":musical_score:", "🎼"}, - {":musical_note:", "🎵"}, - {":notes:", "🎶"}, - {":musical_keyboard:", "🎹"}, - {":violin:", "🎻"}, - {":trumpet:", "🎺"}, - {":saxophone:", "🎷"}, - {":guitar:", "🎸"}, - {":space_invader:", "👾"}, - {":video_game:", "🎮"}, - {":black_joker:", "🃏"}, - {":flower_playing_cards:", "🎴"}, - {":mahjong:", "🀄"}, - {":game_die:", "🎲"}, - {":dart:", "🎯"}, - {":football:", "🏈"}, - {":basketball:", "🏀"}, - {":soccer:", "⚽"}, - {":baseball:", "⚾️"}, - {":tennis:", "🎾"}, - {":8ball:", "🎱"}, - {":rugby_football:", "🏉"}, - {":bowling:", "🎳"}, - {":golf:", "⛳"}, - {":mountain_bicyclist:", "🚵"}, - {":bicyclist:", "🚴"}, - {":checkered_flag:", "🏁"}, - {":horse_racing:", "🏇"}, - {":trophy:", "🏆"}, - {":ski:", "🎿"}, - {":snowboarder:", "🏂"}, - {":swimmer:", "🏊"}, - {":surfer:", "🏄"}, - {":fishing_pole_and_fish:", "🎣"}, - {":coffee:", "☕"}, - {":tea:", "🍵"}, - {":sake:", "🍶"}, - {":baby_bottle:", "🍼"}, - {":beer:", "🍺"}, - {":beers:", "🍻"}, - {":cocktail:", "🍸"}, - {":tropical_drink:", "🍹"}, - {":wine_glass:", "🍷"}, - {":fork_and_knife:", "🍴"}, - {":pizza:", "🍕"}, - {":hamburger:", "🍔"}, - {":fries:", "🍟"}, - {":poultry_leg:", "🍗"}, - {":meat_on_bone:", "🍖"}, - {":spaghetti:", "🍝"}, - {":curry:", "🍛"}, - {":fried_shrimp:", "🍤"}, - {":bento:", "🍱"}, - {":sushi:", "🍣"}, - {":fish_cake:", "🍥"}, - {":rice_ball:", "🍙"}, - {":rice_cracker:", "🍘"}, - {":rice:", "🍚"}, - {":ramen:", "🍜"}, - {":stew:", "🍲"}, - {":oden:", "🍢"}, - {":dango:", "🍡"}, - {":egg:", "🍳"}, - {":bread:", "🍞"}, - {":doughnut:", "🍩"}, - {":custard:", "🍮"}, - {":icecream:", "🍦"}, - {":ice_cream:", "🍨"}, - {":shaved_ice:", "🍧"}, - {":birthday:", "🎂"}, - {":cake:", "🍰"}, - {":cookie:", "🍪"}, - {":chocolate_bar:", "🍫"}, - {":candy:", "🍬"}, - {":lollipop:", "🍭"}, - {":honey_pot:", "🍯"}, - {":apple:", "🍎"}, - {":green_apple:", "🍏"}, - {":tangerine:", "🍊"}, - {":lemon:", "🍋"}, - {":cherries:", "🍒"}, - {":grapes:", "🍇"}, - {":watermelon:", "🍉"}, - {":strawberry:", "🍓"}, - {":peach:", "🍑"}, - {":melon:", "🍈"}, - {":banana:", "🍌"}, - {":pear:", "🍐"}, - {":pineapple:", "🍍"}, - {":sweet_potato:", "🍠"}, - {":eggplant:", "🍆"}, - {":tomato:", "🍅"}, - {":corn:", "🌽"}, - {":house:", "🏠"}, - {":house_with_garden:", "🏡"}, - {":school:", "🏫"}, - {":office:", "🏢"}, - {":post_office:", "🏣"}, - {":hospital:", "🏥"}, - {":bank:", "🏦"}, - {":convenience_store:", "🏪"}, - {":love_hotel:", "🏩"}, - {":hotel:", "🏨"}, - {":wedding:", "💒"}, - {":church:", "⛪"}, - {":department_store:", "🏬"}, - {":european_post_office:", "🏤"}, - {":city_sunrise:", "🌇"}, - {":city_sunset:", "🌆"}, - {":japanese_castle:", "🏯"}, - {":european_castle:", "🏰"}, - {":tent:", "⛺"}, - {":factory:", "🏭"}, - {":tokyo_tower:", "🗼"}, - {":japan:", "🗾"}, - {":mount_fuji:", "🗻"}, - {":sunrise_over_mountains:", "🌄"}, - {":sunrise:", "🌅"}, - {":night_with_stars:", "🌃"}, - {":statue_of_liberty:", "🗽"}, - {":bridge_at_night:", "🌉"}, - {":carousel_horse:", "🎠"}, - {":ferris_wheel:", "🎡"}, - {":fountain:", "⛲"}, - {":roller_coaster:", "🎢"}, - {":ship:", "🚢"}, - {":boat:", "⛵"}, - {":sailboat:", "⛵"}, - {":speedboat:", "🚤"}, - {":rowboat:", "🚣"}, - {":anchor:", "⚓"}, - {":rocket:", "🚀"}, - {":airplane:", "✈️"}, - {":seat:", "💺"}, - {":helicopter:", "🚁"}, - {":steam_locomotive:", "🚂"}, - {":tram:", "🚊"}, - {":station:", "🚉"}, - {":mountain_railway:", "🚞"}, - {":train2:", "🚆"}, - {":bullettrain_side:", "🚄"}, - {":bullettrain_front:", "🚅"}, - {":light_rail:", "🚈"}, - {":metro:", "🚇"}, - {":monorail:", "🚝"}, - {":train:", "🚋"}, - {":railway_car:", "🚃"}, - {":trolleybus:", "🚎"}, - {":bus:", "🚌"}, - {":oncoming_bus:", "🚍"}, - {":blue_car:", "🚙"}, - {":oncoming_automobile:", "🚘"}, - {":car:", "🚗"}, - {":red_car:", "🚗"}, - {":taxi:", "🚕"}, - {":oncoming_taxi:", "🚖"}, - {":articulated_lorry:", "🚛"}, - {":truck:", "🚚"}, - {":rotating_light:", "🚨"}, - {":police_car:", "🚓"}, - {":oncoming_police_car:", "🚔"}, - {":fire_engine:", "🚒"}, - {":ambulance:", "🚑"}, - {":minibus:", "🚐"}, - {":bike:", "🚲"}, - {":aerial_tramway:", "🚡"}, - {":suspension_railway:", "🚟"}, - {":mountain_cableway:", "🚠"}, - {":tractor:", "🚜"}, - {":barber:", "💈"}, - {":busstop:", "🚏"}, - {":ticket:", "🎫"}, - {":vertical_traffic_light:", "🚦"}, - {":traffic_light:", "🚥"}, - {":warning:", "⚠️"}, - {":construction:", "🚧"}, - {":beginner:", "🔰"}, - {":fuelpump:", "⛽"}, - {":izakaya_lantern:", "🏮"}, - {":lantern:", "🏮"}, - {":slot_machine:", "🎰"}, - {":hotsprings:", "♨️"}, - {":moyai:", "🗿"}, - {":circus_tent:", "🎪"}, - {":performing_arts:", "🎭"}, - {":round_pushpin:", "📍"}, - {":triangular_flag_on_post:", "🚩"}, - {":jp:", "🇯🇵"}, - {":kr:", "🇰🇷"}, - {":de:", "🇩🇪"}, - {":cn:", "🇨🇳"}, - {":us:", "🇺🇸"}, - {":fr:", "🇫🇷"}, - {":es:", "🇪🇸"}, - {":it:", "🇮🇹"}, - {":ru:", "🇷🇺"}, - {":gb:", "🇬🇧"}, - {":uk:", "🇬🇧"}, - {":one:", "1️⃣"}, - {":two:", "2️⃣"}, - {":three:", "3️⃣"}, - {":four:", "4️⃣"}, - {":five:", "5️⃣"}, - {":six:", "6️⃣"}, - {":seven:", "7️⃣"}, - {":eight:", "8️⃣"}, - {":nine:", "9️⃣"}, - {":zero:", "0️⃣"}, - {":keycap_ten:", "🔟"}, - {":hash:", "#️⃣"}, - {":symbols:", "🔣"}, - {":arrow_up:", "⬆️"}, - {":arrow_down:", "⬇️"}, - {":arrow_left:", "⬅️"}, - {":arrow_right:", "➡️"}, - {":capital_abcd:", "🔠"}, - {":abcd:", "🔡"}, - {":abc:", "🔤"}, - {":arrow_upper_right:", "↗️"}, - {":arrow_upper_left:", "↖️"}, - {":arrow_lower_right:", "↘️"}, - {":arrow_lower_left:", "↙️"}, - {":left_right_arrow:", "↔️"}, - {":arrow_up_down:", "↕️"}, - {":arrows_counterclockwise:", "🔄"}, - {":arrow_backward:", "◀️"}, - {":arrow_forward:", "▶️"}, - {":arrow_up_small:", "🔼"}, - {":arrow_down_small:", "🔽"}, - {":leftwards_arrow_with_hook:", "↩️"}, - {":arrow_right_hook:", "↪️"}, - {":information_source:", "ℹ️"}, - {":rewind:", "⏪"}, - {":fast_forward:", "⏩"}, - {":arrow_double_up:", "⏫"}, - {":arrow_double_down:", "⏬"}, - {":arrow_heading_down:", "⤵️"}, - {":arrow_heading_up:", "⤴️"}, - {":ok:", "🆗"}, - {":twisted_rightwards_arrows:", "🔀"}, - {":repeat:", "🔁"}, - {":repeat_one:", "🔂"}, - {":new:", "🆕"}, - {":up:", "🆙"}, - {":cool:", "🆒"}, - {":free:", "🆓"}, - {":ng:", "🆖"}, - {":signal_strength:", "📶"}, - {":cinema:", "🎦"}, - {":koko:", "🈁"}, - {":u6307:", "🈯"}, - {":u7a7a:", "🈳"}, - {":u6e80:", "🈵"}, - {":u5408:", "🈴"}, - {":u7981:", "🈲"}, - {":ideograph_advantage:", "🉐"}, - {":u5272:", "🈹"}, - {":u55b6:", "🈺"}, - {":u6709:", "🈶"}, - {":u7121:", "🈚"}, - {":restroom:", "🚻"}, - {":mens:", "🚹"}, - {":womens:", "🚺"}, - {":baby_symbol:", "🚼"}, - {":wc:", "🚾"}, - {":potable_water:", "🚰"}, - {":put_litter_in_its_place:", "🚮"}, - {":parking:", "🅿️"}, - {":wheelchair:", "♿"}, - {":no_smoking:", "🚭"}, - {":u6708:", "🈷️"}, - {":u7533:", "🈸"}, - {":sa:", "🈂️"}, - {":m:", "Ⓜ️"}, - {":passport_control:", "🛂"}, - {":baggage_claim:", "🛄"}, - {":left_luggage:", "🛅"}, - {":customs:", "🛃"}, - {":accept:", "🉑"}, - {":secret:", "㊙️"}, - {":congratulations:", "㊗️"}, - {":cl:", "🆑"}, - {":sos:", "🆘"}, - {":id:", "🆔"}, - {":no_entry_sign:", "🚫"}, - {":underage:", "🔞"}, - {":no_mobile_phones:", "📵"}, - {":do_not_litter:", "🚯"}, - {":non-potable_water:", "🚱"}, - {":no_bicycles:", "🚳"}, - {":no_pedestrians:", "🚷"}, - {":children_crossing:", "🚸"}, - {":no_entry:", "⛔"}, - {":eight_spoked_asterisk:", "✳️"}, - {":sparkle:", "❇️"}, - {":negative_squared_cross_mark:", "❎"}, - {":white_check_mark:", "✅"}, - {":eight_pointed_black_star:", "✴️"}, - {":heart_decoration:", "💟"}, - {":vs:", "🆚"}, - {":vibration_mode:", "📳"}, - {":mobile_phone_off:", "📴"}, - {":a:", "🅰️"}, - {":b:", "🅱️"}, - {":ab:", "🆎"}, - {":o2:", "🅾️"}, - {":diamond_shape_with_a_dot_inside:", "💠"}, - {":loop:", "➿"}, - {":recycle:", "♻️"}, - {":aries:", "♈"}, - {":taurus:", "♉"}, - {":gemini:", "♊"}, - {":cancer:", "♋"}, - {":leo:", "♌"}, - {":virgo:", "♍"}, - {":libra:", "♎"}, - {":scorpius:", "♏"}, - {":sagittarius:", "♐"}, - {":capricorn:", "♑"}, - {":aquarius:", "♒"}, - {":pisces:", "♓"}, - {":ophiuchus:", "⛎"}, - {":six_pointed_star:", "🔯"}, - {":atm:", "🏧"}, - {":chart:", "💹"}, - {":heavy_dollar_sign:", "💲"}, - {":currency_exchange:", "💱"}, - {":copyright:", "©️"}, - {":registered:", "®️"}, - {":tm:", "™️"}, - {":x:", "❌"}, - {":bangbang:", "‼️"}, - {":interrobang:", "⁉️"}, - {":exclamation:", "❗"}, - {":heavy_exclamation_mark:", "❗"}, - {":question:", "❓"}, - {":grey_exclamation:", "❕"}, - {":grey_question:", "❔"}, - {":o:", "⭕"}, - {":top:", "🔝"}, - {":end:", "🔚"}, - {":back:", "🔙"}, - {":on:", "🔛"}, - {":soon:", "🔜"}, - {":arrows_clockwise:", "🔃"}, - {":clock12:", "🕛"}, - {":clock1230:", "🕧"}, - {":clock1:", "🕐"}, - {":clock130:", "🕜"}, - {":clock2:", "🕑"}, - {":clock230:", "🕝"}, - {":clock3:", "🕒"}, - {":clock330:", "🕞"}, - {":clock4:", "🕓"}, - {":clock430:", "🕟"}, - {":clock5:", "🕔"}, - {":clock530:", "🕠"}, - {":clock6:", "🕕"}, - {":clock7:", "🕖"}, - {":clock8:", "🕗"}, - {":clock9:", "🕘"}, - {":clock10:", "🕙"}, - {":clock11:", "🕚"}, - {":clock630:", "🕡"}, - {":clock730:", "🕢"}, - {":clock830:", "🕣"}, - {":clock930:", "🕤"}, - {":clock1030:", "🕥"}, - {":clock1130:", "🕦"}, - {":heavy_multiplication_x:", "✖️"}, - {":heavy_plus_sign:", "➕"}, - {":heavy_minus_sign:", "➖"}, - {":heavy_division_sign:", "➗"}, - {":spades:", "♠️"}, - {":hearts:", "♥️"}, - {":clubs:", "♣️"}, - {":diamonds:", "♦️"}, - {":white_flower:", "💮"}, - {":heavy_check_mark:", "✔️"}, - {":ballot_box_with_check:", "☑️"}, - {":radio_button:", "🔘"}, - {":link:", "🔗"}, - {":curly_loop:", "➰"}, - {":wavy_dash:", "〰️"}, - {":part_alternation_mark:", "〽️"}, - {":trident:", "🔱"}, - {":black_medium_square:", "◼️"}, - {":white_medium_square:", "◻️"}, - {":black_medium_small_square:", "◾"}, - {":white_medium_small_square:", "◽"}, - {":black_small_square:", "▪️"}, - {":white_small_square:", "▫️"}, - {":small_red_triangle:", "🔺"}, - {":black_square_button:", "🔲"}, - {":white_square_button:", "🔳"}, - {":black_circle:", "⚫"}, - {":white_circle:", "⚪"}, - {":red_circle:", "🔴"}, - {":large_blue_circle:", "🔵"}, - {":small_red_triangle_down:", "🔻"}, - {":white_large_square:", "⬜"}, - {":black_large_square:", "⬛"}, - {":large_orange_diamond:", "🔶"}, - {":large_blue_diamond:", "🔷"}, - {":small_orange_diamond:", "🔸"}, - {":small_blue_diamond:", "🔹"}, - - // Custom additions - { ":custom_arrow_left:", "←"}, - { ":custom_arrow_right:", "→"}, - { ":custom_arrow_left_right:", "↔"}, - - { ":custom_arrow_left_strong:", "⇐"}, - { ":custom_arrow_right_strong:", "⇒"}, - { ":custom_arrow_left_right_strong:", "⇔"}, - }; - - SmileyToEmojiDefault = new Dictionary() - { - {">:(", ":angry:"}, - {">:-(", ":angry:"}, - {":\")", ":blush:"}, - {":-\")", ":blush:"}, - {"", ":custom_arrow_right:" }, - {"<->", ":custom_arrow_left_right:" }, - - {"<=", ":custom_arrow_left_strong:" }, - {"=>", ":custom_arrow_right_strong:" }, - {"<=>", ":custom_arrow_left_right_strong:" }, - }; - - // Build Emoji and Smiley CompactPrefixTree - EmojiPrefixTreeDefault = new CompactPrefixTree(EmojiToUnicodeDefault); - - int jointCount = EmojiToUnicodeDefault.Count + SmileyToEmojiDefault.Count; - // Count * 2 seems to be a good fit for the data set - EmojiSmileyPrefixTreeDefault = new CompactPrefixTree(jointCount, jointCount * 2, jointCount * 2); - - // This is not the best data set for the prefix tree as it will have to check the first character linearly - // A work-around would require a bunch of substrings / removing the leading ':' from emojis, neither one is pretty - // This way we sacrifice a few microseconds for not introducing breaking changes, emojis aren't all that common anyhow - - var firstChars = new HashSet { ':' }; - foreach (var emoji in EmojiToUnicodeDefault) - EmojiSmileyPrefixTreeDefault.Add(emoji); - foreach (var smiley in SmileyToEmojiDefault) - { - if (!EmojiToUnicodeDefault.TryGetValue(smiley.Value, out string unicode)) - throw new ArgumentException("Invalid smiley target: {0} is not present in the emoji dictionary", smiley.Value); - - firstChars.Add(smiley.Key[0]); - - if (!EmojiSmileyPrefixTreeDefault.TryAdd(smiley.Key, unicode)) - throw new ArgumentException("Smiley {0} is already present in the Emoji dictionary", smiley.Key); - } - - EmojiOpeningCharactersDefault = new[] { ':' }; - EmojiSmileyOpeningCharactersDefault = new List(firstChars).ToArray(); - } - #endregion - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/EmphasisExtras/EmphasisExtraExtension.cs b/NppMarkdownPanel/Markdig/Extensions/EmphasisExtras/EmphasisExtraExtension.cs deleted file mode 100644 index ac12ca7..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/EmphasisExtras/EmphasisExtraExtension.cs +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Parsers.Inlines; -using Markdig.Renderers; -using Markdig.Renderers.Html.Inlines; -using Markdig.Syntax.Inlines; -using System.Diagnostics; - -namespace Markdig.Extensions.EmphasisExtras -{ - /// - /// Extension for strikethrough, subscript, superscript, inserted and marked. - /// - /// - public class EmphasisExtraExtension : IMarkdownExtension - { - /// - /// Initializes a new instance of the class. - /// - /// The options. - public EmphasisExtraExtension(EmphasisExtraOptions options = EmphasisExtraOptions.Default) - { - Options = options; - } - - /// - /// Gets the options. - /// - public EmphasisExtraOptions Options { get; } - - public void Setup(MarkdownPipelineBuilder pipeline) - { - var parser = pipeline.InlineParsers.FindExact(); - if (parser != null) - { - var hasTilde = false; - var hasSup = false; - var hasPlus = false; - var hasEqual = false; - - var requireTilde = ((Options & EmphasisExtraOptions.Strikethrough) != 0 || - (Options & EmphasisExtraOptions.Subscript) != 0); - - var requireSup = (Options & EmphasisExtraOptions.Superscript) != 0; - var requirePlus = (Options & EmphasisExtraOptions.Inserted) != 0; - var requireEqual = (Options & EmphasisExtraOptions.Marked) != 0; - - foreach (var emphasis in parser.EmphasisDescriptors) - { - if (requireTilde && emphasis.Character == '~') - { - hasTilde = true; - } - if (requireSup && emphasis.Character == '^') - { - hasSup = true; - } - if (requirePlus && emphasis.Character == '+') - { - hasPlus = true; - } - if (requireEqual && emphasis.Character == '=') - { - hasEqual = true; - } - } - - if (requireTilde && !hasTilde) - { - int minimumCount = (Options & EmphasisExtraOptions.Subscript) != 0 ? 1 : 2; - int maximumCount = (Options & EmphasisExtraOptions.Strikethrough) != 0 ? 2 : 1; - parser.EmphasisDescriptors.Add(new EmphasisDescriptor('~', minimumCount, maximumCount, true)); - } - if (requireSup && !hasSup) - { - parser.EmphasisDescriptors.Add(new EmphasisDescriptor('^', 1, 1, true)); - } - if (requirePlus && !hasPlus) - { - parser.EmphasisDescriptors.Add(new EmphasisDescriptor('+', 2, 2, true)); - } - if (requireEqual && !hasEqual) - { - parser.EmphasisDescriptors.Add(new EmphasisDescriptor('=', 2, 2, true)); - } - } - } - - public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer) - { - if (renderer is HtmlRenderer htmlRenderer) - { - // Extend the rendering here. - var emphasisRenderer = htmlRenderer.ObjectRenderers.FindExact(); - if (emphasisRenderer != null) - { - var previousTag = emphasisRenderer.GetTag; - emphasisRenderer.GetTag = inline => GetTag(inline) ?? previousTag(inline); - } - } - } - - private string GetTag(EmphasisInline emphasisInline) - { - var c = emphasisInline.DelimiterChar; - switch (c) - { - case '~': - Debug.Assert(emphasisInline.DelimiterCount <= 2); - return emphasisInline.DelimiterCount == 2 ? "del" : "sub"; - case '^': - return "sup"; - case '+': - return "ins"; - case '=': - return "mark"; - } - - return null; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/EmphasisExtras/EmphasisExtraOptions.cs b/NppMarkdownPanel/Markdig/Extensions/EmphasisExtras/EmphasisExtraOptions.cs deleted file mode 100644 index 2359381..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/EmphasisExtras/EmphasisExtraOptions.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; - -namespace Markdig.Extensions.EmphasisExtras -{ - /// - /// Options for enabling support for extra emphasis. - /// - [Flags] - public enum EmphasisExtraOptions - { - /// - /// Allows all extra emphasis (default). - /// - Default = Strikethrough | Subscript | Superscript | Inserted | Marked, - - /// - /// A text that can be strikethrough using the double character ~~ - /// - Strikethrough = 1, - - /// - /// A text that can be rendered as a subscript using the character ~ - /// - Subscript = 2, - - /// - /// A text that can be rendered as a superscript using the character ^ - /// - Superscript = 4, - - /// - /// A text that can be rendered as a inserted using the character ++ - /// - Inserted = 8, - - /// - /// A text that can be rendered as a inserted using the character == - /// - Marked = 16, - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Figures/Figure.cs b/NppMarkdownPanel/Markdig/Extensions/Figures/Figure.cs deleted file mode 100644 index 140bf0a..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Figures/Figure.cs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Parsers; -using Markdig.Syntax; - -namespace Markdig.Extensions.Figures -{ - /// - /// Defines a figure container. - /// - /// - public class Figure : ContainerBlock - { - /// - /// Initializes a new instance of the class. - /// - /// The parser used to create this block. - public Figure(BlockParser parser) : base(parser) - { - } - - /// - /// Gets or sets the opening character count used to open this figure code block. - /// - public int OpeningCharacterCount { get; set; } - - /// - /// Gets or sets the opening character used to open and close this figure code block. - /// - public char OpeningCharacter { get; set; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Figures/FigureBlockParser.cs b/NppMarkdownPanel/Markdig/Extensions/Figures/FigureBlockParser.cs deleted file mode 100644 index 790e096..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Figures/FigureBlockParser.cs +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Parsers; -using Markdig.Syntax; - -namespace Markdig.Extensions.Figures -{ - /// - /// The block parser for a block. - /// - /// - public class FigureBlockParser : BlockParser - { - /// - /// Initializes a new instance of the class. - /// - public FigureBlockParser() - { - OpeningCharacters = new [] {'^'}; - } - - public override BlockState TryOpen(BlockProcessor processor) - { - // We expect no indentation for a figure block. - if (processor.IsCodeIndent) - { - return BlockState.None; - } - - // Match fenced char - int count = 0; - var column = processor.Column; - var line = processor.Line; - var startPosition = line.Start; - char c = line.CurrentChar; - var matchChar = c; - while (c != '\0') - { - if (c != matchChar) - { - break; - } - count++; - c = line.NextChar(); - } - - // Requires at least 3 opening chars - if (count < 3) - { - return BlockState.None; - } - - var figure = new Figure(this) - { - Span = new SourceSpan(startPosition, line.End), - Line = processor.LineIndex, - Column = processor.Column, - OpeningCharacter = matchChar, - OpeningCharacterCount = count - }; - - line.TrimStart(); - if (!line.IsEmpty) - { - var caption = new FigureCaption(this) - { - Span = new SourceSpan(line.Start, line.End), - Line = processor.LineIndex, - Column = column + line.Start - startPosition, - IsOpen = false - }; - caption.AppendLine(ref line, caption.Column, processor.LineIndex, processor.CurrentLineStartPosition); - figure.Add(caption); - } - processor.NewBlocks.Push(figure); - - // Discard the current line as it is already parsed - return BlockState.ContinueDiscard; - } - - public override BlockState TryContinue(BlockProcessor processor, Block block) - { - var figure = (Figure)block; - var count = figure.OpeningCharacterCount; - var matchChar = figure.OpeningCharacter; - var c = processor.CurrentChar; - - var column = processor.Column; - // Match if we have a closing fence - var line = processor.Line; - var startPosition = line.Start; - while (c == matchChar) - { - c = line.NextChar(); - count--; - } - - // If we have a closing fence, close it and discard the current line - // The line must contain only fence opening character followed only by whitespaces. - if (count <= 0 && !processor.IsCodeIndent) - { - line.TrimStart(); - if (!line.IsEmpty) - { - var caption = new FigureCaption(this) - { - Span = new SourceSpan(line.Start, line.End), - Line = processor.LineIndex, - Column = column + line.Start - startPosition, - IsOpen = false - }; - caption.AppendLine(ref line, caption.Column, processor.LineIndex, processor.CurrentLineStartPosition); - figure.Add(caption); - } - - figure.UpdateSpanEnd(line.End); - - // Don't keep the last line - return BlockState.BreakDiscard; - } - - // Reset the indentation to the column before the indent - processor.GoToColumn(processor.ColumnBeforeIndent); - - figure.UpdateSpanEnd(line.End); - - return BlockState.Continue; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Figures/FigureCaption.cs b/NppMarkdownPanel/Markdig/Extensions/Figures/FigureCaption.cs deleted file mode 100644 index 16da49e..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Figures/FigureCaption.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Parsers; -using Markdig.Syntax; - -namespace Markdig.Extensions.Figures -{ - /// - /// Defines a figure caption. - /// - /// - public class FigureCaption : LeafBlock - { - /// - /// Initializes a new instance of the class. - /// - /// The parser used to create this block. - public FigureCaption(BlockParser parser) : base(parser) - { - ProcessInlines = true; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Figures/FigureExtension.cs b/NppMarkdownPanel/Markdig/Extensions/Figures/FigureExtension.cs deleted file mode 100644 index 549c738..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Figures/FigureExtension.cs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Extensions.Footers; -using Markdig.Renderers; - -namespace Markdig.Extensions.Figures -{ - /// - /// Extension to allow usage of figures and figure captions. - /// - /// - public class FigureExtension : IMarkdownExtension - { - public void Setup(MarkdownPipelineBuilder pipeline) - { - if (!pipeline.BlockParsers.Contains()) - { - // The Figure extension must come before the Footer extension - if (pipeline.BlockParsers.Contains()) - { - pipeline.BlockParsers.InsertBefore(new FigureBlockParser()); - } - else - { - pipeline.BlockParsers.Insert(0, new FigureBlockParser()); - } - } - } - - public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer) - { - var htmlRenderer = renderer as HtmlRenderer; - if (htmlRenderer != null) - { - htmlRenderer.ObjectRenderers.AddIfNotAlready(); - htmlRenderer.ObjectRenderers.AddIfNotAlready(); - } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Figures/HtmlFigureCaptionRenderer.cs b/NppMarkdownPanel/Markdig/Extensions/Figures/HtmlFigureCaptionRenderer.cs deleted file mode 100644 index b3c8b81..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Figures/HtmlFigureCaptionRenderer.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Renderers; -using Markdig.Renderers.Html; - -namespace Markdig.Extensions.Figures -{ - /// - /// A HTML renderer for a . - /// - /// - public class HtmlFigureCaptionRenderer : HtmlObjectRenderer - { - protected override void Write(HtmlRenderer renderer, FigureCaption obj) - { - renderer.EnsureLine(); - renderer.Write(""); - renderer.WriteLeafInline(obj); - renderer.WriteLine(""); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Figures/HtmlFigureRenderer.cs b/NppMarkdownPanel/Markdig/Extensions/Figures/HtmlFigureRenderer.cs deleted file mode 100644 index a5065db..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Figures/HtmlFigureRenderer.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Renderers; -using Markdig.Renderers.Html; - -namespace Markdig.Extensions.Figures -{ - /// - /// A HTML renderer for a . - /// - /// - public class HtmlFigureRenderer : HtmlObjectRenderer
- { - protected override void Write(HtmlRenderer renderer, Figure obj) - { - renderer.EnsureLine(); - renderer.Write(""); - renderer.WriteChildren(obj); - renderer.WriteLine("
"); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Footers/FooterBlock.cs b/NppMarkdownPanel/Markdig/Extensions/Footers/FooterBlock.cs deleted file mode 100644 index bac8103..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Footers/FooterBlock.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Parsers; -using Markdig.Syntax; - -namespace Markdig.Extensions.Footers -{ - /// - /// A block elemeent for a footer. - /// - /// - public class FooterBlock : ContainerBlock - { - /// - /// Initializes a new instance of the class. - /// - /// The parser used to create this block. - public FooterBlock(BlockParser parser) : base(parser) - { - } - - /// - /// Gets or sets the opening character used to match this footer (by default it is ^) - /// - public char OpeningCharacter { get; set; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Footers/FooterBlockParser.cs b/NppMarkdownPanel/Markdig/Extensions/Footers/FooterBlockParser.cs deleted file mode 100644 index fba7fc6..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Footers/FooterBlockParser.cs +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Helpers; -using Markdig.Parsers; -using Markdig.Syntax; - -namespace Markdig.Extensions.Footers -{ - /// - /// A block parser for a . - /// - /// - public class FooterBlockParser : BlockParser - { - /// - /// Initializes a new instance of the class. - /// - public FooterBlockParser() - { - OpeningCharacters = new[] {'^'}; - } - - public override BlockState TryOpen(BlockProcessor processor) - { - if (processor.IsCodeIndent) - { - return BlockState.None; - } - - var column = processor.Column; - var startPosition = processor.Start; - - // A footer - // A Footer marker consists of 0-3 spaces of initial indent, plus (a) the characters ^^ together with a following space, or (b) a double character ^^ not followed by a space. - var openingChar = processor.CurrentChar; - if (processor.PeekChar(1) != openingChar) - { - return BlockState.None; - } - processor.NextChar(); // Grab 2nd^ - var c = processor.NextChar(); // grab space - if (c.IsSpaceOrTab()) - { - processor.NextColumn(); - } - processor.NewBlocks.Push(new FooterBlock(this) - { - Span = new SourceSpan(startPosition, processor.Line.End), - OpeningCharacter = openingChar, - Column = column, - Line = processor.LineIndex, - }); - return BlockState.Continue; - } - - public override BlockState TryContinue(BlockProcessor processor, Block block) - { - if (processor.IsCodeIndent) - { - return BlockState.None; - } - - var quote = (FooterBlock) block; - - // A footer - // A Footer marker consists of 0-3 spaces of initial indent, plus (a) the characters ^^ together with a following space, or (b) a double character ^^ not followed by a space. - var c = processor.CurrentChar; - var result = BlockState.Continue; - if (c != quote.OpeningCharacter || processor.PeekChar(1) != c) - { - result = processor.IsBlankLine ? BlockState.BreakDiscard : BlockState.None; - } - else - { - processor.NextChar(); // Skip ^^ char (1st) - c = processor.NextChar(); // Skip ^^ char (2nd) - if (c.IsSpace()) - { - processor.NextChar(); // Skip following space - } - block.UpdateSpanEnd(processor.Line.End); - } - return result; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Footers/FooterExtension.cs b/NppMarkdownPanel/Markdig/Extensions/Footers/FooterExtension.cs deleted file mode 100644 index 6b8a285..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Footers/FooterExtension.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Extensions.Figures; -using Markdig.Renderers; - -namespace Markdig.Extensions.Footers -{ - /// - /// Extension that provides footer. - /// - /// - public class FooterExtension : IMarkdownExtension - { - public void Setup(MarkdownPipelineBuilder pipeline) - { - if (!pipeline.BlockParsers.Contains()) - { - // The Figure extension must come before the Footer extension - if (pipeline.BlockParsers.Contains()) - { - pipeline.BlockParsers.InsertAfter(new FooterBlockParser()); - } - else - { - pipeline.BlockParsers.Insert(0, new FooterBlockParser()); - } - } - } - - public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer) - { - var htmlRenderer = renderer as HtmlRenderer; - if (htmlRenderer != null) - { - htmlRenderer.ObjectRenderers.AddIfNotAlready(new HtmlFooterBlockRenderer()); - } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Footers/HtmlFooterRenderer.cs b/NppMarkdownPanel/Markdig/Extensions/Footers/HtmlFooterRenderer.cs deleted file mode 100644 index 92fa81f..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Footers/HtmlFooterRenderer.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Renderers; -using Markdig.Renderers.Html; - -namespace Markdig.Extensions.Footers -{ - /// - /// A HTML renderer for a . - /// - /// - public class HtmlFooterBlockRenderer : HtmlObjectRenderer - { - protected override void Write(HtmlRenderer renderer, FooterBlock footer) - { - renderer.EnsureLine(); - renderer.Write(""); - var implicitParagraph = renderer.ImplicitParagraph; - renderer.ImplicitParagraph = true; - renderer.WriteChildren(footer); - renderer.ImplicitParagraph = implicitParagraph; - renderer.WriteLine(""); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Footnotes/Footnote.cs b/NppMarkdownPanel/Markdig/Extensions/Footnotes/Footnote.cs deleted file mode 100644 index b77d6ef..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Footnotes/Footnote.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System.Collections.Generic; -using Markdig.Parsers; -using Markdig.Syntax; - -namespace Markdig.Extensions.Footnotes -{ - /// - /// A block for a footnote. - /// - /// - public class Footnote : ContainerBlock - { - public Footnote(BlockParser parser) : base(parser) - { - Links = new List(); - Order = -1; - } - - /// - /// Gets or sets the label used by this footnote. - /// - public string Label { get; set; } - - /// - /// Gets or sets the order of this footnote (determined by the order of the in the document) - /// - public int Order { get; set; } - - /// - /// Gets the links referencing this footnote. - /// - public List Links { get; private set; } - - /// - /// The label span - /// - public SourceSpan LabelSpan; - - internal bool IsLastLineEmpty { get; set; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Footnotes/FootnoteExtension.cs b/NppMarkdownPanel/Markdig/Extensions/Footnotes/FootnoteExtension.cs deleted file mode 100644 index 94e7a19..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Footnotes/FootnoteExtension.cs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Renderers; - -namespace Markdig.Extensions.Footnotes -{ - /// - /// Extension to allow footnotes. - /// - /// - public class FootnoteExtension : IMarkdownExtension - { - public void Setup(MarkdownPipelineBuilder pipeline) - { - if (!pipeline.BlockParsers.Contains()) - { - // Insert the parser before any other parsers - pipeline.BlockParsers.Insert(0, new FootnoteParser()); - } - } - - public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer) - { - var htmlRenderer = renderer as HtmlRenderer; - if (htmlRenderer != null) - { - htmlRenderer.ObjectRenderers.AddIfNotAlready(new HtmlFootnoteGroupRenderer()); - htmlRenderer.ObjectRenderers.AddIfNotAlready(new HtmlFootnoteLinkRenderer()); - } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Footnotes/FootnoteGroup.cs b/NppMarkdownPanel/Markdig/Extensions/Footnotes/FootnoteGroup.cs deleted file mode 100644 index 577c24d..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Footnotes/FootnoteGroup.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Parsers; -using Markdig.Syntax; - -namespace Markdig.Extensions.Footnotes -{ - /// - /// A block that contains all the footnotes at the end of a . - /// - /// - public class FootnoteGroup : ContainerBlock - { - /// - /// Initializes a new instance of the class. - /// - /// The parser used to create this block. - public FootnoteGroup(BlockParser parser) : base(parser) - { - } - - internal int CurrentOrder { get; set; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Footnotes/FootnoteLink.cs b/NppMarkdownPanel/Markdig/Extensions/Footnotes/FootnoteLink.cs deleted file mode 100644 index d94c342..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Footnotes/FootnoteLink.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax.Inlines; - -namespace Markdig.Extensions.Footnotes -{ - /// - /// A inline link to a . - /// - /// - public class FootnoteLink : Inline - { - /// - /// Gets or sets a value indicating whether this instance is back link (from a footnote to the link) - /// - public bool IsBackLink { get; set; } - - /// - /// Gets or sets the global index number of this link. - /// - public int Index { get; set; } - - /// - /// Gets or sets the footnote this link refers to. - /// - public Footnote Footnote { get; set; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Footnotes/FootnoteLinkReferenceDefinition.cs b/NppMarkdownPanel/Markdig/Extensions/Footnotes/FootnoteLinkReferenceDefinition.cs deleted file mode 100644 index 78bdd39..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Footnotes/FootnoteLinkReferenceDefinition.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax; - -namespace Markdig.Extensions.Footnotes -{ - /// - /// A link reference definition stored at the level. - /// - /// - public class FootnoteLinkReferenceDefinition : LinkReferenceDefinition - { - /// - /// Gets or sets the footnote related to this link reference definition. - /// - public Footnote Footnote { get; set; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Footnotes/FootnoteParser.cs b/NppMarkdownPanel/Markdig/Extensions/Footnotes/FootnoteParser.cs deleted file mode 100644 index ca95a2f..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Footnotes/FootnoteParser.cs +++ /dev/null @@ -1,212 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Helpers; -using Markdig.Parsers; -using Markdig.Syntax; -using Markdig.Syntax.Inlines; - -namespace Markdig.Extensions.Footnotes -{ - /// - /// The block parser for a . - /// - /// - public class FootnoteParser : BlockParser - { - /// - /// The key used to store at the document level the pending - /// - private static readonly object DocumentKey = typeof(Footnote); - - public FootnoteParser() - { - OpeningCharacters = new [] {'['}; - } - - public override BlockState TryOpen(BlockProcessor processor) - { - return TryOpen(processor, false); - } - - private BlockState TryOpen(BlockProcessor processor, bool isContinue) - { - // We expect footnote to appear only at document level and not indented more than a code indent block - var currentContainer = processor.GetCurrentContainerOpened(); - if (processor.IsCodeIndent || (!isContinue && currentContainer.GetType() != typeof(MarkdownDocument)) || (isContinue && !(currentContainer is FootnoteGroup))) - { - return BlockState.None; - } - - var saved = processor.Column; - string label; - int start = processor.Start; - SourceSpan labelSpan; - if (!LinkHelper.TryParseLabel(ref processor.Line, false, out label, out labelSpan) || !label.StartsWith("^") || processor.CurrentChar != ':') - { - processor.GoToColumn(saved); - return BlockState.None; - } - - // Advance the column - int deltaColumn = processor.Start - start; - processor.Column = processor.Column + deltaColumn; - - processor.NextChar(); // Skip ':' - - var footnote = new Footnote(this) - { - Label = label, - LabelSpan = labelSpan, - }; - - // Maintain a list of all footnotes at document level - var footnotes = processor.Document.GetData(DocumentKey) as FootnoteGroup; - if (footnotes == null) - { - footnotes = new FootnoteGroup(this); - processor.Document.Add(footnotes); - processor.Document.SetData(DocumentKey, footnotes); - processor.Document.ProcessInlinesEnd += Document_ProcessInlinesEnd; - } - footnotes.Add(footnote); - - var linkRef = new FootnoteLinkReferenceDefinition() - { - Footnote = footnote, - CreateLinkInline = CreateLinkToFootnote, - Line = processor.LineIndex, - Span = new SourceSpan(start, processor.Start - 2), // account for ]: - LabelSpan = labelSpan, - Label = label - }; - processor.Document.SetLinkReferenceDefinition(footnote.Label, linkRef); - processor.NewBlocks.Push(footnote); - return BlockState.Continue; - } - - public override BlockState TryContinue(BlockProcessor processor, Block block) - { - var footnote = (Footnote) block; - - if (processor.CurrentBlock == null || processor.CurrentBlock.IsBreakable) - { - if (processor.IsBlankLine) - { - footnote.IsLastLineEmpty = true; - return BlockState.ContinueDiscard; - } - - if (processor.Column == 0) - { - if (footnote.IsLastLineEmpty) - { - // Close the current footnote - processor.Close(footnote); - - // Parse any opening footnote - return TryOpen(processor); - } - - // Make sure that consecutive footnotes without a blanklines are parsed correctly - if (TryOpen(processor, true) == BlockState.Continue) - { - processor.Close(footnote); - return BlockState.Continue; - } - } - } - footnote.IsLastLineEmpty = false; - - if (processor.IsCodeIndent) - { - processor.GoToCodeIndent(); - } - - return BlockState.Continue; - } - - /// - /// Add footnotes to the end of the document - /// - /// The processor. - /// The inline. - private void Document_ProcessInlinesEnd(InlineProcessor state, Inline inline) - { - // Unregister - state.Document.ProcessInlinesEnd -= Document_ProcessInlinesEnd; - - var footnotes = ((FootnoteGroup)state.Document.GetData(DocumentKey)); - // Remove the footnotes from the document and readd them at the end - state.Document.Remove(footnotes); - state.Document.Add(footnotes); - state.Document.RemoveData(DocumentKey); - - footnotes.Sort( - (leftObj, rightObj) => - { - var left = (Footnote)leftObj; - var right = (Footnote)rightObj; - - return left.Order >= 0 && right.Order >= 0 - ? left.Order.CompareTo(right.Order) - : 0; - }); - - int linkIndex = 0; - for (int i = 0; i < footnotes.Count; i++) - { - var footnote = (Footnote)footnotes[i]; - if (footnote.Order < 0) - { - // Remove this footnote if it doesn't have any links - footnotes.RemoveAt(i); - i--; - continue; - } - - // Insert all footnote backlinks - var paragraphBlock = footnote.LastChild as ParagraphBlock; - if (paragraphBlock == null) - { - paragraphBlock = new ParagraphBlock(); - footnote.Add(paragraphBlock); - } - if (paragraphBlock.Inline == null) - { - paragraphBlock.Inline = new ContainerInline(); - } - - foreach (var link in footnote.Links) - { - linkIndex++; - link.Index = linkIndex; - var backLink = new FootnoteLink() - { - Index = linkIndex, - IsBackLink = true, - Footnote = footnote - }; - paragraphBlock.Inline.AppendChild(backLink); - } - } - } - - private static Inline CreateLinkToFootnote(InlineProcessor state, LinkReferenceDefinition linkRef, Inline child) - { - var footnote = ((FootnoteLinkReferenceDefinition)linkRef).Footnote; - if (footnote.Order < 0) - { - var footnotes = (FootnoteGroup)state.Document.GetData(DocumentKey); - footnotes.CurrentOrder++; - footnote.Order = footnotes.CurrentOrder; - } - - var link = new FootnoteLink() {Footnote = footnote}; - footnote.Links.Add(link); - - return link; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Footnotes/HtmlFootnoteGroupRenderer.cs b/NppMarkdownPanel/Markdig/Extensions/Footnotes/HtmlFootnoteGroupRenderer.cs deleted file mode 100644 index a4e8b01..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Footnotes/HtmlFootnoteGroupRenderer.cs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Renderers; -using Markdig.Renderers.Html; - -namespace Markdig.Extensions.Footnotes -{ - /// - /// A HTML renderer for a . - /// - /// - public class HtmlFootnoteGroupRenderer : HtmlObjectRenderer - { - /// - /// Initializes a new instance of the class. - /// - public HtmlFootnoteGroupRenderer() - { - GroupClass = "footnotes"; - } - - /// - /// Gets or sets the CSS group class used when rendering the <div> of this instance. - /// - public string GroupClass { get; set; } - - protected override void Write(HtmlRenderer renderer, FootnoteGroup footnotes) - { - renderer.EnsureLine(); - renderer.WriteLine($"
"); - renderer.WriteLine("
"); - renderer.WriteLine("
    "); - - for (int i = 0; i < footnotes.Count; i++) - { - var footnote = (Footnote)footnotes[i]; - renderer.WriteLine($"
  1. "); - renderer.WriteChildren(footnote); - renderer.WriteLine("
  2. "); - } - renderer.WriteLine("
"); - renderer.WriteLine("
"); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Footnotes/HtmlFootnoteLinkRenderer.cs b/NppMarkdownPanel/Markdig/Extensions/Footnotes/HtmlFootnoteLinkRenderer.cs deleted file mode 100644 index 7289c5e..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Footnotes/HtmlFootnoteLinkRenderer.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Helpers; -using Markdig.Renderers; -using Markdig.Renderers.Html; - -namespace Markdig.Extensions.Footnotes -{ - /// - /// A HTML renderer for a . - /// - /// - public class HtmlFootnoteLinkRenderer : HtmlObjectRenderer - { - public HtmlFootnoteLinkRenderer() - { - BackLinkString = "↩"; - FootnoteLinkClass = "footnote-ref"; - FootnoteBackLinkClass = "footnote-back-ref"; - } - public string BackLinkString { get; set; } - - public string FootnoteLinkClass { get; set; } - - public string FootnoteBackLinkClass { get; set; } - - protected override void Write(HtmlRenderer renderer, FootnoteLink link) - { - var order = link.Footnote.Order; - renderer.Write(link.IsBackLink - ? $"
{BackLinkString}" - : $"{order}"); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/GenericAttributes/GenericAttributesExtension.cs b/NppMarkdownPanel/Markdig/Extensions/GenericAttributes/GenericAttributesExtension.cs deleted file mode 100644 index eb4821a..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/GenericAttributes/GenericAttributesExtension.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using Markdig.Helpers; -using Markdig.Parsers; -using Markdig.Renderers; -using Markdig.Renderers.Html; -using Markdig.Syntax; -using Markdig.Syntax.Inlines; - -namespace Markdig.Extensions.GenericAttributes -{ - /// - /// Extension that allows to attach HTML attributes to the previous or current . - /// This extension should be enabled last after enabling other extensions. - /// - /// - public class GenericAttributesExtension : IMarkdownExtension - { - public void Setup(MarkdownPipelineBuilder pipeline) - { - if (!pipeline.InlineParsers.Contains()) - { - pipeline.InlineParsers.Insert(0, new GenericAttributesParser()); - } - - // Plug into all IAttributesParseable - foreach (var parser in pipeline.BlockParsers) - { - var attributesParseable = parser as IAttributesParseable; - if (attributesParseable != null) - { - attributesParseable.TryParseAttributes = TryProcessAttributesForHeading; - } - } - } - - public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer) - { - } - - private bool TryProcessAttributesForHeading(BlockProcessor processor, ref StringSlice line, IBlock block) - { - // Try to find if there is any attributes { in the info string on the first line of a FencedCodeBlock - if (line.Start < line.End) - { - int indexOfAttributes = line.IndexOf('{'); - if (indexOfAttributes >= 0) - { - // Work on a copy - var copy = line; - copy.Start = indexOfAttributes; - var startOfAttributes = copy.Start; - HtmlAttributes attributes; - if (GenericAttributesParser.TryParse(ref copy, out attributes)) - { - var htmlAttributes = block.GetAttributes(); - attributes.CopyTo(htmlAttributes); - - // Update position for HtmlAttributes - htmlAttributes.Line = processor.LineIndex; - htmlAttributes.Column = startOfAttributes - processor.CurrentLineStartPosition; // This is not accurate with tabs! - htmlAttributes.Span.Start = startOfAttributes; - htmlAttributes.Span.End = copy.Start - 1; - - line.End = indexOfAttributes - 1; - return true; - } - } - } - return false; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/GenericAttributes/GenericAttributesParser.cs b/NppMarkdownPanel/Markdig/Extensions/GenericAttributes/GenericAttributesParser.cs deleted file mode 100644 index 0fa4bf2..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/GenericAttributes/GenericAttributesParser.cs +++ /dev/null @@ -1,278 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.Collections.Generic; -using Markdig.Helpers; -using Markdig.Parsers; -using Markdig.Renderers.Html; -using Markdig.Syntax; -using Markdig.Syntax.Inlines; - -namespace Markdig.Extensions.GenericAttributes -{ - /// - /// An inline parser used to parse a HTML attributes that can be attached to the previous or current . - /// - /// - public class GenericAttributesParser : InlineParser - { - /// - /// Initializes a new instance of the class. - /// - public GenericAttributesParser() - { - OpeningCharacters = new[] { '{' }; - } - - public override bool Match(InlineProcessor processor, ref StringSlice slice) - { - HtmlAttributes attributes; - var startPosition = slice.Start; - if (TryParse(ref slice, out attributes)) - { - var inline = processor.Inline; - - // If the curent object to attach is either a literal or delimiter - // try to find a suitable parent, otherwise attach the html attributes to the block - if (inline is LiteralInline) - { - while (true) - { - inline = inline.Parent; - if (!(inline is DelimiterInline)) - { - break; - } - } - } - var objectToAttach = inline == null || inline == processor.Root ? (MarkdownObject) processor.Block : inline; - - // If the current block is a Paragraph, but only the HtmlAttributes is used, - // Try to attach the attributes to the following block - var paragraph = objectToAttach as ParagraphBlock; - if (paragraph != null && paragraph.Inline.FirstChild == null && processor.Inline == null && slice.IsEmptyOrWhitespace()) - { - var parent = paragraph.Parent; - var indexOfParagraph = parent.IndexOf(paragraph); - if (indexOfParagraph + 1 < parent.Count) - { - objectToAttach = parent[indexOfParagraph + 1]; - // We can remove the paragraph as it is empty - paragraph.RemoveAfterProcessInlines = true; - } - } - - var currentHtmlAttributes = objectToAttach.GetAttributes(); - attributes.CopyTo(currentHtmlAttributes, true, false); - - // Update the position of the attributes - int line; - int column; - currentHtmlAttributes.Span.Start = processor.GetSourcePosition(startPosition, out line, out column); - currentHtmlAttributes.Line = line; - currentHtmlAttributes.Column = column; - currentHtmlAttributes.Span.End = currentHtmlAttributes.Span.Start + slice.Start - startPosition - 1; - - // We don't set the processor.Inline as we don't want to add attach attributes to a particular entity - return true; - } - - return false; - } - - /// - /// Tries to extra from the current position of a slice an HTML attributes {...} - /// - /// The slice to parse. - /// The output attributes or null if not found or invalid - /// true if parsing the HTML attributes was succsesfull - public static bool TryParse(ref StringSlice slice, out HtmlAttributes attributes) - { - attributes = null; - if (slice.PeekCharExtra(-1) == '{') - { - return false; - } - - var line = slice; - - string id = null; - List classes = null; - List> properties = null; - - bool isValid = false; - var c = line.NextChar(); - while (true) - { - if (c == '}') - { - isValid = true; - line.NextChar(); // skip } - break; - } - - if (c == '\0') - { - break; - } - - bool isClass = c == '.'; - if (c == '#' || isClass) - { - c = line.NextChar(); // Skip # - var start = line.Start; - // Get all non-whitespace characters following a # - // But stop if we found a } or \0 - while (c != '}' && c != '\0' && !c.IsWhitespace()) - { - c = line.NextChar(); - } - var end = line.Start - 1; - if (end == start) - { - break; - } - var text = slice.Text.Substring(start, end - start + 1); - if (isClass) - { - if (classes == null) - { - classes = new List(); - } - classes.Add(text); - } - else - { - id = text; - } - continue; - } - - if (!c.IsWhitespace()) - { - // Parse the attribute name - if (!IsStartAttributeName(c)) - { - break; - } - var startName = line.Start; - while (true) - { - c = line.NextChar(); - if (!(c.IsAlphaNumeric() || c == '_' || c == ':' || c == '.' || c == '-')) - { - break; - } - } - var name = slice.Text.Substring(startName, line.Start - startName); - - var hasSpace = c.IsSpaceOrTab(); - - // Skip any whitespaces - line.TrimStart(); - c = line.CurrentChar; - - // Handle boolean properties that are not followed by = - if ((hasSpace && (c == '.' || c == '#' || IsStartAttributeName(c))) || c == '}') - { - if (properties == null) - { - properties = new List>(); - } - // Add a null value for the property - properties.Add(new KeyValuePair(name, null)); - continue; - } - - // Else we expect a regular property - if (line.CurrentChar != '=') - { - break; - } - - // Go to next char, skip any spaces - line.NextChar(); - line.TrimStart(); - - int startValue = -1; - int endValue = -1; - - c = line.CurrentChar; - // Parse a quoted string - if (c == '\'' || c == '"') - { - char openingStringChar = c; - startValue = line.Start + 1; - while (true) - { - c = line.NextChar(); - if (c == '\0') - { - return false; - } - if (c == openingStringChar) - { - break; - } - } - endValue = line.Start - 1; - c = line.NextChar(); // Skip closing opening string char - } - else - { - // Parse until we match a space or a special html character - startValue = line.Start; - while (true) - { - if (c == '\0') - { - return false; - } - if (c.IsWhitespace() || c == '}') - { - break; - } - c = line.NextChar(); - } - endValue = line.Start - 1; - if (endValue == startValue) - { - break; - } - } - - var value = slice.Text.Substring(startValue, endValue - startValue + 1); - - if (properties == null) - { - properties = new List>(); - } - properties.Add(new KeyValuePair(name, value)); - continue; - } - - c = line.NextChar(); - } - - if (isValid) - { - attributes = new HtmlAttributes() - { - Id = id, - Classes = classes, - Properties = properties - }; - - // Assign back the current processor of the line to - slice = line; - } - return isValid; - } - - private static bool IsStartAttributeName(char c) - { - return c.IsAlpha() || c == '_' || c == ':'; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Globalization/GlobalizationExtension.cs b/NppMarkdownPanel/Markdig/Extensions/Globalization/GlobalizationExtension.cs deleted file mode 100644 index 5855fa4..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Globalization/GlobalizationExtension.cs +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Extensions.Tables; -using Markdig.Extensions.TaskLists; -using Markdig.Helpers; -using Markdig.Renderers; -using Markdig.Renderers.Html; -using Markdig.Syntax; -using Markdig.Syntax.Inlines; -using System.Collections.Generic; - -namespace Markdig.Extensions.Globalization -{ - /// - /// Extension to add support for RTL content. - /// - public class GlobalizationExtension : IMarkdownExtension - { - - public void Setup(MarkdownPipelineBuilder pipeline) - { - // Make sure we don't have a delegate twice - pipeline.DocumentProcessed -= Pipeline_DocumentProcessed; - pipeline.DocumentProcessed += Pipeline_DocumentProcessed; - } - - private void Pipeline_DocumentProcessed(MarkdownDocument document) - { - foreach (var node in document.Descendants()) - { - if (node is TableRow || node is TableCell || node is ListItemBlock) - continue; - - if (ShouldBeRightToLeft(node)) - { - var attributes = node.GetAttributes(); - attributes.AddPropertyIfNotExist("dir", "rtl"); - - if (node is Table table) - { - attributes.AddPropertyIfNotExist("align", "right"); - } - } - } - } - - public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer) - { - - } - - private bool ShouldBeRightToLeft(MarkdownObject item) - { - if (item is IEnumerable container) - { - foreach (var child in container) - { - // TaskList items contain an "X", which will cause - // the function to always return false. - if (child is TaskList) - continue; - - return ShouldBeRightToLeft(child); - } - } - else if (item is LeafBlock leaf) - { - return ShouldBeRightToLeft(leaf.Inline); - } - else if (item is LiteralInline literal) - { - return StartsWithRtlCharacter(literal.ToString()); - } - - foreach (var descendant in item.Descendants()) - { - if (descendant is ParagraphBlock p) - { - foreach (var i in p.Inline) - { - if (i is LiteralInline l) - { - return StartsWithRtlCharacter(l.ToString()); - } - } - } - } - - return false; - } - - private bool StartsWithRtlCharacter(string text) - { - foreach (var c in CharHelper.ToUtf32(text)) - { - if (CharHelper.IsRightToLeft(c)) - return true; - - else if (CharHelper.IsLeftToRight(c)) - return false; - } - - return false; - } - } -} diff --git a/NppMarkdownPanel/Markdig/Extensions/Hardlines/SoftlineBreakAsHardlineExtension.cs b/NppMarkdownPanel/Markdig/Extensions/Hardlines/SoftlineBreakAsHardlineExtension.cs deleted file mode 100644 index 791bcc0..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Hardlines/SoftlineBreakAsHardlineExtension.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Parsers.Inlines; -using Markdig.Renderers; - -namespace Markdig.Extensions.Hardlines -{ - /// - /// Extension to generate hardline break for softline breaks. - /// - /// - public class SoftlineBreakAsHardlineExtension : IMarkdownExtension - { - public void Setup(MarkdownPipelineBuilder pipeline) - { - // Simply modify the LineBreakInlineParser - // TODO: We might want more options (like pandoc) - var parser = pipeline.InlineParsers.Find(); - if (parser != null) - { - parser.EnableSoftAsHard = true; - } - } - - public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer) - { - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/JiraLinks/JiraLink.cs b/NppMarkdownPanel/Markdig/Extensions/JiraLinks/JiraLink.cs deleted file mode 100644 index 078865e..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/JiraLinks/JiraLink.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System.Diagnostics; -using Markdig.Helpers; -using Markdig.Syntax.Inlines; - -namespace Markdig.Extensions.JiraLinks -{ - /// - /// Model for a JIRA link item - /// - [DebuggerDisplay("{ProjectKey}-{Issue}")] - public class JiraLink : LinkInline - { - public JiraLink() - { - IsClosed = true; - } - - /// - /// JIRA Project Key - /// - public StringSlice ProjectKey { get; set; } - - /// - /// JIRA Issue Number - /// - public StringSlice Issue { get; set; } - } -} diff --git a/NppMarkdownPanel/Markdig/Extensions/JiraLinks/JiraLinkExtension.cs b/NppMarkdownPanel/Markdig/Extensions/JiraLinks/JiraLinkExtension.cs deleted file mode 100644 index 169970f..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/JiraLinks/JiraLinkExtension.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Parsers.Inlines; -using Markdig.Renderers; -using Markdig.Renderers.Normalize.Inlines; -using Markdig.Renderers.Normalize; - -namespace Markdig.Extensions.JiraLinks -{ - /// - /// Simple inline parser extension for Markdig to find, and - /// automatically add links to JIRA issue numbers. - /// - public class JiraLinkExtension : IMarkdownExtension - { - private readonly JiraLinkOptions _options; - - public JiraLinkExtension(JiraLinkOptions options) - { - _options = options; - } - - public void Setup(MarkdownPipelineBuilder pipeline) - { - if (!pipeline.InlineParsers.Contains()) - { - // Insert the parser before the link inline parser - pipeline.InlineParsers.InsertBefore(new JiraLinkInlineParser(_options)); - } - } - - public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer) - { - // No HTML renderer required, since JiraLink type derives from InlineLink (which already has an HTML renderer) - - var normalizeRenderer = renderer as NormalizeRenderer; - if (normalizeRenderer != null && !normalizeRenderer.ObjectRenderers.Contains()) - { - normalizeRenderer.ObjectRenderers.InsertBefore(new NormalizeJiraLinksRenderer()); - } - } - } - -} diff --git a/NppMarkdownPanel/Markdig/Extensions/JiraLinks/JiraLinkInlineParser.cs b/NppMarkdownPanel/Markdig/Extensions/JiraLinks/JiraLinkInlineParser.cs deleted file mode 100644 index 2191189..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/JiraLinks/JiraLinkInlineParser.cs +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System; -using System.Text; -using Markdig.Helpers; -using Markdig.Parsers; -using Markdig.Renderers.Html; -using Markdig.Syntax.Inlines; - -namespace Markdig.Extensions.JiraLinks -{ - /// - /// Finds and replaces JIRA links inline - /// - public class JiraLinkInlineParser : InlineParser - { - private readonly JiraLinkOptions _options; - private readonly string _baseUrl; - - public JiraLinkInlineParser(JiraLinkOptions options) - { - _options = options ?? throw new ArgumentNullException(nameof(options)); - _baseUrl = _options.GetUrl(); - //look for uppercase chars at the start (for the project key) - OpeningCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray(); - } - - public override bool Match(InlineProcessor processor, ref StringSlice slice) - { - // Allow preceding whitespace or `(` - var pc = slice.PeekCharExtra(-1); - if (!pc.IsWhiteSpaceOrZero() && pc != '(') - { - return false; - } - - var current = slice.CurrentChar; - - var startKey = slice.Start; - var endKey = slice.Start; - - //read as many uppercase characters as required - project key - while (current.IsAlphaUpper()) - { - endKey = slice.Start; - current = slice.NextChar(); - } - - //require a '-' between key and issue number - if (!current.Equals('-')) - { - return false; - } - - current = slice.NextChar(); // skip - - - //read as many numbers as required - issue number - if (!current.IsDigit()) - { - return false; - } - - var startIssue = slice.Start; - var endIssue = slice.Start; - - while (current.IsDigit()) - { - endIssue = slice.Start; - current = slice.NextChar(); - } - - if (!current.IsWhiteSpaceOrZero() && current != ')') //can be followed only by a whitespace or `)` - { - return false; - } - - int line; - int column; - - var jiraLink = new JiraLink() //create the link at the relevant position - { - Span = - { - Start = processor.GetSourcePosition(slice.Start, out line, out column) - }, - Line = line, - Column = column, - Issue = new StringSlice(slice.Text, startIssue, endIssue), - ProjectKey = new StringSlice(slice.Text, startKey, endKey), - }; - jiraLink.Span.End = jiraLink.Span.Start + (endIssue - startKey); - - // Builds the Url - var builder = new StringBuilder(); - builder.Append(_baseUrl).Append('/').Append(jiraLink.ProjectKey).Append('-').Append(jiraLink.Issue); - jiraLink.Url = builder.ToString(); - - // Builds the Label - builder.Length = 0; - builder.Append(jiraLink.ProjectKey).Append('-').Append(jiraLink.Issue); - jiraLink.AppendChild(new LiteralInline(builder.ToString())); - - if (_options.OpenInNewWindow) - { - jiraLink.GetAttributes().AddProperty("target", "blank"); - } - - processor.Inline = jiraLink; - - return true; - } - } - -} diff --git a/NppMarkdownPanel/Markdig/Extensions/JiraLinks/JiraLinkOptions.cs b/NppMarkdownPanel/Markdig/Extensions/JiraLinks/JiraLinkOptions.cs deleted file mode 100644 index 16f5d91..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/JiraLinks/JiraLinkOptions.cs +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System.Text; - -namespace Markdig.Extensions.JiraLinks -{ - /// - /// Available options for replacing JIRA links - /// - public class JiraLinkOptions - { - /// - /// The base Url (e.g. `https://mycompany.atlassian.net`) - /// - public string BaseUrl { get; set; } - - /// - /// The base path after the base url (default is `/browse`) - /// - public string BasePath { get; set; } - - /// - /// Should the link open in a new window when clicked - /// - public bool OpenInNewWindow { get; set; } - - public JiraLinkOptions(string baseUrl) - { - OpenInNewWindow = true; //default - BaseUrl = baseUrl; - BasePath = "/browse"; - } - - /// - /// Gets the full url composed of the and with no trailing `/` - /// - public virtual string GetUrl() - { - var url = new StringBuilder(); - var baseUrl = BaseUrl; - if (baseUrl != null) - { - url.Append(baseUrl.TrimEnd('/')); - } - - url.Append("/"); - - if (BasePath != null) - { - url.Append(BasePath.Trim('/')); - } - - return url.ToString(); - } - } -} diff --git a/NppMarkdownPanel/Markdig/Extensions/JiraLinks/NormalizeJiraLinksRenderer.cs b/NppMarkdownPanel/Markdig/Extensions/JiraLinks/NormalizeJiraLinksRenderer.cs deleted file mode 100644 index 754bc96..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/JiraLinks/NormalizeJiraLinksRenderer.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Markdig.Renderers.Normalize; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Markdig.Extensions.JiraLinks -{ - public class NormalizeJiraLinksRenderer : NormalizeObjectRenderer - { - protected override void Write(NormalizeRenderer renderer, JiraLink obj) - { - renderer.Write(obj.ProjectKey); - renderer.Write("-"); - renderer.Write(obj.Issue); - } - } -} diff --git a/NppMarkdownPanel/Markdig/Extensions/ListExtras/ListExtraExtension.cs b/NppMarkdownPanel/Markdig/Extensions/ListExtras/ListExtraExtension.cs deleted file mode 100644 index 6dd2712..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/ListExtras/ListExtraExtension.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Parsers; -using Markdig.Renderers; - -namespace Markdig.Extensions.ListExtras -{ - /// - /// Extension for adding new type of list items (a., A., i., I.) - /// - /// - public class ListExtraExtension : IMarkdownExtension - { - public void Setup(MarkdownPipelineBuilder pipeline) - { - var parser = pipeline.BlockParsers.Find(); - if (parser != null) - { - parser.ItemParsers.AddIfNotAlready(); - } - } - - public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer) - { - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/ListExtras/ListExtraItemParser.cs b/NppMarkdownPanel/Markdig/Extensions/ListExtras/ListExtraItemParser.cs deleted file mode 100644 index e195902..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/ListExtras/ListExtraItemParser.cs +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Helpers; -using Markdig.Parsers; - -namespace Markdig.Extensions.ListExtras -{ - using System; - - /// - /// Parser that adds supports for parsing alpha/roman list items (e.g: `a)` or `a.` or `ii.` or `II.`) - /// - /// - /// Note that we don't validate roman numbers. - /// - /// - public class ListExtraItemParser : OrderedListItemParser - { - /// - /// Initializes a new instance of the class. - /// - public ListExtraItemParser() - { - OpeningCharacters = new char[('z' - 'a' + 1)*2]; - int index = 0; - for (var c = 'A'; c <= 'Z'; c++) - { - OpeningCharacters[index++] = c; - OpeningCharacters[index++] = (char)(c - 'A' + 'a'); - } - } - - public override bool TryParse(BlockProcessor state, char pendingBulletType, out ListInfo result) - { - result = new ListInfo(); - - var c = state.CurrentChar; - - var isRomanLow = CharHelper.IsRomanLetterLowerPartial(c); - var isRomanUp = !isRomanLow && CharHelper.IsRomanLetterUpperPartial(c); - - // We allow to parse roman only if we start on a new list or the pending list is already a roman list) - if ((isRomanLow || isRomanUp) && (pendingBulletType == '\0' || pendingBulletType == 'i' || pendingBulletType == 'I')) - { - int startChar = state.Start; - int endChar = 0; - // With a roman, we can have multiple characters - // Note that we don't validate roman numbers - while (isRomanLow ? CharHelper.IsRomanLetterLowerPartial(c) : CharHelper.IsRomanLetterUpperPartial(c)) - { - endChar = state.Start; - c = state.NextChar(); - } - - result.OrderedStart = CharHelper.RomanToArabic(state.Line.Text.Substring(startChar, endChar - startChar + 1)).ToString(); - result.BulletType = isRomanLow ? 'i' : 'I'; - result.DefaultOrderedStart = isRomanLow ? "i" : "I"; - } - else - { - // otherwise we expect a regular alpha lettered list with a single character. - var isUpper = c.IsAlphaUpper(); - result.OrderedStart = (Char.ToUpperInvariant(c) - 64).ToString(); - result.BulletType = isUpper ? 'A' : 'a'; - result.DefaultOrderedStart = isUpper ? "A" : "a"; - state.NextChar(); - } - - // Finally we expect to always have a delimiter '.' or ')' - char orderedDelimiter; - if (!TryParseDelimiter(state, out orderedDelimiter)) - { - return false; - } - - result.OrderedDelimiter = orderedDelimiter; - return true; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Mathematics/HtmlMathBlockRenderer.cs b/NppMarkdownPanel/Markdig/Extensions/Mathematics/HtmlMathBlockRenderer.cs deleted file mode 100644 index e5b19ad..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Mathematics/HtmlMathBlockRenderer.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Renderers; -using Markdig.Renderers.Html; - -namespace Markdig.Extensions.Mathematics -{ - /// - /// A HTML renderer for a . - /// - /// - public class HtmlMathBlockRenderer : HtmlObjectRenderer - { - protected override void Write(HtmlRenderer renderer, MathBlock obj) - { - renderer.EnsureLine(); - renderer.Write(""); - renderer.WriteLine("\\["); - renderer.WriteLeafRawLines(obj, true, true); - renderer.Write("\\]"); - renderer.WriteLine(""); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Mathematics/HtmlMathInlineRenderer.cs b/NppMarkdownPanel/Markdig/Extensions/Mathematics/HtmlMathInlineRenderer.cs deleted file mode 100644 index b01f6a0..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Mathematics/HtmlMathInlineRenderer.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Renderers; -using Markdig.Renderers.Html; - -namespace Markdig.Extensions.Mathematics -{ - /// - /// A HTML renderer for a . - /// - /// - public class HtmlMathInlineRenderer : HtmlObjectRenderer - { - protected override void Write(HtmlRenderer renderer, MathInline obj) - { - renderer.Write("\\("); - renderer.WriteEscape(ref obj.Content); - renderer.Write("\\)"); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Mathematics/MathBlock.cs b/NppMarkdownPanel/Markdig/Extensions/Mathematics/MathBlock.cs deleted file mode 100644 index 866d500..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Mathematics/MathBlock.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Parsers; -using Markdig.Syntax; - -namespace Markdig.Extensions.Mathematics -{ - /// - /// A math block. - /// - /// - public class MathBlock : FencedCodeBlock - { - /// - /// Initializes a new instance of the class. - /// - /// The parser. - public MathBlock(BlockParser parser) : base(parser) - { - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Mathematics/MathBlockParser.cs b/NppMarkdownPanel/Markdig/Extensions/Mathematics/MathBlockParser.cs deleted file mode 100644 index 61c5368..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Mathematics/MathBlockParser.cs +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Helpers; -using Markdig.Parsers; -using Markdig.Renderers.Html; -using Markdig.Syntax; - -namespace Markdig.Extensions.Mathematics -{ - /// - /// The block parser for a . - /// - /// - public class MathBlockParser : FencedBlockParserBase - { - /// - /// Initializes a new instance of the class. - /// - public MathBlockParser() - { - OpeningCharacters = new [] {'$'}; - // We expect to match only a $$, no less, no more - MinimumMatchCount = 2; - MaximumMatchCount = 2; - - InfoParser = NoInfoParser; - - DefaultClass = "math"; - - // We don't need a prefix - InfoPrefix = null; - } - - public string DefaultClass { get; set; } - - protected override MathBlock CreateFencedBlock(BlockProcessor processor) - { - var block = new MathBlock(this); - if (DefaultClass != null) - { - block.GetAttributes().AddClass(DefaultClass); - } - return block; - } - - private static bool NoInfoParser(BlockProcessor state, ref StringSlice line, IFencedBlock fenced) - { - var c = line.CurrentChar; - for (int i = line.Start; i <= line.End; i++) - { - c = line.Text[i]; - if (!c.IsSpaceOrTab()) - { - return false; - } - } - return true; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Mathematics/MathExtension.cs b/NppMarkdownPanel/Markdig/Extensions/Mathematics/MathExtension.cs deleted file mode 100644 index 17d58e7..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Mathematics/MathExtension.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Parsers.Inlines; -using Markdig.Renderers; -using Markdig.Renderers.Html.Inlines; - -namespace Markdig.Extensions.Mathematics -{ - /// - /// Extension for adding inline mathematics $...$ - /// - /// - public class MathExtension : IMarkdownExtension - { - public void Setup(MarkdownPipelineBuilder pipeline) - { - // Adds the inline parser - if (!pipeline.InlineParsers.Contains()) - { - pipeline.InlineParsers.Insert(0, new MathInlineParser()); - } - - // Adds the block parser - if (!pipeline.BlockParsers.Contains()) - { - // Insert before EmphasisInlineParser to take precedence - pipeline.BlockParsers.Insert(0, new MathBlockParser()); - } - } - - public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer) - { - var htmlRenderer = renderer as HtmlRenderer; - if (htmlRenderer != null) - { - if (!htmlRenderer.ObjectRenderers.Contains()) - { - htmlRenderer.ObjectRenderers.Insert(0, new HtmlMathInlineRenderer()); - } - if (!htmlRenderer.ObjectRenderers.Contains()) - { - htmlRenderer.ObjectRenderers.Insert(0, new HtmlMathBlockRenderer()); - } - } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Mathematics/MathInline.cs b/NppMarkdownPanel/Markdig/Extensions/Mathematics/MathInline.cs deleted file mode 100644 index ea48048..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Mathematics/MathInline.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Helpers; -using Markdig.Syntax.Inlines; - -namespace Markdig.Extensions.Mathematics -{ - /// - /// A math inline element. - /// - /// - public class MathInline : LeafInline - { - /// - /// Gets or sets the delimiter character used by this code inline. - /// - public char Delimiter { get; set; } - - /// - /// Gets or sets the delimiter count. - /// - public int DelimiterCount { get; set; } - - /// - /// The content as a . - /// - public StringSlice Content; - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Mathematics/MathInlineParser.cs b/NppMarkdownPanel/Markdig/Extensions/Mathematics/MathInlineParser.cs deleted file mode 100644 index 48cff5b..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Mathematics/MathInlineParser.cs +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Helpers; -using Markdig.Parsers; -using Markdig.Renderers.Html; -using Markdig.Syntax; - -namespace Markdig.Extensions.Mathematics -{ - /// - /// An inline parser for . - /// - /// - /// - public class MathInlineParser : InlineParser - { - /// - /// Initializes a new instance of the class. - /// - public MathInlineParser() - { - OpeningCharacters = new[] {'$'}; - DefaultClass = "math"; - } - - /// - /// Gets or sets the default class to use when creating a math inline block. - /// - public string DefaultClass { get; set; } - - public override bool Match(InlineProcessor processor, ref StringSlice slice) - { - var match = slice.CurrentChar; - var pc = slice.PeekCharExtra(-1); - if (pc == match) - { - return false; - } - - var startPosition = slice.Start; - - // Match the opened $ or $$ - int openDollars = 1; // we have at least a $ - var c = slice.NextChar(); - if (c == match) - { - openDollars++; - c = slice.NextChar(); - } - - bool openPrevIsPunctuation; - bool openPrevIsWhiteSpace; - bool openNextIsPunctuation; - bool openNextIsWhiteSpace; - bool openNextIsDigit = c.IsDigit(); - pc.CheckUnicodeCategory(out openPrevIsWhiteSpace, out openPrevIsPunctuation); - c.CheckUnicodeCategory(out openNextIsWhiteSpace, out openNextIsPunctuation); - - // Check that opening $/$$ is correct, using the different heuristics than for emphasis delimiters - // If a $/$$ is not preceded by a whitespace or punctuation, or followed by a digit - // this is a not a math block - if ((!openPrevIsWhiteSpace && !openPrevIsPunctuation) || openNextIsDigit) - { - return false; - } - - bool isMatching = false; - int closeDollars = 0; - - // Eat any leading spaces - while (c.IsSpaceOrTab()) - { - c = slice.NextChar(); - } - - var start = slice.Start; - var end = 0; - - pc = match; - var lastWhiteSpace = -1; - while (c != '\0') - { - // Don't allow newline in an inline math expression - if (c == '\r' || c == '\n') - { - return false; - } - - // Don't process sticks if we have a '\' as a previous char - if (pc != '\\' ) - { - // Record continous whitespaces at the end - if (c.IsSpaceOrTab()) - { - if (lastWhiteSpace < 0) - { - lastWhiteSpace = slice.Start; - } - } - else - { - bool hasClosingDollars = c == match; - if (hasClosingDollars) - { - while (c == match) - { - closeDollars++; - c = slice.NextChar(); - } - } - - if (closeDollars >= openDollars) - { - break; - } - - lastWhiteSpace = -1; - if (hasClosingDollars) - { - pc = match; - continue; - } - } - } - - if (closeDollars > 0) - { - closeDollars = 0; - } - else - { - pc = c; - c = slice.NextChar(); - } - } - - if (closeDollars >= openDollars) - { - bool closePrevIsPunctuation; - bool closePrevIsWhiteSpace; - bool closeNextIsPunctuation; - bool closeNextIsWhiteSpace; - pc.CheckUnicodeCategory(out closePrevIsWhiteSpace, out closePrevIsPunctuation); - c.CheckUnicodeCategory(out closeNextIsWhiteSpace, out closeNextIsPunctuation); - - // A closing $/$$ should be followed by at least a punctuation or a whitespace - // and if the character after an openning $/$$ was a whitespace, it should be - // a whitespace as well for the character preceding the closing of $/$$ - if ((!closeNextIsPunctuation && !closeNextIsWhiteSpace) || (openNextIsWhiteSpace != closePrevIsWhiteSpace)) - { - return false; - } - - if (closePrevIsWhiteSpace && lastWhiteSpace > 0) - { - end = lastWhiteSpace + openDollars - 1; - } - else - { - end = slice.Start - 1; - } - - // Create a new MathInline - int line; - int column; - var inline = new MathInline() - { - Span = new SourceSpan(processor.GetSourcePosition(startPosition, out line, out column), processor.GetSourcePosition(slice.End)), - Line = line, - Column = column, - Delimiter = match, - DelimiterCount = openDollars, - Content = slice - }; - inline.Content.Start = start; - // We substract the end to the number of opening $ to keep inside the block the additionals $ - inline.Content.End = end - openDollars; - - // Add the default class if necessary - if (DefaultClass != null) - { - inline.GetAttributes().AddClass(DefaultClass); - } - processor.Inline = inline; - isMatching = true; - } - - return isMatching; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/MediaLinks/MediaLinkExtension.cs b/NppMarkdownPanel/Markdig/Extensions/MediaLinks/MediaLinkExtension.cs deleted file mode 100644 index a0ea4b7..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/MediaLinks/MediaLinkExtension.cs +++ /dev/null @@ -1,226 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Linq; -using Markdig.Renderers; -using Markdig.Renderers.Html; -using Markdig.Renderers.Html.Inlines; -using Markdig.Syntax.Inlines; - -namespace Markdig.Extensions.MediaLinks -{ - /// - /// Extension for extending image Markdown links in case a video or an audio file is linked and output proper link. - /// - /// - public class MediaLinkExtension : IMarkdownExtension - { - public MediaLinkExtension() : this(new MediaOptions()) - { - } - - public MediaLinkExtension(MediaOptions options) - { - Options = options ?? new MediaOptions(); - } - - public MediaOptions Options { get; } - - public void Setup(MarkdownPipelineBuilder pipeline) - { - } - - public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer) - { - var htmlRenderer = renderer as HtmlRenderer; - if (htmlRenderer != null) - { - var inlineRenderer = htmlRenderer.ObjectRenderers.FindExact(); - if (inlineRenderer != null) - { - inlineRenderer.TryWriters.Remove(TryLinkInlineRenderer); - inlineRenderer.TryWriters.Add(TryLinkInlineRenderer); - } - } - } - - private bool TryLinkInlineRenderer(HtmlRenderer renderer, LinkInline linkInline) - { - if (!linkInline.IsImage || linkInline.Url == null) - { - return false; - } - - Uri uri; - // Only process absolute Uri - if (!Uri.TryCreate(linkInline.Url, UriKind.RelativeOrAbsolute, out uri) || !uri.IsAbsoluteUri) - { - return false; - } - - if (TryRenderIframeFromKnownProviders(uri, renderer, linkInline)) - { - return true; - } - - if (TryGuessAudioVideoFile(uri, renderer, linkInline)) - { - return true; - } - - return false; - } - - private static HtmlAttributes GetHtmlAttributes(LinkInline linkInline) - { - var htmlAttributes = new HtmlAttributes(); - var fromAttributes = linkInline.TryGetAttributes(); - if (fromAttributes != null) - { - fromAttributes.CopyTo(htmlAttributes, false, false); - } - - return htmlAttributes; - } - - private bool TryGuessAudioVideoFile(Uri uri, HtmlRenderer renderer, LinkInline linkInline) - { - var path = uri.GetComponents(UriComponents.Path, UriFormat.Unescaped); - // Otherwise try to detect if we have an audio/video from the file extension - string mimeType; - var lastDot = path.LastIndexOf('.'); - if (lastDot >= 0 && - Options.ExtensionToMimeType.TryGetValue(path.Substring(lastDot), out mimeType)) - { - var htmlAttributes = GetHtmlAttributes(linkInline); - var isAudio = mimeType.StartsWith("audio"); - var tagType = isAudio ? "audio" : "video"; - - renderer.Write($"<{tagType}"); - htmlAttributes.AddPropertyIfNotExist("width", Options.Width); - if (!isAudio) - { - htmlAttributes.AddPropertyIfNotExist("height", Options.Height); - } - htmlAttributes.AddPropertyIfNotExist("controls", null); - renderer.WriteAttributes(htmlAttributes); - - renderer.Write($">"); - - return true; - } - return false; - } - - #region Known providers - - private class KnownProvider - { - public string HostPrefix { get; set; } - public Func Delegate { get; set; } - public bool AllowFullScreen { get; set; } = true; //Should be false for audio embedding - } - - private static readonly List KnownHosts = new List() - { - new KnownProvider {HostPrefix = "www.youtube.com", Delegate = YouTube}, - new KnownProvider {HostPrefix = "vimeo.com", Delegate = Vimeo}, - new KnownProvider {HostPrefix = "music.yandex.ru", Delegate = Yandex, AllowFullScreen = false}, - new KnownProvider {HostPrefix = "ok.ru", Delegate = Odnoklassniki}, - }; - - - private bool TryRenderIframeFromKnownProviders(Uri uri, HtmlRenderer renderer, LinkInline linkInline) - { - var foundProvider = - KnownHosts - .Where(pair => uri.Host.StartsWith(pair.HostPrefix, StringComparison.OrdinalIgnoreCase)) // when host is match - .Select(provider => - new - { - provider.AllowFullScreen, - Result = provider.Delegate(uri) // try to call delegate to get iframeUrl - } - ) - .FirstOrDefault(provider => provider.Result != null); // use first success - - if (foundProvider == null) - { - return false; - } - - var htmlAttributes = GetHtmlAttributes(linkInline); - renderer.Write($""); - - return true; - } - - private static readonly string[] SplitAnd = {"&"}; - private static string[] SplitQuery(Uri uri) - { - var query = uri.Query.Substring(uri.Query.IndexOf('?') + 1); - return query.Split(SplitAnd, StringSplitOptions.RemoveEmptyEntries); - } - - private static string YouTube(Uri uri) - { - var query = SplitQuery(uri); - return query.Length > 0 && query[0].StartsWith("v=") - ? $"https://www.youtube.com/embed/{query[0].Substring(2)}" - : null; - } - - private static string Vimeo(Uri uri) - { - var items = uri.GetComponents(UriComponents.Path, UriFormat.Unescaped).Split('/'); - return items.Length > 0 ? $"https://player.vimeo.com/video/{items[items.Length - 1]}" : null; - } - - private static string Odnoklassniki(Uri uri) - { - var items = uri.GetComponents(UriComponents.Path, UriFormat.Unescaped).Split('/'); - return items.Length > 0 ? $"https://ok.ru/videoembed/{items[items.Length - 1]}" : null; - } - - private static string Yandex(Uri uri) - { - var items = uri.GetComponents(UriComponents.Path, UriFormat.Unescaped).Split('/'); - var albumKeyword - = items.Skip(0).FirstOrDefault(); - var albumId - = items.Skip(1).FirstOrDefault(); - var trackKeyword - = items.Skip(2).FirstOrDefault(); - var trackId - = items.Skip(3).FirstOrDefault(); - - if (albumKeyword != "album" || albumId == null || trackKeyword != "track" || trackId == null) - { - return null; - } - - return $"https://music.yandex.ru/iframe/#track/{trackId}/{albumId}/"; - } - #endregion - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/MediaLinks/MediaOptions.cs b/NppMarkdownPanel/Markdig/Extensions/MediaLinks/MediaOptions.cs deleted file mode 100644 index 124b541..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/MediaLinks/MediaOptions.cs +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Collections.Generic; - -namespace Markdig.Extensions.MediaLinks -{ - /// - /// Options for the . - /// - public class MediaOptions - { - public MediaOptions() - { - Width = "500"; - Height = "281"; - Class = ""; - ExtensionToMimeType = new Dictionary(StringComparer.OrdinalIgnoreCase) - { - {".3gp", "video/3gpp"}, - {".3g2", "video/3gpp2"}, - {".avi", "video/x-msvideo"}, - {".uvh", "video/vnd.dece.hd"}, - {".uvm", "video/vnd.dece.mobile"}, - {".uvu", "video/vnd.uvvu.mp4"}, - {".uvp", "video/vnd.dece.pd"}, - {".uvs", "video/vnd.dece.sd"}, - {".uvv", "video/vnd.dece.video"}, - {".fvt", "video/vnd.fvt"}, - {".f4v", "video/x-f4v"}, - {".flv", "video/x-flv"}, - {".fli", "video/x-fli"}, - {".h261", "video/h261"}, - {".h263", "video/h263"}, - {".h264", "video/h264"}, - {".jpm", "video/jpm"}, - {".jpgv", "video/jpeg"}, - {".m4v", "video/x-m4v"}, - {".asf", "video/x-ms-asf"}, - {".pyv", "video/vnd.ms-playready.media.pyv"}, - {".wm", "video/x-ms-wm"}, - {".wmx", "video/x-ms-wmx"}, - {".wmv", "video/x-ms-wmv"}, - {".wvx", "video/x-ms-wvx"}, - {".mj2", "video/mj2"}, - {".mxu", "video/vnd.mpegurl"}, - {".mpeg", "video/mpeg"}, - {".mp4", "video/mp4"}, - {".ogv", "video/ogg"}, - {".webm", "video/webm"}, - {".qt", "video/quicktime"}, - {".movie", "video/x-sgi-movie"}, - {".viv", "video/vnd.vivo"}, - - {".adp", "audio/adpcm"}, - {".aac", "audio/x-aac"}, - {".aif", "audio/x-aiff"}, - {".uva", "audio/vnd.dece.audio"}, - {".eol", "audio/vnd.digital-winds"}, - {".dra", "audio/vnd.dra"}, - {".dts", "audio/vnd.dts"}, - {".dtshd", "audio/vnd.dts.hd"}, - {".rip", "audio/vnd.rip"}, - {".lvp", "audio/vnd.lucent.voice"}, - {".m3u", "audio/x-mpegurl"}, - {".pya", "audio/vnd.ms-playready.media.pya"}, - {".wma", "audio/x-ms-wma"}, - {".wax", "audio/x-ms-wax"}, - {".mid", "audio/midi"}, - {".mp3", "audio/mpeg"}, - {".mpga", "audio/mpeg"}, - {".mp4a", "audio/mp4"}, - {".ecelp4800", "audio/vnd.nuera.ecelp4800"}, - {".ecelp7470", "audio/vnd.nuera.ecelp7470"}, - {".ecelp9600", "audio/vnd.nuera.ecelp9600"}, - {".oga", "audio/ogg"}, - {".weba", "audio/webm"}, - {".ram", "audio/x-pn-realaudio"}, - {".rmp", "audio/x-pn-realaudio-plugin"}, - {".au", "audio/basic"}, - {".wav", "audio/x-wav"}, - }; - } - - public string Width { get; set; } - - public string Height { get; set; } - - public string Class { get; set; } - - public Dictionary ExtensionToMimeType { get; } - } -} diff --git a/NppMarkdownPanel/Markdig/Extensions/NoRefLinks/NoFollowLinksExtension.cs b/NppMarkdownPanel/Markdig/Extensions/NoRefLinks/NoFollowLinksExtension.cs deleted file mode 100644 index b631fc9..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/NoRefLinks/NoFollowLinksExtension.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Renderers; -using Markdig.Renderers.Html.Inlines; - -namespace Markdig.Extensions.NoRefLinks -{ - /// - /// Extension to automatically render rel=nofollow to all links in an HTML output. - /// - public class NoFollowLinksExtension : IMarkdownExtension - { - public void Setup(MarkdownPipelineBuilder pipeline) - { - } - - public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer) - { - var linkRenderer = renderer.ObjectRenderers.Find(); - if (linkRenderer != null) - { - linkRenderer.AutoRelNoFollow = true; - } - - var autolinkRenderer = renderer.ObjectRenderers.Find(); - if (autolinkRenderer != null) - { - autolinkRenderer.AutoRelNoFollow = true; - } - } - } -} diff --git a/NppMarkdownPanel/Markdig/Extensions/NonAsciiNoEscape/NonAsciiNoEscapeExtension.cs b/NppMarkdownPanel/Markdig/Extensions/NonAsciiNoEscape/NonAsciiNoEscapeExtension.cs deleted file mode 100644 index 981480d..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/NonAsciiNoEscape/NonAsciiNoEscapeExtension.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Renderers; - -namespace Markdig.Extensions.NonAsciiNoEscape -{ - /// - /// Extension that will disable URI escape with % characters for non-US-ASCII characters in order to workaround a bug under IE/Edge with local file links containing non US-ASCII chars. DO NOT USE OTHERWISE. - /// - public class NonAsciiNoEscapeExtension : IMarkdownExtension - { - public void Setup(MarkdownPipelineBuilder pipeline) - { - } - - public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer) - { - var htmlRenderer = renderer as HtmlRenderer; - if (htmlRenderer != null) - { - htmlRenderer.UseNonAsciiNoEscape = true; - } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/PragmaLines/PragmaLineExtension.cs b/NppMarkdownPanel/Markdig/Extensions/PragmaLines/PragmaLineExtension.cs deleted file mode 100644 index aa5763d..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/PragmaLines/PragmaLineExtension.cs +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using Markdig.Helpers; -using Markdig.Renderers; -using Markdig.Renderers.Html; -using Markdig.Syntax; -using Markdig.Syntax.Inlines; - -namespace Markdig.Extensions.PragmaLines -{ - /// - /// Extension to a span for each line containing the original line id (using id = pragma-line#line_number_zero_based) - /// - /// - public class PragmaLineExtension : IMarkdownExtension - { - public void Setup(MarkdownPipelineBuilder pipeline) - { - pipeline.DocumentProcessed -= PipelineOnDocumentProcessed; - pipeline.DocumentProcessed += PipelineOnDocumentProcessed; - } - - public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer) - { - } - - private static void PipelineOnDocumentProcessed(MarkdownDocument document) - { - int index = 0; - AddPragmas(document, ref index); - } - - private static void AddPragmas(Block block, ref int index) - { - var attribute = block.GetAttributes(); - var pragmaId = GetPragmaId(block); - if ( attribute.Id == null) - { - attribute.Id = pragmaId; - } - else if (block.Parent != null) - { - var heading = block as HeadingBlock; - - // If we have a heading, we will try to add the tag inside it - // otherwise we will add it just before - var tag = $""; - if (heading?.Inline?.FirstChild != null) - { - heading.Inline.FirstChild.InsertBefore(new HtmlInline() { Tag = tag }); - - } - else - { - block.Parent.Insert(index, new HtmlBlock(null) { Lines = new StringLineGroup(tag) }); - index++; - } - } - - var container = block as ContainerBlock; - if (container != null) - { - for (int i = 0; i < container.Count; i++) - { - var subBlock = container[i]; - AddPragmas(subBlock, ref i); - } - } - } - - private static string GetPragmaId(Block block) - { - return $"pragma-line-{block.Line}"; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/SelfPipeline/SelfPipelineExtension.cs b/NppMarkdownPanel/Markdig/Extensions/SelfPipeline/SelfPipelineExtension.cs deleted file mode 100644 index f3bc188..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/SelfPipeline/SelfPipelineExtension.cs +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using Markdig.Renderers; - -namespace Markdig.Extensions.SelfPipeline -{ - /// - /// Extension to enable SelfPipeline, to configure a Markdown parsing/convertion to HTML automatically - /// from an embedded special tag in the input text <!--markdig:extensions--> where extensions is a string - /// that specifies the extensions to use for the pipeline as exposed by extension method - /// on the . This extension will invalidate all other extensions and will override them. - /// - public sealed class SelfPipelineExtension : IMarkdownExtension - { - public const string DefaultTag = "markdig"; - - /// - /// Initializes a new instance of the class. - /// - /// The matching start tag. - /// The default extensions. - /// Tag cannot contain `<` or `>` characters - public SelfPipelineExtension(string tag = null, string defaultExtensions = null) - { - tag = tag?.Trim(); - tag = string.IsNullOrEmpty(tag) ? DefaultTag : tag; - if (tag.IndexOfAny(new []{'<', '>'}) >= 0) - { - throw new ArgumentException("Tag cannot contain `<` or `>` characters", nameof(tag)); - } - - if (defaultExtensions != null) - { - // Check that this default pipeline is supported - // Will throw an ArgumentInvalidException if not - new MarkdownPipelineBuilder().Configure(defaultExtensions); - } - DefaultExtensions = defaultExtensions; - SelfPipelineHintTagStart = "", optionStart, StringComparison.OrdinalIgnoreCase); - if (endOfTag >= 0) - { - defaultConfig = inputText.Substring(optionStart, endOfTag - optionStart).Trim(); - } - } - - if (!string.IsNullOrEmpty(defaultConfig)) - { - builder.Configure(defaultConfig); - } - return builder.Build(); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/SmartyPants/HtmlSmartyPantRenderer.cs b/NppMarkdownPanel/Markdig/Extensions/SmartyPants/HtmlSmartyPantRenderer.cs deleted file mode 100644 index e1df73e..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/SmartyPants/HtmlSmartyPantRenderer.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System; -using Markdig.Renderers; -using Markdig.Renderers.Html; - -namespace Markdig.Extensions.SmartyPants -{ - /// - /// A HTML renderer for a . - /// - /// - public class HtmlSmartyPantRenderer : HtmlObjectRenderer - { - private static readonly SmartyPantOptions DefaultOptions = new SmartyPantOptions(); - - private readonly SmartyPantOptions options; - - /// - /// Initializes a new instance of the class. - /// - /// The options. - /// - public HtmlSmartyPantRenderer(SmartyPantOptions options) - { - if (options == null) throw new ArgumentNullException(nameof(options)); - this.options = options; - } - - protected override void Write(HtmlRenderer renderer, SmartyPant obj) - { - string text; - if (!options.Mapping.TryGetValue(obj.Type, out text)) - { - DefaultOptions.Mapping.TryGetValue(obj.Type, out text); - } - renderer.Write(text); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/SmartyPants/SmartyPant.cs b/NppMarkdownPanel/Markdig/Extensions/SmartyPants/SmartyPant.cs deleted file mode 100644 index 51b5548..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/SmartyPants/SmartyPant.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System.Diagnostics; -using Markdig.Syntax.Inlines; - -namespace Markdig.Extensions.SmartyPants -{ - /// - /// An inline for SmartyPant. - /// - [DebuggerDisplay("SmartyPant {ToString()}")] - public class SmartyPant : LeafInline - { - public char OpeningCharacter { get; set; } - - public SmartyPantType Type { get; set; } - - /// - /// Converts this instance to a literal text. - /// - /// - public override string ToString() - { - switch (Type) - { - case SmartyPantType.Quote: - case SmartyPantType.LeftQuote: - case SmartyPantType.RightQuote: - return "'"; - case SmartyPantType.DoubleQuote: - return "\""; - case SmartyPantType.LeftDoubleQuote: - return OpeningCharacter == '`' ? "``" : "\""; - case SmartyPantType.RightDoubleQuote: - return OpeningCharacter == '\'' ? "''" : "\""; - case SmartyPantType.Dash2: - return "--"; - case SmartyPantType.Dash3: - return "--"; - case SmartyPantType.LeftAngleQuote: - return "<<"; - case SmartyPantType.RightAngleQuote: - return ">>"; - } - return OpeningCharacter != 0 ? OpeningCharacter.ToString() : string.Empty; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/SmartyPants/SmartyPantOptions.cs b/NppMarkdownPanel/Markdig/Extensions/SmartyPants/SmartyPantOptions.cs deleted file mode 100644 index 77222c6..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/SmartyPants/SmartyPantOptions.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System.Collections.Generic; - -namespace Markdig.Extensions.SmartyPants -{ - /// - /// The options used for . - /// - public class SmartyPantOptions - { - /// - /// Initializes a new instance of the class. - /// - public SmartyPantOptions() - { - Mapping = new Dictionary() - { - {SmartyPantType.Quote, "'"}, - {SmartyPantType.DoubleQuote, "\""}, - {SmartyPantType.LeftQuote, "‘"}, - {SmartyPantType.RightQuote, "’"}, - {SmartyPantType.LeftDoubleQuote, "“"}, - {SmartyPantType.RightDoubleQuote, "”"}, - {SmartyPantType.LeftAngleQuote, "«"}, - {SmartyPantType.RightAngleQuote, "»"}, - {SmartyPantType.Ellipsis, "…"}, - {SmartyPantType.Dash2, "–"}, - {SmartyPantType.Dash3, "—"}, - }; - } - - /// - /// Gets the mapping between a and its textual representation - /// (usually an HTML entity). - /// - public Dictionary Mapping { get; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/SmartyPants/SmartyPantType.cs b/NppMarkdownPanel/Markdig/Extensions/SmartyPants/SmartyPantType.cs deleted file mode 100644 index 6352b9b..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/SmartyPants/SmartyPantType.cs +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -namespace Markdig.Extensions.SmartyPants -{ - /// - /// Types of a . - /// - public enum SmartyPantType - { - /// - /// This is a single quote ' - /// - Quote = 1, - - /// - /// This is a left single quote ' -gt; ‘ - /// - LeftQuote, - - /// - /// This is a right single quote ' -gt; ’ - /// - RightQuote, - - /// - /// This is a double quote " - /// - DoubleQuote, - - /// - /// This is a left double quote " -gt; “ - /// - LeftDoubleQuote, - - /// - /// This is a right double quote " -gt; ” - /// - RightDoubleQuote, - - /// - /// This is a right double quote << -gt; « - /// - LeftAngleQuote, - - /// - /// This is a right angle quote >> -gt; » - /// - RightAngleQuote, - - /// - /// This is an ellipsis ... -gt; … - /// - Ellipsis, - - /// - /// This is a ndash -- -gt; – - /// - Dash2, - - /// - /// This is a mdash --- -gt; — - /// - Dash3, - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/SmartyPants/SmartyPantsExtension.cs b/NppMarkdownPanel/Markdig/Extensions/SmartyPants/SmartyPantsExtension.cs deleted file mode 100644 index cb97c90..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/SmartyPants/SmartyPantsExtension.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Parsers.Inlines; -using Markdig.Renderers; - -namespace Markdig.Extensions.SmartyPants -{ - /// - /// Extension to enable SmartyPants. - /// - public class SmartyPantsExtension : IMarkdownExtension - { - /// - /// Initializes a new instance of the class. - /// - /// The options. - public SmartyPantsExtension(SmartyPantOptions options) - { - Options = options ?? new SmartyPantOptions(); - } - - /// - /// Gets the options. - /// - public SmartyPantOptions Options { get; } - - public void Setup(MarkdownPipelineBuilder pipeline) - { - if (!pipeline.InlineParsers.Contains()) - { - // Insert the parser after the code span parser - pipeline.InlineParsers.InsertAfter(new SmartyPantsInlineParser()); - } - } - - public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer) - { - var htmlRenderer = renderer as HtmlRenderer; - if (htmlRenderer != null) - { - if (!htmlRenderer.ObjectRenderers.Contains()) - { - htmlRenderer.ObjectRenderers.Add(new HtmlSmartyPantRenderer(Options)); - } - } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/SmartyPants/SmartyPantsInlineParser.cs b/NppMarkdownPanel/Markdig/Extensions/SmartyPants/SmartyPantsInlineParser.cs deleted file mode 100644 index 28b1f47..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/SmartyPants/SmartyPantsInlineParser.cs +++ /dev/null @@ -1,380 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System.Collections.Generic; -using Markdig.Helpers; -using Markdig.Parsers; -using Markdig.Syntax; -using Markdig.Syntax.Inlines; - -namespace Markdig.Extensions.SmartyPants -{ - /// - /// The inline parser for SmartyPants. - /// - public class SmartyPantsInlineParser : InlineParser, IPostInlineProcessor - { - /// - /// Initializes a new instance of the class. - /// - public SmartyPantsInlineParser() - { - OpeningCharacters = new[] {'\'', '"', '<', '>', '.', '-'}; - } - - public override bool Match(InlineProcessor processor, ref StringSlice slice) - { - // We are matching the following characters: - // - // ' ‘ ’ ‘ ’ 'left-single-quote', 'right-single-quote' - // '' “ ” “ ” 'left-double-quote', 'right-double-quote' - // " “ ” “ ” 'left-double-quote', 'right-double-quote' - // << >> « » « » 'left-angle-quote', 'right-angle-quote' - // ... … … 'ellipsis' - - // Special case: – and — are handle as a PostProcess step to avoid conflicts with pipetables header separator row - // -- – – 'ndash' - // --- — — 'mdash' - - var pc = slice.PeekCharExtra(-1); - var c = slice.CurrentChar; - var openingChar = c; - - var startingPosition = slice.Start; - - // undefined first - var type = (SmartyPantType) 0; - - switch (c) - { - case '\'': - type = SmartyPantType.Quote; // We will resolve them at the end of parsing all inlines - if (slice.PeekChar(1) == '\'') - { - slice.NextChar(); - type = SmartyPantType.DoubleQuote; // We will resolve them at the end of parsing all inlines - } - break; - case '"': - type = SmartyPantType.DoubleQuote; - break; - case '<': - if (slice.NextChar() == '<') - { - type = SmartyPantType.LeftAngleQuote; - } - break; - case '>': - if (slice.NextChar() == '>') - { - type = SmartyPantType.RightAngleQuote; - } - break; - case '.': - if (slice.NextChar() == '.' && slice.NextChar() == '.') - { - type = SmartyPantType.Ellipsis; - } - break; - case '-': - if (slice.NextChar() == '-') - { - var quotePants = GetOrCreateState(processor); - quotePants.HasDash = true; - return false; - } - break; - } - - // If it is not matched, early exit - if (type == 0) - { - return false; - } - - // Skip char - c = slice.NextChar(); - - bool canOpen; - bool canClose; - CharHelper.CheckOpenCloseDelimiter(pc, c, false, out canOpen, out canClose); - - bool postProcess = false; - - switch (type) - { - case SmartyPantType.Quote: - postProcess = true; - if (canOpen && !canClose) - { - type = SmartyPantType.LeftQuote; - } - else if (!canOpen && canClose) - { - type = SmartyPantType.RightQuote; - } - else - { - return false; - } - break; - case SmartyPantType.DoubleQuote: - postProcess = true; - if (canOpen && !canClose) - { - type = SmartyPantType.LeftDoubleQuote; - } - else if (!canOpen && canClose) - { - type = SmartyPantType.RightDoubleQuote; - } - else - { - return false; - } - break; - case SmartyPantType.LeftAngleQuote: - postProcess = true; - if (!canOpen || canClose) - { - return false; - } - break; - case SmartyPantType.RightAngleQuote: - postProcess = true; - if (canOpen || !canClose) - { - return false; - } - break; - case SmartyPantType.Ellipsis: - if (canOpen || !canClose) - { - return false; - } - break; - } - - // Create the SmartyPant inline - int line; - int column; - var pant = new SmartyPant() - { - Span = {Start = processor.GetSourcePosition(startingPosition, out line, out column)}, - Line = line, - Column = column, - OpeningCharacter = openingChar, - Type = type - }; - pant.Span.End = pant.Span.Start + slice.Start - startingPosition - 1; - - // We will check in a post-process step for balanaced open/close quotes - if (postProcess) - { - var quotePants = GetOrCreateState(processor); - - // Register only if we don't have yet any quotes - if (quotePants.Count == 0) - { - processor.Block.ProcessInlinesEnd += BlockOnProcessInlinesEnd; - } - quotePants.Add(pant); - } - - processor.Inline = pant; - return true; - } - - private ListSmartyPants GetOrCreateState(InlineProcessor processor) - { - var quotePants = processor.ParserStates[Index] as ListSmartyPants; - if (quotePants == null) - { - processor.ParserStates[Index] = quotePants = new ListSmartyPants(); - } - return quotePants; - } - - private void BlockOnProcessInlinesEnd(InlineProcessor processor, Inline inline) - { - processor.Block.ProcessInlinesEnd -= BlockOnProcessInlinesEnd; - - var pants = (ListSmartyPants) processor.ParserStates[Index]; - - // We only change quote into left or right quotes if we find proper balancing - var previousIndices = new int[3] {-1, -1, -1}; - - for (int i = 0; i < pants.Count; i++) - { - var quote = pants[i]; - - int currentTypeIndex = -1; - SmartyPantType expectedLeftQuote = 0; - SmartyPantType expectedRightQuote = 0; - - if (quote.Type == SmartyPantType.LeftQuote || quote.Type == SmartyPantType.RightQuote) - { - currentTypeIndex = 0; - expectedLeftQuote = SmartyPantType.LeftQuote; - expectedRightQuote = SmartyPantType.RightQuote; - } - else if (quote.Type == SmartyPantType.LeftDoubleQuote || quote.Type == SmartyPantType.RightDoubleQuote) - { - currentTypeIndex = 1; - expectedLeftQuote = SmartyPantType.LeftDoubleQuote; - expectedRightQuote = SmartyPantType.RightDoubleQuote; - } - else if (quote.Type == SmartyPantType.LeftAngleQuote || quote.Type == SmartyPantType.RightAngleQuote) - { - currentTypeIndex = 2; - expectedLeftQuote = SmartyPantType.LeftAngleQuote; - expectedRightQuote = SmartyPantType.RightAngleQuote; - } - - if (currentTypeIndex < 0) - { - continue; - } - - int previousIndex = previousIndices[currentTypeIndex]; - var previousQuote = previousIndex >= 0 ? pants[previousIndex] : null; - if (previousQuote == null) - { - if (quote.Type == expectedLeftQuote) - { - previousIndices[currentTypeIndex] = i; - } - } - else - { - if (quote.Type == expectedRightQuote) - { - // Replace all intermediate unmatched left or right SmartyPants to their literal equivalent - pants.RemoveAt(i); - i--; - for (int j = i; j > previousIndex; j--) - { - var toReplace = pants[j]; - pants.RemoveAt(j); - toReplace.ReplaceBy(new LiteralInline(toReplace.ToString()) - { - Span = toReplace.Span, - Line = toReplace.Line, - Column = toReplace.Column, - }); - i--; - } - - // If we matched, we remove left/right quotes from the list - pants.RemoveAt(previousIndex); - previousIndices[currentTypeIndex] = -1; - } - else - { - previousIndices[currentTypeIndex] = i; - } - } - } - - // If we have any quotes lefts, replace them by there literal equivalent - foreach (var quote in pants) - { - quote.ReplaceBy(new LiteralInline(quote.ToString()) - { - Span = quote.Span, - Line = quote.Line, - Column = quote.Column, - }); - } - - pants.Clear(); - } - - bool IPostInlineProcessor.PostProcess(InlineProcessor state, Inline root, Inline lastChild, int postInlineProcessorIndex, - bool isFinalProcessing) - { - // Don't try to process anything if there are no dash - var quotePants = state.ParserStates[Index] as ListSmartyPants; - if (quotePants == null || !quotePants.HasDash) - { - return true; - } - - var child = root; - var pendingContainers = new Stack(); - - while (true) - { - while (child != null) - { - var next = child.NextSibling; - - if (child is LiteralInline) - { - var literal = (LiteralInline) child; - - var startIndex = 0; - - var indexOfDash = literal.Content.IndexOf("--", startIndex); - if (indexOfDash >= 0) - { - var type = SmartyPantType.Dash2; - if (literal.Content.PeekCharAbsolute(indexOfDash + 2) == '-') - { - type = SmartyPantType.Dash3; - } - var nextContent = literal.Content; - var originalSpan = literal.Span; - literal.Span.End -= literal.Content.End - indexOfDash + 1; - literal.Content.End = indexOfDash - 1; - nextContent.Start = indexOfDash + (type == SmartyPantType.Dash2 ? 2 : 3); - - var pant = new SmartyPant() - { - Span = new SourceSpan(literal.Content.End + 1, nextContent.Start - 1), - Line = literal.Line, - Column = literal.Column, - OpeningCharacter = '-', - Type = type - }; - literal.InsertAfter(pant); - - var postLiteral = new LiteralInline() - { - Span = new SourceSpan(pant.Span.End + 1, originalSpan.End), - Line = literal.Line, - Column = literal.Column, - Content = nextContent - }; - pant.InsertAfter(postLiteral); - - // Use the pending literal to proceed further - next = postLiteral; - } - } - else if (child is ContainerInline) - { - pendingContainers.Push(((ContainerInline)child).FirstChild); - } - - child = next; - } - if (pendingContainers.Count > 0) - { - child = pendingContainers.Pop(); - } - else - { - break; - } - } - return true; - } - - - private class ListSmartyPants : List - { - public bool HasDash { get; set; } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Tables/GridTableExtension.cs b/NppMarkdownPanel/Markdig/Extensions/Tables/GridTableExtension.cs deleted file mode 100644 index fe6c4c8..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Tables/GridTableExtension.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Renderers; - -namespace Markdig.Extensions.Tables -{ - /// - /// Extension that allows to use grid tables. - /// - /// - public class GridTableExtension : IMarkdownExtension - { - public void Setup(MarkdownPipelineBuilder pipeline) - { - if (!pipeline.BlockParsers.Contains()) - { - pipeline.BlockParsers.Insert(0, new GridTableParser()); - } - } - - public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer) - { - var htmlRenderer = renderer as HtmlRenderer; - if (htmlRenderer != null && !htmlRenderer.ObjectRenderers.Contains()) - { - htmlRenderer.ObjectRenderers.Add(new HtmlTableRenderer()); - } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Tables/GridTableParser.cs b/NppMarkdownPanel/Markdig/Extensions/Tables/GridTableParser.cs deleted file mode 100644 index bd4642f..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Tables/GridTableParser.cs +++ /dev/null @@ -1,366 +0,0 @@ - -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System.Collections.Generic; -using Markdig.Helpers; -using Markdig.Parsers; -using Markdig.Syntax; - -namespace Markdig.Extensions.Tables -{ - public class GridTableParser : BlockParser - { - public GridTableParser() - { - OpeningCharacters = new[] { '+' }; - } - - public override BlockState TryOpen(BlockProcessor processor) - { - // A grid table cannot start more than an indent - if (processor.IsCodeIndent) - { - return BlockState.None; - } - - var line = processor.Line; - GridTableState tableState = null; - - // Match the first row that should be of the minimal form: +--------------- - var c = line.CurrentChar; - var lineStart = line.Start; - while (c == '+') - { - var columnStart = line.Start; - line.NextChar(); - line.TrimStart(); - - // if we have reached the end of the line, exit - c = line.CurrentChar; - if (c == 0) - { - break; - } - - // Parse a column alignment - TableColumnAlign? columnAlign; - if (!TableHelper.ParseColumnHeader(ref line, '-', out columnAlign)) - { - return BlockState.None; - } - - tableState = tableState ?? new GridTableState { Start = processor.Start, ExpectRow = true }; - tableState.AddColumn(columnStart - lineStart, line.Start - lineStart, columnAlign); - - c = line.CurrentChar; - } - - if (c != 0 || tableState == null) - { - return BlockState.None; - } - // Store the line (if we need later to build a ParagraphBlock because the GridTable was in fact invalid) - tableState.AddLine(ref processor.Line); - var table = new Table(this); - table.SetData(typeof(GridTableState), tableState); - - // Calculate the total width of all columns - int totalWidth = 0; - foreach (var columnSlice in tableState.ColumnSlices) - { - totalWidth += columnSlice.End - columnSlice.Start - 1; - } - - // Store the column width and alignment - foreach (var columnSlice in tableState.ColumnSlices) - { - var columnDefinition = new TableColumnDefinition - { - // Column width proportional to the total width - Width = (float)(columnSlice.End - columnSlice.Start - 1) * 100.0f / totalWidth, - Alignment = columnSlice.Align - }; - table.ColumnDefinitions.Add(columnDefinition); - } - - processor.NewBlocks.Push(table); - - return BlockState.ContinueDiscard; - } - - public override BlockState TryContinue(BlockProcessor processor, Block block) - { - var gridTable = (Table)block; - var tableState = (GridTableState)block.GetData(typeof(GridTableState)); - tableState.AddLine(ref processor.Line); - if (processor.CurrentChar == '+') - { - return HandleNewRow(processor, tableState, gridTable); - } - if (processor.CurrentChar == '|') - { - return HandleContents(processor, tableState, gridTable); - } - TerminateCurrentRow(processor, tableState, gridTable, true); - // If the table is not valid we need to remove the grid table, - // and create a ParagraphBlock with the slices - if (!gridTable.IsValid()) - { - Undo(processor, tableState, gridTable); - } - return BlockState.Break; - } - - private BlockState HandleNewRow(BlockProcessor processor, GridTableState tableState, Table gridTable) - { - bool isHeaderRow, hasRowSpan; - var columns = tableState.ColumnSlices; - SetRowSpanState(columns, processor.Line, out isHeaderRow, out hasRowSpan); - SetColumnSpanState(columns, processor.Line); - TerminateCurrentRow(processor, tableState, gridTable, false); - if (isHeaderRow) - { - for (int i = 0; i < gridTable.Count; i++) - { - var row = (TableRow)gridTable[i]; - row.IsHeader = true; - } - } - tableState.StartRowGroup = gridTable.Count; - if (hasRowSpan) - { - HandleContents(processor, tableState, gridTable); - } - return BlockState.ContinueDiscard; - } - - private static void SetRowSpanState(List columns, StringSlice line, out bool isHeaderRow, out bool hasRowSpan) - { - var lineStart = line.Start; - isHeaderRow = line.PeekChar(1) == '=' || line.PeekChar(2) == '='; - hasRowSpan = false; - foreach (var columnSlice in columns) - { - if (columnSlice.CurrentCell != null) - { - line.Start = lineStart + columnSlice.Start + 1; - line.End = lineStart + columnSlice.End - 1; - line.Trim(); - if (line.IsEmptyOrWhitespace() || !IsRowSeperator(line)) - { - hasRowSpan = true; - columnSlice.CurrentCell.RowSpan++; - columnSlice.CurrentCell.AllowClose = false; - } - else - { - columnSlice.CurrentCell.AllowClose = true; - } - } - } - } - - private static bool IsRowSeperator(StringSlice slice) - { - while (slice.Length > 0) - { - if (slice.CurrentChar != '-' && slice.CurrentChar != '=' && slice.CurrentChar != ':') - { - return false; - } - slice.NextChar(); - } - return true; - } - - private static void TerminateCurrentRow(BlockProcessor processor, GridTableState tableState, Table gridTable, bool isLastRow) - { - var columns = tableState.ColumnSlices; - TableRow currentRow = null; - for (int i = 0; i < columns.Count; i++) - { - var columnSlice = columns[i]; - if (columnSlice.CurrentCell != null) - { - if (currentRow == null) - { - currentRow = new TableRow(); - } - // If this cell does not already belong to a row - if (columnSlice.CurrentCell.Parent == null) - { - currentRow.Add(columnSlice.CurrentCell); - } - // If the cell is not going to span through to the next row - if (columnSlice.CurrentCell.AllowClose) - { - columnSlice.BlockProcessor.Close(columnSlice.CurrentCell); - } - } - - // Renew the block parser processor (or reset it for the last row) - if (columnSlice.BlockProcessor != null && (columnSlice.CurrentCell == null || columnSlice.CurrentCell.AllowClose)) - { - columnSlice.BlockProcessor.ReleaseChild(); - columnSlice.BlockProcessor = isLastRow ? null : processor.CreateChild(); - } - - // Create or erase the cell - if (isLastRow || columnSlice.CurrentColumnSpan == 0 || (columnSlice.CurrentCell != null && columnSlice.CurrentCell.AllowClose)) - { - // We don't need the cell anymore if we have a last row - // Or the cell has a columnspan == 0 - // And the cell does not have to be kept open to span rows - columnSlice.CurrentCell = null; - } - } - - if (currentRow != null && currentRow.Count > 0) - { - gridTable.Add(currentRow); - } - } - - private BlockState HandleContents(BlockProcessor processor, GridTableState tableState, Table gridTable) - { - var isRowLine = processor.CurrentChar == '+'; - var columns = tableState.ColumnSlices; - var line = processor.Line; - SetColumnSpanState(columns, line); - if (!isRowLine && !CanContinueRow(columns)) - { - TerminateCurrentRow(processor, tableState, gridTable, false); - } - for (int i = 0; i < columns.Count;) - { - var columnSlice = columns[i]; - var nextColumnIndex = i + columnSlice.CurrentColumnSpan; - // If the span is 0, we exit - if (nextColumnIndex == i) - { - break; - } - var nextColumn = nextColumnIndex < columns.Count ? columns[nextColumnIndex] : null; - - var sliceForCell = line; - sliceForCell.Start = line.Start + columnSlice.Start + 1; - if (nextColumn != null) - { - sliceForCell.End = line.Start + nextColumn.Start - 1; - } - else - { - var columnEnd = columns[columns.Count - 1].End; - var columnEndChar = line.PeekCharExtra(columnEnd); - // If there is a `|` (or a `+` in the case that we are dealing with a row line - // with spanned contents) exactly at the expected end of the table row, we cut the line - // otherwise we allow to have the last cell of a row to be open for longer cell content - if (columnEndChar == '|' || (isRowLine && columnEndChar == '+')) - { - sliceForCell.End = line.Start + columnEnd - 1; - } - else if (line.PeekCharExtra(line.End) == '|') - { - sliceForCell.End = line.End - 1; - } - } - sliceForCell.TrimEnd(); - - if (!isRowLine || !IsRowSeperator(sliceForCell)) - { - if (columnSlice.CurrentCell == null) - { - columnSlice.CurrentCell = new TableCell(this) - { - ColumnSpan = columnSlice.CurrentColumnSpan, - ColumnIndex = i - }; - - if (columnSlice.BlockProcessor == null) - { - columnSlice.BlockProcessor = processor.CreateChild(); - } - - // Ensure that the BlockParser is aware that the TableCell is the top-level container - columnSlice.BlockProcessor.Open(columnSlice.CurrentCell); - } - // Process the content of the cell - columnSlice.BlockProcessor.LineIndex = processor.LineIndex; - columnSlice.BlockProcessor.ProcessLine(sliceForCell); - } - - // Go to next column - i = nextColumnIndex; - } - return BlockState.ContinueDiscard; - } - - private static void SetColumnSpanState(List columns, StringSlice line) - { - foreach (var columnSlice in columns) - { - columnSlice.PreviousColumnSpan = columnSlice.CurrentColumnSpan; - columnSlice.CurrentColumnSpan = 0; - } - // | ------------- | ------------ | ---------------------------------------- | - // Calculate the colspan for the new row - int columnIndex = -1; - for (int i = 0; i < columns.Count; i++) - { - var columnSlice = columns[i]; - var peek = line.PeekChar(columnSlice.Start); - if (peek == '|' || peek == '+') - { - columnIndex = i; - } - if (columnIndex >= 0) - { - columns[columnIndex].CurrentColumnSpan++; - } - } - } - - private static bool CanContinueRow(List columns) - { - foreach (var columnSlice in columns) - { - if (columnSlice.PreviousColumnSpan != columnSlice.CurrentColumnSpan) - { - return false; - } - } - return true; - } - - private static void Undo(BlockProcessor processor, GridTableState tableState, Table gridTable) - { - var parser = processor.Parsers.FindExact(); - // Discard the grid table - var parent = gridTable.Parent; - processor.Discard(gridTable); - var paragraphBlock = new ParagraphBlock(parser) - { - Lines = tableState.Lines, - }; - parent.Add(paragraphBlock); - processor.Open(paragraphBlock); - } - - public override bool Close(BlockProcessor processor, Block block) - { - // Work only on Table, not on TableCell - var gridTable = block as Table; - if (gridTable != null) - { - var tableState = (GridTableState)block.GetData(typeof(GridTableState)); - TerminateCurrentRow(processor, tableState, gridTable, true); - if (!gridTable.IsValid()) - { - Undo(processor, tableState, gridTable); - } - } - return true; - } - } -} diff --git a/NppMarkdownPanel/Markdig/Extensions/Tables/GridTableState.cs b/NppMarkdownPanel/Markdig/Extensions/Tables/GridTableState.cs deleted file mode 100644 index a07a13b..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Tables/GridTableState.cs +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System.Collections.Generic; -using Markdig.Helpers; -using Markdig.Parsers; - -namespace Markdig.Extensions.Tables -{ - /// - /// Internal state used by the - /// - internal class GridTableState - { - public int Start { get; set; } - - public StringLineGroup Lines; - - public List ColumnSlices { get; private set; } - - public bool ExpectRow { get; set; } - - public int StartRowGroup { get; set; } - - public void AddLine(ref StringSlice line) - { - if (Lines.Lines == null) - { - Lines = new StringLineGroup(4); - } - Lines.Add(line); - } - - public void AddColumn(int start, int end, TableColumnAlign? align) - { - if (ColumnSlices == null) - { - ColumnSlices = new List(); - } - - ColumnSlices.Add(new ColumnSlice() - { - Start = start, - End = end, - Align = align, - }); - } - - public class ColumnSlice - { - public ColumnSlice() - { - CurrentColumnSpan = -1; - } - - /// - /// Gets or sets the index position of this column (after the |) - /// - public int Start { get; set; } - - public int End { get; set; } - - public TableColumnAlign? Align { get; set; } - - public int CurrentColumnSpan { get; set; } - - public int PreviousColumnSpan { get; set; } - - public BlockProcessor BlockProcessor { get; set; } - - public TableCell CurrentCell { get; set; } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Tables/HtmlTableRenderer.cs b/NppMarkdownPanel/Markdig/Extensions/Tables/HtmlTableRenderer.cs deleted file mode 100644 index 03bc626..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Tables/HtmlTableRenderer.cs +++ /dev/null @@ -1,138 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Globalization; -using Markdig.Renderers; -using Markdig.Renderers.Html; - -namespace Markdig.Extensions.Tables -{ - /// - /// A HTML renderer for a - /// - /// - public class HtmlTableRenderer : HtmlObjectRenderer - { - protected override void Write(HtmlRenderer renderer, Table table) - { - renderer.EnsureLine(); - renderer.Write(""); - - bool hasBody = false; - bool hasAlreadyHeader = false; - bool isHeaderOpen = false; - - - bool hasColumnWidth = false; - foreach (var tableColumnDefinition in table.ColumnDefinitions) - { - if (tableColumnDefinition.Width != 0.0f && tableColumnDefinition.Width != 1.0f) - { - hasColumnWidth = true; - break; - } - } - - if (hasColumnWidth) - { - foreach (var tableColumnDefinition in table.ColumnDefinitions) - { - var width = Math.Round(tableColumnDefinition.Width*100)/100; - var widthValue = string.Format(CultureInfo.InvariantCulture, "{0:0.##}", width); - renderer.WriteLine($""); - } - } - - foreach (var rowObj in table) - { - var row = (TableRow)rowObj; - if (row.IsHeader) - { - // Allow a single thead - if (!hasAlreadyHeader) - { - renderer.WriteLine(""); - isHeaderOpen = true; - } - hasAlreadyHeader = true; - } - else if (!hasBody) - { - if (isHeaderOpen) - { - renderer.WriteLine(""); - isHeaderOpen = false; - } - - renderer.WriteLine(""); - hasBody = true; - } - renderer.Write(""); - for (int i = 0; i < row.Count; i++) - { - var cellObj = row[i]; - var cell = (TableCell)cellObj; - - renderer.EnsureLine(); - renderer.Write(row.IsHeader ? " 0) - { - var columnIndex = cell.ColumnIndex < 0 || cell.ColumnIndex >= table.ColumnDefinitions.Count - ? i - : cell.ColumnIndex; - columnIndex = columnIndex >= table.ColumnDefinitions.Count ? table.ColumnDefinitions.Count - 1 : columnIndex; - var alignment = table.ColumnDefinitions[columnIndex].Alignment; - if (alignment.HasValue) - { - switch (alignment) - { - case TableColumnAlign.Center: - renderer.Write(" style=\"text-align: center;\""); - break; - case TableColumnAlign.Right: - renderer.Write(" style=\"text-align: right;\""); - break; - case TableColumnAlign.Left: - renderer.Write(" style=\"text-align: left;\""); - break; - } - } - } - renderer.WriteAttributes(cell); - renderer.Write(">"); - - var previousImplicitParagraph = renderer.ImplicitParagraph; - if (cell.Count == 1) - { - renderer.ImplicitParagraph = true; - } - renderer.Write(cell); - renderer.ImplicitParagraph = previousImplicitParagraph; - - renderer.WriteLine(row.IsHeader ? "" : ""); - } - renderer.WriteLine(""); - } - - if (hasBody) - { - renderer.WriteLine(""); - } - else if (isHeaderOpen) - { - renderer.WriteLine(""); - } - renderer.WriteLine("
"); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Tables/PipeTableBlockParser.cs b/NppMarkdownPanel/Markdig/Extensions/Tables/PipeTableBlockParser.cs deleted file mode 100644 index 31ca7a9..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Tables/PipeTableBlockParser.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Helpers; -using Markdig.Parsers; -using Markdig.Syntax; - -namespace Markdig.Extensions.Tables -{ - /// - /// This block parsers for pipe tables is used to by-pass list items that could start by a single '-' - /// and would disallow to detect a pipe tables at inline parsing time, so we are basically forcing a line - /// that starts by a '-' and have at least a '|' (and have optional spaces) and is a continuation of a - /// paragraph. - /// - /// - public class PipeTableBlockParser : BlockParser - { - /// - /// Initializes a new instance of the class. - /// - public PipeTableBlockParser() - { - OpeningCharacters = new[] {'-'}; - } - - public override BlockState TryOpen(BlockProcessor processor) - { - // Only if we have already a paragraph - var paragraph = processor.CurrentBlock as ParagraphBlock; - if (processor.IsCodeIndent || paragraph == null) - { - return BlockState.None; - } - - // We require at least a pipe (and we allow only : - | and space characters) - var line = processor.Line; - var countPipe = 0; - while (true) - { - var c = line.NextChar(); - if (c == '\0') - { - if (countPipe > 0) - { - // Mark the paragraph as open (important, otherwise we would have an infinite loop) - paragraph.AppendLine(ref processor.Line, processor.Column, processor.LineIndex, processor.Line.Start); - paragraph.IsOpen = true; - return BlockState.BreakDiscard; - } - - return BlockState.None; - } - - if (c.IsSpace() || c == '-' || c == '|' || c == ':') - { - if (c == '|') - { - countPipe++; - } - continue; - } - - return BlockState.None; - } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Tables/PipeTableDelimiterInline.cs b/NppMarkdownPanel/Markdig/Extensions/Tables/PipeTableDelimiterInline.cs deleted file mode 100644 index 2a4c125..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Tables/PipeTableDelimiterInline.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Parsers; -using Markdig.Syntax.Inlines; - -namespace Markdig.Extensions.Tables -{ - /// - /// The delimiter used to separate the columns of a pipe table. - /// - /// - public class PipeTableDelimiterInline : DelimiterInline - { - public PipeTableDelimiterInline(InlineParser parser) : base(parser) - { - } - - /// - /// Gets or sets the index of line where this delimiter was found relative to the current block. - /// - public int LocalLineIndex { get; set; } - - public override string ToLiteral() - { - return "|"; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Tables/PipeTableExtension.cs b/NppMarkdownPanel/Markdig/Extensions/Tables/PipeTableExtension.cs deleted file mode 100644 index e4a73a2..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Tables/PipeTableExtension.cs +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Parsers.Inlines; -using Markdig.Renderers; - -namespace Markdig.Extensions.Tables -{ - /// - /// Extension that allows to use pipe tables. - /// - /// - public class PipeTableExtension : IMarkdownExtension - { - /// - /// Initializes a new instance of the class. - /// - /// The options. - public PipeTableExtension(PipeTableOptions options = null) - { - Options = options ?? new PipeTableOptions(); - } - - /// - /// Gets the options. - /// - public PipeTableOptions Options { get; } - - public void Setup(MarkdownPipelineBuilder pipeline) - { - // Pipe tables require precise source location - pipeline.PreciseSourceLocation = true; - if (!pipeline.BlockParsers.Contains()) - { - pipeline.BlockParsers.Insert(0, new PipeTableBlockParser()); - } - var lineBreakParser = pipeline.InlineParsers.FindExact(); - if (!pipeline.InlineParsers.Contains()) - { - pipeline.InlineParsers.InsertBefore(new PipeTableParser(lineBreakParser, Options)); - } - } - - public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer) - { - var htmlRenderer = renderer as HtmlRenderer; - if (htmlRenderer != null && !htmlRenderer.ObjectRenderers.Contains()) - { - htmlRenderer.ObjectRenderers.Add(new HtmlTableRenderer()); - } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Tables/PipeTableOptions.cs b/NppMarkdownPanel/Markdig/Extensions/Tables/PipeTableOptions.cs deleted file mode 100644 index 01a6c73..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Tables/PipeTableOptions.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -namespace Markdig.Extensions.Tables -{ - /// - /// Options for the extension - /// - public class PipeTableOptions - { - /// - /// Initializes a new instance of the class. - /// - public PipeTableOptions() - { - RequireHeaderSeparator = true; - } - - /// - /// Gets or sets a value indicating whether to require header separator. true by default (Kramdown is using false) - /// - public bool RequireHeaderSeparator { get; set; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Tables/PipeTableParser.cs b/NppMarkdownPanel/Markdig/Extensions/Tables/PipeTableParser.cs deleted file mode 100644 index 06356e0..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Tables/PipeTableParser.cs +++ /dev/null @@ -1,653 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using Markdig.Helpers; -using Markdig.Parsers; -using Markdig.Parsers.Inlines; -using Markdig.Renderers.Html; -using Markdig.Syntax; -using Markdig.Syntax.Inlines; - -namespace Markdig.Extensions.Tables -{ - /// - /// The inline parser used to transform a into a at inline parsing time. - /// - /// - /// - public class PipeTableParser : InlineParser, IPostInlineProcessor - { - private readonly LineBreakInlineParser lineBreakParser; - - /// - /// Initializes a new instance of the class. - /// - /// The linebreak parser to use - /// The options. - public PipeTableParser(LineBreakInlineParser lineBreakParser, PipeTableOptions options = null) - { - if (lineBreakParser == null) throw new ArgumentNullException(nameof(lineBreakParser)); - this.lineBreakParser = lineBreakParser; - OpeningCharacters = new[] { '|', '\n' }; - Options = options ?? new PipeTableOptions(); - } - - /// - /// Gets the options. - /// - public PipeTableOptions Options { get; } - - public override bool Match(InlineProcessor processor, ref StringSlice slice) - { - // Only working on Paragraph block - if (!(processor.Block is ParagraphBlock)) - { - return false; - } - - var c = slice.CurrentChar; - - // If we have not a delimiter on the first line of a paragraph, don't bother to continue - // tracking other delimiters on following lines - var tableState = processor.ParserStates[Index] as TableState; - bool isFirstLineEmpty = false; - - - int globalLineIndex; - int column; - var position = processor.GetSourcePosition(slice.Start, out globalLineIndex, out column); - var localLineIndex = globalLineIndex - processor.LineIndex; - - if (tableState == null) - { - - // A table could be preceded by an empty line or a line containing an inline - // that has not been added to the stack, so we consider this as a valid - // start for a table. Typically, with this, we can have an attributes {...} - // starting on the first line of a pipe table, even if the first line - // doesn't have a pipe - if (processor.Inline != null && (localLineIndex > 0 || c == '\n')) - { - return false; - } - - if (processor.Inline == null) - { - isFirstLineEmpty = true; - } - // Else setup a table processor - tableState = new TableState(); - processor.ParserStates[Index] = tableState; - } - - if (c == '\n') - { - if (!isFirstLineEmpty && !tableState.LineHasPipe) - { - tableState.IsInvalidTable = true; - } - tableState.LineHasPipe = false; - lineBreakParser.Match(processor, ref slice); - tableState.LineIndex++; - if (!isFirstLineEmpty) - { - tableState.ColumnAndLineDelimiters.Add(processor.Inline); - tableState.EndOfLines.Add(processor.Inline); - } - } - else - { - processor.Inline = new PipeTableDelimiterInline(this) - { - Span = new SourceSpan(position, position), - Line = globalLineIndex, - Column = column, - LocalLineIndex = localLineIndex - }; - var deltaLine = localLineIndex - tableState.LineIndex; - if (deltaLine > 0) - { - tableState.IsInvalidTable = true; - } - tableState.LineHasPipe = true; - tableState.LineIndex = localLineIndex; - slice.NextChar(); // Skip the `|` character - - tableState.ColumnAndLineDelimiters.Add(processor.Inline); - } - - - return true; - } - - public bool PostProcess(InlineProcessor state, Inline root, Inline lastChild, int postInlineProcessorIndex, bool isFinalProcessing) - { - var container = root as ContainerInline; - var tableState = state.ParserStates[Index] as TableState; - - // If the delimiters are being processed by an image link, we need to transform them back to literals - if (!isFinalProcessing) - { - if (container == null || tableState == null) - { - return true; - } - - var child = container.LastChild; - List delimitersToRemove = null; - - while (child != null) - { - var pipeDelimiter = child as PipeTableDelimiterInline; - if (pipeDelimiter != null) - { - if (delimitersToRemove == null) - { - delimitersToRemove = new List(); - } - delimitersToRemove.Add(pipeDelimiter); - } - - if (child == lastChild) - { - break; - } - - var subContainer = child as ContainerInline; - child = subContainer?.LastChild; - } - - // If we have found any delimiters, transform them to literals - if (delimitersToRemove != null) - { - bool leftIsDelimiter = false; - bool rightIsDelimiter = false; - for (int i = 0; i < delimitersToRemove.Count; i++) - { - var pipeDelimiter = delimitersToRemove[i]; - pipeDelimiter.ReplaceByLiteral(); - - // Check that the pipe that is being removed is not going to make a line without pipe delimiters - var tableDelimiters = tableState.ColumnAndLineDelimiters; - var delimiterIndex = tableDelimiters.IndexOf(pipeDelimiter); - - if (i == 0) - { - leftIsDelimiter = delimiterIndex > 0 && tableDelimiters[delimiterIndex - 1] is PipeTableDelimiterInline; - } - else if (i + 1 == delimitersToRemove.Count) - { - rightIsDelimiter = delimiterIndex + 1 < tableDelimiters.Count && - tableDelimiters[delimiterIndex + 1] is PipeTableDelimiterInline; - } - // Remove this delimiter from the table processor - tableState.ColumnAndLineDelimiters.Remove(pipeDelimiter); - } - - // If we didn't have any delimiter before and after the delimiters we jsut removed, we mark the processor of the current line as no pipe - if (!leftIsDelimiter && !rightIsDelimiter) - { - tableState.LineHasPipe = false; - } - } - - return true; - } - - // Remove previous state - state.ParserStates[Index] = null; - - // Continue - if (tableState == null || container == null || tableState.IsInvalidTable || !tableState.LineHasPipe ) //|| tableState.LineIndex != state.LocalLineIndex) - { - return true; - } - - // Detect the header row - var delimiters = tableState.ColumnAndLineDelimiters; - // TODO: we could optimize this by merging FindHeaderRow and the cell loop - var aligns = FindHeaderRow(delimiters); - - if (Options.RequireHeaderSeparator && aligns == null) - { - return true; - } - - var table = new Table(); - - // If the current paragraph block has any attributes attached, we can copy them - var attributes = state.Block.TryGetAttributes(); - if (attributes != null) - { - attributes.CopyTo(table.GetAttributes()); - } - - state.BlockNew = table; - var cells = tableState.Cells; - cells.Clear(); - - //delimiters[0].DumpTo(state.DebugLog); - - // delimiters contain a list of `|` and `\n` delimiters - // The `|` delimiters are created as child containers. - // So the following: - // | a | b \n - // | d | e \n - // - // Will generate a tree of the following node: - // | - // a - // | - // b - // \n - // | - // d - // | - // e - // \n - // When parsing delimiters, we need to recover whether a row is of the following form: - // 0) | a | b | \n - // 1) | a | b \n - // 2) a | b \n - // 3) a | b | \n - - // If the last element is not a line break, add a line break to homogenize parsing in the next loop - var lastElement = delimiters[delimiters.Count - 1]; - if (!(lastElement is LineBreakInline)) - { - while (true) - { - if (lastElement is ContainerInline) - { - var nextElement = ((ContainerInline) lastElement).LastChild; - if (nextElement != null) - { - lastElement = nextElement; - continue; - } - } - break; - } - - var endOfTable = new LineBreakInline(); - // If the last element is a container, we have to add the EOL to its child - // otherwise only next sibling - if (lastElement is ContainerInline) - { - ((ContainerInline)lastElement).AppendChild(endOfTable); - } - else - { - lastElement.InsertAfter(endOfTable); - } - delimiters.Add(endOfTable); - tableState.EndOfLines.Add(endOfTable); - } - - // Cell loop - // Reconstruct the table from the delimiters - TableRow row = null; - TableRow firstRow = null; - for (int i = 0; i < delimiters.Count; i++) - { - var delimiter = delimiters[i]; - var pipeSeparator = delimiter as PipeTableDelimiterInline; - var isLine = delimiter is LineBreakInline; - - if (row == null) - { - row = new TableRow(); - if (firstRow == null) - { - firstRow = row; - } - - // If the first delimiter is a pipe and doesn't have any parent or previous sibling, for cases like: - // 0) | a | b | \n - // 1) | a | b \n - if (pipeSeparator != null && (delimiter.PreviousSibling == null || delimiter.PreviousSibling is LineBreakInline)) - { - delimiter.Remove(); - continue; - } - } - - // We need to find the beginning/ending of a cell from a right delimiter. From the delimiter 'x', we need to find a (without the delimiter start `|`) - // So we iterate back to the first pipe or line break - // x - // 1) | a | b \n - // 2) a | b \n - Inline endOfCell = null; - Inline beginOfCell = null; - var cellContentIt = delimiter; - while (true) - { - cellContentIt = cellContentIt.PreviousSibling ?? cellContentIt.Parent; - - if (cellContentIt == null || cellContentIt is LineBreakInline) - { - break; - } - - // The cell begins at the first effective child after a | or the top ContainerInline (which is not necessary to bring into the tree + it contains an invalid span calculation) - if (cellContentIt is PipeTableDelimiterInline || (cellContentIt.GetType() == typeof(ContainerInline) && cellContentIt.Parent == null )) - { - beginOfCell = ((ContainerInline)cellContentIt).FirstChild; - if (endOfCell == null) - { - endOfCell = beginOfCell; - } - break; - } - - beginOfCell = cellContentIt; - if (endOfCell == null) - { - endOfCell = beginOfCell; - } - } - - - // If the current deilimiter is a pipe `|` OR - // the beginOfCell/endOfCell are not null and - // either they are : - // - different - // - they contain a single element, but it is not a line break (\n) or an empty/whitespace Literal. - // Then we can add a cell to the current row - if (!isLine || (beginOfCell != null && endOfCell != null && ( beginOfCell != endOfCell || !(beginOfCell is LineBreakInline || (beginOfCell is LiteralInline && ((LiteralInline)beginOfCell).Content.IsEmptyOrWhitespace()))))) - { - if (!isLine) - { - // If the delimiter is a pipe, we need to remove it from the tree - // so that previous loop looking for a parent will not go further on subsequent cells - delimiter.Remove(); - } - - // We trim whitespace at the beginning and ending of the cell - TrimStart(beginOfCell); - TrimEnd(endOfCell); - - var cellContainer = new ContainerInline(); - - // Copy elements from beginOfCell on the first level - var cellIt = beginOfCell; - while (cellIt != null && !IsLine(cellIt) && !(cellIt is PipeTableDelimiterInline)) - { - var nextSibling = cellIt.NextSibling; - cellIt.Remove(); - if (cellContainer.Span.IsEmpty) - { - cellContainer.Line = cellIt.Line; - cellContainer.Column = cellIt.Column; - cellContainer.Span = cellIt.Span; - } - cellContainer.AppendChild(cellIt); - cellContainer.Span.End = cellIt.Span.End; - cellIt = nextSibling; - } - - // Create the cell and add it to the pending row - var tableParagraph = new ParagraphBlock() - { - Span = cellContainer.Span, - Line = cellContainer.Line, - Column = cellContainer.Column, - Inline = cellContainer - }; - - var tableCell = new TableCell() - { - Span = cellContainer.Span, - Line = cellContainer.Line, - Column = cellContainer.Column, - }; - - tableCell.Add(tableParagraph); - if (row.Span.IsEmpty) - { - row.Span = cellContainer.Span; - row.Line = cellContainer.Line; - row.Column = cellContainer.Column; - } - row.Add(tableCell); - cells.Add(tableCell); - } - - // If we have a new line, we can add the row - if (isLine) - { - Debug.Assert(row != null); - if (table.Span.IsEmpty) - { - table.Span = row.Span; - table.Line = row.Line; - table.Column = row.Column; - } - table.Add(row); - row = null; - } - } - - // Once we are done with the cells, we can remove all end of lines in the table tree - foreach (var endOfLine in tableState.EndOfLines) - { - endOfLine.Remove(); - } - - // If we have a header row, we can remove it - // TODO: we could optimize this by merging FindHeaderRow and the previous loop - var tableRow = (TableRow)table[0]; - tableRow.IsHeader = Options.RequireHeaderSeparator; - if (aligns != null) - { - tableRow.IsHeader = true; - table.RemoveAt(1); - table.ColumnDefinitions.AddRange(aligns); - } - - // Perform delimiter processor that are coming after this processor - foreach (var cell in cells) - { - var paragraph = (ParagraphBlock) cell[0]; - state.PostProcessInlines(postInlineProcessorIndex + 1, paragraph.Inline, null, true); - } - - // Clear cells when we are done - cells.Clear(); - - // Normalize the table - table.Normalize(); - - // We don't want to continue procesing delimiters, as we are already processing them here - return false; - } - - private static bool ParseHeaderString(Inline inline, out TableColumnAlign? align) - { - align = 0; - var literal = inline as LiteralInline; - if (literal == null) - { - return false; - } - - // Work on a copy of the slice - var line = literal.Content; - if (TableHelper.ParseColumnHeader(ref line, '-', out align)) - { - if (line.CurrentChar != '\0') - { - return false; - } - return true; - } - - return false; - } - - private List FindHeaderRow(List delimiters) - { - bool isValidRow = false; - List aligns = null; - for (int i = 0; i < delimiters.Count; i++) - { - if (!IsLine(delimiters[i])) - { - continue; - } - - // The last delimiter is always null, - for (int j = i + 1; j < delimiters.Count; j++) - { - var delimiter = delimiters[j]; - var nextDelimiter = j + 1 < delimiters.Count ? delimiters[j + 1] : null; - - var columnDelimiter = delimiter as PipeTableDelimiterInline; - if (j == i + 1 && IsStartOfLineColumnDelimiter(columnDelimiter)) - { - continue; - } - - // Check the left side of a `|` delimiter - TableColumnAlign? align = null; - if (delimiter.PreviousSibling != null && !ParseHeaderString(delimiter.PreviousSibling, out align)) - { - break; - } - - // Create aligns until we may have a header row - if (aligns == null) - { - aligns = new List(); - } - aligns.Add(new TableColumnDefinition() { Alignment = align }); - - // If this is the last delimiter, we need to check the right side of the `|` delimiter - if (nextDelimiter == null) - { - var nextSibling = columnDelimiter != null - ? columnDelimiter.FirstChild - : delimiter.NextSibling; - - // If there is no content after - if (IsNullOrSpace(nextSibling)) - { - isValidRow = true; - break; - } - - if (!ParseHeaderString(nextSibling, out align)) - { - break; - } - - isValidRow = true; - aligns.Add(new TableColumnDefinition() { Alignment = align }); - break; - } - - // If we are on a Line delimiter, exit - if (IsLine(delimiter)) - { - isValidRow = true; - break; - } - } - break; - } - - return isValidRow ? aligns : null; - } - - private static bool IsLine(Inline inline) - { - return inline is LineBreakInline; - } - - private static bool IsStartOfLineColumnDelimiter(Inline inline) - { - if (inline == null) - { - return false; - } - - var previous = inline.PreviousSibling; - if (previous == null) - { - return true; - } - var literal = previous as LiteralInline; - if (literal != null) - { - if (!literal.Content.IsEmptyOrWhitespace()) - { - return false; - } - previous = previous.PreviousSibling; - } - return previous == null || IsLine(previous); - } - - private static void TrimStart(Inline inline) - { - while (inline is ContainerInline && !(inline is DelimiterInline)) - { - inline = ((ContainerInline)inline).FirstChild; - } - var literal = inline as LiteralInline; - if (literal != null) - { - literal.Content.TrimStart(); - } - } - - private static void TrimEnd(Inline inline) - { - var literal = inline as LiteralInline; - if (literal != null) - { - literal.Content.TrimEnd(); - } - } - - private static bool IsNullOrSpace(Inline inline) - { - if (inline == null) - { - return true; - } - var literal = inline as LiteralInline; - if (literal != null) - { - return literal.Content.IsEmptyOrWhitespace(); - } - return false; - } - - private class TableState - { - public TableState() - { - ColumnAndLineDelimiters = new List(); - Cells = new List(); - EndOfLines = new List(); - } - - public bool IsInvalidTable { get; set; } - - public bool LineHasPipe { get; set; } - - public int LineIndex { get; set; } - - public List ColumnAndLineDelimiters { get; } - - public List Cells { get; } - - public List EndOfLines { get; } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Tables/Table.cs b/NppMarkdownPanel/Markdig/Extensions/Tables/Table.cs deleted file mode 100644 index 9ec8cd8..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Tables/Table.cs +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.Collections.Generic; -using Markdig.Parsers; -using Markdig.Syntax; - -namespace Markdig.Extensions.Tables -{ - /// - /// Defines a table that contains an optional . - /// - /// - public class Table : ContainerBlock - { - /// - /// Initializes a new instance of the class. - /// - public Table() : this(null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The parser used to create this block. - public Table(BlockParser parser) : base(parser) - { - ColumnDefinitions = new List(); - } - - /// - /// Gets or sets the column alignments. May be null. - /// - public List ColumnDefinitions { get; } - - /// - /// Checks if the table structure is valid. - /// - /// True if the table has rows and the number of cells per row is correct, other wise false. - public bool IsValid() - { - // A table with no rows is not valid. - if (Count == 0) - { - return false; - } - var columnCount = ColumnDefinitions.Count; - var rows = new int[Count]; - for (int i = 0; i < Count; i++) - { - var row = (TableRow)this[i]; - for (int j = 0; j < row.Count; j++) - { - var cell = (TableCell)row[j]; - rows[i] += cell.ColumnSpan; - var rowSpan = cell.RowSpan - 1; - while (rowSpan > 0) - { - rows[i + rowSpan] += cell.ColumnSpan; - rowSpan--; - } - } - if (rows[i] > columnCount) - { - return false; - } - } - return true; - } - - /// - /// Normalizes the number of columns of this table by taking the maximum columns and appending empty cells. - /// - public void Normalize() - { - var maxColumn = 0; - for (int i = 0; i < this.Count; i++) - { - var row = this[i] as TableRow; - if (row != null && row.Count > maxColumn) - { - maxColumn = row.Count; - } - } - - for (int i = 0; i < this.Count; i++) - { - var row = this[i] as TableRow; - if (row != null) - { - for (int j = row.Count; j < maxColumn; j++) - { - row.Add(new TableCell()); - } - } - } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Tables/TableCell.cs b/NppMarkdownPanel/Markdig/Extensions/Tables/TableCell.cs deleted file mode 100644 index 968fdb4..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Tables/TableCell.cs +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Parsers; -using Markdig.Syntax; - -namespace Markdig.Extensions.Tables -{ - /// - /// Defines a cell in a - /// - /// - public class TableCell : ContainerBlock - { - /// - /// Initializes a new instance of the class. - /// - public TableCell() : this(null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The parser used to create this block. - public TableCell(BlockParser parser) : base(parser) - { - AllowClose = true; - ColumnSpan = 1; - ColumnIndex = -1; - RowSpan = 1; - } - - /// - /// Gets or sets the index of the column to which this cell belongs. - /// - public int ColumnIndex { get; set; } - - /// - /// Gets or sets the column span this cell is covering. Default is 1. - /// - public int ColumnSpan { get; set; } - - /// - /// Gets or sets the row span this cell is covering. Default is 1. - /// - public int RowSpan { get; set; } - - /// - /// Gets or sets whether this cell can be closed. - /// - public bool AllowClose { get; set; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Tables/TableColumnAlign.cs b/NppMarkdownPanel/Markdig/Extensions/Tables/TableColumnAlign.cs deleted file mode 100644 index c846794..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Tables/TableColumnAlign.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -namespace Markdig.Extensions.Tables -{ - /// - /// Defines the alignment of a column - /// - public enum TableColumnAlign - { - /// - /// Align the column to the left - /// - Left, - - /// - /// Align the column to the center - /// - Center, - - /// - /// Align the column to the right - /// - Right, - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Tables/TableColumnDefinition.cs b/NppMarkdownPanel/Markdig/Extensions/Tables/TableColumnDefinition.cs deleted file mode 100644 index feeb11b..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Tables/TableColumnDefinition.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace Markdig.Extensions.Tables -{ - /// - /// Defines a column. - /// - public class TableColumnDefinition - { - /// - /// Gets or sets the width (in percentage) of this column. A value of 0 is unspecified. - /// - public float Width { get; set; } - - /// - /// Gets or sets the column alignment. - /// - public TableColumnAlign? Alignment { get; set; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Tables/TableHelper.cs b/NppMarkdownPanel/Markdig/Extensions/Tables/TableHelper.cs deleted file mode 100644 index e10b364..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Tables/TableHelper.cs +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Helpers; - -namespace Markdig.Extensions.Tables -{ - /// - /// Helper methods for parsing tables. - /// - public static class TableHelper - { - /// - /// Parses a column header equivalent to the regexp: \s*:\s*[delimiterChar]+\s*:\s* - /// - /// The text slice. - /// The delimiter character (either `-` or `=`). - /// The alignment of the column. - /// - /// true if parsing was successfull - /// - public static bool ParseColumnHeader(ref StringSlice slice, char delimiterChar, out TableColumnAlign? align) - { - return ParseColumnHeaderDetect(ref slice, ref delimiterChar, out align); - } - - /// - /// Parses a column header equivalent to the regexp: \s*:\s*[delimiterChar]+\s*:\s* - /// - /// The text slice. - /// The delimiter character (either `-` or `=`). - /// The alignment of the column. - /// - /// true if parsing was successfull - /// - public static bool ParseColumnHeaderAuto(ref StringSlice slice, out char delimiterChar, out TableColumnAlign? align) - { - delimiterChar = '\0'; - return ParseColumnHeaderDetect(ref slice, ref delimiterChar, out align); - } - - /// - /// Parses a column header equivalent to the regexp: \s*:\s*[delimiterChar]+\s*:\s* - /// - /// The text slice. - /// The delimiter character (either `-` or `=`). If `\0`, it will detect the character (either `-` or `=`) - /// The alignment of the column. - /// - /// true if parsing was successfull - /// - public static bool ParseColumnHeaderDetect(ref StringSlice slice, ref char delimiterChar, out TableColumnAlign? align) - { - align = null; - - slice.TrimStart(); - var c = slice.CurrentChar; - bool hasLeft = false; - bool hasRight = false; - if (c == ':') - { - hasLeft = true; - slice.NextChar(); - } - - slice.TrimStart(); - c = slice.CurrentChar; - - // if we want to automatically detect - if (delimiterChar == '\0') - { - if (c == '=' || c == '-') - { - delimiterChar = c; - } - else - { - return false; - } - } - - int count = 0; - while (c == delimiterChar) - { - c = slice.NextChar(); - count++; - } - - // We expect at least one `-` delimiter char - if (count == 0) - { - return false; - } - - slice.TrimStart(); - c = slice.CurrentChar; - - if (c == ':') - { - hasRight = true; - slice.NextChar(); - } - slice.TrimStart(); - - align = hasLeft && hasRight - ? TableColumnAlign.Center - : hasRight ? TableColumnAlign.Right : hasLeft ? TableColumnAlign.Left : (TableColumnAlign?) null; - - return true; - } - - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Tables/TableRow.cs b/NppMarkdownPanel/Markdig/Extensions/Tables/TableRow.cs deleted file mode 100644 index 4b7720c..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Tables/TableRow.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax; - -namespace Markdig.Extensions.Tables -{ - /// - /// Defines a row in a , contains , parent is . - /// - /// - public class TableRow : ContainerBlock - { - /// - /// Initializes a new instance of the class. - /// - public TableRow() : base(null) - { - } - - /// - /// Gets or sets a value indicating whether this instance is header row. - /// - public bool IsHeader { get; set; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/TaskLists/HtmlTaskListRenderer.cs b/NppMarkdownPanel/Markdig/Extensions/TaskLists/HtmlTaskListRenderer.cs deleted file mode 100644 index e6e0563..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/TaskLists/HtmlTaskListRenderer.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System; -using Markdig.Renderers; -using Markdig.Renderers.Html; - -namespace Markdig.Extensions.TaskLists -{ - /// - /// A HTML renderer for a . - /// - /// - public class HtmlTaskListRenderer : HtmlObjectRenderer - { - protected override void Write(HtmlRenderer renderer, TaskList obj) - { - if (renderer.EnableHtmlForInline) - { - renderer.Write(""); - } - else - { - renderer.Write('['); - renderer.Write(obj.Checked ? "x" : " "); - renderer.Write(']'); - } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/TaskLists/NormalizeTaskListRenderer.cs b/NppMarkdownPanel/Markdig/Extensions/TaskLists/NormalizeTaskListRenderer.cs deleted file mode 100644 index 73b757f..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/TaskLists/NormalizeTaskListRenderer.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Markdig.Renderers.Normalize; - -namespace Markdig.Extensions.TaskLists -{ - public class NormalizeTaskListRenderer : NormalizeObjectRenderer - { - protected override void Write(NormalizeRenderer renderer, TaskList obj) - { - renderer.Write("["); - renderer.Write(obj.Checked ? "X" : " "); - renderer.Write("]"); - } - } -} diff --git a/NppMarkdownPanel/Markdig/Extensions/TaskLists/TaskList.cs b/NppMarkdownPanel/Markdig/Extensions/TaskLists/TaskList.cs deleted file mode 100644 index 9949791..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/TaskLists/TaskList.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System.Diagnostics; -using Markdig.Syntax.Inlines; - -namespace Markdig.Extensions.TaskLists -{ - /// - /// An inline for TaskList. - /// - [DebuggerDisplay("TaskList {Checked}")] - public class TaskList : LeafInline - { - public bool Checked { get; set; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/TaskLists/TaskListExtension.cs b/NppMarkdownPanel/Markdig/Extensions/TaskLists/TaskListExtension.cs deleted file mode 100644 index caf8193..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/TaskLists/TaskListExtension.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Parsers.Inlines; -using Markdig.Renderers; -using Markdig.Renderers.Normalize; - -namespace Markdig.Extensions.TaskLists -{ - /// - /// Extension to enable TaskList. - /// - public class TaskListExtension : IMarkdownExtension - { - public void Setup(MarkdownPipelineBuilder pipeline) - { - if (!pipeline.InlineParsers.Contains()) - { - // Insert the parser after the code span parser - pipeline.InlineParsers.InsertBefore(new TaskListInlineParser()); - } - } - - public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer) - { - var htmlRenderer = renderer as HtmlRenderer; - if (htmlRenderer != null) - { - htmlRenderer.ObjectRenderers.AddIfNotAlready(); - } - - var normalizeRenderer = renderer as NormalizeRenderer; - if (normalizeRenderer != null) - { - normalizeRenderer.ObjectRenderers.AddIfNotAlready(); - } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/TaskLists/TaskListInlineParser.cs b/NppMarkdownPanel/Markdig/Extensions/TaskLists/TaskListInlineParser.cs deleted file mode 100644 index 4259175..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/TaskLists/TaskListInlineParser.cs +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Helpers; -using Markdig.Parsers; -using Markdig.Renderers.Html; -using Markdig.Syntax; - -namespace Markdig.Extensions.TaskLists -{ - /// - /// The inline parser for SmartyPants. - /// - public class TaskListInlineParser : InlineParser - { - /// - /// Initializes a new instance of the class. - /// - public TaskListInlineParser() - { - OpeningCharacters = new[] {'['}; - ListClass = "contains-task-list"; - ListItemClass = "task-list-item"; - } - - /// - /// Gets or sets the list class used for a task list. - /// - public string ListClass { get; set; } - - /// - /// Gets or sets the list item class used for a task list. - /// - public string ListItemClass { get; set; } - - public override bool Match(InlineProcessor processor, ref StringSlice slice) - { - // A tasklist is either - // [ ] - // or [x] or [X] - - var listItemBlock = processor.Block.Parent as ListItemBlock; - - if (listItemBlock == null) - { - return false; - } - - var startingPosition = slice.Start; - var c = slice.NextChar(); - if (!c.IsSpace() && c != 'x' && c != 'X') - { - return false; - } - if (slice.NextChar() != ']') - { - return false; - } - // Skip last ] - slice.NextChar(); - - // Create the TaskList - int line; - int column; - var taskItem = new TaskList() - { - Span = { Start = processor.GetSourcePosition(startingPosition, out line, out column)}, - Line = line, - Column = column, - Checked = !c.IsSpace() - }; - taskItem.Span.End = taskItem.Span.Start + 2; - processor.Inline = taskItem; - - // Add proper class for task list - if (!string.IsNullOrEmpty(ListItemClass)) - { - listItemBlock.GetAttributes().AddClass(ListItemClass); - } - - var listBlock = (ListBlock) listItemBlock.Parent; - if (!string.IsNullOrEmpty(ListClass)) - { - listBlock.GetAttributes().AddClass(ListClass); - } - - return true; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/TextRenderer/ConfigureNewLineExtension.cs b/NppMarkdownPanel/Markdig/Extensions/TextRenderer/ConfigureNewLineExtension.cs deleted file mode 100644 index df02202..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/TextRenderer/ConfigureNewLineExtension.cs +++ /dev/null @@ -1,34 +0,0 @@ -using Markdig.Renderers; - -namespace Markdig.Extensions.TextRenderer -{ - /// - /// Extension that allows setting line-endings for any IMarkdownRenderer - /// that inherits from - /// - /// - public class ConfigureNewLineExtension : IMarkdownExtension - { - private readonly string newLine; - - public ConfigureNewLineExtension(string newLine) - { - this.newLine = newLine; - } - - public void Setup(MarkdownPipelineBuilder pipeline) - { - } - - public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer) - { - var textRenderer = renderer as TextRendererBase; - if (textRenderer == null) - { - return; - } - - textRenderer.Writer.NewLine = newLine; - } - } -} diff --git a/NppMarkdownPanel/Markdig/Extensions/Yaml/YamlFrontMatterBlock.cs b/NppMarkdownPanel/Markdig/Extensions/Yaml/YamlFrontMatterBlock.cs deleted file mode 100644 index e601874..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Yaml/YamlFrontMatterBlock.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Parsers; -using Markdig.Syntax; - -namespace Markdig.Extensions.Yaml -{ - /// - /// A YAML frontmatter block. - /// - /// - public class YamlFrontMatterBlock : CodeBlock - { - /// - /// Initializes a new instance of the class. - /// - /// The parser. - public YamlFrontMatterBlock(BlockParser parser) : base(parser) - { - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Yaml/YamlFrontMatterExtension.cs b/NppMarkdownPanel/Markdig/Extensions/Yaml/YamlFrontMatterExtension.cs deleted file mode 100644 index 9cb50a2..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Yaml/YamlFrontMatterExtension.cs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Parsers; -using Markdig.Renderers; -using Markdig.Renderers.Html; - -namespace Markdig.Extensions.Yaml -{ - /// - /// Extension to discard a YAML frontmatter at the beginning of a Markdown document. - /// - public class YamlFrontMatterExtension : IMarkdownExtension - { - public void Setup(MarkdownPipelineBuilder pipeline) - { - if (!pipeline.BlockParsers.Contains()) - { - // Insert the YAML parser before the thematic break parser, as it is also triggered on a --- dash - pipeline.BlockParsers.InsertBefore(new YamlFrontMatterParser()); - } - } - - public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer) - { - if (!renderer.ObjectRenderers.Contains()) - { - renderer.ObjectRenderers.InsertBefore(new YamlFrontMatterRenderer()); - } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Yaml/YamlFrontMatterParser.cs b/NppMarkdownPanel/Markdig/Extensions/Yaml/YamlFrontMatterParser.cs deleted file mode 100644 index 062b109..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Yaml/YamlFrontMatterParser.cs +++ /dev/null @@ -1,166 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Helpers; -using Markdig.Parsers; -using Markdig.Syntax; - -namespace Markdig.Extensions.Yaml -{ - /// - /// Block parser for a YAML frontmatter. - /// - /// - public class YamlFrontMatterParser : BlockParser - { - // We reuse a FencedCodeBlock parser to grab a frontmatter, only active if it happens on the first line of the document. - - /// - /// Initializes a new instance of the class. - /// - public YamlFrontMatterParser() - { - this.OpeningCharacters = new[] { '-' }; - } - - /// - /// Creates the front matter block. - /// - /// The block processor - /// The front matter block - protected virtual YamlFrontMatterBlock CreateFrontMatterBlock(BlockProcessor processor) - { - return new YamlFrontMatterBlock(this); - } - - /// - /// Tries to match a block opening. - /// - /// The parser processor. - /// The result of the match - public override BlockState TryOpen(BlockProcessor processor) - { - // We expect no indentation for a fenced code block. - if (processor.IsCodeIndent) - { - return BlockState.None; - } - - // Only accept a frontmatter at the beginning of the file - if (processor.Start != 0) - { - return BlockState.None; - } - - int count = 0; - var line = processor.Line; - char c = line.CurrentChar; - - // Must consist of exactly three dashes - while (c == '-' && count < 4) - { - count++; - c = line.NextChar(); - } - - // If three dashes (optionally followed by whitespace) - // this is a YAML front matter blcok - if (count == 3 && (c == '\0' || c.IsWhitespace()) && line.TrimEnd()) - { - bool hasFullYamlFrontMatter = false; - // We make sure that there is a closing frontmatter somewhere in the document - // so here we work on the full document instead of just the line - var fullLine = new StringSlice(line.Text, line.Start, line.Text.Length - 1); - c = fullLine.CurrentChar; - while (c != '\0') - { - c = fullLine.NextChar(); - if (c == '\n' || c == '\r') - { - var nc = fullLine.PeekChar(); - if (c == '\r' && nc == '\n') - { - c = fullLine.NextChar(); - } - nc = fullLine.PeekChar(); - if (nc == '-') - { - if (fullLine.NextChar() == '-' && fullLine.NextChar() == '-' && fullLine.NextChar() == '-' && (fullLine.NextChar() == '\0' || fullLine.SkipSpacesToEndOfLineOrEndOfDocument())) - { - hasFullYamlFrontMatter = true; - break; - } - } - else if (nc == '.') - { - if (fullLine.NextChar() == '.' && fullLine.NextChar() == '.' && fullLine.NextChar() == '.' && (fullLine.NextChar() == '\0' || fullLine.SkipSpacesToEndOfLineOrEndOfDocument())) - { - hasFullYamlFrontMatter = true; - break; - } - } - } - } - - if (hasFullYamlFrontMatter) - { - // Create a front matter block - var block = this.CreateFrontMatterBlock(processor); - block.Column = processor.Column; - block.Span.Start = 0; - block.Span.End = line.Start; - - // Store the number of matched string into the context - processor.NewBlocks.Push(block); - - // Discard the current line as it is already parsed - return BlockState.ContinueDiscard; - } - } - - return BlockState.None; - } - - /// - /// Tries to continue matching a block already opened. - /// - /// The parser processor. - /// The block already opened. - /// The result of the match. By default, don't expect any newline - public override BlockState TryContinue(BlockProcessor processor, Block block) - { - char matchChar; - int count = 0; - var c = processor.CurrentChar; - - // Determine if we have a closing fence. - // It can start or end with either --- or ... - var line = processor.Line; - if (processor.Column == 0 && (c == '-' || c == '.')) - { - matchChar = c; - - while (c == matchChar) - { - c = line.NextChar(); - count++; - } - - // If we have a closing fence, close it and discard the current line - // The line must contain only fence characters and optional following whitespace. - if (count == 3 && !processor.IsCodeIndent && (c == '\0' || c.IsWhitespace()) && line.TrimEnd()) - { - block.UpdateSpanEnd(line.Start - 1); - - // Don't keep the last line - return BlockState.BreakDiscard; - } - } - - // Reset the indentation to the column before the indent - processor.GoToColumn(processor.ColumnBeforeIndent); - - return BlockState.Continue; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Extensions/Yaml/YamlFrontMatterRenderer.cs b/NppMarkdownPanel/Markdig/Extensions/Yaml/YamlFrontMatterRenderer.cs deleted file mode 100644 index 14ac904..0000000 --- a/NppMarkdownPanel/Markdig/Extensions/Yaml/YamlFrontMatterRenderer.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Renderers; -using Markdig.Renderers.Html; - -namespace Markdig.Extensions.Yaml -{ - /// - /// Empty renderer for a - /// - /// - public class YamlFrontMatterRenderer : HtmlObjectRenderer - { - protected override void Write(HtmlRenderer renderer, YamlFrontMatterBlock obj) - { - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Helpers/ArrayHelper.cs b/NppMarkdownPanel/Markdig/Helpers/ArrayHelper.cs deleted file mode 100644 index 9ec8ff0..0000000 --- a/NppMarkdownPanel/Markdig/Helpers/ArrayHelper.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -namespace Markdig.Helpers -{ - /// - /// Helper class for defining Empty arrays. - /// - /// Type of an element of the array - public static class ArrayHelper - { - /// - /// An empty array. - /// - public static readonly T[] Empty = new T[0]; - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Helpers/CharHelper.cs b/NppMarkdownPanel/Markdig/Helpers/CharHelper.cs deleted file mode 100644 index 5e6da0b..0000000 --- a/NppMarkdownPanel/Markdig/Helpers/CharHelper.cs +++ /dev/null @@ -1,759 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - - -// The IsHighSurrogate, IsLowSurrogate and ConvertToUtf32 methods are copied from -// .Net Core source code which is under MIT license. They are copied here because -// they don't exist in `portable40-net40+sl5+win8+wp8+wpa81`, We probably should remove them -// once we dropped support for that target platform and use the official .Net methods. - -//The MIT License(MIT) - -//Copyright(c) .NET Foundation and Contributors - -//All rights reserved. - -//Permission is hereby granted, free of charge, to any person obtaining a copy -//of this software and associated documentation files (the "Software"), to deal -//in the Software without restriction, including without limitation the rights -//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -//copies of the Software, and to permit persons to whom the Software is -//furnished to do so, subject to the following conditions: - -//The above copyright notice and this permission notice shall be included in all -//copies or substantial portions of the Software. - -//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -//SOFTWARE. - -using System; -using System.Globalization; -using System.Runtime.CompilerServices; - -namespace Markdig.Helpers -{ - using System.Collections.Generic; - - /// - /// Helper class for handling characters. - /// - public static class CharHelper - { - public const int TabSize = 4; - - public const char ZeroSafeChar = '\uFFFD'; - - public const string ZeroSafeString = "\uFFFD"; - - private const char HighSurrogateStart = '\ud800'; - private const char HighSurrogateEnd = '\udbff'; - private const char LowSurrogateStart = '\udc00'; - private const char LowSurrogateEnd = '\udfff'; - - // The starting codepoint for Unicode plane 1. Plane 1 contains 0x010000 ~ 0x01ffff. - private const int UnicodePlane01Start = 0x10000; - - // We don't support LCDM - private static readonly Dictionary romanMap = new Dictionary { { 'I', 1 }, { 'V', 5 }, { 'X', 10 } }; - - private static readonly char[] punctuationExceptions = { '−', '-', '†', '‡' }; - - public static void CheckOpenCloseDelimiter(char pc, char c, bool enableWithinWord, out bool canOpen, out bool canClose) - { - // A left-flanking delimiter run is a delimiter run that is - // (a) not followed by Unicode whitespace, and - // (b) either not followed by a punctuation character, or preceded by Unicode whitespace - // or a punctuation character. - // For purposes of this definition, the beginning and the end of the line count as Unicode whitespace. - pc.CheckUnicodeCategory(out bool prevIsWhiteSpace, out bool prevIsPunctuation); - c.CheckUnicodeCategory(out bool nextIsWhiteSpace, out bool nextIsPunctuation); - - var prevIsExcepted = prevIsPunctuation && punctuationExceptions.Contains(pc); - var nextIsExcepted = nextIsPunctuation && punctuationExceptions.Contains(c); - - canOpen = !nextIsWhiteSpace && - ((!nextIsPunctuation || nextIsExcepted) || prevIsWhiteSpace || prevIsPunctuation); - - - // A right-flanking delimiter run is a delimiter run that is - // (a) not preceded by Unicode whitespace, and - // (b) either not preceded by a punctuation character, or followed by Unicode whitespace - // or a punctuation character. - // For purposes of this definition, the beginning and the end of the line count as Unicode whitespace. - canClose = !prevIsWhiteSpace && - ((!prevIsPunctuation || prevIsExcepted) || nextIsWhiteSpace || nextIsPunctuation); - - if (!enableWithinWord) - { - var temp = canOpen; - // A single _ character can open emphasis iff it is part of a left-flanking delimiter run and either - // (a) not part of a right-flanking delimiter run or - // (b) part of a right-flanking delimiter run preceded by punctuation. - canOpen = canOpen && (!canClose || prevIsPunctuation); - - // A single _ character can close emphasis iff it is part of a right-flanking delimiter run and either - // (a) not part of a left-flanking delimiter run or - // (b) part of a left-flanking delimiter run followed by punctuation. - canClose = canClose && (!temp || nextIsPunctuation); - } - } - - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public static bool IsRomanLetterPartial(char c) - { - // We don't support LCDM - return IsRomanLetterLowerPartial(c) || IsRomanLetterUpperPartial(c); - } - - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public static bool IsRomanLetterLowerPartial(char c) - { - // We don't support LCDM - return c == 'i' || c == 'v' || c == 'x'; - } - - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public static bool IsRomanLetterUpperPartial(char c) - { - // We don't support LCDM - return c == 'I' || c == 'V' || c == 'X'; - } - - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public static int RomanToArabic(string text) - { - int result = 0; - for (int i = 0; i < text.Length; i++) - { - var character = Char.ToUpperInvariant(text[i]); - var candidate = romanMap[character]; - if (i + 1 < text.Length && candidate < romanMap[Char.ToUpperInvariant(text[i + 1])]) - { - result -= candidate; - } - else - { - result += candidate; - } - } - return result; - } - - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public static int AddTab(int column) - { - return ((column + TabSize) / TabSize) * TabSize; - } - - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public static bool IsAcrossTab(int column) - { - return (column & (TabSize - 1)) != 0; - } - - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public static bool Contains(this char[] charList, char c) - { - for (int i = 0; i < charList.Length; i++) - { - if (charList[i] == c) - { - return true; - } - } - return false; - } - - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public static bool IsWhitespace(this char c) - { - // 2.1 Characters and lines - // A whitespace character is a space(U + 0020), tab(U + 0009), newline(U + 000A), line tabulation (U + 000B), form feed (U + 000C), or carriage return (U + 000D). - return c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r'; - } - - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public static bool IsControl(this char c) - { - return c < ' ' || Char.IsControl(c); - } - - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public static bool IsEscapableSymbol(this char c) - { - // char.IsSymbol also works with Unicode symbols that cannot be escaped based on the specification. - return (c > ' ' && c < '0') || (c > '9' && c < 'A') || (c > 'Z' && c < 'a') || (c > 'z' && c < 127) || c == '•'; - } - - //[MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public static bool IsWhiteSpaceOrZero(this char c) - { - return IsWhitespace(c) || IsZero(c); - } - - // Note that we are not considering the character & as a punctuation in HTML - // as it is used for HTML entities, print unicode, so we assume that when we have a `&` - // it is more likely followed by a valid HTML Entity that represents a non punctuation - public static void CheckUnicodeCategory(this char c, out bool space, out bool punctuation) - { - // Credits: code from CommonMark.NET - // Copyright (c) 2014, Kārlis Gaņģis All rights reserved. - // See license for details: https://github.com/Knagis/CommonMark.NET/blob/master/LICENSE.md - if (c <= 'ÿ') - { - space = c == '\0' || c == ' ' || (c >= '\t' && c <= '\r') || c == '\u00a0' || c == '\u0085'; - punctuation = c == '\0' || (c >= 33 && c <= 47 && c != 38) || (c >= 58 && c <= 64) || (c >= 91 && c <= 96) || (c >= 123 && c <= 126); - } - else - { - var category = CharUnicodeInfo.GetUnicodeCategory(c); - space = category == UnicodeCategory.SpaceSeparator - || category == UnicodeCategory.LineSeparator - || category == UnicodeCategory.ParagraphSeparator; - punctuation = !space && - (category == UnicodeCategory.ConnectorPunctuation - || category == UnicodeCategory.DashPunctuation - || category == UnicodeCategory.OpenPunctuation - || category == UnicodeCategory.ClosePunctuation - || category == UnicodeCategory.InitialQuotePunctuation - || category == UnicodeCategory.FinalQuotePunctuation - || category == UnicodeCategory.OtherPunctuation); - } - } - - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public static bool IsNewLine(this char c) - { - return c == '\n'; - } - - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public static bool IsZero(this char c) - { - return c == '\0'; - } - - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public static bool IsSpace(this char c) - { - // 2.1 Characters and lines - // A space is U+0020. - return c == ' '; - } - - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public static bool IsTab(this char c) - { - // 2.1 Characters and lines - // A space is U+0009. - return c == '\t'; - } - - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public static bool IsSpaceOrTab(this char c) - { - return IsSpace(c) || IsTab(c); - } - - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public static char EscapeInsecure(this char c) - { - // 2.3 Insecure characters - // For security reasons, the Unicode character U+0000 must be replaced with the REPLACEMENT CHARACTER (U+FFFD). - return c == '\0' ? '\ufffd' : c; - } - - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public static bool IsAlphaUpper(this char c) - { - return c >= 'A' && c <= 'Z'; - } - - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public static bool IsAlpha(this char c) - { - return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); - } - - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public static bool IsAlphaNumeric(this char c) - { - return IsAlpha(c) || IsDigit(c); - } - - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public static bool IsDigit(this char c) - { - return c >= '0' && c <= '9'; - } - - public static bool IsAsciiPunctuation(this char c) - { - // 2.1 Characters and lines - // An ASCII punctuation character is !, ", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, @, [, \, ], ^, _, `, {, |, }, or ~. - switch (c) - { - case '!': - case '"': - case '#': - case '$': - case '%': - case '&': - case '\'': - case '(': - case ')': - case '*': - case '+': - case ',': - case '-': - case '.': - case '/': - case ':': - case ';': - case '<': - case '=': - case '>': - case '?': - case '@': - case '[': - case '\\': - case ']': - case '^': - case '_': - case '`': - case '{': - case '|': - case '}': - case '~': - return true; - } - return false; - } - - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public static bool IsEmailUsernameSpecialChar(char c) - { - return ".!#$%&'*+/=?^_`{|}~-+.~".IndexOf(c) >= 0; - } - - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public static bool IsHighSurrogate(char c) - { - return ((c >= HighSurrogateStart) && (c <= HighSurrogateEnd)); - } - - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public static bool IsLowSurrogate(char c) - { - return ((c >= LowSurrogateStart) && (c <= LowSurrogateEnd)); - } - - public static int ConvertToUtf32(char highSurrogate, char lowSurrogate) - { - if (!IsHighSurrogate(highSurrogate)) - { - throw new ArgumentOutOfRangeException(nameof(highSurrogate), "Invalid high surrogate"); - } - if (!IsLowSurrogate(lowSurrogate)) - { - throw new ArgumentOutOfRangeException(nameof(lowSurrogate), "Invalid low surrogate"); - } - return (((highSurrogate - HighSurrogateStart) * 0x400) + (lowSurrogate - LowSurrogateStart) + UnicodePlane01Start); - } - - public static IEnumerable ToUtf32(string text) - { - for (int i = 0; i < text.Length; i++) - { - if (IsHighSurrogate(text[i]) && i < text.Length - 1 && IsLowSurrogate(text[i + 1])) - { - yield return ConvertToUtf32(text[i], text[i + 1]); - } - else - { - yield return text[i]; - } - } - } - - public static bool IsRightToLeft(int c) - { - // Generated from Table D.1 of RFC3454 - // http://www.ietf.org/rfc/rfc3454.txt - - // Probably should use a binary search approach - - return c >= 0x0005D0 && c <= 0x0005EA || - c >= 0x0005F0 && c <= 0x0005F4 || - c >= 0x000621 && c <= 0x00063A || - c >= 0x000640 && c <= 0x00064A || - c >= 0x00066D && c <= 0x00066F || - c >= 0x000671 && c <= 0x0006D5 || - c >= 0x0006E5 && c <= 0x0006E6 || - c >= 0x0006FA && c <= 0x0006FE || - c >= 0x000700 && c <= 0x00070D || - c >= 0x000712 && c <= 0x00072C || - c >= 0x000780 && c <= 0x0007A5 || - c >= 0x00FB1F && c <= 0x00FB28 || - c >= 0x00FB2A && c <= 0x00FB36 || - c >= 0x00FB38 && c <= 0x00FB3C || - c >= 0x00FB40 && c <= 0x00FB41 || - c >= 0x00FB43 && c <= 0x00FB44 || - c >= 0x00FB46 && c <= 0x00FBB1 || - c >= 0x00FBD3 && c <= 0x00FD3D || - c >= 0x00FD50 && c <= 0x00FD8F || - c >= 0x00FD92 && c <= 0x00FDC7 || - c >= 0x00FDF0 && c <= 0x00FDFC || - c >= 0x00FE70 && c <= 0x00FE74 || - c >= 0x00FE76 && c <= 0x00FEFC || - c == 0x0005BE || c == 0x0005C0 || - c == 0x0005C3 || c == 0x00061B || - c == 0x00061F || c == 0x0006DD || - c == 0x000710 || c == 0x0007B1 || - c == 0x00200F || c == 0x00FB1D || - c == 0x00FB3E; - } - - public static bool IsLeftToRight(int c) - { - // Generated from Table D.2 of RFC3454 - // http://www.ietf.org/rfc/rfc3454.txt - - // Probably should use a binary search approach - - return c >= 0x000041 && c <= 0x00005A || - c >= 0x000061 && c <= 0x00007A || - c >= 0x0000C0 && c <= 0x0000D6 || - c >= 0x0000D8 && c <= 0x0000F6 || - c >= 0x0000F8 && c <= 0x000220 || - c >= 0x000222 && c <= 0x000233 || - c >= 0x000250 && c <= 0x0002AD || - c >= 0x0002B0 && c <= 0x0002B8 || - c >= 0x0002BB && c <= 0x0002C1 || - c >= 0x0002D0 && c <= 0x0002D1 || - c >= 0x0002E0 && c <= 0x0002E4 || - c >= 0x000388 && c <= 0x00038A || - c >= 0x00038E && c <= 0x0003A1 || - c >= 0x0003A3 && c <= 0x0003CE || - c >= 0x0003D0 && c <= 0x0003F5 || - c >= 0x000400 && c <= 0x000482 || - c >= 0x00048A && c <= 0x0004CE || - c >= 0x0004D0 && c <= 0x0004F5 || - c >= 0x0004F8 && c <= 0x0004F9 || - c >= 0x000500 && c <= 0x00050F || - c >= 0x000531 && c <= 0x000556 || - c >= 0x000559 && c <= 0x00055F || - c >= 0x000561 && c <= 0x000587 || - c >= 0x000905 && c <= 0x000939 || - c >= 0x00093D && c <= 0x000940 || - c >= 0x000949 && c <= 0x00094C || - c >= 0x000958 && c <= 0x000961 || - c >= 0x000964 && c <= 0x000970 || - c >= 0x000982 && c <= 0x000983 || - c >= 0x000985 && c <= 0x00098C || - c >= 0x00098F && c <= 0x000990 || - c >= 0x000993 && c <= 0x0009A8 || - c >= 0x0009AA && c <= 0x0009B0 || - c >= 0x0009B6 && c <= 0x0009B9 || - c >= 0x0009BE && c <= 0x0009C0 || - c >= 0x0009C7 && c <= 0x0009C8 || - c >= 0x0009CB && c <= 0x0009CC || - c >= 0x0009DC && c <= 0x0009DD || - c >= 0x0009DF && c <= 0x0009E1 || - c >= 0x0009E6 && c <= 0x0009F1 || - c >= 0x0009F4 && c <= 0x0009FA || - c >= 0x000A05 && c <= 0x000A0A || - c >= 0x000A0F && c <= 0x000A10 || - c >= 0x000A13 && c <= 0x000A28 || - c >= 0x000A2A && c <= 0x000A30 || - c >= 0x000A32 && c <= 0x000A33 || - c >= 0x000A35 && c <= 0x000A36 || - c >= 0x000A38 && c <= 0x000A39 || - c >= 0x000A3E && c <= 0x000A40 || - c >= 0x000A59 && c <= 0x000A5C || - c >= 0x000A66 && c <= 0x000A6F || - c >= 0x000A72 && c <= 0x000A74 || - c >= 0x000A85 && c <= 0x000A8B || - c >= 0x000A8F && c <= 0x000A91 || - c >= 0x000A93 && c <= 0x000AA8 || - c >= 0x000AAA && c <= 0x000AB0 || - c >= 0x000AB2 && c <= 0x000AB3 || - c >= 0x000AB5 && c <= 0x000AB9 || - c >= 0x000ABD && c <= 0x000AC0 || - c >= 0x000ACB && c <= 0x000ACC || - c >= 0x000AE6 && c <= 0x000AEF || - c >= 0x000B02 && c <= 0x000B03 || - c >= 0x000B05 && c <= 0x000B0C || - c >= 0x000B0F && c <= 0x000B10 || - c >= 0x000B13 && c <= 0x000B28 || - c >= 0x000B2A && c <= 0x000B30 || - c >= 0x000B32 && c <= 0x000B33 || - c >= 0x000B36 && c <= 0x000B39 || - c >= 0x000B3D && c <= 0x000B3E || - c >= 0x000B47 && c <= 0x000B48 || - c >= 0x000B4B && c <= 0x000B4C || - c >= 0x000B5C && c <= 0x000B5D || - c >= 0x000B5F && c <= 0x000B61 || - c >= 0x000B66 && c <= 0x000B70 || - c >= 0x000B85 && c <= 0x000B8A || - c >= 0x000B8E && c <= 0x000B90 || - c >= 0x000B92 && c <= 0x000B95 || - c >= 0x000B99 && c <= 0x000B9A || - c >= 0x000B9E && c <= 0x000B9F || - c >= 0x000BA3 && c <= 0x000BA4 || - c >= 0x000BA8 && c <= 0x000BAA || - c >= 0x000BAE && c <= 0x000BB5 || - c >= 0x000BB7 && c <= 0x000BB9 || - c >= 0x000BBE && c <= 0x000BBF || - c >= 0x000BC1 && c <= 0x000BC2 || - c >= 0x000BC6 && c <= 0x000BC8 || - c >= 0x000BCA && c <= 0x000BCC || - c >= 0x000BE7 && c <= 0x000BF2 || - c >= 0x000C01 && c <= 0x000C03 || - c >= 0x000C05 && c <= 0x000C0C || - c >= 0x000C0E && c <= 0x000C10 || - c >= 0x000C12 && c <= 0x000C28 || - c >= 0x000C2A && c <= 0x000C33 || - c >= 0x000C35 && c <= 0x000C39 || - c >= 0x000C41 && c <= 0x000C44 || - c >= 0x000C60 && c <= 0x000C61 || - c >= 0x000C66 && c <= 0x000C6F || - c >= 0x000C82 && c <= 0x000C83 || - c >= 0x000C85 && c <= 0x000C8C || - c >= 0x000C8E && c <= 0x000C90 || - c >= 0x000C92 && c <= 0x000CA8 || - c >= 0x000CAA && c <= 0x000CB3 || - c >= 0x000CB5 && c <= 0x000CB9 || - c >= 0x000CC0 && c <= 0x000CC4 || - c >= 0x000CC7 && c <= 0x000CC8 || - c >= 0x000CCA && c <= 0x000CCB || - c >= 0x000CD5 && c <= 0x000CD6 || - c >= 0x000CE0 && c <= 0x000CE1 || - c >= 0x000CE6 && c <= 0x000CEF || - c >= 0x000D02 && c <= 0x000D03 || - c >= 0x000D05 && c <= 0x000D0C || - c >= 0x000D0E && c <= 0x000D10 || - c >= 0x000D12 && c <= 0x000D28 || - c >= 0x000D2A && c <= 0x000D39 || - c >= 0x000D3E && c <= 0x000D40 || - c >= 0x000D46 && c <= 0x000D48 || - c >= 0x000D4A && c <= 0x000D4C || - c >= 0x000D60 && c <= 0x000D61 || - c >= 0x000D66 && c <= 0x000D6F || - c >= 0x000D82 && c <= 0x000D83 || - c >= 0x000D85 && c <= 0x000D96 || - c >= 0x000D9A && c <= 0x000DB1 || - c >= 0x000DB3 && c <= 0x000DBB || - c >= 0x000DC0 && c <= 0x000DC6 || - c >= 0x000DCF && c <= 0x000DD1 || - c >= 0x000DD8 && c <= 0x000DDF || - c >= 0x000DF2 && c <= 0x000DF4 || - c >= 0x000E01 && c <= 0x000E30 || - c >= 0x000E32 && c <= 0x000E33 || - c >= 0x000E40 && c <= 0x000E46 || - c >= 0x000E4F && c <= 0x000E5B || - c >= 0x000E81 && c <= 0x000E82 || - c >= 0x000E87 && c <= 0x000E88 || - c >= 0x000E94 && c <= 0x000E97 || - c >= 0x000E99 && c <= 0x000E9F || - c >= 0x000EA1 && c <= 0x000EA3 || - c >= 0x000EAA && c <= 0x000EAB || - c >= 0x000EAD && c <= 0x000EB0 || - c >= 0x000EB2 && c <= 0x000EB3 || - c >= 0x000EC0 && c <= 0x000EC4 || - c >= 0x000ED0 && c <= 0x000ED9 || - c >= 0x000EDC && c <= 0x000EDD || - c >= 0x000F00 && c <= 0x000F17 || - c >= 0x000F1A && c <= 0x000F34 || - c >= 0x000F3E && c <= 0x000F47 || - c >= 0x000F49 && c <= 0x000F6A || - c >= 0x000F88 && c <= 0x000F8B || - c >= 0x000FBE && c <= 0x000FC5 || - c >= 0x000FC7 && c <= 0x000FCC || - c >= 0x001000 && c <= 0x001021 || - c >= 0x001023 && c <= 0x001027 || - c >= 0x001029 && c <= 0x00102A || - c >= 0x001040 && c <= 0x001057 || - c >= 0x0010A0 && c <= 0x0010C5 || - c >= 0x0010D0 && c <= 0x0010F8 || - c >= 0x001100 && c <= 0x001159 || - c >= 0x00115F && c <= 0x0011A2 || - c >= 0x0011A8 && c <= 0x0011F9 || - c >= 0x001200 && c <= 0x001206 || - c >= 0x001208 && c <= 0x001246 || - c >= 0x00124A && c <= 0x00124D || - c >= 0x001250 && c <= 0x001256 || - c >= 0x00125A && c <= 0x00125D || - c >= 0x001260 && c <= 0x001286 || - c >= 0x00128A && c <= 0x00128D || - c >= 0x001290 && c <= 0x0012AE || - c >= 0x0012B2 && c <= 0x0012B5 || - c >= 0x0012B8 && c <= 0x0012BE || - c >= 0x0012C2 && c <= 0x0012C5 || - c >= 0x0012C8 && c <= 0x0012CE || - c >= 0x0012D0 && c <= 0x0012D6 || - c >= 0x0012D8 && c <= 0x0012EE || - c >= 0x0012F0 && c <= 0x00130E || - c >= 0x001312 && c <= 0x001315 || - c >= 0x001318 && c <= 0x00131E || - c >= 0x001320 && c <= 0x001346 || - c >= 0x001348 && c <= 0x00135A || - c >= 0x001361 && c <= 0x00137C || - c >= 0x0013A0 && c <= 0x0013F4 || - c >= 0x001401 && c <= 0x001676 || - c >= 0x001681 && c <= 0x00169A || - c >= 0x0016A0 && c <= 0x0016F0 || - c >= 0x001700 && c <= 0x00170C || - c >= 0x00170E && c <= 0x001711 || - c >= 0x001720 && c <= 0x001731 || - c >= 0x001735 && c <= 0x001736 || - c >= 0x001740 && c <= 0x001751 || - c >= 0x001760 && c <= 0x00176C || - c >= 0x00176E && c <= 0x001770 || - c >= 0x001780 && c <= 0x0017B6 || - c >= 0x0017BE && c <= 0x0017C5 || - c >= 0x0017C7 && c <= 0x0017C8 || - c >= 0x0017D4 && c <= 0x0017DA || - c >= 0x0017E0 && c <= 0x0017E9 || - c >= 0x001810 && c <= 0x001819 || - c >= 0x001820 && c <= 0x001877 || - c >= 0x001880 && c <= 0x0018A8 || - c >= 0x001E00 && c <= 0x001E9B || - c >= 0x001EA0 && c <= 0x001EF9 || - c >= 0x001F00 && c <= 0x001F15 || - c >= 0x001F18 && c <= 0x001F1D || - c >= 0x001F20 && c <= 0x001F45 || - c >= 0x001F48 && c <= 0x001F4D || - c >= 0x001F50 && c <= 0x001F57 || - c >= 0x001F5F && c <= 0x001F7D || - c >= 0x001F80 && c <= 0x001FB4 || - c >= 0x001FB6 && c <= 0x001FBC || - c >= 0x001FC2 && c <= 0x001FC4 || - c >= 0x001FC6 && c <= 0x001FCC || - c >= 0x001FD0 && c <= 0x001FD3 || - c >= 0x001FD6 && c <= 0x001FDB || - c >= 0x001FE0 && c <= 0x001FEC || - c >= 0x001FF2 && c <= 0x001FF4 || - c >= 0x001FF6 && c <= 0x001FFC || - c >= 0x00210A && c <= 0x002113 || - c >= 0x002119 && c <= 0x00211D || - c >= 0x00212A && c <= 0x00212D || - c >= 0x00212F && c <= 0x002131 || - c >= 0x002133 && c <= 0x002139 || - c >= 0x00213D && c <= 0x00213F || - c >= 0x002145 && c <= 0x002149 || - c >= 0x002160 && c <= 0x002183 || - c >= 0x002336 && c <= 0x00237A || - c >= 0x00249C && c <= 0x0024E9 || - c >= 0x003005 && c <= 0x003007 || - c >= 0x003021 && c <= 0x003029 || - c >= 0x003031 && c <= 0x003035 || - c >= 0x003038 && c <= 0x00303C || - c >= 0x003041 && c <= 0x003096 || - c >= 0x00309D && c <= 0x00309F || - c >= 0x0030A1 && c <= 0x0030FA || - c >= 0x0030FC && c <= 0x0030FF || - c >= 0x003105 && c <= 0x00312C || - c >= 0x003131 && c <= 0x00318E || - c >= 0x003190 && c <= 0x0031B7 || - c >= 0x0031F0 && c <= 0x00321C || - c >= 0x003220 && c <= 0x003243 || - c >= 0x003260 && c <= 0x00327B || - c >= 0x00327F && c <= 0x0032B0 || - c >= 0x0032C0 && c <= 0x0032CB || - c >= 0x0032D0 && c <= 0x0032FE || - c >= 0x003300 && c <= 0x003376 || - c >= 0x00337B && c <= 0x0033DD || - c >= 0x0033E0 && c <= 0x0033FE || - c >= 0x003400 && c <= 0x004DB5 || - c >= 0x004E00 && c <= 0x009FA5 || - c >= 0x00A000 && c <= 0x00A48C || - c >= 0x00AC00 && c <= 0x00D7A3 || - c >= 0x00D800 && c <= 0x00FA2D || - c >= 0x00FA30 && c <= 0x00FA6A || - c >= 0x00FB00 && c <= 0x00FB06 || - c >= 0x00FB13 && c <= 0x00FB17 || - c >= 0x00FF21 && c <= 0x00FF3A || - c >= 0x00FF41 && c <= 0x00FF5A || - c >= 0x00FF66 && c <= 0x00FFBE || - c >= 0x00FFC2 && c <= 0x00FFC7 || - c >= 0x00FFCA && c <= 0x00FFCF || - c >= 0x00FFD2 && c <= 0x00FFD7 || - c >= 0x00FFDA && c <= 0x00FFDC || - c >= 0x010300 && c <= 0x01031E || - c >= 0x010320 && c <= 0x010323 || - c >= 0x010330 && c <= 0x01034A || - c >= 0x010400 && c <= 0x010425 || - c >= 0x010428 && c <= 0x01044D || - c >= 0x01D000 && c <= 0x01D0F5 || - c >= 0x01D100 && c <= 0x01D126 || - c >= 0x01D12A && c <= 0x01D166 || - c >= 0x01D16A && c <= 0x01D172 || - c >= 0x01D183 && c <= 0x01D184 || - c >= 0x01D18C && c <= 0x01D1A9 || - c >= 0x01D1AE && c <= 0x01D1DD || - c >= 0x01D400 && c <= 0x01D454 || - c >= 0x01D456 && c <= 0x01D49C || - c >= 0x01D49E && c <= 0x01D49F || - c >= 0x01D4A5 && c <= 0x01D4A6 || - c >= 0x01D4A9 && c <= 0x01D4AC || - c >= 0x01D4AE && c <= 0x01D4B9 || - c >= 0x01D4BD && c <= 0x01D4C0 || - c >= 0x01D4C2 && c <= 0x01D4C3 || - c >= 0x01D4C5 && c <= 0x01D505 || - c >= 0x01D507 && c <= 0x01D50A || - c >= 0x01D50D && c <= 0x01D514 || - c >= 0x01D516 && c <= 0x01D51C || - c >= 0x01D51E && c <= 0x01D539 || - c >= 0x01D53B && c <= 0x01D53E || - c >= 0x01D540 && c <= 0x01D544 || - c >= 0x01D54A && c <= 0x01D550 || - c >= 0x01D552 && c <= 0x01D6A3 || - c >= 0x01D6A8 && c <= 0x01D7C9 || - c >= 0x020000 && c <= 0x02A6D6 || - c >= 0x02F800 && c <= 0x02FA1D || - c >= 0x0F0000 && c <= 0x0FFFFD || - c >= 0x100000 && c <= 0x10FFFD || - c == 0x0000AA || c == 0x0000B5 || - c == 0x0000BA || c == 0x0002EE || - c == 0x00037A || c == 0x000386 || - c == 0x00038C || c == 0x000589 || - c == 0x000903 || c == 0x000950 || - c == 0x0009B2 || c == 0x0009D7 || - c == 0x000A5E || c == 0x000A83 || - c == 0x000A8D || c == 0x000AC9 || - c == 0x000AD0 || c == 0x000AE0 || - c == 0x000B40 || c == 0x000B57 || - c == 0x000B83 || c == 0x000B9C || - c == 0x000BD7 || c == 0x000CBE || - c == 0x000CDE || c == 0x000D57 || - c == 0x000DBD || c == 0x000E84 || - c == 0x000E8A || c == 0x000E8D || - c == 0x000EA5 || c == 0x000EA7 || - c == 0x000EBD || c == 0x000EC6 || - c == 0x000F36 || c == 0x000F38 || - c == 0x000F7F || c == 0x000F85 || - c == 0x000FCF || c == 0x00102C || - c == 0x001031 || c == 0x001038 || - c == 0x0010FB || c == 0x001248 || - c == 0x001258 || c == 0x001288 || - c == 0x0012B0 || c == 0x0012C0 || - c == 0x001310 || c == 0x0017DC || - c == 0x001F59 || c == 0x001F5B || - c == 0x001F5D || c == 0x001FBE || - c == 0x00200E || c == 0x002071 || - c == 0x00207F || c == 0x002102 || - c == 0x002107 || c == 0x002115 || - c == 0x002124 || c == 0x002126 || - c == 0x002128 || c == 0x002395 || - c == 0x01D4A2 || c == 0x01D4BB || - c == 0x01D546; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Helpers/CharNormalizer.cs b/NppMarkdownPanel/Markdig/Helpers/CharNormalizer.cs deleted file mode 100644 index 4df206c..0000000 --- a/NppMarkdownPanel/Markdig/Helpers/CharNormalizer.cs +++ /dev/null @@ -1,1304 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.Collections.Generic; - -namespace Markdig.Helpers -{ - /// - /// Class used to simplify a unicode char to a simple ASCII string - /// - public static class CharNormalizer - { - private static readonly Dictionary CodeToAscii; - - /// - /// Converts a unicode char to a simple ASCII string. - /// - /// The input char. - /// The simple ASCII string or null if the char itself cannot be simplified - public static string ConvertToAscii(char c) - { - string str; - return CodeToAscii.TryGetValue(c, out str) ? str : null; - } - - static CharNormalizer() - { - // This table was generated by the app UnicodeNormDApp - CodeToAscii = new Dictionary(1269) - { - {'Ḋ', "D"}, - {'Ḍ', "D"}, - {'È', "E"}, - {'Ē', "E"}, - {'Ḕ', "E"}, - {'ª', "a"}, - {'²', "2"}, - {'³', "3"}, - {'¹', "1"}, - {'º', "o"}, - {'¼', "14"}, - {'½', "12"}, - {'¾', "34"}, - {'À', "A"}, - {'Á', "A"}, - {'Â', "A"}, - {'Ã', "A"}, - {'Ä', "A"}, - {'Å', "A"}, - {'Ç', "C"}, - {'É', "E"}, - {'Ê', "E"}, - {'Ë', "E"}, - {'Ì', "I"}, - {'Í', "I"}, - {'Î', "I"}, - {'Ï', "I"}, - {'Ñ', "N"}, - {'Ò', "O"}, - {'Ó', "O"}, - {'Ô', "O"}, - {'Õ', "O"}, - {'Ö', "O"}, - {'Ù', "U"}, - {'Ú', "U"}, - {'Û', "U"}, - {'Ü', "U"}, - {'Ý', "Y"}, - {'à', "a"}, - {'á', "a"}, - {'â', "a"}, - {'ã', "a"}, - {'ä', "a"}, - {'å', "a"}, - {'ç', "c"}, - {'è', "e"}, - {'é', "e"}, - {'ê', "e"}, - {'ë', "e"}, - {'ì', "i"}, - {'í', "i"}, - {'î', "i"}, - {'ï', "i"}, - {'ñ', "n"}, - {'ò', "o"}, - {'ó', "o"}, - {'ô', "o"}, - {'õ', "o"}, - {'ö', "o"}, - {'ù', "u"}, - {'ú', "u"}, - {'û', "u"}, - {'ü', "u"}, - {'ý', "y"}, - {'ÿ', "y"}, - {'Ā', "A"}, - {'ā', "a"}, - {'Ă', "A"}, - {'ă', "a"}, - {'Ą', "A"}, - {'ą', "a"}, - {'Ć', "C"}, - {'ć', "c"}, - {'Ĉ', "C"}, - {'ĉ', "c"}, - {'Ċ', "C"}, - {'ċ', "c"}, - {'Č', "C"}, - {'č', "c"}, - {'Ď', "D"}, - {'ď', "d"}, - {'ē', "e"}, - {'Ĕ', "E"}, - {'ĕ', "e"}, - {'Ė', "E"}, - {'ė', "e"}, - {'Ę', "E"}, - {'ę', "e"}, - {'Ě', "E"}, - {'ě', "e"}, - {'Ĝ', "G"}, - {'ĝ', "g"}, - {'Ğ', "G"}, - {'ğ', "g"}, - {'Ġ', "G"}, - {'ġ', "g"}, - {'Ģ', "G"}, - {'ģ', "g"}, - {'Ĥ', "H"}, - {'ĥ', "h"}, - {'Ĩ', "I"}, - {'ĩ', "i"}, - {'Ī', "I"}, - {'ī', "i"}, - {'Ĭ', "I"}, - {'ĭ', "i"}, - {'Į', "I"}, - {'į', "i"}, - {'İ', "I"}, - {'IJ', "IJ"}, - {'ij', "ij"}, - {'Ĵ', "J"}, - {'ĵ', "j"}, - {'Ķ', "K"}, - {'ķ', "k"}, - {'Ĺ', "L"}, - {'ĺ', "l"}, - {'Ļ', "L"}, - {'ļ', "l"}, - {'Ľ', "L"}, - {'ľ', "l"}, - {'Ŀ', "L"}, - {'ŀ', "l"}, - {'Ń', "N"}, - {'ń', "n"}, - {'Ņ', "N"}, - {'ņ', "n"}, - {'Ň', "N"}, - {'ň', "n"}, - {'ʼn', "n"}, - {'Ō', "O"}, - {'ō', "o"}, - {'Ŏ', "O"}, - {'ŏ', "o"}, - {'Ő', "O"}, - {'ő', "o"}, - {'Ŕ', "R"}, - {'ŕ', "r"}, - {'Ŗ', "R"}, - {'ŗ', "r"}, - {'Ř', "R"}, - {'ř', "r"}, - {'Ś', "S"}, - {'ś', "s"}, - {'Ŝ', "S"}, - {'ŝ', "s"}, - {'Ş', "S"}, - {'ş', "s"}, - {'Š', "S"}, - {'š', "s"}, - {'Ţ', "T"}, - {'ţ', "t"}, - {'Ť', "T"}, - {'ť', "t"}, - {'Ũ', "U"}, - {'ũ', "u"}, - {'Ū', "U"}, - {'ū', "u"}, - {'Ŭ', "U"}, - {'ŭ', "u"}, - {'Ů', "U"}, - {'ů', "u"}, - {'Ű', "U"}, - {'ű', "u"}, - {'Ų', "U"}, - {'ų', "u"}, - {'Ŵ', "W"}, - {'ŵ', "w"}, - {'Ŷ', "Y"}, - {'ŷ', "y"}, - {'Ÿ', "Y"}, - {'Ź', "Z"}, - {'ź', "z"}, - {'Ż', "Z"}, - {'ż', "z"}, - {'Ž', "Z"}, - {'ž', "z"}, - {'ſ', "s"}, - {'Ơ', "O"}, - {'ơ', "o"}, - {'Ư', "U"}, - {'ư', "u"}, - {'DŽ', "DZ"}, - {'Dž', "Dz"}, - {'dž', "dz"}, - {'LJ', "LJ"}, - {'Lj', "Lj"}, - {'lj', "lj"}, - {'NJ', "NJ"}, - {'Nj', "Nj"}, - {'nj', "nj"}, - {'Ǎ', "A"}, - {'ǎ', "a"}, - {'Ǐ', "I"}, - {'ǐ', "i"}, - {'Ǒ', "O"}, - {'ǒ', "o"}, - {'Ǔ', "U"}, - {'ǔ', "u"}, - {'Ǖ', "U"}, - {'ǖ', "u"}, - {'Ǘ', "U"}, - {'ǘ', "u"}, - {'Ǚ', "U"}, - {'ǚ', "u"}, - {'Ǜ', "U"}, - {'ǜ', "u"}, - {'Ǟ', "A"}, - {'ǟ', "a"}, - {'Ǡ', "A"}, - {'ǡ', "a"}, - {'Ǧ', "G"}, - {'ǧ', "g"}, - {'Ǩ', "K"}, - {'ǩ', "k"}, - {'Ǫ', "O"}, - {'ǫ', "o"}, - {'Ǭ', "O"}, - {'ǭ', "o"}, - {'ǰ', "j"}, - {'DZ', "DZ"}, - {'Dz', "Dz"}, - {'dz', "dz"}, - {'Ǵ', "G"}, - {'ǵ', "g"}, - {'Ǹ', "N"}, - {'ǹ', "n"}, - {'Ǻ', "A"}, - {'ǻ', "a"}, - {'Ȁ', "A"}, - {'ȁ', "a"}, - {'Ȃ', "A"}, - {'ȃ', "a"}, - {'Ȅ', "E"}, - {'ȅ', "e"}, - {'Ȇ', "E"}, - {'ȇ', "e"}, - {'Ȉ', "I"}, - {'ȉ', "i"}, - {'Ȋ', "I"}, - {'ȋ', "i"}, - {'Ȍ', "O"}, - {'ȍ', "o"}, - {'Ȏ', "O"}, - {'ȏ', "o"}, - {'Ȑ', "R"}, - {'ȑ', "r"}, - {'Ȓ', "R"}, - {'ȓ', "r"}, - {'Ȕ', "U"}, - {'ȕ', "u"}, - {'Ȗ', "U"}, - {'ȗ', "u"}, - {'Ș', "S"}, - {'ș', "s"}, - {'Ț', "T"}, - {'ț', "t"}, - {'Ȟ', "H"}, - {'ȟ', "h"}, - {'Ȧ', "A"}, - {'ȧ', "a"}, - {'Ȩ', "E"}, - {'ȩ', "e"}, - {'Ȫ', "O"}, - {'ȫ', "o"}, - {'Ȭ', "O"}, - {'ȭ', "o"}, - {'Ȯ', "O"}, - {'ȯ', "o"}, - {'Ȱ', "O"}, - {'ȱ', "o"}, - {'Ȳ', "Y"}, - {'ȳ', "y"}, - {'ʰ', "h"}, - {'ʲ', "j"}, - {'ʳ', "r"}, - {'ʷ', "w"}, - {'ʸ', "y"}, - {'ˡ', "l"}, - {'ˢ', "s"}, - {'ˣ', "x"}, - {';', ";"}, - {'ᴬ', "A"}, - {'ᴮ', "B"}, - {'ᴰ', "D"}, - {'ᴱ', "E"}, - {'ᴳ', "G"}, - {'ᴴ', "H"}, - {'ᴵ', "I"}, - {'ᴶ', "J"}, - {'ᴷ', "K"}, - {'ᴸ', "L"}, - {'ᴹ', "M"}, - {'ᴺ', "N"}, - {'ᴼ', "O"}, - {'ᴾ', "P"}, - {'ᴿ', "R"}, - {'ᵀ', "T"}, - {'ᵁ', "U"}, - {'ᵂ', "W"}, - {'ᵃ', "a"}, - {'ᵇ', "b"}, - {'ᵈ', "d"}, - {'ᵉ', "e"}, - {'ᵍ', "g"}, - {'ᵏ', "k"}, - {'ᵐ', "m"}, - {'ᵒ', "o"}, - {'ᵖ', "p"}, - {'ᵗ', "t"}, - {'ᵘ', "u"}, - {'ᵛ', "v"}, - {'ᵢ', "i"}, - {'ᵣ', "r"}, - {'ᵤ', "u"}, - {'ᵥ', "v"}, - {'ᶜ', "c"}, - {'ᶠ', "f"}, - {'ᶻ', "z"}, - {'Ḁ', "A"}, - {'ḁ', "a"}, - {'Ḃ', "B"}, - {'ḃ', "b"}, - {'Ḅ', "B"}, - {'ḅ', "b"}, - {'Ḇ', "B"}, - {'ḇ', "b"}, - {'Ḉ', "C"}, - {'ḉ', "c"}, - {'ḋ', "d"}, - {'ḍ', "d"}, - {'Ḏ', "D"}, - {'ḏ', "d"}, - {'Ḑ', "D"}, - {'ḑ', "d"}, - {'Ḓ', "D"}, - {'ḓ', "d"}, - {'ḕ', "e"}, - {'Ḗ', "E"}, - {'ḗ', "e"}, - {'Ḙ', "E"}, - {'ḙ', "e"}, - {'Ḛ', "E"}, - {'ḛ', "e"}, - {'Ḝ', "E"}, - {'ḝ', "e"}, - {'Ḟ', "F"}, - {'ḟ', "f"}, - {'Ḡ', "G"}, - {'ḡ', "g"}, - {'Ḣ', "H"}, - {'ḣ', "h"}, - {'Ḥ', "H"}, - {'ḥ', "h"}, - {'Ḧ', "H"}, - {'ḧ', "h"}, - {'Ḩ', "H"}, - {'ḩ', "h"}, - {'Ḫ', "H"}, - {'ḫ', "h"}, - {'Ḭ', "I"}, - {'ḭ', "i"}, - {'Ḯ', "I"}, - {'ḯ', "i"}, - {'Ḱ', "K"}, - {'ḱ', "k"}, - {'Ḳ', "K"}, - {'ḳ', "k"}, - {'Ḵ', "K"}, - {'ḵ', "k"}, - {'Ḷ', "L"}, - {'ḷ', "l"}, - {'Ḹ', "L"}, - {'ḹ', "l"}, - {'Ḻ', "L"}, - {'ḻ', "l"}, - {'Ḽ', "L"}, - {'ḽ', "l"}, - {'Ḿ', "M"}, - {'ḿ', "m"}, - {'Ṁ', "M"}, - {'ṁ', "m"}, - {'Ṃ', "M"}, - {'ṃ', "m"}, - {'Ṅ', "N"}, - {'ṅ', "n"}, - {'Ṇ', "N"}, - {'ṇ', "n"}, - {'Ṉ', "N"}, - {'ṉ', "n"}, - {'Ṋ', "N"}, - {'ṋ', "n"}, - {'Ṍ', "O"}, - {'ṍ', "o"}, - {'Ṏ', "O"}, - {'ṏ', "o"}, - {'Ṑ', "O"}, - {'ṑ', "o"}, - {'Ṓ', "O"}, - {'ṓ', "o"}, - {'Ṕ', "P"}, - {'ṕ', "p"}, - {'Ṗ', "P"}, - {'ṗ', "p"}, - {'Ṙ', "R"}, - {'ṙ', "r"}, - {'Ṛ', "R"}, - {'ṛ', "r"}, - {'Ṝ', "R"}, - {'ṝ', "r"}, - {'Ṟ', "R"}, - {'ṟ', "r"}, - {'Ṡ', "S"}, - {'ṡ', "s"}, - {'Ṣ', "S"}, - {'ṣ', "s"}, - {'Ṥ', "S"}, - {'ṥ', "s"}, - {'Ṧ', "S"}, - {'ṧ', "s"}, - {'Ṩ', "S"}, - {'ṩ', "s"}, - {'Ṫ', "T"}, - {'ṫ', "t"}, - {'Ṭ', "T"}, - {'ṭ', "t"}, - {'Ṯ', "T"}, - {'ṯ', "t"}, - {'Ṱ', "T"}, - {'ṱ', "t"}, - {'Ṳ', "U"}, - {'ṳ', "u"}, - {'Ṵ', "U"}, - {'ṵ', "u"}, - {'Ṷ', "U"}, - {'ṷ', "u"}, - {'Ṹ', "U"}, - {'ṹ', "u"}, - {'Ṻ', "U"}, - {'ṻ', "u"}, - {'Ṽ', "V"}, - {'ṽ', "v"}, - {'Ṿ', "V"}, - {'ṿ', "v"}, - {'Ẁ', "W"}, - {'ẁ', "w"}, - {'Ẃ', "W"}, - {'ẃ', "w"}, - {'Ẅ', "W"}, - {'ẅ', "w"}, - {'Ẇ', "W"}, - {'ẇ', "w"}, - {'Ẉ', "W"}, - {'ẉ', "w"}, - {'Ẋ', "X"}, - {'ẋ', "x"}, - {'Ẍ', "X"}, - {'ẍ', "x"}, - {'Ẏ', "Y"}, - {'ẏ', "y"}, - {'Ẑ', "Z"}, - {'ẑ', "z"}, - {'Ẓ', "Z"}, - {'ẓ', "z"}, - {'Ẕ', "Z"}, - {'ẕ', "z"}, - {'ẖ', "h"}, - {'ẗ', "t"}, - {'ẘ', "w"}, - {'ẙ', "y"}, - {'ẚ', "a"}, - {'ẛ', "s"}, - {'Ạ', "A"}, - {'ạ', "a"}, - {'Ả', "A"}, - {'ả', "a"}, - {'Ấ', "A"}, - {'ấ', "a"}, - {'Ầ', "A"}, - {'ầ', "a"}, - {'Ẩ', "A"}, - {'ẩ', "a"}, - {'Ẫ', "A"}, - {'ẫ', "a"}, - {'Ậ', "A"}, - {'ậ', "a"}, - {'Ắ', "A"}, - {'ắ', "a"}, - {'Ằ', "A"}, - {'ằ', "a"}, - {'Ẳ', "A"}, - {'ẳ', "a"}, - {'Ẵ', "A"}, - {'ẵ', "a"}, - {'Ặ', "A"}, - {'ặ', "a"}, - {'Ẹ', "E"}, - {'ẹ', "e"}, - {'Ẻ', "E"}, - {'ẻ', "e"}, - {'Ẽ', "E"}, - {'ẽ', "e"}, - {'Ế', "E"}, - {'ế', "e"}, - {'Ề', "E"}, - {'ề', "e"}, - {'Ể', "E"}, - {'ể', "e"}, - {'Ễ', "E"}, - {'ễ', "e"}, - {'Ệ', "E"}, - {'ệ', "e"}, - {'Ỉ', "I"}, - {'ỉ', "i"}, - {'Ị', "I"}, - {'ị', "i"}, - {'Ọ', "O"}, - {'ọ', "o"}, - {'Ỏ', "O"}, - {'ỏ', "o"}, - {'Ố', "O"}, - {'ố', "o"}, - {'Ồ', "O"}, - {'ồ', "o"}, - {'Ổ', "O"}, - {'ổ', "o"}, - {'Ỗ', "O"}, - {'ỗ', "o"}, - {'Ộ', "O"}, - {'ộ', "o"}, - {'Ớ', "O"}, - {'ớ', "o"}, - {'Ờ', "O"}, - {'ờ', "o"}, - {'Ở', "O"}, - {'ở', "o"}, - {'Ỡ', "O"}, - {'ỡ', "o"}, - {'Ợ', "O"}, - {'ợ', "o"}, - {'Ụ', "U"}, - {'ụ', "u"}, - {'Ủ', "U"}, - {'ủ', "u"}, - {'Ứ', "U"}, - {'ứ', "u"}, - {'Ừ', "U"}, - {'ừ', "u"}, - {'Ử', "U"}, - {'ử', "u"}, - {'Ữ', "U"}, - {'ữ', "u"}, - {'Ự', "U"}, - {'ự', "u"}, - {'Ỳ', "Y"}, - {'ỳ', "y"}, - {'Ỵ', "Y"}, - {'ỵ', "y"}, - {'Ỷ', "Y"}, - {'ỷ', "y"}, - {'Ỹ', "Y"}, - {'ỹ', "y"}, - {'`', "`"}, - {'․', "."}, - {'‥', ".."}, - {'…', "..."}, - {'‼', "!!"}, - {'⁇', "??"}, - {'⁈', "?!"}, - {'⁉', "!?"}, - {'⁰', "0"}, - {'ⁱ', "i"}, - {'⁴', "4"}, - {'⁵', "5"}, - {'⁶', "6"}, - {'⁷', "7"}, - {'⁸', "8"}, - {'⁹', "9"}, - {'⁺', "+"}, - {'⁼', "="}, - {'⁽', "("}, - {'⁾', ")"}, - {'ⁿ', "n"}, - {'₀', "0"}, - {'₁', "1"}, - {'₂', "2"}, - {'₃', "3"}, - {'₄', "4"}, - {'₅', "5"}, - {'₆', "6"}, - {'₇', "7"}, - {'₈', "8"}, - {'₉', "9"}, - {'₊', "+"}, - {'₌', "="}, - {'₍', "("}, - {'₎', ")"}, - {'ₐ', "a"}, - {'ₑ', "e"}, - {'ₒ', "o"}, - {'ₓ', "x"}, - {'ₕ', "h"}, - {'ₖ', "k"}, - {'ₗ', "l"}, - {'ₘ', "m"}, - {'ₙ', "n"}, - {'ₚ', "p"}, - {'ₛ', "s"}, - {'ₜ', "t"}, - {'₨', "Rs"}, - {'℀', "a/c"}, - {'℁', "a/s"}, - {'ℂ', "C"}, - {'℃', "C"}, - {'℅', "c/o"}, - {'℆', "c/u"}, - {'℉', "F"}, - {'ℊ', "g"}, - {'ℋ', "H"}, - {'ℌ', "H"}, - {'ℍ', "H"}, - {'ℎ', "h"}, - {'ℐ', "I"}, - {'ℑ', "I"}, - {'ℒ', "L"}, - {'ℓ', "l"}, - {'ℕ', "N"}, - {'№', "No"}, - {'ℙ', "P"}, - {'ℚ', "Q"}, - {'ℛ', "R"}, - {'ℜ', "R"}, - {'ℝ', "R"}, - {'℠', "SM"}, - {'℡', "TEL"}, - {'™', "TM"}, - {'ℤ', "Z"}, - {'ℨ', "Z"}, - {'K', "K"}, - {'Å', "A"}, - {'ℬ', "B"}, - {'ℭ', "C"}, - {'ℯ', "e"}, - {'ℰ', "E"}, - {'ℱ', "F"}, - {'ℳ', "M"}, - {'ℴ', "o"}, - {'ℹ', "i"}, - {'℻', "FAX"}, - {'ⅅ', "D"}, - {'ⅆ', "d"}, - {'ⅇ', "e"}, - {'ⅈ', "i"}, - {'ⅉ', "j"}, - {'⅐', "17"}, - {'⅑', "19"}, - {'⅒', "110"}, - {'⅓', "13"}, - {'⅔', "23"}, - {'⅕', "15"}, - {'⅖', "25"}, - {'⅗', "35"}, - {'⅘', "45"}, - {'⅙', "16"}, - {'⅚', "56"}, - {'⅛', "18"}, - {'⅜', "38"}, - {'⅝', "58"}, - {'⅞', "78"}, - {'⅟', "1"}, - {'Ⅰ', "I"}, - {'Ⅱ', "II"}, - {'Ⅲ', "III"}, - {'Ⅳ', "IV"}, - {'Ⅴ', "V"}, - {'Ⅵ', "VI"}, - {'Ⅶ', "VII"}, - {'Ⅷ', "VIII"}, - {'Ⅸ', "IX"}, - {'Ⅹ', "X"}, - {'Ⅺ', "XI"}, - {'Ⅻ', "XII"}, - {'Ⅼ', "L"}, - {'Ⅽ', "C"}, - {'Ⅾ', "D"}, - {'Ⅿ', "M"}, - {'ⅰ', "i"}, - {'ⅱ', "ii"}, - {'ⅲ', "iii"}, - {'ⅳ', "iv"}, - {'ⅴ', "v"}, - {'ⅵ', "vi"}, - {'ⅶ', "vii"}, - {'ⅷ', "viii"}, - {'ⅸ', "ix"}, - {'ⅹ', "x"}, - {'ⅺ', "xi"}, - {'ⅻ', "xii"}, - {'ⅼ', "l"}, - {'ⅽ', "c"}, - {'ⅾ', "d"}, - {'ⅿ', "m"}, - {'↉', "03"}, - {'≠', "="}, - {'≮', "<"}, - {'≯', ">"}, - {'①', "1"}, - {'②', "2"}, - {'③', "3"}, - {'④', "4"}, - {'⑤', "5"}, - {'⑥', "6"}, - {'⑦', "7"}, - {'⑧', "8"}, - {'⑨', "9"}, - {'⑩', "10"}, - {'⑪', "11"}, - {'⑫', "12"}, - {'⑬', "13"}, - {'⑭', "14"}, - {'⑮', "15"}, - {'⑯', "16"}, - {'⑰', "17"}, - {'⑱', "18"}, - {'⑲', "19"}, - {'⑳', "20"}, - {'⑴', "(1)"}, - {'⑵', "(2)"}, - {'⑶', "(3)"}, - {'⑷', "(4)"}, - {'⑸', "(5)"}, - {'⑹', "(6)"}, - {'⑺', "(7)"}, - {'⑻', "(8)"}, - {'⑼', "(9)"}, - {'⑽', "(10)"}, - {'⑾', "(11)"}, - {'⑿', "(12)"}, - {'⒀', "(13)"}, - {'⒁', "(14)"}, - {'⒂', "(15)"}, - {'⒃', "(16)"}, - {'⒄', "(17)"}, - {'⒅', "(18)"}, - {'⒆', "(19)"}, - {'⒇', "(20)"}, - {'⒈', "1."}, - {'⒉', "2."}, - {'⒊', "3."}, - {'⒋', "4."}, - {'⒌', "5."}, - {'⒍', "6."}, - {'⒎', "7."}, - {'⒏', "8."}, - {'⒐', "9."}, - {'⒑', "10."}, - {'⒒', "11."}, - {'⒓', "12."}, - {'⒔', "13."}, - {'⒕', "14."}, - {'⒖', "15."}, - {'⒗', "16."}, - {'⒘', "17."}, - {'⒙', "18."}, - {'⒚', "19."}, - {'⒛', "20."}, - {'⒜', "(a)"}, - {'⒝', "(b)"}, - {'⒞', "(c)"}, - {'⒟', "(d)"}, - {'⒠', "(e)"}, - {'⒡', "(f)"}, - {'⒢', "(g)"}, - {'⒣', "(h)"}, - {'⒤', "(i)"}, - {'⒥', "(j)"}, - {'⒦', "(k)"}, - {'⒧', "(l)"}, - {'⒨', "(m)"}, - {'⒩', "(n)"}, - {'⒪', "(o)"}, - {'⒫', "(p)"}, - {'⒬', "(q)"}, - {'⒭', "(r)"}, - {'⒮', "(s)"}, - {'⒯', "(t)"}, - {'⒰', "(u)"}, - {'⒱', "(v)"}, - {'⒲', "(w)"}, - {'⒳', "(x)"}, - {'⒴', "(y)"}, - {'⒵', "(z)"}, - {'Ⓐ', "A"}, - {'Ⓑ', "B"}, - {'Ⓒ', "C"}, - {'Ⓓ', "D"}, - {'Ⓔ', "E"}, - {'Ⓕ', "F"}, - {'Ⓖ', "G"}, - {'Ⓗ', "H"}, - {'Ⓘ', "I"}, - {'Ⓙ', "J"}, - {'Ⓚ', "K"}, - {'Ⓛ', "L"}, - {'Ⓜ', "M"}, - {'Ⓝ', "N"}, - {'Ⓞ', "O"}, - {'Ⓟ', "P"}, - {'Ⓠ', "Q"}, - {'Ⓡ', "R"}, - {'Ⓢ', "S"}, - {'Ⓣ', "T"}, - {'Ⓤ', "U"}, - {'Ⓥ', "V"}, - {'Ⓦ', "W"}, - {'Ⓧ', "X"}, - {'Ⓨ', "Y"}, - {'Ⓩ', "Z"}, - {'ⓐ', "a"}, - {'ⓑ', "b"}, - {'ⓒ', "c"}, - {'ⓓ', "d"}, - {'ⓔ', "e"}, - {'ⓕ', "f"}, - {'ⓖ', "g"}, - {'ⓗ', "h"}, - {'ⓘ', "i"}, - {'ⓙ', "j"}, - {'ⓚ', "k"}, - {'ⓛ', "l"}, - {'ⓜ', "m"}, - {'ⓝ', "n"}, - {'ⓞ', "o"}, - {'ⓟ', "p"}, - {'ⓠ', "q"}, - {'ⓡ', "r"}, - {'ⓢ', "s"}, - {'ⓣ', "t"}, - {'ⓤ', "u"}, - {'ⓥ', "v"}, - {'ⓦ', "w"}, - {'ⓧ', "x"}, - {'ⓨ', "y"}, - {'ⓩ', "z"}, - {'⓪', "0"}, - {'⩴', "::="}, - {'⩵', "=="}, - {'⩶', "==="}, - {'ⱼ', "j"}, - {'ⱽ', "V"}, - {'㈀', "()"}, - {'㈁', "()"}, - {'㈂', "()"}, - {'㈃', "()"}, - {'㈄', "()"}, - {'㈅', "()"}, - {'㈆', "()"}, - {'㈇', "()"}, - {'㈈', "()"}, - {'㈉', "()"}, - {'㈊', "()"}, - {'㈋', "()"}, - {'㈌', "()"}, - {'㈍', "()"}, - {'㈎', "()"}, - {'㈏', "()"}, - {'㈐', "()"}, - {'㈑', "()"}, - {'㈒', "()"}, - {'㈓', "()"}, - {'㈔', "()"}, - {'㈕', "()"}, - {'㈖', "()"}, - {'㈗', "()"}, - {'㈘', "()"}, - {'㈙', "()"}, - {'㈚', "()"}, - {'㈛', "()"}, - {'㈜', "()"}, - {'㈝', "()"}, - {'㈞', "()"}, - {'㈠', "()"}, - {'㈡', "()"}, - {'㈢', "()"}, - {'㈣', "()"}, - {'㈤', "()"}, - {'㈥', "()"}, - {'㈦', "()"}, - {'㈧', "()"}, - {'㈨', "()"}, - {'㈩', "()"}, - {'㈪', "()"}, - {'㈫', "()"}, - {'㈬', "()"}, - {'㈭', "()"}, - {'㈮', "()"}, - {'㈯', "()"}, - {'㈰', "()"}, - {'㈱', "()"}, - {'㈲', "()"}, - {'㈳', "()"}, - {'㈴', "()"}, - {'㈵', "()"}, - {'㈶', "()"}, - {'㈷', "()"}, - {'㈸', "()"}, - {'㈹', "()"}, - {'㈺', "()"}, - {'㈻', "()"}, - {'㈼', "()"}, - {'㈽', "()"}, - {'㈾', "()"}, - {'㈿', "()"}, - {'㉀', "()"}, - {'㉁', "()"}, - {'㉂', "()"}, - {'㉃', "()"}, - {'㉐', "PTE"}, - {'㉑', "21"}, - {'㉒', "22"}, - {'㉓', "23"}, - {'㉔', "24"}, - {'㉕', "25"}, - {'㉖', "26"}, - {'㉗', "27"}, - {'㉘', "28"}, - {'㉙', "29"}, - {'㉚', "30"}, - {'㉛', "31"}, - {'㉜', "32"}, - {'㉝', "33"}, - {'㉞', "34"}, - {'㉟', "35"}, - {'㊱', "36"}, - {'㊲', "37"}, - {'㊳', "38"}, - {'㊴', "39"}, - {'㊵', "40"}, - {'㊶', "41"}, - {'㊷', "42"}, - {'㊸', "43"}, - {'㊹', "44"}, - {'㊺', "45"}, - {'㊻', "46"}, - {'㊼', "47"}, - {'㊽', "48"}, - {'㊾', "49"}, - {'㊿', "50"}, - {'㋀', "1"}, - {'㋁', "2"}, - {'㋂', "3"}, - {'㋃', "4"}, - {'㋄', "5"}, - {'㋅', "6"}, - {'㋆', "7"}, - {'㋇', "8"}, - {'㋈', "9"}, - {'㋉', "10"}, - {'㋊', "11"}, - {'㋋', "12"}, - {'㋌', "Hg"}, - {'㋍', "erg"}, - {'㋎', "eV"}, - {'㋏', "LTD"}, - {'㍘', "0"}, - {'㍙', "1"}, - {'㍚', "2"}, - {'㍛', "3"}, - {'㍜', "4"}, - {'㍝', "5"}, - {'㍞', "6"}, - {'㍟', "7"}, - {'㍠', "8"}, - {'㍡', "9"}, - {'㍢', "10"}, - {'㍣', "11"}, - {'㍤', "12"}, - {'㍥', "13"}, - {'㍦', "14"}, - {'㍧', "15"}, - {'㍨', "16"}, - {'㍩', "17"}, - {'㍪', "18"}, - {'㍫', "19"}, - {'㍬', "20"}, - {'㍭', "21"}, - {'㍮', "22"}, - {'㍯', "23"}, - {'㍰', "24"}, - {'㍱', "hPa"}, - {'㍲', "da"}, - {'㍳', "AU"}, - {'㍴', "bar"}, - {'㍵', "oV"}, - {'㍶', "pc"}, - {'㍷', "dm"}, - {'㍸', "dm2"}, - {'㍹', "dm3"}, - {'㍺', "IU"}, - {'㎀', "pA"}, - {'㎁', "nA"}, - {'㎂', "A"}, - {'㎃', "mA"}, - {'㎄', "kA"}, - {'㎅', "KB"}, - {'㎆', "MB"}, - {'㎇', "GB"}, - {'㎈', "cal"}, - {'㎉', "kcal"}, - {'㎊', "pF"}, - {'㎋', "nF"}, - {'㎌', "F"}, - {'㎍', "g"}, - {'㎎', "mg"}, - {'㎏', "kg"}, - {'㎐', "Hz"}, - {'㎑', "kHz"}, - {'㎒', "MHz"}, - {'㎓', "GHz"}, - {'㎔', "THz"}, - {'㎕', "l"}, - {'㎖', "ml"}, - {'㎗', "dl"}, - {'㎘', "kl"}, - {'㎙', "fm"}, - {'㎚', "nm"}, - {'㎛', "m"}, - {'㎜', "mm"}, - {'㎝', "cm"}, - {'㎞', "km"}, - {'㎟', "mm2"}, - {'㎠', "cm2"}, - {'㎡', "m2"}, - {'㎢', "km2"}, - {'㎣', "mm3"}, - {'㎤', "cm3"}, - {'㎥', "m3"}, - {'㎦', "km3"}, - {'㎧', "ms"}, - {'㎨', "ms2"}, - {'㎩', "Pa"}, - {'㎪', "kPa"}, - {'㎫', "MPa"}, - {'㎬', "GPa"}, - {'㎭', "rad"}, - {'㎮', "rads"}, - {'㎯', "rads2"}, - {'㎰', "ps"}, - {'㎱', "ns"}, - {'㎲', "s"}, - {'㎳', "ms"}, - {'㎴', "pV"}, - {'㎵', "nV"}, - {'㎶', "V"}, - {'㎷', "mV"}, - {'㎸', "kV"}, - {'㎹', "MV"}, - {'㎺', "pW"}, - {'㎻', "nW"}, - {'㎼', "W"}, - {'㎽', "mW"}, - {'㎾', "kW"}, - {'㎿', "MW"}, - {'㏀', "k"}, - {'㏁', "M"}, - {'㏂', "a.m."}, - {'㏃', "Bq"}, - {'㏄', "cc"}, - {'㏅', "cd"}, - {'㏆', "Ckg"}, - {'㏇', "Co."}, - {'㏈', "dB"}, - {'㏉', "Gy"}, - {'㏊', "ha"}, - {'㏋', "HP"}, - {'㏌', "in"}, - {'㏍', "KK"}, - {'㏎', "KM"}, - {'㏏', "kt"}, - {'㏐', "lm"}, - {'㏑', "ln"}, - {'㏒', "log"}, - {'㏓', "lx"}, - {'㏔', "mb"}, - {'㏕', "mil"}, - {'㏖', "mol"}, - {'㏗', "PH"}, - {'㏘', "p.m."}, - {'㏙', "PPM"}, - {'㏚', "PR"}, - {'㏛', "sr"}, - {'㏜', "Sv"}, - {'㏝', "Wb"}, - {'㏞', "Vm"}, - {'㏟', "Am"}, - {'㏠', "1"}, - {'㏡', "2"}, - {'㏢', "3"}, - {'㏣', "4"}, - {'㏤', "5"}, - {'㏥', "6"}, - {'㏦', "7"}, - {'㏧', "8"}, - {'㏨', "9"}, - {'㏩', "10"}, - {'㏪', "11"}, - {'㏫', "12"}, - {'㏬', "13"}, - {'㏭', "14"}, - {'㏮', "15"}, - {'㏯', "16"}, - {'㏰', "17"}, - {'㏱', "18"}, - {'㏲', "19"}, - {'㏳', "20"}, - {'㏴', "21"}, - {'㏵', "22"}, - {'㏶', "23"}, - {'㏷', "24"}, - {'㏸', "25"}, - {'㏹', "26"}, - {'㏺', "27"}, - {'㏻', "28"}, - {'㏼', "29"}, - {'㏽', "30"}, - {'㏾', "31"}, - {'㏿', "gal"}, - {'ff', "ff"}, - {'fi', "fi"}, - {'fl', "fl"}, - {'ffi', "ffi"}, - {'ffl', "ffl"}, - {'ſt', "st"}, - {'st', "st"}, - {'﬩', "+"}, - {'︐', ","}, - {'︓', ":"}, - {'︔', ";"}, - {'︕', "!"}, - {'︖', "?"}, - {'︙', "..."}, - {'︰', ".."}, - {'︳', "_"}, - {'︴', "_"}, - {'︵', "("}, - {'︶', ")"}, - {'︷', "{"}, - {'︸', "}"}, - {'﹇', "["}, - {'﹈', "]"}, - {'﹍', "_"}, - {'﹎', "_"}, - {'﹏', "_"}, - {'﹐', ","}, - {'﹒', "."}, - {'﹔', ";"}, - {'﹕', ":"}, - {'﹖', "?"}, - {'﹗', "!"}, - {'﹙', "("}, - {'﹚', ")"}, - {'﹛', "{"}, - {'﹜', "}"}, - {'﹟', "#"}, - {'﹠', "&"}, - {'﹡', "*"}, - {'﹢', "+"}, - {'﹣', "-"}, - {'﹤', "<"}, - {'﹥', ">"}, - {'﹦', "="}, - {'﹨', "\\"}, - {'﹩', "$"}, - {'﹪', "%"}, - {'﹫', "@"}, - {'!', "!"}, - {'"', "\""}, - {'#', "#"}, - {'$', "$"}, - {'%', "%"}, - {'&', "&"}, - {''', "'"}, - {'(', "("}, - {')', ")"}, - {'*', "*"}, - {'+', "+"}, - {',', ","}, - {'-', "-"}, - {'.', "."}, - {'/', "/"}, - {'0', "0"}, - {'1', "1"}, - {'2', "2"}, - {'3', "3"}, - {'4', "4"}, - {'5', "5"}, - {'6', "6"}, - {'7', "7"}, - {'8', "8"}, - {'9', "9"}, - {':', ":"}, - {';', ";"}, - {'<', "<"}, - {'=', "="}, - {'>', ">"}, - {'?', "?"}, - {'@', "@"}, - {'A', "A"}, - {'B', "B"}, - {'C', "C"}, - {'D', "D"}, - {'E', "E"}, - {'F', "F"}, - {'G', "G"}, - {'H', "H"}, - {'I', "I"}, - {'J', "J"}, - {'K', "K"}, - {'L', "L"}, - {'M', "M"}, - {'N', "N"}, - {'O', "O"}, - {'P', "P"}, - {'Q', "Q"}, - {'R', "R"}, - {'S', "S"}, - {'T', "T"}, - {'U', "U"}, - {'V', "V"}, - {'W', "W"}, - {'X', "X"}, - {'Y', "Y"}, - {'Z', "Z"}, - {'[', "["}, - {'\', "\\"}, - {']', "]"}, - {'^', "^"}, - {'_', "_"}, - {'`', "`"}, - {'a', "a"}, - {'b', "b"}, - {'c', "c"}, - {'d', "d"}, - {'e', "e"}, - {'f', "f"}, - {'g', "g"}, - {'h', "h"}, - {'i', "i"}, - {'j', "j"}, - {'k', "k"}, - {'l', "l"}, - {'m', "m"}, - {'n', "n"}, - {'o', "o"}, - {'p', "p"}, - {'q', "q"}, - {'r', "r"}, - {'s', "s"}, - {'t', "t"}, - {'u', "u"}, - {'v', "v"}, - {'w', "w"}, - {'x', "x"}, - {'y', "y"}, - {'z', "z"}, - {'{', "{"}, - {'|', "|"}, - {'}', "}"}, - {'~', "~"}, - }; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Helpers/CharacterMap.cs b/NppMarkdownPanel/Markdig/Helpers/CharacterMap.cs deleted file mode 100644 index b7a42ba..0000000 --- a/NppMarkdownPanel/Markdig/Helpers/CharacterMap.cs +++ /dev/null @@ -1,163 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.CompilerServices; - -namespace Markdig.Helpers -{ - /// - /// Allows to associate characters to a data structures and query efficiently for them. - /// - /// - public class CharacterMap where T : class - { - private readonly T[] asciiMap; - private readonly Dictionary nonAsciiMap; - private readonly bool[] isOpeningCharacter; - - /// - /// Initializes a new instance of the class. - /// - /// The states. - /// - public CharacterMap(IEnumerable> maps) - { - if (maps == null) throw new ArgumentNullException(nameof(maps)); - var charCounter = new Dictionary(); - int maxChar = 0; - - foreach (var map in maps) - { - var openingChar = map.Key; - - if (!charCounter.ContainsKey(openingChar)) - { - charCounter[openingChar] = 0; - } - charCounter[openingChar]++; - - if (openingChar < 127 && openingChar > maxChar) - { - maxChar = openingChar; - } - else if (openingChar >= 127 && nonAsciiMap == null) - { - // Initialize only if with have an actual non-ASCII opening character - nonAsciiMap = new Dictionary(); - } - } - OpeningCharacters = charCounter.Keys.ToArray(); - Array.Sort(OpeningCharacters); - - asciiMap = new T[maxChar + 1]; - isOpeningCharacter = new bool[maxChar + 1]; - - foreach (var state in maps) - { - var openingChar = state.Key; - T stateByChar; - if (openingChar < 127) - { - stateByChar = asciiMap[openingChar]; - - if (stateByChar == null) - { - asciiMap[openingChar] = state.Value; - } - isOpeningCharacter[openingChar] = true; - } - else - { - if (!nonAsciiMap.TryGetValue(openingChar, out stateByChar)) - { - nonAsciiMap[openingChar] = state.Value; - } - } - } - } - - /// - /// Gets all the opening characters defined. - /// - public char[] OpeningCharacters { get; } - - /// - /// Gets the list of parsers valid for the specified opening character. - /// - /// The opening character. - /// A list of parsers valid for the specified opening character or null if no parsers registered. - public T this[char openingChar] - { - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - get - { - T map = null; - if (openingChar < asciiMap.Length) - { - map = asciiMap[openingChar]; - } - else if (nonAsciiMap != null) - { - nonAsciiMap.TryGetValue(openingChar, out map); - } - return map; - } - } - - /// - /// Searches for an opening character from a registered parser in the specified string. - /// - /// The text. - /// The start. - /// The end. - /// Index position within the string of the first opening character found in the specified text; if not found, returns -1 - public int IndexOfOpeningCharacter(string text, int start, int end) - { - var maxChar = isOpeningCharacter.Length; -#if SUPPORT_UNSAFE - unsafe -#endif - { -#if SUPPORT_FIXED_STRING - fixed (char* pText = text) -#else - var pText = text; -#endif -#if SUPPORT_UNSAFE - fixed (bool* openingChars = isOpeningCharacter) -#else - var openingChars = isOpeningCharacter; -#endif - { - if (nonAsciiMap == null) - { - for (int i = start; i <= end; i++) - { - var c = pText[i]; - if (c < maxChar && openingChars[c]) - { - return i; - } - } - } - else - { - for (int i = start; i <= end; i++) - { - var c = pText[i]; - if ((c < maxChar && openingChars[c]) || nonAsciiMap.ContainsKey(c)) - { - return i; - } - } - } - } - } - return -1; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Helpers/CompactPrefixTree.cs b/NppMarkdownPanel/Markdig/Helpers/CompactPrefixTree.cs deleted file mode 100644 index 1e99773..0000000 --- a/NppMarkdownPanel/Markdig/Helpers/CompactPrefixTree.cs +++ /dev/null @@ -1,1221 +0,0 @@ -// Copyright (c) Miha Zupan. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics; -using System.Runtime.CompilerServices; - -/* - * Ported to Markdig from https://github.com/MihaZupan/SharpCollections - * - * If you encounter any problems related to this data structure, please cc @MihaZupan - * - * This data structure aims to use less memory than reference-based implementations. - * Please note the lack of a Remove method on this data structure - */ - -// Relies on NETCORE being set for selective use of Spans - -//namespace SharpCollections.Generic -namespace Markdig.Helpers -{ - /// - /// A compact insert-only key/value collection for fast prefix lookups - /// Something between a Trie and a full Radix tree, but stored linearly in memory - /// - /// The value associated with the key - internal class CompactPrefixTree -//#if !LEGACY -// : IReadOnlyDictionary, IReadOnlyList> -//#endif - { - /// - /// Used internally to control behavior of insertion - /// Copied from internals - /// - internal enum InsertionBehavior : byte - { - /// - /// The default insertion behavior. Does not overwrite or throw. - /// - None = 0, - - /// - /// Specifies that an existing entry with the same key should be overwritten if encountered. - /// - OverwriteExisting = 1, - - /// - /// Specifies that if an existing entry with the same key is encountered, an exception should be thrown. - /// - ThrowOnExisting = 2 - } - - [DebuggerDisplay("{Char}, Child: {ChildChar} at {ChildIndex}, Match: {MatchIndex}, Children: {Children?.Count ?? 0}")] - private struct Node - { - /// - /// The character this node represents, should never be 0 - /// - public char Char; - /// - /// Will be 0 if this is a leaf node - /// - public char ChildChar; - public int ChildIndex; - /// - /// Set to -1 if it does not point to a match - /// - public int MatchIndex; - /// - /// -1 if not present - /// - public int Children; - } - - private Node[] _tree; - private static readonly Node[] _emptyTree = new Node[0]; - - private KeyValuePair[] _matches; - private static readonly KeyValuePair[] _emptyMatches = new KeyValuePair[0]; - - private int _childrenIndex = 0; - private int[] _children = _emptyChildren; - private static readonly int[] _emptyChildren = new int[0]; - - #region Size and Capacity - - /// - /// Gets the number of nodes in the internal tree structure - /// You might be looking for - /// Exposing this might help in deducing more efficient initial parameters - /// - public int TreeSize { get; private set; } - /// - /// Gets or sets the capacity of the internal tree structure buffer - /// You might be looking for - /// - public int TreeCapacity - { - get - { - return _tree.Length; - } - set - { - if (value < TreeSize) - ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.value, ExceptionReason.SmallCapacity); - - if (value != TreeSize) - { - Node[] newTree = new Node[value]; - if (TreeSize > 0) - { - Array.Copy(_tree, 0, newTree, 0, TreeSize); - } - _tree = newTree; - } - } - } - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - private void EnsureTreeCapacity(int min) - { - if (_tree.Length < min) - { - EnsureTreeCapacityRare(min); - } - Debug.Assert(_tree.Length >= min); - } - [MethodImpl(MethodImplOptions.NoInlining)] - private void EnsureTreeCapacityRare(int min) - { - // Expansion logic as in System.Collections.Generic.List - Debug.Assert(min > _tree.Length); - int newCapacity = _tree.Length * 2; - if ((uint)min > int.MaxValue) newCapacity = int.MaxValue; - if (newCapacity < min) newCapacity = min; - TreeCapacity = newCapacity; - } - - /// - /// Gets the number of key/value pairs contained in the - /// - public int Count { get; private set; } - /// - /// Gets or sets the capacity of the internal key/value pair buffer - /// - public int Capacity - { - get - { - return _matches.Length; - } - set - { - if (value < Count) - ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.value, ExceptionReason.SmallCapacity); - - if (value != Count) - { - KeyValuePair[] newMatches = new KeyValuePair[value]; - if (Count > 0) - { - Array.Copy(_matches, 0, newMatches, 0, Count); - } - _matches = newMatches; - } - } - } - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - private void EnsureCapacity(int min) - { - // Expansion logic as in System.Collections.Generic.List - if (_matches.Length < min) - { - EnsureCapacityRare(min); - } - Debug.Assert(_matches.Length >= min); - } - [MethodImpl(MethodImplOptions.NoInlining)] - private void EnsureCapacityRare(int min) - { - // Expansion logic as in System.Collections.Generic.List - Debug.Assert(min > _matches.Length); - int newCapacity = _matches.Length * 2; - if ((uint)min > int.MaxValue) newCapacity = int.MaxValue; - if (newCapacity < min) newCapacity = min; - Capacity = newCapacity; - } - - /// - /// Gets the size of the children buffer in the internal tree structure - /// You might be looking for - /// Exposing this might help in deducing more efficient initial parameters - /// - public int ChildrenCount => _childrenIndex; - /// - /// Gets or sets the capacity of the internal children buffer - /// You might be looking for - /// - public int ChildrenCapacity - { - get - { - return _children.Length; - } - set - { - if (value < _childrenIndex) - ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.value, ExceptionReason.SmallCapacity); - - if (value != _childrenIndex) - { - int[] newChildren = new int[value]; - if (_childrenIndex > 0) - { - Array.Copy(_children, 0, newChildren, 0, _childrenIndex); - } - - // Set new odd indexes to -1 - for (int i = _childrenIndex + 1; i < newChildren.Length; i += 2) - newChildren[i] = -1; - - _children = newChildren; - } - } - } - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - private void EnsureChildrenCapacity(int min) - { - if (_children.Length < min) - { - EnsureChildrenCapacityRare(min); - } - Debug.Assert(_children.Length >= min); - } - [MethodImpl(MethodImplOptions.NoInlining)] - private void EnsureChildrenCapacityRare(int min) - { - // Expansion logic as in System.Collections.Generic.List - Debug.Assert(min > _children.Length); - Debug.Assert(_childrenIndex % 2 == 0); - int newCapacity = _children.Length * 2; - if ((uint)min > int.MaxValue) newCapacity = int.MaxValue; - if (newCapacity < min) newCapacity = min; - ChildrenCapacity = newCapacity; - } - - #endregion Size and Capacity - - #region RootChar - - // Inspired by Markdig's CharacterMap - - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - private bool TryGetRoot(char rootChar, out int rootNodeIndex) - { - if (rootChar < 128) - { - rootNodeIndex = _asciiRootMap[rootChar]; - return rootNodeIndex != -1; - } - - if (_unicodeRootMap != null) - { - return _unicodeRootMap.TryGetValue(rootChar, out rootNodeIndex); - } - - rootNodeIndex = -1; - return false; - } - private void SetRootChar(char rootChar) - { - if (rootChar < 128) - { - Debug.Assert(_asciiRootMap[rootChar] == -1); - _asciiRootMap[rootChar] = TreeSize; - } - else - { - if (_unicodeRootMap == null) - { - _unicodeRootMap = new Dictionary(); - } - _unicodeRootMap.Add(rootChar, TreeSize); - } - } - private readonly int[] _asciiRootMap = new int[128]; - private Dictionary _unicodeRootMap; - - #endregion RootChar - - private void Init(int matchCapacity, int treeCapacity, int childrenCapacity) - { - for (int i = 0; i < _asciiRootMap.Length; i++) - _asciiRootMap[i] = -1; - - _matches = matchCapacity == 0 ? _emptyMatches : new KeyValuePair[matchCapacity]; - _tree = treeCapacity == 0 ? _emptyTree : new Node[treeCapacity]; - EnsureChildrenCapacity(childrenCapacity); - } - - /// - /// Constructs a new with no initial prefixes - /// - public CompactPrefixTree(int matchCapacity = 0, int treeCapacity = 0, int childrenCapacity = 0) - { - Init(matchCapacity, treeCapacity, childrenCapacity); - } - /// - /// Constructs a new with the supplied matches - /// - /// Matches to initialize the with. For best lookup performance, this collection should be sorted. - public CompactPrefixTree(ICollection> input) - { - if (input == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.input); - - Init(input.Count, input.Count * 2, input.Count * 2); - - using (var e = input.GetEnumerator()) - { - for (int i = 0; i < input.Count; i++) - { - e.MoveNext(); - TryInsert(e.Current, InsertionBehavior.ThrowOnExisting); - } - } - } - - #region this[] accessors - - /// - /// Retrieves the key/value pair at the specified index (must be lower than ) - /// - /// Index of pair to get, must be lower than (the order is the same as the order in which the elements were added) - /// The key/value pair of the element at the specified index - public KeyValuePair this[int index] - { - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - get - { - if ((uint)index >= (uint)Count) ThrowHelper.ThrowIndexOutOfRangeException(); - return _matches[index]; - } - } - - /// - /// Gets or sets the value associated with the specified key - /// - /// The key of the value to get or set - /// The value of the element with the specified key - public TValue this[string key] - { - get - { - if (TryMatchExact(key, out KeyValuePair match)) - return match.Value; - throw new KeyNotFoundException(key); - } - set - { - var pair = new KeyValuePair(key, value); - bool modified = TryInsert(in pair, InsertionBehavior.OverwriteExisting); - Debug.Assert(modified); - } - } // Get, Set - -#if NETCORE - /// - /// Gets the value associated with the specified key - /// - /// The key of the value to get - /// The key/value pair of the element with the specified key - public KeyValuePair this[ReadOnlySpan key] - { - get - { - if (TryMatchExact(key, out KeyValuePair match)) - return match; - throw new KeyNotFoundException(key.ToString()); - } - } // Get only -#endif - - #endregion this[] accessors - - #region Add, TryAdd - - /// - /// Adds the specified key/value pair to the - /// - /// The key of the element to add - /// The value of the element to add - public void Add(string key, TValue value) - { - var pair = new KeyValuePair(key, value); - TryInsert(in pair, InsertionBehavior.ThrowOnExisting); - } - /// - /// Adds the specified key/value pair to the - /// - /// The key/value pair to add - public void Add(KeyValuePair pair) - => TryInsert(in pair, InsertionBehavior.ThrowOnExisting); - - /// - /// Tries to add the key/value pair to the if the key is not yet present - /// - /// The key of the element to add - /// The value of the element to add - /// True if the element was added, false otherwise - public bool TryAdd(string key, TValue value) - { - var pair = new KeyValuePair(key, value); - return TryInsert(in pair, InsertionBehavior.None); - } - /// - /// Tries to add the key/value pair to the if the key is not yet present - /// - /// The pair to add - /// True if the element was added, false otherwise - public bool TryAdd(KeyValuePair pair) - => TryInsert(in pair, InsertionBehavior.None); - - #endregion Add, TryAdd - - #region Insert internal - - private bool TryInsert(in KeyValuePair pair, InsertionBehavior behavior) - { - string key = pair.Key; - if (key == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key); - if (key.Length == 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.key, ExceptionReason.String_Empty); - Debug.Assert(!string.IsNullOrEmpty(key)); - - char rootChar = key[0]; - if (TryGetRoot(rootChar, out int rootNodeIndex)) - { - var tree = _tree; - ref Node node = ref tree[rootNodeIndex]; - for (int i = 1; i < key.Length; i++) - { - char c = key[i]; - - if (node.ChildChar == c) - { - node = ref tree[node.ChildIndex]; - continue; - } - - if (node.Children == -1) - { - // This could be a leaf node - if (node.ChildChar == 0) - { - // This is a leaf node - int previousMatchIndex = node.MatchIndex; - ref KeyValuePair previousMatch = ref _matches[previousMatchIndex]; - string previousKey = previousMatch.Key; - - // Find out for how long the two keys continue to share a prefix - int previousIndex = i; - int minLength = Math.Min(key.Length, previousKey.Length); - for (; i < minLength; i++) - { - // We haven't checked the i-th character of key so far - if (key[i] != previousKey[i]) break; - } - - if (i == minLength && key.Length == previousKey.Length) - { - // The two keys are of the same length and i has reached the length of the key => duplicate - Debug.Assert(i == key.Length && i == previousKey.Length); - Debug.Assert(key == previousKey); - goto HandleDuplicateKey; - } - - // Clear the match index on the current node as it's no longer a leaf node - node.MatchIndex = -1; - - // insert (i - previousIndex) intermediary nodes (could be 0) - int intermediaryNodesToInsert = i - previousIndex; - if (intermediaryNodesToInsert > 0) - { - node.ChildIndex = TreeSize; - node.ChildChar = key[previousIndex]; - EnsureTreeCapacity(TreeSize + intermediaryNodesToInsert); - tree = _tree; - for (int j = 0; j < intermediaryNodesToInsert - 1; j++) - { - tree[TreeSize + j] = new Node() - { - Char = previousKey[previousIndex + j], - ChildChar = previousKey[previousIndex + j + 1], - ChildIndex = TreeSize + j + 1, - MatchIndex = -1, - Children = -1 - }; - } - TreeSize += intermediaryNodesToInsert; - tree[TreeSize - 1] = new Node() - { - Char = previousKey[previousIndex + intermediaryNodesToInsert - 1], - MatchIndex = -1, - Children = -1 - }; - node = ref tree[TreeSize - 1]; - } - - node.ChildIndex = TreeSize; - - // Insert the pair - EnsureCapacity(Count + 1); - _matches[Count] = pair; - - // One of the strings could be a prefix of the other, in that case we're only inserting one leaf node - if (i == minLength) - { - Debug.Assert(key.Length != previousKey.Length); - if (previousKey.Length < key.Length) // If the input was sorted, this should be hit - { - Debug.Assert(key.StartsWith(previousKey)); - node.ChildChar = key[i]; - node.MatchIndex = previousMatchIndex; - EnsureTreeCapacity(TreeSize + 1); - _tree[TreeSize] = new Node() - { - Char = key[i], - MatchIndex = Count, - Children = -1 - }; - } - else // if key.Length < previousKey.Length - { - Debug.Assert(key.Length < previousKey.Length); - Debug.Assert(previousKey.StartsWith(key)); - node.ChildChar = previousKey[i]; - node.MatchIndex = Count; - EnsureTreeCapacity(TreeSize + 1); - _tree[TreeSize] = new Node() - { - Char = previousKey[i], - MatchIndex = previousMatchIndex, - Children = -1 - }; - } - Count++; - TreeSize++; - return true; - } - - // Insert two leaf nodes - Debug.Assert(node.Char != 0 && node.Char == previousKey[i - 1]); - Debug.Assert(node.MatchIndex == -1); - Debug.Assert(node.Children == -1); - - node.ChildChar = previousKey[i]; - node.Children = _childrenIndex; - - EnsureChildrenCapacity(_childrenIndex + 2); - _children[_childrenIndex] = TreeSize + 1; - _childrenIndex += 2; - - // Insert the two leaf nodes - EnsureTreeCapacity(TreeSize + 2); - _tree[TreeSize] = new Node() - { - Char = previousKey[i], - MatchIndex = previousMatchIndex, - Children = -1 - }; - _tree[TreeSize + 1] = new Node() - { - Char = key[i], - MatchIndex = Count, - Children = -1 - }; - - Count++; - TreeSize += 2; - return true; - } - else - { - // This node has a child char, therefore we either don't have a match attached or that match is simply a prefix of the current key - Debug.Assert(node.MatchIndex == -1 || key.StartsWith(_matches[node.MatchIndex].Key)); - - // Set this pair as the current node's first element in the Children list - node.Children = _childrenIndex; - EnsureChildrenCapacity(_childrenIndex + 2); - _children[_childrenIndex] = TreeSize; - _childrenIndex += 2; - - InsertLeafNode(in pair, c); - return true; - } - } - else - { - // Look for a child node with a matching Char in all of children - var children = _children; - int childrenIndex = node.Children; - int lastChildrenIndex = childrenIndex; - do - { - if ((uint)childrenIndex >= (uint)children.Length) - break; - node = ref _tree[children[childrenIndex]]; - if (node.Char == c) goto NextChar; - lastChildrenIndex = childrenIndex; - childrenIndex = children[childrenIndex + 1]; - } - while (true); - - // A child node was not found, add a new one to children - EnsureChildrenCapacity(_childrenIndex + 2); - _children[lastChildrenIndex + 1] = _childrenIndex; - _children[_childrenIndex] = TreeSize; - _childrenIndex += 2; - - InsertLeafNode(in pair, c); - return true; - } - - NextChar:; - } - - // We have found our final node, check if a match already claimed this node - if (node.MatchIndex != -1) - { - ref KeyValuePair previousMatch = ref _matches[node.MatchIndex]; - - // Either some other key is the leaf here, or the key is duplicated - if (previousMatch.Key.Length == key.Length) - { - Debug.Assert(previousMatch.Key == key); - goto HandleDuplicateKey; - } - else - { - // It's not a duplicate but shares key.Length characters, therefore it's longer - // This will never occur if the input was sorted - Debug.Assert(previousMatch.Key.Length > key.Length); - Debug.Assert(previousMatch.Key.StartsWith(key)); - Debug.Assert(node.ChildChar == 0 && node.Children == -1); - - // It is a leaf node - // Move the prevMatch one node inward - int previousMatchIndex = node.MatchIndex; - node.MatchIndex = Count; - node.ChildChar = previousMatch.Key[key.Length]; - node.ChildIndex = TreeSize; - EnsureTreeCapacity(TreeSize + 1); - _tree[TreeSize] = new Node() - { - Char = previousMatch.Key[key.Length], - MatchIndex = previousMatchIndex, - Children = -1 - }; - TreeSize++; - - // Set the pair as a match on this node - } - } - - // Set the pair as a match on this node - node.MatchIndex = Count; // This might be modifying a forgotten node reference, but in that case it was already set - EnsureCapacity(Count + 1); - _matches[Count] = pair; - Count++; - return true; - - HandleDuplicateKey:; - Debug.Assert(key == _matches[node.MatchIndex].Key); - if (behavior == InsertionBehavior.None) return false; - if (behavior == InsertionBehavior.OverwriteExisting) - { - _matches[node.MatchIndex] = pair; - return true; - } - Debug.Assert(behavior == InsertionBehavior.ThrowOnExisting); - ThrowHelper.ThrowArgumentException(ExceptionArgument.key, ExceptionReason.DuplicateKey); - Debug.Assert(false, "Should throw by now"); - return false; - } - else // if the root character is not yet in the collection - { - SetRootChar(rootChar); - InsertLeafNode(in pair, rootChar); - return true; - } - } - private void InsertLeafNode(in KeyValuePair pair, char nodeChar) - { - EnsureCapacity(Count + 1); - _matches[Count] = pair; - - EnsureTreeCapacity(TreeSize + 1); - _tree[TreeSize] = new Node() - { - Char = nodeChar, - MatchIndex = Count, - Children = -1 - }; - - Count++; - TreeSize++; - } - - #endregion Insert internal - - #region TryMatch longest - - /// - /// Tries to find the longest prefix of text, starting at offset, that is contained in this - /// - /// The text in which to search for the prefix - /// Index of the character at which to start searching - /// The found prefix and the corresponding value - /// True if a match was found, false otherwise - public bool TryMatchLongest(string text, int offset, out KeyValuePair match) - { -#if NETCORE - return TryMatchLongest(text.AsSpan(offset), out match); -#else - return TryMatchLongest(text, offset, text.Length - offset, out match); -#endif - } - - /// - /// Tries to find the longest prefix of text, that is contained in this - /// - /// The text in which to search for the prefix - /// The found prefix and the corresponding value - /// True if a match was found, false otherwise - public bool TryMatchLongest(string text, out KeyValuePair match) - { - if (text == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.text); -#if NETCORE - return TryMatchLongest(text.AsSpan(), out match); -#else - return TryMatchLongest(text, 0, text.Length, out match); -#endif - } - - /// - /// Tries to find the longest prefix of text, starting at offset, that is contained in this - /// - /// The text in which to search for the prefix - /// The offset in text at which to start looking for the prefix - /// The longest prefix allowed to match - /// The found prefix and the corresponding value - /// True if a match was found, false otherwise -#if NETCORE - public bool TryMatchLongest(string text, int offset, int length, out KeyValuePair match) - => TryMatchLongest(text.AsSpan(offset, length), out match); - - /// - /// Tries to find the longest prefix of text, that is contained in this - /// - /// The text in which to search for the prefix - /// The found prefix and the corresponding value - /// True if a match was found, false otherwise - public bool TryMatchLongest(ReadOnlySpan text, out KeyValuePair match) - { - match = default; - if (text.Length == 0 || !TryGetRoot(text[0], out int nodeIndex)) - return false; -#else - public bool TryMatchLongest(string text, int offset, int length, out KeyValuePair match) - { - int limit = offset + length; - if (text == null) - ThrowHelper.ThrowArgumentNullException(ExceptionArgument.text); - - if (offset < 0 || length < 0 || text.Length < limit) - ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.offsetLength, ExceptionReason.InvalidOffsetLength); - - match = default; - if (length == 0 || !TryGetRoot(text[offset], out int nodeIndex)) - return false; -#endif - - int matchIndex = -1; - int depth = 1; - - ref Node node = ref _tree[nodeIndex]; - if (node.ChildChar == 0) goto LeafNodeFound; - if (node.MatchIndex != -1) matchIndex = node.MatchIndex; - -#if NETCORE - for (int i = 1; i < text.Length; i++) -#else - for (int i = offset + 1; i < limit; i++) -#endif - { - char c = text[i]; - - if (node.ChildChar == c) - { - node = ref _tree[node.ChildIndex]; - goto NextChar; - } - - var children = _children; - int childrenIndex = node.Children; - do - { - if ((uint)childrenIndex >= (uint)children.Length) - goto Return; - node = ref _tree[children[childrenIndex]]; - if (node.Char == c) goto NextChar; - childrenIndex = children[childrenIndex + 1]; - } - while (true); - - NextChar:; - depth++; - if (node.ChildChar == 0) goto LeafNodeFound; - if (node.MatchIndex != -1) matchIndex = node.MatchIndex; - } - // We have ran out of our string, return the longest match we've found - goto Return; - - LeafNodeFound:; - ref KeyValuePair possibleMatch = ref _matches[node.MatchIndex]; -#if NETCORE - if (possibleMatch.Key.Length <= text.Length) - { - // Check that the rest of the strings match - if (text.Slice(depth).StartsWith(possibleMatch.Key.AsSpan(depth), StringComparison.Ordinal)) - { - matchIndex = node.MatchIndex; - } - } -#else - if (possibleMatch.Key.Length <= length) - { - // Check that the rest of the strings match - for (int i = offset + depth, j = depth; j < possibleMatch.Key.Length; i++, j++) - { - if (text[i] != possibleMatch.Key[j]) - goto Return; - } - matchIndex = node.MatchIndex; - } -#endif - - Return:; - if (matchIndex != -1) - { - match = _matches[matchIndex]; - return true; - } - return false; - } - - #endregion TryMatch longest - - #region TryMatch exact - - /// - /// Tries to find a suffix of text, starting at offset, that is contained in this and is exactly (text.Length - offset) characters long - /// - /// The text in which to search for the prefix - /// Index of the character at which to start searching - /// The found prefix and the corresponding value - /// True if a match was found, false otherwise - public bool TryMatchExact(string text, int offset, out KeyValuePair match) - { -#if NETCORE - return TryMatchExact(text.AsSpan(offset), out match); -#else - return TryMatchExact(text, offset, text.Length - offset, out match); -#endif - } - - /// - /// Tries to find a prefix of text, that is contained in this and is exactly text.Length characters long - /// - /// The text in which to search for the prefix - /// The found prefix and the corresponding value - /// True if a match was found, false otherwise - public bool TryMatchExact(string text, out KeyValuePair match) - { - if (text == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.text); -#if NETCORE - return TryMatchExact(text.AsSpan(), out match); -#else - return TryMatchExact(text, 0, text.Length, out match); -#endif - } - - /// - /// Tries to find a prefix of text, starting at offset, that is contained in this and is exactly length characters long - /// - /// The text in which to search for the prefix - /// The offset in text at which to start looking for the prefix - /// The longest prefix allowed to match - /// The found prefix and the corresponding value - /// True if a match was found, false otherwise -#if NETCORE - public bool TryMatchExact(string text, int offset, int length, out KeyValuePair match) - => TryMatchExact(text.AsSpan(offset, length), out match); - - /// - /// Tries to find a prefix of text, that is contained in this and is exactly text.Length characters long - /// - /// The text in which to search for the prefix - /// The found prefix and the corresponding value - /// True if a match was found, false otherwise - public bool TryMatchExact(ReadOnlySpan text, out KeyValuePair match) - { - match = default; - if (text.Length == 0 || !TryGetRoot(text[0], out int nodeIndex)) - return false; -#else - public bool TryMatchExact(string text, int offset, int length, out KeyValuePair match) - { - int limit = offset + length; - if (text == null) - ThrowHelper.ThrowArgumentNullException(ExceptionArgument.text); - - if (offset < 0 || length < 0 || text.Length < limit) - ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.offsetLength, ExceptionReason.InvalidOffsetLength); - - match = default; - if (length == 0 || !TryGetRoot(text[offset], out int nodeIndex)) - return false; -#endif - int depth = 1; - - ref Node node = ref _tree[nodeIndex]; - if (node.ChildChar == 0) goto LeafNodeFound; -#if NETCORE - if (node.MatchIndex != -1 && text.Length == 1) -#else - if (node.MatchIndex != -1 && length == 1) -#endif - { - match = _matches[node.MatchIndex]; - return true; - } - -#if NETCORE - for (int i = 1; i < text.Length; i++) -#else - for (int i = offset + 1; i < limit; i++) -#endif - { - char c = text[i]; - - if (node.ChildChar == c) - { - node = ref _tree[node.ChildIndex]; - goto NextChar; - } - - var children = _children; - int childrenIndex = node.Children; - do - { - if ((uint)childrenIndex >= (uint)children.Length) - return false; - node = ref _tree[children[childrenIndex]]; - if (node.Char == c) goto NextChar; - childrenIndex = children[childrenIndex + 1]; - } - while (true); - - NextChar:; - depth++; - if (node.ChildChar == 0) goto LeafNodeFound; - } - - if (node.MatchIndex == -1) return false; - match = _matches[node.MatchIndex]; -#if NETCORE - Debug.Assert(match.Key.Length == text.Length); -#else - Debug.Assert(match.Key.Length == length); -#endif - return true; - - LeafNodeFound:; - match = _matches[node.MatchIndex]; -#if NETCORE - return match.Key.Length == text.Length && - text.Slice(depth).Equals(match.Key.AsSpan(depth), StringComparison.Ordinal); -#else - if (match.Key.Length == length) - { - // Check that the rest of the strings match - for (int i = offset + depth, j = depth; j < match.Key.Length; i++, j++) - { - if (text[i] != match.Key[j]) - return false; - } - return true; - } - return false; -#endif - } - - #endregion TryMatch exact - - #region TryMatch shortest - - /// - /// Tries to find the shortest prefix of text, starting at offset, that is contained in this - /// - /// The text in which to search for the prefix - /// Index of the character at which to start searching - /// The found prefix and the corresponding value - /// True if a match was found, false otherwise - public bool TryMatchShortest(string text, int offset, out KeyValuePair match) - { -#if NETCORE - return TryMatchShortest(text.AsSpan(offset), out match); -#else - return TryMatchShortest(text, offset, text.Length - offset, out match); -#endif - } - - /// - /// Tries to find the shortest prefix of text, that is contained in this - /// - /// The text in which to search for the prefix - /// The found prefix and the corresponding value - /// True if a match was found, false otherwise - public bool TryMatchShortest(string text, out KeyValuePair match) - { - if (text == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.text); -#if NETCORE - return TryMatchShortest(text.AsSpan(), out match); -#else - return TryMatchShortest(text, 0, text.Length, out match); -#endif - } - - /// - /// Tries to find the shortest prefix of text, starting at offset, that is contained in this - /// - /// The text in which to search for the prefix - /// The offset in text at which to start looking for the prefix - /// The longest prefix allowed to match - /// The found prefix and the corresponding value - /// True if a match was found, false otherwise -#if NETCORE - public bool TryMatchShortest(string text, int offset, int length, out KeyValuePair match) - => TryMatchShortest(text.AsSpan(offset, length), out match); - - /// - /// Tries to find the shortest prefix of text, that is contained in this - /// - /// The text in which to search for the prefix - /// The found prefix and the corresponding value - /// True if a match was found, false otherwise - public bool TryMatchShortest(ReadOnlySpan text, out KeyValuePair match) - { - match = default; - if (text.Length == 0 || !TryGetRoot(text[0], out int nodeIndex)) - return false; -#else - public bool TryMatchShortest(string text, int offset, int length, out KeyValuePair match) - { - int limit = offset + length; - if (text == null) - ThrowHelper.ThrowArgumentNullException(ExceptionArgument.text); - - if (offset < 0 || length < 0 || text.Length < limit) - ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.offsetLength, ExceptionReason.InvalidOffsetLength); - - match = default; - if (length == 0 || !TryGetRoot(text[offset], out int nodeIndex)) - return false; -#endif - ref Node node = ref _tree[nodeIndex]; - if (node.MatchIndex != -1) - { - match = _matches[node.MatchIndex]; - return true; - } - -#if NETCORE - for (int i = 1; i < text.Length; i++) -#else - for (int i = offset + 1; i < limit; i++) -#endif - { - char c = text[i]; - - if (node.ChildChar == c) - { - node = ref _tree[node.ChildIndex]; - goto NextChar; - } - - var children = _children; - int childrenIndex = node.Children; - do - { - if ((uint)childrenIndex >= (uint)children.Length) - return false; - node = ref _tree[children[childrenIndex]]; - if (node.Char == c) goto NextChar; - childrenIndex = children[childrenIndex + 1]; - } - while (true); - - NextChar:; - if (node.MatchIndex != -1) - { - match = _matches[node.MatchIndex]; - return true; - } - } - Debug.Assert(node.MatchIndex == -1); - return false; - } - - #endregion TryMatch shortest - - #region Interface implementations - - /// - /// Determines whether the contains the specified key - /// - /// The key to locate in this - /// True if the key is contained in this PrefixTree, false otherwise. - public bool ContainsKey(string key) - => TryMatchExact(key, out _); - - /// - /// Gets the value associated with the specified key - /// - /// The key of the value to get - /// The value associated with the specified key - /// True if the key is contained in this PrefixTree, false otherwise. - public bool TryGetValue(string key, out TValue value) - { - bool ret = TryMatchExact(key, out KeyValuePair match); - value = match.Value; - return ret; - } - - /// - /// Gets a collection containing the keys in this - /// - public IEnumerable Keys - { - get - { - for (int i = 0; i < Count; i++) - yield return _matches[i].Key; - } - } - /// - /// Gets a collection containing the values in this - /// - public IEnumerable Values - { - get - { - for (int i = 0; i < Count; i++) - yield return _matches[i].Value; - } - } - - /// - /// Returns an Enumerator that iterates through the . - /// Use the index accessor instead () - /// - /// - public IEnumerator> GetEnumerator() => new Enumerator(_matches); -//#if !LEGACY - //IEnumerator IEnumerable.GetEnumerator() => new Enumerator(_matches); -//#endif - - /// - /// Enumerates the elements of a - /// - public struct Enumerator : IEnumerator>, IEnumerator - { - private readonly KeyValuePair[] _matches; - private int _index; - - internal Enumerator(KeyValuePair[] matches) - { - _matches = matches; - _index = -1; - } - - /// - /// Increments the internal index - /// - /// True if the index is less than the length of the internal array - public bool MoveNext() => ++_index < _matches.Length; - /// - /// Gets the at the current position - /// - public KeyValuePair Current => _matches[_index]; - object IEnumerator.Current => _matches[_index]; - - /// - /// Does nothing - /// - public void Dispose() { } - - /// - /// Resets the internal index to the beginning of the array - /// - public void Reset() - { - _index = -1; - } - } - - #endregion Interface implementations - } -} diff --git a/NppMarkdownPanel/Markdig/Helpers/DefaultObjectCache.cs b/NppMarkdownPanel/Markdig/Helpers/DefaultObjectCache.cs deleted file mode 100644 index f0ce95d..0000000 --- a/NppMarkdownPanel/Markdig/Helpers/DefaultObjectCache.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.Collections; -using System.Collections.Generic; - -namespace Markdig.Helpers -{ - /// - /// A default object cache that expect the type {T} to provide a parameter less constructor - /// - /// The type of item to cache - /// - public abstract class DefaultObjectCache : ObjectCache where T : class, new() - { - protected override T NewInstance() - { - return new T(); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Helpers/EntityHelper.cs b/NppMarkdownPanel/Markdig/Helpers/EntityHelper.cs deleted file mode 100644 index 2f1c648..0000000 --- a/NppMarkdownPanel/Markdig/Helpers/EntityHelper.cs +++ /dev/null @@ -1,2212 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -// Original file released under the following license: -// Copyright(c) 2014, Kārlis Gaņģis -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Kārlis Gaņģis nor the names of other contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED.IN NO EVENT SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -using System; -using System.Collections.Generic; - -namespace Markdig.Helpers -{ - /// - /// Helper class to decode an entity. - /// - public static class EntityHelper - { - /// - /// Decodes the given HTML entity to the matching Unicode characters. - /// - /// The entity without & and ; symbols, for example, copy. - /// The unicode character set or null if the entity was not recognized. - public static string DecodeEntity(string entity) - { - string result; - if (EntityMap.TryGetValue(entity, out result)) - return result; - - return null; - } - - /// - /// Decodes the given UTF-32 character code to the matching set of UTF-16 characters. - /// - /// The unicode character set or null if the entity was not recognized. - public static string DecodeEntity(int utf32) - { - if (utf32 < 0 || utf32 > 1114111 || (utf32 >= 55296 && utf32 <= 57343)) - return null; - - if (utf32 < 65536) - return char.ToString((char)utf32); - - utf32 -= 65536; - return new string(new char[] - { - (char)(utf32 / 1024 + 55296), - (char)(utf32 % 1024 + 56320) - }); - } - - #region [ EntityMap ] - /// - /// Source: http://www.w3.org/html/wg/drafts/html/master/syntax.html#named-character-references - /// - private static readonly Dictionary EntityMap = new Dictionary(2125, StringComparer.Ordinal) - { - { "Aacute", "\u00C1" }, - { "aacute", "\u00E1" }, - { "Abreve", "\u0102" }, - { "abreve", "\u0103" }, - { "ac", "\u223E" }, - { "acd", "\u223F" }, - { "acE", "\u223E\u0333" }, - { "Acirc", "\u00C2" }, - { "acirc", "\u00E2" }, - { "acute", "\u00B4" }, - { "Acy", "\u0410" }, - { "acy", "\u0430" }, - { "AElig", "\u00C6" }, - { "aelig", "\u00E6" }, - { "af", "\u2061" }, - { "Afr", "\uD835\uDD04" }, - { "afr", "\uD835\uDD1E" }, - { "Agrave", "\u00C0" }, - { "agrave", "\u00E0" }, - { "alefsym", "\u2135" }, - { "aleph", "\u2135" }, - { "Alpha", "\u0391" }, - { "alpha", "\u03B1" }, - { "Amacr", "\u0100" }, - { "amacr", "\u0101" }, - { "amalg", "\u2A3F" }, - { "AMP", "\u0026" }, - { "amp", "\u0026" }, - { "And", "\u2A53" }, - { "and", "\u2227" }, - { "andand", "\u2A55" }, - { "andd", "\u2A5C" }, - { "andslope", "\u2A58" }, - { "andv", "\u2A5A" }, - { "ang", "\u2220" }, - { "ange", "\u29A4" }, - { "angle", "\u2220" }, - { "angmsd", "\u2221" }, - { "angmsdaa", "\u29A8" }, - { "angmsdab", "\u29A9" }, - { "angmsdac", "\u29AA" }, - { "angmsdad", "\u29AB" }, - { "angmsdae", "\u29AC" }, - { "angmsdaf", "\u29AD" }, - { "angmsdag", "\u29AE" }, - { "angmsdah", "\u29AF" }, - { "angrt", "\u221F" }, - { "angrtvb", "\u22BE" }, - { "angrtvbd", "\u299D" }, - { "angsph", "\u2222" }, - { "angst", "\u00C5" }, - { "angzarr", "\u237C" }, - { "Aogon", "\u0104" }, - { "aogon", "\u0105" }, - { "Aopf", "\uD835\uDD38" }, - { "aopf", "\uD835\uDD52" }, - { "ap", "\u2248" }, - { "apacir", "\u2A6F" }, - { "apE", "\u2A70" }, - { "ape", "\u224A" }, - { "apid", "\u224B" }, - { "apos", "\u0027" }, - { "ApplyFunction", "\u2061" }, - { "approx", "\u2248" }, - { "approxeq", "\u224A" }, - { "Aring", "\u00C5" }, - { "aring", "\u00E5" }, - { "Ascr", "\uD835\uDC9C" }, - { "ascr", "\uD835\uDCB6" }, - { "Assign", "\u2254" }, - { "ast", "\u002A" }, - { "asymp", "\u2248" }, - { "asympeq", "\u224D" }, - { "Atilde", "\u00C3" }, - { "atilde", "\u00E3" }, - { "Auml", "\u00C4" }, - { "auml", "\u00E4" }, - { "awconint", "\u2233" }, - { "awint", "\u2A11" }, - { "backcong", "\u224C" }, - { "backepsilon", "\u03F6" }, - { "backprime", "\u2035" }, - { "backsim", "\u223D" }, - { "backsimeq", "\u22CD" }, - { "Backslash", "\u2216" }, - { "Barv", "\u2AE7" }, - { "barvee", "\u22BD" }, - { "Barwed", "\u2306" }, - { "barwed", "\u2305" }, - { "barwedge", "\u2305" }, - { "bbrk", "\u23B5" }, - { "bbrktbrk", "\u23B6" }, - { "bcong", "\u224C" }, - { "Bcy", "\u0411" }, - { "bcy", "\u0431" }, - { "bdquo", "\u201E" }, - { "becaus", "\u2235" }, - { "Because", "\u2235" }, - { "because", "\u2235" }, - { "bemptyv", "\u29B0" }, - { "bepsi", "\u03F6" }, - { "bernou", "\u212C" }, - { "Bernoullis", "\u212C" }, - { "Beta", "\u0392" }, - { "beta", "\u03B2" }, - { "beth", "\u2136" }, - { "between", "\u226C" }, - { "Bfr", "\uD835\uDD05" }, - { "bfr", "\uD835\uDD1F" }, - { "bigcap", "\u22C2" }, - { "bigcirc", "\u25EF" }, - { "bigcup", "\u22C3" }, - { "bigodot", "\u2A00" }, - { "bigoplus", "\u2A01" }, - { "bigotimes", "\u2A02" }, - { "bigsqcup", "\u2A06" }, - { "bigstar", "\u2605" }, - { "bigtriangledown", "\u25BD" }, - { "bigtriangleup", "\u25B3" }, - { "biguplus", "\u2A04" }, - { "bigvee", "\u22C1" }, - { "bigwedge", "\u22C0" }, - { "bkarow", "\u290D" }, - { "blacklozenge", "\u29EB" }, - { "blacksquare", "\u25AA" }, - { "blacktriangle", "\u25B4" }, - { "blacktriangledown", "\u25BE" }, - { "blacktriangleleft", "\u25C2" }, - { "blacktriangleright", "\u25B8" }, - { "blank", "\u2423" }, - { "blk12", "\u2592" }, - { "blk14", "\u2591" }, - { "blk34", "\u2593" }, - { "block", "\u2588" }, - { "bne", "\u003D\u20E5" }, - { "bnequiv", "\u2261\u20E5" }, - { "bNot", "\u2AED" }, - { "bnot", "\u2310" }, - { "Bopf", "\uD835\uDD39" }, - { "bopf", "\uD835\uDD53" }, - { "bot", "\u22A5" }, - { "bottom", "\u22A5" }, - { "bowtie", "\u22C8" }, - { "boxbox", "\u29C9" }, - { "boxDL", "\u2557" }, - { "boxDl", "\u2556" }, - { "boxdL", "\u2555" }, - { "boxdl", "\u2510" }, - { "boxDR", "\u2554" }, - { "boxDr", "\u2553" }, - { "boxdR", "\u2552" }, - { "boxdr", "\u250C" }, - { "boxH", "\u2550" }, - { "boxh", "\u2500" }, - { "boxHD", "\u2566" }, - { "boxHd", "\u2564" }, - { "boxhD", "\u2565" }, - { "boxhd", "\u252C" }, - { "boxHU", "\u2569" }, - { "boxHu", "\u2567" }, - { "boxhU", "\u2568" }, - { "boxhu", "\u2534" }, - { "boxminus", "\u229F" }, - { "boxplus", "\u229E" }, - { "boxtimes", "\u22A0" }, - { "boxUL", "\u255D" }, - { "boxUl", "\u255C" }, - { "boxuL", "\u255B" }, - { "boxul", "\u2518" }, - { "boxUR", "\u255A" }, - { "boxUr", "\u2559" }, - { "boxuR", "\u2558" }, - { "boxur", "\u2514" }, - { "boxV", "\u2551" }, - { "boxv", "\u2502" }, - { "boxVH", "\u256C" }, - { "boxVh", "\u256B" }, - { "boxvH", "\u256A" }, - { "boxvh", "\u253C" }, - { "boxVL", "\u2563" }, - { "boxVl", "\u2562" }, - { "boxvL", "\u2561" }, - { "boxvl", "\u2524" }, - { "boxVR", "\u2560" }, - { "boxVr", "\u255F" }, - { "boxvR", "\u255E" }, - { "boxvr", "\u251C" }, - { "bprime", "\u2035" }, - { "Breve", "\u02D8" }, - { "breve", "\u02D8" }, - { "brvbar", "\u00A6" }, - { "Bscr", "\u212C" }, - { "bscr", "\uD835\uDCB7" }, - { "bsemi", "\u204F" }, - { "bsim", "\u223D" }, - { "bsime", "\u22CD" }, - { "bsol", "\u005C" }, - { "bsolb", "\u29C5" }, - { "bsolhsub", "\u27C8" }, - { "bull", "\u2022" }, - { "bullet", "\u2022" }, - { "bump", "\u224E" }, - { "bumpE", "\u2AAE" }, - { "bumpe", "\u224F" }, - { "Bumpeq", "\u224E" }, - { "bumpeq", "\u224F" }, - { "Cacute", "\u0106" }, - { "cacute", "\u0107" }, - { "Cap", "\u22D2" }, - { "cap", "\u2229" }, - { "capand", "\u2A44" }, - { "capbrcup", "\u2A49" }, - { "capcap", "\u2A4B" }, - { "capcup", "\u2A47" }, - { "capdot", "\u2A40" }, - { "CapitalDifferentialD", "\u2145" }, - { "caps", "\u2229\uFE00" }, - { "caret", "\u2041" }, - { "caron", "\u02C7" }, - { "Cayleys", "\u212D" }, - { "ccaps", "\u2A4D" }, - { "Ccaron", "\u010C" }, - { "ccaron", "\u010D" }, - { "Ccedil", "\u00C7" }, - { "ccedil", "\u00E7" }, - { "Ccirc", "\u0108" }, - { "ccirc", "\u0109" }, - { "Cconint", "\u2230" }, - { "ccups", "\u2A4C" }, - { "ccupssm", "\u2A50" }, - { "Cdot", "\u010A" }, - { "cdot", "\u010B" }, - { "cedil", "\u00B8" }, - { "Cedilla", "\u00B8" }, - { "cemptyv", "\u29B2" }, - { "cent", "\u00A2" }, - { "CenterDot", "\u00B7" }, - { "centerdot", "\u00B7" }, - { "Cfr", "\u212D" }, - { "cfr", "\uD835\uDD20" }, - { "CHcy", "\u0427" }, - { "chcy", "\u0447" }, - { "check", "\u2713" }, - { "checkmark", "\u2713" }, - { "Chi", "\u03A7" }, - { "chi", "\u03C7" }, - { "cir", "\u25CB" }, - { "circ", "\u02C6" }, - { "circeq", "\u2257" }, - { "circlearrowleft", "\u21BA" }, - { "circlearrowright", "\u21BB" }, - { "circledast", "\u229B" }, - { "circledcirc", "\u229A" }, - { "circleddash", "\u229D" }, - { "CircleDot", "\u2299" }, - { "circledR", "\u00AE" }, - { "circledS", "\u24C8" }, - { "CircleMinus", "\u2296" }, - { "CirclePlus", "\u2295" }, - { "CircleTimes", "\u2297" }, - { "cirE", "\u29C3" }, - { "cire", "\u2257" }, - { "cirfnint", "\u2A10" }, - { "cirmid", "\u2AEF" }, - { "cirscir", "\u29C2" }, - { "ClockwiseContourIntegral", "\u2232" }, - { "CloseCurlyDoubleQuote", "\u201D" }, - { "CloseCurlyQuote", "\u2019" }, - { "clubs", "\u2663" }, - { "clubsuit", "\u2663" }, - { "Colon", "\u2237" }, - { "colon", "\u003A" }, - { "Colone", "\u2A74" }, - { "colone", "\u2254" }, - { "coloneq", "\u2254" }, - { "comma", "\u002C" }, - { "commat", "\u0040" }, - { "comp", "\u2201" }, - { "compfn", "\u2218" }, - { "complement", "\u2201" }, - { "complexes", "\u2102" }, - { "cong", "\u2245" }, - { "congdot", "\u2A6D" }, - { "Congruent", "\u2261" }, - { "Conint", "\u222F" }, - { "conint", "\u222E" }, - { "ContourIntegral", "\u222E" }, - { "Copf", "\u2102" }, - { "copf", "\uD835\uDD54" }, - { "coprod", "\u2210" }, - { "Coproduct", "\u2210" }, - { "COPY", "\u00A9" }, - { "copy", "\u00A9" }, - { "copysr", "\u2117" }, - { "CounterClockwiseContourIntegral", "\u2233" }, - { "crarr", "\u21B5" }, - { "Cross", "\u2A2F" }, - { "cross", "\u2717" }, - { "Cscr", "\uD835\uDC9E" }, - { "cscr", "\uD835\uDCB8" }, - { "csub", "\u2ACF" }, - { "csube", "\u2AD1" }, - { "csup", "\u2AD0" }, - { "csupe", "\u2AD2" }, - { "ctdot", "\u22EF" }, - { "cudarrl", "\u2938" }, - { "cudarrr", "\u2935" }, - { "cuepr", "\u22DE" }, - { "cuesc", "\u22DF" }, - { "cularr", "\u21B6" }, - { "cularrp", "\u293D" }, - { "Cup", "\u22D3" }, - { "cup", "\u222A" }, - { "cupbrcap", "\u2A48" }, - { "CupCap", "\u224D" }, - { "cupcap", "\u2A46" }, - { "cupcup", "\u2A4A" }, - { "cupdot", "\u228D" }, - { "cupor", "\u2A45" }, - { "cups", "\u222A\uFE00" }, - { "curarr", "\u21B7" }, - { "curarrm", "\u293C" }, - { "curlyeqprec", "\u22DE" }, - { "curlyeqsucc", "\u22DF" }, - { "curlyvee", "\u22CE" }, - { "curlywedge", "\u22CF" }, - { "curren", "\u00A4" }, - { "curvearrowleft", "\u21B6" }, - { "curvearrowright", "\u21B7" }, - { "cuvee", "\u22CE" }, - { "cuwed", "\u22CF" }, - { "cwconint", "\u2232" }, - { "cwint", "\u2231" }, - { "cylcty", "\u232D" }, - { "Dagger", "\u2021" }, - { "dagger", "\u2020" }, - { "daleth", "\u2138" }, - { "Darr", "\u21A1" }, - { "dArr", "\u21D3" }, - { "darr", "\u2193" }, - { "dash", "\u2010" }, - { "Dashv", "\u2AE4" }, - { "dashv", "\u22A3" }, - { "dbkarow", "\u290F" }, - { "dblac", "\u02DD" }, - { "Dcaron", "\u010E" }, - { "dcaron", "\u010F" }, - { "Dcy", "\u0414" }, - { "dcy", "\u0434" }, - { "DD", "\u2145" }, - { "dd", "\u2146" }, - { "ddagger", "\u2021" }, - { "ddarr", "\u21CA" }, - { "DDotrahd", "\u2911" }, - { "ddotseq", "\u2A77" }, - { "deg", "\u00B0" }, - { "Del", "\u2207" }, - { "Delta", "\u0394" }, - { "delta", "\u03B4" }, - { "demptyv", "\u29B1" }, - { "dfisht", "\u297F" }, - { "Dfr", "\uD835\uDD07" }, - { "dfr", "\uD835\uDD21" }, - { "dHar", "\u2965" }, - { "dharl", "\u21C3" }, - { "dharr", "\u21C2" }, - { "DiacriticalAcute", "\u00B4" }, - { "DiacriticalDot", "\u02D9" }, - { "DiacriticalDoubleAcute", "\u02DD" }, - { "DiacriticalGrave", "\u0060" }, - { "DiacriticalTilde", "\u02DC" }, - { "diam", "\u22C4" }, - { "Diamond", "\u22C4" }, - { "diamond", "\u22C4" }, - { "diamondsuit", "\u2666" }, - { "diams", "\u2666" }, - { "die", "\u00A8" }, - { "DifferentialD", "\u2146" }, - { "digamma", "\u03DD" }, - { "disin", "\u22F2" }, - { "div", "\u00F7" }, - { "divide", "\u00F7" }, - { "divideontimes", "\u22C7" }, - { "divonx", "\u22C7" }, - { "DJcy", "\u0402" }, - { "djcy", "\u0452" }, - { "dlcorn", "\u231E" }, - { "dlcrop", "\u230D" }, - { "dollar", "\u0024" }, - { "Dopf", "\uD835\uDD3B" }, - { "dopf", "\uD835\uDD55" }, - { "Dot", "\u00A8" }, - { "dot", "\u02D9" }, - { "DotDot", "\u20DC" }, - { "doteq", "\u2250" }, - { "doteqdot", "\u2251" }, - { "DotEqual", "\u2250" }, - { "dotminus", "\u2238" }, - { "dotplus", "\u2214" }, - { "dotsquare", "\u22A1" }, - { "doublebarwedge", "\u2306" }, - { "DoubleContourIntegral", "\u222F" }, - { "DoubleDot", "\u00A8" }, - { "DoubleDownArrow", "\u21D3" }, - { "DoubleLeftArrow", "\u21D0" }, - { "DoubleLeftRightArrow", "\u21D4" }, - { "DoubleLeftTee", "\u2AE4" }, - { "DoubleLongLeftArrow", "\u27F8" }, - { "DoubleLongLeftRightArrow", "\u27FA" }, - { "DoubleLongRightArrow", "\u27F9" }, - { "DoubleRightArrow", "\u21D2" }, - { "DoubleRightTee", "\u22A8" }, - { "DoubleUpArrow", "\u21D1" }, - { "DoubleUpDownArrow", "\u21D5" }, - { "DoubleVerticalBar", "\u2225" }, - { "DownArrow", "\u2193" }, - { "Downarrow", "\u21D3" }, - { "downarrow", "\u2193" }, - { "DownArrowBar", "\u2913" }, - { "DownArrowUpArrow", "\u21F5" }, - { "DownBreve", "\u0311" }, - { "downdownarrows", "\u21CA" }, - { "downharpoonleft", "\u21C3" }, - { "downharpoonright", "\u21C2" }, - { "DownLeftRightVector", "\u2950" }, - { "DownLeftTeeVector", "\u295E" }, - { "DownLeftVector", "\u21BD" }, - { "DownLeftVectorBar", "\u2956" }, - { "DownRightTeeVector", "\u295F" }, - { "DownRightVector", "\u21C1" }, - { "DownRightVectorBar", "\u2957" }, - { "DownTee", "\u22A4" }, - { "DownTeeArrow", "\u21A7" }, - { "drbkarow", "\u2910" }, - { "drcorn", "\u231F" }, - { "drcrop", "\u230C" }, - { "Dscr", "\uD835\uDC9F" }, - { "dscr", "\uD835\uDCB9" }, - { "DScy", "\u0405" }, - { "dscy", "\u0455" }, - { "dsol", "\u29F6" }, - { "Dstrok", "\u0110" }, - { "dstrok", "\u0111" }, - { "dtdot", "\u22F1" }, - { "dtri", "\u25BF" }, - { "dtrif", "\u25BE" }, - { "duarr", "\u21F5" }, - { "duhar", "\u296F" }, - { "dwangle", "\u29A6" }, - { "DZcy", "\u040F" }, - { "dzcy", "\u045F" }, - { "dzigrarr", "\u27FF" }, - { "Eacute", "\u00C9" }, - { "eacute", "\u00E9" }, - { "easter", "\u2A6E" }, - { "Ecaron", "\u011A" }, - { "ecaron", "\u011B" }, - { "ecir", "\u2256" }, - { "Ecirc", "\u00CA" }, - { "ecirc", "\u00EA" }, - { "ecolon", "\u2255" }, - { "Ecy", "\u042D" }, - { "ecy", "\u044D" }, - { "eDDot", "\u2A77" }, - { "Edot", "\u0116" }, - { "eDot", "\u2251" }, - { "edot", "\u0117" }, - { "ee", "\u2147" }, - { "efDot", "\u2252" }, - { "Efr", "\uD835\uDD08" }, - { "efr", "\uD835\uDD22" }, - { "eg", "\u2A9A" }, - { "Egrave", "\u00C8" }, - { "egrave", "\u00E8" }, - { "egs", "\u2A96" }, - { "egsdot", "\u2A98" }, - { "el", "\u2A99" }, - { "Element", "\u2208" }, - { "elinters", "\u23E7" }, - { "ell", "\u2113" }, - { "els", "\u2A95" }, - { "elsdot", "\u2A97" }, - { "Emacr", "\u0112" }, - { "emacr", "\u0113" }, - { "empty", "\u2205" }, - { "emptyset", "\u2205" }, - { "EmptySmallSquare", "\u25FB" }, - { "emptyv", "\u2205" }, - { "EmptyVerySmallSquare", "\u25AB" }, - { "emsp", "\u2003" }, - { "emsp13", "\u2004" }, - { "emsp14", "\u2005" }, - { "ENG", "\u014A" }, - { "eng", "\u014B" }, - { "ensp", "\u2002" }, - { "Eogon", "\u0118" }, - { "eogon", "\u0119" }, - { "Eopf", "\uD835\uDD3C" }, - { "eopf", "\uD835\uDD56" }, - { "epar", "\u22D5" }, - { "eparsl", "\u29E3" }, - { "eplus", "\u2A71" }, - { "epsi", "\u03B5" }, - { "Epsilon", "\u0395" }, - { "epsilon", "\u03B5" }, - { "epsiv", "\u03F5" }, - { "eqcirc", "\u2256" }, - { "eqcolon", "\u2255" }, - { "eqsim", "\u2242" }, - { "eqslantgtr", "\u2A96" }, - { "eqslantless", "\u2A95" }, - { "Equal", "\u2A75" }, - { "equals", "\u003D" }, - { "EqualTilde", "\u2242" }, - { "equest", "\u225F" }, - { "Equilibrium", "\u21CC" }, - { "equiv", "\u2261" }, - { "equivDD", "\u2A78" }, - { "eqvparsl", "\u29E5" }, - { "erarr", "\u2971" }, - { "erDot", "\u2253" }, - { "Escr", "\u2130" }, - { "escr", "\u212F" }, - { "esdot", "\u2250" }, - { "Esim", "\u2A73" }, - { "esim", "\u2242" }, - { "Eta", "\u0397" }, - { "eta", "\u03B7" }, - { "ETH", "\u00D0" }, - { "eth", "\u00F0" }, - { "Euml", "\u00CB" }, - { "euml", "\u00EB" }, - { "euro", "\u20AC" }, - { "excl", "\u0021" }, - { "exist", "\u2203" }, - { "Exists", "\u2203" }, - { "expectation", "\u2130" }, - { "ExponentialE", "\u2147" }, - { "exponentiale", "\u2147" }, - { "fallingdotseq", "\u2252" }, - { "Fcy", "\u0424" }, - { "fcy", "\u0444" }, - { "female", "\u2640" }, - { "ffilig", "\uFB03" }, - { "fflig", "\uFB00" }, - { "ffllig", "\uFB04" }, - { "Ffr", "\uD835\uDD09" }, - { "ffr", "\uD835\uDD23" }, - { "filig", "\uFB01" }, - { "FilledSmallSquare", "\u25FC" }, - { "FilledVerySmallSquare", "\u25AA" }, - { "fjlig", "\u0066\u006A" }, - { "flat", "\u266D" }, - { "fllig", "\uFB02" }, - { "fltns", "\u25B1" }, - { "fnof", "\u0192" }, - { "Fopf", "\uD835\uDD3D" }, - { "fopf", "\uD835\uDD57" }, - { "ForAll", "\u2200" }, - { "forall", "\u2200" }, - { "fork", "\u22D4" }, - { "forkv", "\u2AD9" }, - { "Fouriertrf", "\u2131" }, - { "fpartint", "\u2A0D" }, - { "frac12", "\u00BD" }, - { "frac13", "\u2153" }, - { "frac14", "\u00BC" }, - { "frac15", "\u2155" }, - { "frac16", "\u2159" }, - { "frac18", "\u215B" }, - { "frac23", "\u2154" }, - { "frac25", "\u2156" }, - { "frac34", "\u00BE" }, - { "frac35", "\u2157" }, - { "frac38", "\u215C" }, - { "frac45", "\u2158" }, - { "frac56", "\u215A" }, - { "frac58", "\u215D" }, - { "frac78", "\u215E" }, - { "frasl", "\u2044" }, - { "frown", "\u2322" }, - { "Fscr", "\u2131" }, - { "fscr", "\uD835\uDCBB" }, - { "gacute", "\u01F5" }, - { "Gamma", "\u0393" }, - { "gamma", "\u03B3" }, - { "Gammad", "\u03DC" }, - { "gammad", "\u03DD" }, - { "gap", "\u2A86" }, - { "Gbreve", "\u011E" }, - { "gbreve", "\u011F" }, - { "Gcedil", "\u0122" }, - { "Gcirc", "\u011C" }, - { "gcirc", "\u011D" }, - { "Gcy", "\u0413" }, - { "gcy", "\u0433" }, - { "Gdot", "\u0120" }, - { "gdot", "\u0121" }, - { "gE", "\u2267" }, - { "ge", "\u2265" }, - { "gEl", "\u2A8C" }, - { "gel", "\u22DB" }, - { "geq", "\u2265" }, - { "geqq", "\u2267" }, - { "geqslant", "\u2A7E" }, - { "ges", "\u2A7E" }, - { "gescc", "\u2AA9" }, - { "gesdot", "\u2A80" }, - { "gesdoto", "\u2A82" }, - { "gesdotol", "\u2A84" }, - { "gesl", "\u22DB\uFE00" }, - { "gesles", "\u2A94" }, - { "Gfr", "\uD835\uDD0A" }, - { "gfr", "\uD835\uDD24" }, - { "Gg", "\u22D9" }, - { "gg", "\u226B" }, - { "ggg", "\u22D9" }, - { "gimel", "\u2137" }, - { "GJcy", "\u0403" }, - { "gjcy", "\u0453" }, - { "gl", "\u2277" }, - { "gla", "\u2AA5" }, - { "glE", "\u2A92" }, - { "glj", "\u2AA4" }, - { "gnap", "\u2A8A" }, - { "gnapprox", "\u2A8A" }, - { "gnE", "\u2269" }, - { "gne", "\u2A88" }, - { "gneq", "\u2A88" }, - { "gneqq", "\u2269" }, - { "gnsim", "\u22E7" }, - { "Gopf", "\uD835\uDD3E" }, - { "gopf", "\uD835\uDD58" }, - { "grave", "\u0060" }, - { "GreaterEqual", "\u2265" }, - { "GreaterEqualLess", "\u22DB" }, - { "GreaterFullEqual", "\u2267" }, - { "GreaterGreater", "\u2AA2" }, - { "GreaterLess", "\u2277" }, - { "GreaterSlantEqual", "\u2A7E" }, - { "GreaterTilde", "\u2273" }, - { "Gscr", "\uD835\uDCA2" }, - { "gscr", "\u210A" }, - { "gsim", "\u2273" }, - { "gsime", "\u2A8E" }, - { "gsiml", "\u2A90" }, - { "GT", "\u003E" }, - { "Gt", "\u226B" }, - { "gt", "\u003E" }, - { "gtcc", "\u2AA7" }, - { "gtcir", "\u2A7A" }, - { "gtdot", "\u22D7" }, - { "gtlPar", "\u2995" }, - { "gtquest", "\u2A7C" }, - { "gtrapprox", "\u2A86" }, - { "gtrarr", "\u2978" }, - { "gtrdot", "\u22D7" }, - { "gtreqless", "\u22DB" }, - { "gtreqqless", "\u2A8C" }, - { "gtrless", "\u2277" }, - { "gtrsim", "\u2273" }, - { "gvertneqq", "\u2269\uFE00" }, - { "gvnE", "\u2269\uFE00" }, - { "Hacek", "\u02C7" }, - { "hairsp", "\u200A" }, - { "half", "\u00BD" }, - { "hamilt", "\u210B" }, - { "HARDcy", "\u042A" }, - { "hardcy", "\u044A" }, - { "hArr", "\u21D4" }, - { "harr", "\u2194" }, - { "harrcir", "\u2948" }, - { "harrw", "\u21AD" }, - { "Hat", "\u005E" }, - { "hbar", "\u210F" }, - { "Hcirc", "\u0124" }, - { "hcirc", "\u0125" }, - { "hearts", "\u2665" }, - { "heartsuit", "\u2665" }, - { "hellip", "\u2026" }, - { "hercon", "\u22B9" }, - { "Hfr", "\u210C" }, - { "hfr", "\uD835\uDD25" }, - { "HilbertSpace", "\u210B" }, - { "hksearow", "\u2925" }, - { "hkswarow", "\u2926" }, - { "hoarr", "\u21FF" }, - { "homtht", "\u223B" }, - { "hookleftarrow", "\u21A9" }, - { "hookrightarrow", "\u21AA" }, - { "Hopf", "\u210D" }, - { "hopf", "\uD835\uDD59" }, - { "horbar", "\u2015" }, - { "HorizontalLine", "\u2500" }, - { "Hscr", "\u210B" }, - { "hscr", "\uD835\uDCBD" }, - { "hslash", "\u210F" }, - { "Hstrok", "\u0126" }, - { "hstrok", "\u0127" }, - { "HumpDownHump", "\u224E" }, - { "HumpEqual", "\u224F" }, - { "hybull", "\u2043" }, - { "hyphen", "\u2010" }, - { "Iacute", "\u00CD" }, - { "iacute", "\u00ED" }, - { "ic", "\u2063" }, - { "Icirc", "\u00CE" }, - { "icirc", "\u00EE" }, - { "Icy", "\u0418" }, - { "icy", "\u0438" }, - { "Idot", "\u0130" }, - { "IEcy", "\u0415" }, - { "iecy", "\u0435" }, - { "iexcl", "\u00A1" }, - { "iff", "\u21D4" }, - { "Ifr", "\u2111" }, - { "ifr", "\uD835\uDD26" }, - { "Igrave", "\u00CC" }, - { "igrave", "\u00EC" }, - { "ii", "\u2148" }, - { "iiiint", "\u2A0C" }, - { "iiint", "\u222D" }, - { "iinfin", "\u29DC" }, - { "iiota", "\u2129" }, - { "IJlig", "\u0132" }, - { "ijlig", "\u0133" }, - { "Im", "\u2111" }, - { "Imacr", "\u012A" }, - { "imacr", "\u012B" }, - { "image", "\u2111" }, - { "ImaginaryI", "\u2148" }, - { "imagline", "\u2110" }, - { "imagpart", "\u2111" }, - { "imath", "\u0131" }, - { "imof", "\u22B7" }, - { "imped", "\u01B5" }, - { "Implies", "\u21D2" }, - { "in", "\u2208" }, - { "incare", "\u2105" }, - { "infin", "\u221E" }, - { "infintie", "\u29DD" }, - { "inodot", "\u0131" }, - { "Int", "\u222C" }, - { "int", "\u222B" }, - { "intcal", "\u22BA" }, - { "integers", "\u2124" }, - { "Integral", "\u222B" }, - { "intercal", "\u22BA" }, - { "Intersection", "\u22C2" }, - { "intlarhk", "\u2A17" }, - { "intprod", "\u2A3C" }, - { "InvisibleComma", "\u2063" }, - { "InvisibleTimes", "\u2062" }, - { "IOcy", "\u0401" }, - { "iocy", "\u0451" }, - { "Iogon", "\u012E" }, - { "iogon", "\u012F" }, - { "Iopf", "\uD835\uDD40" }, - { "iopf", "\uD835\uDD5A" }, - { "Iota", "\u0399" }, - { "iota", "\u03B9" }, - { "iprod", "\u2A3C" }, - { "iquest", "\u00BF" }, - { "Iscr", "\u2110" }, - { "iscr", "\uD835\uDCBE" }, - { "isin", "\u2208" }, - { "isindot", "\u22F5" }, - { "isinE", "\u22F9" }, - { "isins", "\u22F4" }, - { "isinsv", "\u22F3" }, - { "isinv", "\u2208" }, - { "it", "\u2062" }, - { "Itilde", "\u0128" }, - { "itilde", "\u0129" }, - { "Iukcy", "\u0406" }, - { "iukcy", "\u0456" }, - { "Iuml", "\u00CF" }, - { "iuml", "\u00EF" }, - { "Jcirc", "\u0134" }, - { "jcirc", "\u0135" }, - { "Jcy", "\u0419" }, - { "jcy", "\u0439" }, - { "Jfr", "\uD835\uDD0D" }, - { "jfr", "\uD835\uDD27" }, - { "jmath", "\u0237" }, - { "Jopf", "\uD835\uDD41" }, - { "jopf", "\uD835\uDD5B" }, - { "Jscr", "\uD835\uDCA5" }, - { "jscr", "\uD835\uDCBF" }, - { "Jsercy", "\u0408" }, - { "jsercy", "\u0458" }, - { "Jukcy", "\u0404" }, - { "jukcy", "\u0454" }, - { "Kappa", "\u039A" }, - { "kappa", "\u03BA" }, - { "kappav", "\u03F0" }, - { "Kcedil", "\u0136" }, - { "kcedil", "\u0137" }, - { "Kcy", "\u041A" }, - { "kcy", "\u043A" }, - { "Kfr", "\uD835\uDD0E" }, - { "kfr", "\uD835\uDD28" }, - { "kgreen", "\u0138" }, - { "KHcy", "\u0425" }, - { "khcy", "\u0445" }, - { "KJcy", "\u040C" }, - { "kjcy", "\u045C" }, - { "Kopf", "\uD835\uDD42" }, - { "kopf", "\uD835\uDD5C" }, - { "Kscr", "\uD835\uDCA6" }, - { "kscr", "\uD835\uDCC0" }, - { "lAarr", "\u21DA" }, - { "Lacute", "\u0139" }, - { "lacute", "\u013A" }, - { "laemptyv", "\u29B4" }, - { "lagran", "\u2112" }, - { "Lambda", "\u039B" }, - { "lambda", "\u03BB" }, - { "Lang", "\u27EA" }, - { "lang", "\u27E8" }, - { "langd", "\u2991" }, - { "langle", "\u27E8" }, - { "lap", "\u2A85" }, - { "Laplacetrf", "\u2112" }, - { "laquo", "\u00AB" }, - { "Larr", "\u219E" }, - { "lArr", "\u21D0" }, - { "larr", "\u2190" }, - { "larrb", "\u21E4" }, - { "larrbfs", "\u291F" }, - { "larrfs", "\u291D" }, - { "larrhk", "\u21A9" }, - { "larrlp", "\u21AB" }, - { "larrpl", "\u2939" }, - { "larrsim", "\u2973" }, - { "larrtl", "\u21A2" }, - { "lat", "\u2AAB" }, - { "lAtail", "\u291B" }, - { "latail", "\u2919" }, - { "late", "\u2AAD" }, - { "lates", "\u2AAD\uFE00" }, - { "lBarr", "\u290E" }, - { "lbarr", "\u290C" }, - { "lbbrk", "\u2772" }, - { "lbrace", "\u007B" }, - { "lbrack", "\u005B" }, - { "lbrke", "\u298B" }, - { "lbrksld", "\u298F" }, - { "lbrkslu", "\u298D" }, - { "Lcaron", "\u013D" }, - { "lcaron", "\u013E" }, - { "Lcedil", "\u013B" }, - { "lcedil", "\u013C" }, - { "lceil", "\u2308" }, - { "lcub", "\u007B" }, - { "Lcy", "\u041B" }, - { "lcy", "\u043B" }, - { "ldca", "\u2936" }, - { "ldquo", "\u201C" }, - { "ldquor", "\u201E" }, - { "ldrdhar", "\u2967" }, - { "ldrushar", "\u294B" }, - { "ldsh", "\u21B2" }, - { "lE", "\u2266" }, - { "le", "\u2264" }, - { "LeftAngleBracket", "\u27E8" }, - { "LeftArrow", "\u2190" }, - { "Leftarrow", "\u21D0" }, - { "leftarrow", "\u2190" }, - { "LeftArrowBar", "\u21E4" }, - { "LeftArrowRightArrow", "\u21C6" }, - { "leftarrowtail", "\u21A2" }, - { "LeftCeiling", "\u2308" }, - { "LeftDoubleBracket", "\u27E6" }, - { "LeftDownTeeVector", "\u2961" }, - { "LeftDownVector", "\u21C3" }, - { "LeftDownVectorBar", "\u2959" }, - { "LeftFloor", "\u230A" }, - { "leftharpoondown", "\u21BD" }, - { "leftharpoonup", "\u21BC" }, - { "leftleftarrows", "\u21C7" }, - { "LeftRightArrow", "\u2194" }, - { "Leftrightarrow", "\u21D4" }, - { "leftrightarrow", "\u2194" }, - { "leftrightarrows", "\u21C6" }, - { "leftrightharpoons", "\u21CB" }, - { "leftrightsquigarrow", "\u21AD" }, - { "LeftRightVector", "\u294E" }, - { "LeftTee", "\u22A3" }, - { "LeftTeeArrow", "\u21A4" }, - { "LeftTeeVector", "\u295A" }, - { "leftthreetimes", "\u22CB" }, - { "LeftTriangle", "\u22B2" }, - { "LeftTriangleBar", "\u29CF" }, - { "LeftTriangleEqual", "\u22B4" }, - { "LeftUpDownVector", "\u2951" }, - { "LeftUpTeeVector", "\u2960" }, - { "LeftUpVector", "\u21BF" }, - { "LeftUpVectorBar", "\u2958" }, - { "LeftVector", "\u21BC" }, - { "LeftVectorBar", "\u2952" }, - { "lEg", "\u2A8B" }, - { "leg", "\u22DA" }, - { "leq", "\u2264" }, - { "leqq", "\u2266" }, - { "leqslant", "\u2A7D" }, - { "les", "\u2A7D" }, - { "lescc", "\u2AA8" }, - { "lesdot", "\u2A7F" }, - { "lesdoto", "\u2A81" }, - { "lesdotor", "\u2A83" }, - { "lesg", "\u22DA\uFE00" }, - { "lesges", "\u2A93" }, - { "lessapprox", "\u2A85" }, - { "lessdot", "\u22D6" }, - { "lesseqgtr", "\u22DA" }, - { "lesseqqgtr", "\u2A8B" }, - { "LessEqualGreater", "\u22DA" }, - { "LessFullEqual", "\u2266" }, - { "LessGreater", "\u2276" }, - { "lessgtr", "\u2276" }, - { "LessLess", "\u2AA1" }, - { "lesssim", "\u2272" }, - { "LessSlantEqual", "\u2A7D" }, - { "LessTilde", "\u2272" }, - { "lfisht", "\u297C" }, - { "lfloor", "\u230A" }, - { "Lfr", "\uD835\uDD0F" }, - { "lfr", "\uD835\uDD29" }, - { "lg", "\u2276" }, - { "lgE", "\u2A91" }, - { "lHar", "\u2962" }, - { "lhard", "\u21BD" }, - { "lharu", "\u21BC" }, - { "lharul", "\u296A" }, - { "lhblk", "\u2584" }, - { "LJcy", "\u0409" }, - { "ljcy", "\u0459" }, - { "Ll", "\u22D8" }, - { "ll", "\u226A" }, - { "llarr", "\u21C7" }, - { "llcorner", "\u231E" }, - { "Lleftarrow", "\u21DA" }, - { "llhard", "\u296B" }, - { "lltri", "\u25FA" }, - { "Lmidot", "\u013F" }, - { "lmidot", "\u0140" }, - { "lmoust", "\u23B0" }, - { "lmoustache", "\u23B0" }, - { "lnap", "\u2A89" }, - { "lnapprox", "\u2A89" }, - { "lnE", "\u2268" }, - { "lne", "\u2A87" }, - { "lneq", "\u2A87" }, - { "lneqq", "\u2268" }, - { "lnsim", "\u22E6" }, - { "loang", "\u27EC" }, - { "loarr", "\u21FD" }, - { "lobrk", "\u27E6" }, - { "LongLeftArrow", "\u27F5" }, - { "Longleftarrow", "\u27F8" }, - { "longleftarrow", "\u27F5" }, - { "LongLeftRightArrow", "\u27F7" }, - { "Longleftrightarrow", "\u27FA" }, - { "longleftrightarrow", "\u27F7" }, - { "longmapsto", "\u27FC" }, - { "LongRightArrow", "\u27F6" }, - { "Longrightarrow", "\u27F9" }, - { "longrightarrow", "\u27F6" }, - { "looparrowleft", "\u21AB" }, - { "looparrowright", "\u21AC" }, - { "lopar", "\u2985" }, - { "Lopf", "\uD835\uDD43" }, - { "lopf", "\uD835\uDD5D" }, - { "loplus", "\u2A2D" }, - { "lotimes", "\u2A34" }, - { "lowast", "\u2217" }, - { "lowbar", "\u005F" }, - { "LowerLeftArrow", "\u2199" }, - { "LowerRightArrow", "\u2198" }, - { "loz", "\u25CA" }, - { "lozenge", "\u25CA" }, - { "lozf", "\u29EB" }, - { "lpar", "\u0028" }, - { "lparlt", "\u2993" }, - { "lrarr", "\u21C6" }, - { "lrcorner", "\u231F" }, - { "lrhar", "\u21CB" }, - { "lrhard", "\u296D" }, - { "lrm", "\u200E" }, - { "lrtri", "\u22BF" }, - { "lsaquo", "\u2039" }, - { "Lscr", "\u2112" }, - { "lscr", "\uD835\uDCC1" }, - { "Lsh", "\u21B0" }, - { "lsh", "\u21B0" }, - { "lsim", "\u2272" }, - { "lsime", "\u2A8D" }, - { "lsimg", "\u2A8F" }, - { "lsqb", "\u005B" }, - { "lsquo", "\u2018" }, - { "lsquor", "\u201A" }, - { "Lstrok", "\u0141" }, - { "lstrok", "\u0142" }, - { "LT", "\u003C" }, - { "Lt", "\u226A" }, - { "lt", "\u003C" }, - { "ltcc", "\u2AA6" }, - { "ltcir", "\u2A79" }, - { "ltdot", "\u22D6" }, - { "lthree", "\u22CB" }, - { "ltimes", "\u22C9" }, - { "ltlarr", "\u2976" }, - { "ltquest", "\u2A7B" }, - { "ltri", "\u25C3" }, - { "ltrie", "\u22B4" }, - { "ltrif", "\u25C2" }, - { "ltrPar", "\u2996" }, - { "lurdshar", "\u294A" }, - { "luruhar", "\u2966" }, - { "lvertneqq", "\u2268\uFE00" }, - { "lvnE", "\u2268\uFE00" }, - { "macr", "\u00AF" }, - { "male", "\u2642" }, - { "malt", "\u2720" }, - { "maltese", "\u2720" }, - { "Map", "\u2905" }, - { "map", "\u21A6" }, - { "mapsto", "\u21A6" }, - { "mapstodown", "\u21A7" }, - { "mapstoleft", "\u21A4" }, - { "mapstoup", "\u21A5" }, - { "marker", "\u25AE" }, - { "mcomma", "\u2A29" }, - { "Mcy", "\u041C" }, - { "mcy", "\u043C" }, - { "mdash", "\u2014" }, - { "mDDot", "\u223A" }, - { "measuredangle", "\u2221" }, - { "MediumSpace", "\u205F" }, - { "Mellintrf", "\u2133" }, - { "Mfr", "\uD835\uDD10" }, - { "mfr", "\uD835\uDD2A" }, - { "mho", "\u2127" }, - { "micro", "\u00B5" }, - { "mid", "\u2223" }, - { "midast", "\u002A" }, - { "midcir", "\u2AF0" }, - { "middot", "\u00B7" }, - { "minus", "\u2212" }, - { "minusb", "\u229F" }, - { "minusd", "\u2238" }, - { "minusdu", "\u2A2A" }, - { "MinusPlus", "\u2213" }, - { "mlcp", "\u2ADB" }, - { "mldr", "\u2026" }, - { "mnplus", "\u2213" }, - { "models", "\u22A7" }, - { "Mopf", "\uD835\uDD44" }, - { "mopf", "\uD835\uDD5E" }, - { "mp", "\u2213" }, - { "Mscr", "\u2133" }, - { "mscr", "\uD835\uDCC2" }, - { "mstpos", "\u223E" }, - { "Mu", "\u039C" }, - { "mu", "\u03BC" }, - { "multimap", "\u22B8" }, - { "mumap", "\u22B8" }, - { "nabla", "\u2207" }, - { "Nacute", "\u0143" }, - { "nacute", "\u0144" }, - { "nang", "\u2220\u20D2" }, - { "nap", "\u2249" }, - { "napE", "\u2A70\u0338" }, - { "napid", "\u224B\u0338" }, - { "napos", "\u0149" }, - { "napprox", "\u2249" }, - { "natur", "\u266E" }, - { "natural", "\u266E" }, - { "naturals", "\u2115" }, - { "nbsp", "\u00A0" }, - { "nbump", "\u224E\u0338" }, - { "nbumpe", "\u224F\u0338" }, - { "ncap", "\u2A43" }, - { "Ncaron", "\u0147" }, - { "ncaron", "\u0148" }, - { "Ncedil", "\u0145" }, - { "ncedil", "\u0146" }, - { "ncong", "\u2247" }, - { "ncongdot", "\u2A6D\u0338" }, - { "ncup", "\u2A42" }, - { "Ncy", "\u041D" }, - { "ncy", "\u043D" }, - { "ndash", "\u2013" }, - { "ne", "\u2260" }, - { "nearhk", "\u2924" }, - { "neArr", "\u21D7" }, - { "nearr", "\u2197" }, - { "nearrow", "\u2197" }, - { "nedot", "\u2250\u0338" }, - { "NegativeMediumSpace", "\u200B" }, - { "NegativeThickSpace", "\u200B" }, - { "NegativeThinSpace", "\u200B" }, - { "NegativeVeryThinSpace", "\u200B" }, - { "nequiv", "\u2262" }, - { "nesear", "\u2928" }, - { "nesim", "\u2242\u0338" }, - { "NestedGreaterGreater", "\u226B" }, - { "NestedLessLess", "\u226A" }, - { "NewLine", "\u000A" }, - { "nexist", "\u2204" }, - { "nexists", "\u2204" }, - { "Nfr", "\uD835\uDD11" }, - { "nfr", "\uD835\uDD2B" }, - { "ngE", "\u2267\u0338" }, - { "nge", "\u2271" }, - { "ngeq", "\u2271" }, - { "ngeqq", "\u2267\u0338" }, - { "ngeqslant", "\u2A7E\u0338" }, - { "nges", "\u2A7E\u0338" }, - { "nGg", "\u22D9\u0338" }, - { "ngsim", "\u2275" }, - { "nGt", "\u226B\u20D2" }, - { "ngt", "\u226F" }, - { "ngtr", "\u226F" }, - { "nGtv", "\u226B\u0338" }, - { "nhArr", "\u21CE" }, - { "nharr", "\u21AE" }, - { "nhpar", "\u2AF2" }, - { "ni", "\u220B" }, - { "nis", "\u22FC" }, - { "nisd", "\u22FA" }, - { "niv", "\u220B" }, - { "NJcy", "\u040A" }, - { "njcy", "\u045A" }, - { "nlArr", "\u21CD" }, - { "nlarr", "\u219A" }, - { "nldr", "\u2025" }, - { "nlE", "\u2266\u0338" }, - { "nle", "\u2270" }, - { "nLeftarrow", "\u21CD" }, - { "nleftarrow", "\u219A" }, - { "nLeftrightarrow", "\u21CE" }, - { "nleftrightarrow", "\u21AE" }, - { "nleq", "\u2270" }, - { "nleqq", "\u2266\u0338" }, - { "nleqslant", "\u2A7D\u0338" }, - { "nles", "\u2A7D\u0338" }, - { "nless", "\u226E" }, - { "nLl", "\u22D8\u0338" }, - { "nlsim", "\u2274" }, - { "nLt", "\u226A\u20D2" }, - { "nlt", "\u226E" }, - { "nltri", "\u22EA" }, - { "nltrie", "\u22EC" }, - { "nLtv", "\u226A\u0338" }, - { "nmid", "\u2224" }, - { "NoBreak", "\u2060" }, - { "NonBreakingSpace", "\u00A0" }, - { "Nopf", "\u2115" }, - { "nopf", "\uD835\uDD5F" }, - { "Not", "\u2AEC" }, - { "not", "\u00AC" }, - { "NotCongruent", "\u2262" }, - { "NotCupCap", "\u226D" }, - { "NotDoubleVerticalBar", "\u2226" }, - { "NotElement", "\u2209" }, - { "NotEqual", "\u2260" }, - { "NotEqualTilde", "\u2242\u0338" }, - { "NotExists", "\u2204" }, - { "NotGreater", "\u226F" }, - { "NotGreaterEqual", "\u2271" }, - { "NotGreaterFullEqual", "\u2267\u0338" }, - { "NotGreaterGreater", "\u226B\u0338" }, - { "NotGreaterLess", "\u2279" }, - { "NotGreaterSlantEqual", "\u2A7E\u0338" }, - { "NotGreaterTilde", "\u2275" }, - { "NotHumpDownHump", "\u224E\u0338" }, - { "NotHumpEqual", "\u224F\u0338" }, - { "notin", "\u2209" }, - { "notindot", "\u22F5\u0338" }, - { "notinE", "\u22F9\u0338" }, - { "notinva", "\u2209" }, - { "notinvb", "\u22F7" }, - { "notinvc", "\u22F6" }, - { "NotLeftTriangle", "\u22EA" }, - { "NotLeftTriangleBar", "\u29CF\u0338" }, - { "NotLeftTriangleEqual", "\u22EC" }, - { "NotLess", "\u226E" }, - { "NotLessEqual", "\u2270" }, - { "NotLessGreater", "\u2278" }, - { "NotLessLess", "\u226A\u0338" }, - { "NotLessSlantEqual", "\u2A7D\u0338" }, - { "NotLessTilde", "\u2274" }, - { "NotNestedGreaterGreater", "\u2AA2\u0338" }, - { "NotNestedLessLess", "\u2AA1\u0338" }, - { "notni", "\u220C" }, - { "notniva", "\u220C" }, - { "notnivb", "\u22FE" }, - { "notnivc", "\u22FD" }, - { "NotPrecedes", "\u2280" }, - { "NotPrecedesEqual", "\u2AAF\u0338" }, - { "NotPrecedesSlantEqual", "\u22E0" }, - { "NotReverseElement", "\u220C" }, - { "NotRightTriangle", "\u22EB" }, - { "NotRightTriangleBar", "\u29D0\u0338" }, - { "NotRightTriangleEqual", "\u22ED" }, - { "NotSquareSubset", "\u228F\u0338" }, - { "NotSquareSubsetEqual", "\u22E2" }, - { "NotSquareSuperset", "\u2290\u0338" }, - { "NotSquareSupersetEqual", "\u22E3" }, - { "NotSubset", "\u2282\u20D2" }, - { "NotSubsetEqual", "\u2288" }, - { "NotSucceeds", "\u2281" }, - { "NotSucceedsEqual", "\u2AB0\u0338" }, - { "NotSucceedsSlantEqual", "\u22E1" }, - { "NotSucceedsTilde", "\u227F\u0338" }, - { "NotSuperset", "\u2283\u20D2" }, - { "NotSupersetEqual", "\u2289" }, - { "NotTilde", "\u2241" }, - { "NotTildeEqual", "\u2244" }, - { "NotTildeFullEqual", "\u2247" }, - { "NotTildeTilde", "\u2249" }, - { "NotVerticalBar", "\u2224" }, - { "npar", "\u2226" }, - { "nparallel", "\u2226" }, - { "nparsl", "\u2AFD\u20E5" }, - { "npart", "\u2202\u0338" }, - { "npolint", "\u2A14" }, - { "npr", "\u2280" }, - { "nprcue", "\u22E0" }, - { "npre", "\u2AAF\u0338" }, - { "nprec", "\u2280" }, - { "npreceq", "\u2AAF\u0338" }, - { "nrArr", "\u21CF" }, - { "nrarr", "\u219B" }, - { "nrarrc", "\u2933\u0338" }, - { "nrarrw", "\u219D\u0338" }, - { "nRightarrow", "\u21CF" }, - { "nrightarrow", "\u219B" }, - { "nrtri", "\u22EB" }, - { "nrtrie", "\u22ED" }, - { "nsc", "\u2281" }, - { "nsccue", "\u22E1" }, - { "nsce", "\u2AB0\u0338" }, - { "Nscr", "\uD835\uDCA9" }, - { "nscr", "\uD835\uDCC3" }, - { "nshortmid", "\u2224" }, - { "nshortparallel", "\u2226" }, - { "nsim", "\u2241" }, - { "nsime", "\u2244" }, - { "nsimeq", "\u2244" }, - { "nsmid", "\u2224" }, - { "nspar", "\u2226" }, - { "nsqsube", "\u22E2" }, - { "nsqsupe", "\u22E3" }, - { "nsub", "\u2284" }, - { "nsubE", "\u2AC5\u0338" }, - { "nsube", "\u2288" }, - { "nsubset", "\u2282\u20D2" }, - { "nsubseteq", "\u2288" }, - { "nsubseteqq", "\u2AC5\u0338" }, - { "nsucc", "\u2281" }, - { "nsucceq", "\u2AB0\u0338" }, - { "nsup", "\u2285" }, - { "nsupE", "\u2AC6\u0338" }, - { "nsupe", "\u2289" }, - { "nsupset", "\u2283\u20D2" }, - { "nsupseteq", "\u2289" }, - { "nsupseteqq", "\u2AC6\u0338" }, - { "ntgl", "\u2279" }, - { "Ntilde", "\u00D1" }, - { "ntilde", "\u00F1" }, - { "ntlg", "\u2278" }, - { "ntriangleleft", "\u22EA" }, - { "ntrianglelefteq", "\u22EC" }, - { "ntriangleright", "\u22EB" }, - { "ntrianglerighteq", "\u22ED" }, - { "Nu", "\u039D" }, - { "nu", "\u03BD" }, - { "num", "\u0023" }, - { "numero", "\u2116" }, - { "numsp", "\u2007" }, - { "nvap", "\u224D\u20D2" }, - { "nVDash", "\u22AF" }, - { "nVdash", "\u22AE" }, - { "nvDash", "\u22AD" }, - { "nvdash", "\u22AC" }, - { "nvge", "\u2265\u20D2" }, - { "nvgt", "\u003E\u20D2" }, - { "nvHarr", "\u2904" }, - { "nvinfin", "\u29DE" }, - { "nvlArr", "\u2902" }, - { "nvle", "\u2264\u20D2" }, - { "nvlt", "\u003C\u20D2" }, - { "nvltrie", "\u22B4\u20D2" }, - { "nvrArr", "\u2903" }, - { "nvrtrie", "\u22B5\u20D2" }, - { "nvsim", "\u223C\u20D2" }, - { "nwarhk", "\u2923" }, - { "nwArr", "\u21D6" }, - { "nwarr", "\u2196" }, - { "nwarrow", "\u2196" }, - { "nwnear", "\u2927" }, - { "Oacute", "\u00D3" }, - { "oacute", "\u00F3" }, - { "oast", "\u229B" }, - { "ocir", "\u229A" }, - { "Ocirc", "\u00D4" }, - { "ocirc", "\u00F4" }, - { "Ocy", "\u041E" }, - { "ocy", "\u043E" }, - { "odash", "\u229D" }, - { "Odblac", "\u0150" }, - { "odblac", "\u0151" }, - { "odiv", "\u2A38" }, - { "odot", "\u2299" }, - { "odsold", "\u29BC" }, - { "OElig", "\u0152" }, - { "oelig", "\u0153" }, - { "ofcir", "\u29BF" }, - { "Ofr", "\uD835\uDD12" }, - { "ofr", "\uD835\uDD2C" }, - { "ogon", "\u02DB" }, - { "Ograve", "\u00D2" }, - { "ograve", "\u00F2" }, - { "ogt", "\u29C1" }, - { "ohbar", "\u29B5" }, - { "ohm", "\u03A9" }, - { "oint", "\u222E" }, - { "olarr", "\u21BA" }, - { "olcir", "\u29BE" }, - { "olcross", "\u29BB" }, - { "oline", "\u203E" }, - { "olt", "\u29C0" }, - { "Omacr", "\u014C" }, - { "omacr", "\u014D" }, - { "Omega", "\u03A9" }, - { "omega", "\u03C9" }, - { "Omicron", "\u039F" }, - { "omicron", "\u03BF" }, - { "omid", "\u29B6" }, - { "ominus", "\u2296" }, - { "Oopf", "\uD835\uDD46" }, - { "oopf", "\uD835\uDD60" }, - { "opar", "\u29B7" }, - { "OpenCurlyDoubleQuote", "\u201C" }, - { "OpenCurlyQuote", "\u2018" }, - { "operp", "\u29B9" }, - { "oplus", "\u2295" }, - { "Or", "\u2A54" }, - { "or", "\u2228" }, - { "orarr", "\u21BB" }, - { "ord", "\u2A5D" }, - { "order", "\u2134" }, - { "orderof", "\u2134" }, - { "ordf", "\u00AA" }, - { "ordm", "\u00BA" }, - { "origof", "\u22B6" }, - { "oror", "\u2A56" }, - { "orslope", "\u2A57" }, - { "orv", "\u2A5B" }, - { "oS", "\u24C8" }, - { "Oscr", "\uD835\uDCAA" }, - { "oscr", "\u2134" }, - { "Oslash", "\u00D8" }, - { "oslash", "\u00F8" }, - { "osol", "\u2298" }, - { "Otilde", "\u00D5" }, - { "otilde", "\u00F5" }, - { "Otimes", "\u2A37" }, - { "otimes", "\u2297" }, - { "otimesas", "\u2A36" }, - { "Ouml", "\u00D6" }, - { "ouml", "\u00F6" }, - { "ovbar", "\u233D" }, - { "OverBar", "\u203E" }, - { "OverBrace", "\u23DE" }, - { "OverBracket", "\u23B4" }, - { "OverParenthesis", "\u23DC" }, - { "par", "\u2225" }, - { "para", "\u00B6" }, - { "parallel", "\u2225" }, - { "parsim", "\u2AF3" }, - { "parsl", "\u2AFD" }, - { "part", "\u2202" }, - { "PartialD", "\u2202" }, - { "Pcy", "\u041F" }, - { "pcy", "\u043F" }, - { "percnt", "\u0025" }, - { "period", "\u002E" }, - { "permil", "\u2030" }, - { "perp", "\u22A5" }, - { "pertenk", "\u2031" }, - { "Pfr", "\uD835\uDD13" }, - { "pfr", "\uD835\uDD2D" }, - { "Phi", "\u03A6" }, - { "phi", "\u03C6" }, - { "phiv", "\u03D5" }, - { "phmmat", "\u2133" }, - { "phone", "\u260E" }, - { "Pi", "\u03A0" }, - { "pi", "\u03C0" }, - { "pitchfork", "\u22D4" }, - { "piv", "\u03D6" }, - { "planck", "\u210F" }, - { "planckh", "\u210E" }, - { "plankv", "\u210F" }, - { "plus", "\u002B" }, - { "plusacir", "\u2A23" }, - { "plusb", "\u229E" }, - { "pluscir", "\u2A22" }, - { "plusdo", "\u2214" }, - { "plusdu", "\u2A25" }, - { "pluse", "\u2A72" }, - { "PlusMinus", "\u00B1" }, - { "plusmn", "\u00B1" }, - { "plussim", "\u2A26" }, - { "plustwo", "\u2A27" }, - { "pm", "\u00B1" }, - { "Poincareplane", "\u210C" }, - { "pointint", "\u2A15" }, - { "Popf", "\u2119" }, - { "popf", "\uD835\uDD61" }, - { "pound", "\u00A3" }, - { "Pr", "\u2ABB" }, - { "pr", "\u227A" }, - { "prap", "\u2AB7" }, - { "prcue", "\u227C" }, - { "prE", "\u2AB3" }, - { "pre", "\u2AAF" }, - { "prec", "\u227A" }, - { "precapprox", "\u2AB7" }, - { "preccurlyeq", "\u227C" }, - { "Precedes", "\u227A" }, - { "PrecedesEqual", "\u2AAF" }, - { "PrecedesSlantEqual", "\u227C" }, - { "PrecedesTilde", "\u227E" }, - { "preceq", "\u2AAF" }, - { "precnapprox", "\u2AB9" }, - { "precneqq", "\u2AB5" }, - { "precnsim", "\u22E8" }, - { "precsim", "\u227E" }, - { "Prime", "\u2033" }, - { "prime", "\u2032" }, - { "primes", "\u2119" }, - { "prnap", "\u2AB9" }, - { "prnE", "\u2AB5" }, - { "prnsim", "\u22E8" }, - { "prod", "\u220F" }, - { "Product", "\u220F" }, - { "profalar", "\u232E" }, - { "profline", "\u2312" }, - { "profsurf", "\u2313" }, - { "prop", "\u221D" }, - { "Proportion", "\u2237" }, - { "Proportional", "\u221D" }, - { "propto", "\u221D" }, - { "prsim", "\u227E" }, - { "prurel", "\u22B0" }, - { "Pscr", "\uD835\uDCAB" }, - { "pscr", "\uD835\uDCC5" }, - { "Psi", "\u03A8" }, - { "psi", "\u03C8" }, - { "puncsp", "\u2008" }, - { "Qfr", "\uD835\uDD14" }, - { "qfr", "\uD835\uDD2E" }, - { "qint", "\u2A0C" }, - { "Qopf", "\u211A" }, - { "qopf", "\uD835\uDD62" }, - { "qprime", "\u2057" }, - { "Qscr", "\uD835\uDCAC" }, - { "qscr", "\uD835\uDCC6" }, - { "quaternions", "\u210D" }, - { "quatint", "\u2A16" }, - { "quest", "\u003F" }, - { "questeq", "\u225F" }, - { "QUOT", "\u0022" }, - { "quot", "\u0022" }, - { "rAarr", "\u21DB" }, - { "race", "\u223D\u0331" }, - { "Racute", "\u0154" }, - { "racute", "\u0155" }, - { "radic", "\u221A" }, - { "raemptyv", "\u29B3" }, - { "Rang", "\u27EB" }, - { "rang", "\u27E9" }, - { "rangd", "\u2992" }, - { "range", "\u29A5" }, - { "rangle", "\u27E9" }, - { "raquo", "\u00BB" }, - { "Rarr", "\u21A0" }, - { "rArr", "\u21D2" }, - { "rarr", "\u2192" }, - { "rarrap", "\u2975" }, - { "rarrb", "\u21E5" }, - { "rarrbfs", "\u2920" }, - { "rarrc", "\u2933" }, - { "rarrfs", "\u291E" }, - { "rarrhk", "\u21AA" }, - { "rarrlp", "\u21AC" }, - { "rarrpl", "\u2945" }, - { "rarrsim", "\u2974" }, - { "Rarrtl", "\u2916" }, - { "rarrtl", "\u21A3" }, - { "rarrw", "\u219D" }, - { "rAtail", "\u291C" }, - { "ratail", "\u291A" }, - { "ratio", "\u2236" }, - { "rationals", "\u211A" }, - { "RBarr", "\u2910" }, - { "rBarr", "\u290F" }, - { "rbarr", "\u290D" }, - { "rbbrk", "\u2773" }, - { "rbrace", "\u007D" }, - { "rbrack", "\u005D" }, - { "rbrke", "\u298C" }, - { "rbrksld", "\u298E" }, - { "rbrkslu", "\u2990" }, - { "Rcaron", "\u0158" }, - { "rcaron", "\u0159" }, - { "Rcedil", "\u0156" }, - { "rcedil", "\u0157" }, - { "rceil", "\u2309" }, - { "rcub", "\u007D" }, - { "Rcy", "\u0420" }, - { "rcy", "\u0440" }, - { "rdca", "\u2937" }, - { "rdldhar", "\u2969" }, - { "rdquo", "\u201D" }, - { "rdquor", "\u201D" }, - { "rdsh", "\u21B3" }, - { "Re", "\u211C" }, - { "real", "\u211C" }, - { "realine", "\u211B" }, - { "realpart", "\u211C" }, - { "reals", "\u211D" }, - { "rect", "\u25AD" }, - { "REG", "\u00AE" }, - { "reg", "\u00AE" }, - { "ReverseElement", "\u220B" }, - { "ReverseEquilibrium", "\u21CB" }, - { "ReverseUpEquilibrium", "\u296F" }, - { "rfisht", "\u297D" }, - { "rfloor", "\u230B" }, - { "Rfr", "\u211C" }, - { "rfr", "\uD835\uDD2F" }, - { "rHar", "\u2964" }, - { "rhard", "\u21C1" }, - { "rharu", "\u21C0" }, - { "rharul", "\u296C" }, - { "Rho", "\u03A1" }, - { "rho", "\u03C1" }, - { "rhov", "\u03F1" }, - { "RightAngleBracket", "\u27E9" }, - { "RightArrow", "\u2192" }, - { "Rightarrow", "\u21D2" }, - { "rightarrow", "\u2192" }, - { "RightArrowBar", "\u21E5" }, - { "RightArrowLeftArrow", "\u21C4" }, - { "rightarrowtail", "\u21A3" }, - { "RightCeiling", "\u2309" }, - { "RightDoubleBracket", "\u27E7" }, - { "RightDownTeeVector", "\u295D" }, - { "RightDownVector", "\u21C2" }, - { "RightDownVectorBar", "\u2955" }, - { "RightFloor", "\u230B" }, - { "rightharpoondown", "\u21C1" }, - { "rightharpoonup", "\u21C0" }, - { "rightleftarrows", "\u21C4" }, - { "rightleftharpoons", "\u21CC" }, - { "rightrightarrows", "\u21C9" }, - { "rightsquigarrow", "\u219D" }, - { "RightTee", "\u22A2" }, - { "RightTeeArrow", "\u21A6" }, - { "RightTeeVector", "\u295B" }, - { "rightthreetimes", "\u22CC" }, - { "RightTriangle", "\u22B3" }, - { "RightTriangleBar", "\u29D0" }, - { "RightTriangleEqual", "\u22B5" }, - { "RightUpDownVector", "\u294F" }, - { "RightUpTeeVector", "\u295C" }, - { "RightUpVector", "\u21BE" }, - { "RightUpVectorBar", "\u2954" }, - { "RightVector", "\u21C0" }, - { "RightVectorBar", "\u2953" }, - { "ring", "\u02DA" }, - { "risingdotseq", "\u2253" }, - { "rlarr", "\u21C4" }, - { "rlhar", "\u21CC" }, - { "rlm", "\u200F" }, - { "rmoust", "\u23B1" }, - { "rmoustache", "\u23B1" }, - { "rnmid", "\u2AEE" }, - { "roang", "\u27ED" }, - { "roarr", "\u21FE" }, - { "robrk", "\u27E7" }, - { "ropar", "\u2986" }, - { "Ropf", "\u211D" }, - { "ropf", "\uD835\uDD63" }, - { "roplus", "\u2A2E" }, - { "rotimes", "\u2A35" }, - { "RoundImplies", "\u2970" }, - { "rpar", "\u0029" }, - { "rpargt", "\u2994" }, - { "rppolint", "\u2A12" }, - { "rrarr", "\u21C9" }, - { "Rrightarrow", "\u21DB" }, - { "rsaquo", "\u203A" }, - { "Rscr", "\u211B" }, - { "rscr", "\uD835\uDCC7" }, - { "Rsh", "\u21B1" }, - { "rsh", "\u21B1" }, - { "rsqb", "\u005D" }, - { "rsquo", "\u2019" }, - { "rsquor", "\u2019" }, - { "rthree", "\u22CC" }, - { "rtimes", "\u22CA" }, - { "rtri", "\u25B9" }, - { "rtrie", "\u22B5" }, - { "rtrif", "\u25B8" }, - { "rtriltri", "\u29CE" }, - { "RuleDelayed", "\u29F4" }, - { "ruluhar", "\u2968" }, - { "rx", "\u211E" }, - { "Sacute", "\u015A" }, - { "sacute", "\u015B" }, - { "sbquo", "\u201A" }, - { "Sc", "\u2ABC" }, - { "sc", "\u227B" }, - { "scap", "\u2AB8" }, - { "Scaron", "\u0160" }, - { "scaron", "\u0161" }, - { "sccue", "\u227D" }, - { "scE", "\u2AB4" }, - { "sce", "\u2AB0" }, - { "Scedil", "\u015E" }, - { "scedil", "\u015F" }, - { "Scirc", "\u015C" }, - { "scirc", "\u015D" }, - { "scnap", "\u2ABA" }, - { "scnE", "\u2AB6" }, - { "scnsim", "\u22E9" }, - { "scpolint", "\u2A13" }, - { "scsim", "\u227F" }, - { "Scy", "\u0421" }, - { "scy", "\u0441" }, - { "sdot", "\u22C5" }, - { "sdotb", "\u22A1" }, - { "sdote", "\u2A66" }, - { "searhk", "\u2925" }, - { "seArr", "\u21D8" }, - { "searr", "\u2198" }, - { "searrow", "\u2198" }, - { "sect", "\u00A7" }, - { "semi", "\u003B" }, - { "seswar", "\u2929" }, - { "setminus", "\u2216" }, - { "setmn", "\u2216" }, - { "sext", "\u2736" }, - { "Sfr", "\uD835\uDD16" }, - { "sfr", "\uD835\uDD30" }, - { "sfrown", "\u2322" }, - { "sharp", "\u266F" }, - { "SHCHcy", "\u0429" }, - { "shchcy", "\u0449" }, - { "SHcy", "\u0428" }, - { "shcy", "\u0448" }, - { "ShortDownArrow", "\u2193" }, - { "ShortLeftArrow", "\u2190" }, - { "shortmid", "\u2223" }, - { "shortparallel", "\u2225" }, - { "ShortRightArrow", "\u2192" }, - { "ShortUpArrow", "\u2191" }, - { "shy", "\u00AD" }, - { "Sigma", "\u03A3" }, - { "sigma", "\u03C3" }, - { "sigmaf", "\u03C2" }, - { "sigmav", "\u03C2" }, - { "sim", "\u223C" }, - { "simdot", "\u2A6A" }, - { "sime", "\u2243" }, - { "simeq", "\u2243" }, - { "simg", "\u2A9E" }, - { "simgE", "\u2AA0" }, - { "siml", "\u2A9D" }, - { "simlE", "\u2A9F" }, - { "simne", "\u2246" }, - { "simplus", "\u2A24" }, - { "simrarr", "\u2972" }, - { "slarr", "\u2190" }, - { "SmallCircle", "\u2218" }, - { "smallsetminus", "\u2216" }, - { "smashp", "\u2A33" }, - { "smeparsl", "\u29E4" }, - { "smid", "\u2223" }, - { "smile", "\u2323" }, - { "smt", "\u2AAA" }, - { "smte", "\u2AAC" }, - { "smtes", "\u2AAC\uFE00" }, - { "SOFTcy", "\u042C" }, - { "softcy", "\u044C" }, - { "sol", "\u002F" }, - { "solb", "\u29C4" }, - { "solbar", "\u233F" }, - { "Sopf", "\uD835\uDD4A" }, - { "sopf", "\uD835\uDD64" }, - { "spades", "\u2660" }, - { "spadesuit", "\u2660" }, - { "spar", "\u2225" }, - { "sqcap", "\u2293" }, - { "sqcaps", "\u2293\uFE00" }, - { "sqcup", "\u2294" }, - { "sqcups", "\u2294\uFE00" }, - { "Sqrt", "\u221A" }, - { "sqsub", "\u228F" }, - { "sqsube", "\u2291" }, - { "sqsubset", "\u228F" }, - { "sqsubseteq", "\u2291" }, - { "sqsup", "\u2290" }, - { "sqsupe", "\u2292" }, - { "sqsupset", "\u2290" }, - { "sqsupseteq", "\u2292" }, - { "squ", "\u25A1" }, - { "Square", "\u25A1" }, - { "square", "\u25A1" }, - { "SquareIntersection", "\u2293" }, - { "SquareSubset", "\u228F" }, - { "SquareSubsetEqual", "\u2291" }, - { "SquareSuperset", "\u2290" }, - { "SquareSupersetEqual", "\u2292" }, - { "SquareUnion", "\u2294" }, - { "squarf", "\u25AA" }, - { "squf", "\u25AA" }, - { "srarr", "\u2192" }, - { "Sscr", "\uD835\uDCAE" }, - { "sscr", "\uD835\uDCC8" }, - { "ssetmn", "\u2216" }, - { "ssmile", "\u2323" }, - { "sstarf", "\u22C6" }, - { "Star", "\u22C6" }, - { "star", "\u2606" }, - { "starf", "\u2605" }, - { "straightepsilon", "\u03F5" }, - { "straightphi", "\u03D5" }, - { "strns", "\u00AF" }, - { "Sub", "\u22D0" }, - { "sub", "\u2282" }, - { "subdot", "\u2ABD" }, - { "subE", "\u2AC5" }, - { "sube", "\u2286" }, - { "subedot", "\u2AC3" }, - { "submult", "\u2AC1" }, - { "subnE", "\u2ACB" }, - { "subne", "\u228A" }, - { "subplus", "\u2ABF" }, - { "subrarr", "\u2979" }, - { "Subset", "\u22D0" }, - { "subset", "\u2282" }, - { "subseteq", "\u2286" }, - { "subseteqq", "\u2AC5" }, - { "SubsetEqual", "\u2286" }, - { "subsetneq", "\u228A" }, - { "subsetneqq", "\u2ACB" }, - { "subsim", "\u2AC7" }, - { "subsub", "\u2AD5" }, - { "subsup", "\u2AD3" }, - { "succ", "\u227B" }, - { "succapprox", "\u2AB8" }, - { "succcurlyeq", "\u227D" }, - { "Succeeds", "\u227B" }, - { "SucceedsEqual", "\u2AB0" }, - { "SucceedsSlantEqual", "\u227D" }, - { "SucceedsTilde", "\u227F" }, - { "succeq", "\u2AB0" }, - { "succnapprox", "\u2ABA" }, - { "succneqq", "\u2AB6" }, - { "succnsim", "\u22E9" }, - { "succsim", "\u227F" }, - { "SuchThat", "\u220B" }, - { "Sum", "\u2211" }, - { "sum", "\u2211" }, - { "sung", "\u266A" }, - { "Sup", "\u22D1" }, - { "sup", "\u2283" }, - { "sup1", "\u00B9" }, - { "sup2", "\u00B2" }, - { "sup3", "\u00B3" }, - { "supdot", "\u2ABE" }, - { "supdsub", "\u2AD8" }, - { "supE", "\u2AC6" }, - { "supe", "\u2287" }, - { "supedot", "\u2AC4" }, - { "Superset", "\u2283" }, - { "SupersetEqual", "\u2287" }, - { "suphsol", "\u27C9" }, - { "suphsub", "\u2AD7" }, - { "suplarr", "\u297B" }, - { "supmult", "\u2AC2" }, - { "supnE", "\u2ACC" }, - { "supne", "\u228B" }, - { "supplus", "\u2AC0" }, - { "Supset", "\u22D1" }, - { "supset", "\u2283" }, - { "supseteq", "\u2287" }, - { "supseteqq", "\u2AC6" }, - { "supsetneq", "\u228B" }, - { "supsetneqq", "\u2ACC" }, - { "supsim", "\u2AC8" }, - { "supsub", "\u2AD4" }, - { "supsup", "\u2AD6" }, - { "swarhk", "\u2926" }, - { "swArr", "\u21D9" }, - { "swarr", "\u2199" }, - { "swarrow", "\u2199" }, - { "swnwar", "\u292A" }, - { "szlig", "\u00DF" }, - { "Tab", "\u0009" }, - { "target", "\u2316" }, - { "Tau", "\u03A4" }, - { "tau", "\u03C4" }, - { "tbrk", "\u23B4" }, - { "Tcaron", "\u0164" }, - { "tcaron", "\u0165" }, - { "Tcedil", "\u0162" }, - { "tcedil", "\u0163" }, - { "Tcy", "\u0422" }, - { "tcy", "\u0442" }, - { "tdot", "\u20DB" }, - { "telrec", "\u2315" }, - { "Tfr", "\uD835\uDD17" }, - { "tfr", "\uD835\uDD31" }, - { "there4", "\u2234" }, - { "Therefore", "\u2234" }, - { "therefore", "\u2234" }, - { "Theta", "\u0398" }, - { "theta", "\u03B8" }, - { "thetasym", "\u03D1" }, - { "thetav", "\u03D1" }, - { "thickapprox", "\u2248" }, - { "thicksim", "\u223C" }, - { "ThickSpace", "\u205F\u200A" }, - { "thinsp", "\u2009" }, - { "ThinSpace", "\u2009" }, - { "thkap", "\u2248" }, - { "thksim", "\u223C" }, - { "THORN", "\u00DE" }, - { "thorn", "\u00FE" }, - { "Tilde", "\u223C" }, - { "tilde", "\u02DC" }, - { "TildeEqual", "\u2243" }, - { "TildeFullEqual", "\u2245" }, - { "TildeTilde", "\u2248" }, - { "times", "\u00D7" }, - { "timesb", "\u22A0" }, - { "timesbar", "\u2A31" }, - { "timesd", "\u2A30" }, - { "tint", "\u222D" }, - { "toea", "\u2928" }, - { "top", "\u22A4" }, - { "topbot", "\u2336" }, - { "topcir", "\u2AF1" }, - { "Topf", "\uD835\uDD4B" }, - { "topf", "\uD835\uDD65" }, - { "topfork", "\u2ADA" }, - { "tosa", "\u2929" }, - { "tprime", "\u2034" }, - { "TRADE", "\u2122" }, - { "trade", "\u2122" }, - { "triangle", "\u25B5" }, - { "triangledown", "\u25BF" }, - { "triangleleft", "\u25C3" }, - { "trianglelefteq", "\u22B4" }, - { "triangleq", "\u225C" }, - { "triangleright", "\u25B9" }, - { "trianglerighteq", "\u22B5" }, - { "tridot", "\u25EC" }, - { "trie", "\u225C" }, - { "triminus", "\u2A3A" }, - { "TripleDot", "\u20DB" }, - { "triplus", "\u2A39" }, - { "trisb", "\u29CD" }, - { "tritime", "\u2A3B" }, - { "trpezium", "\u23E2" }, - { "Tscr", "\uD835\uDCAF" }, - { "tscr", "\uD835\uDCC9" }, - { "TScy", "\u0426" }, - { "tscy", "\u0446" }, - { "TSHcy", "\u040B" }, - { "tshcy", "\u045B" }, - { "Tstrok", "\u0166" }, - { "tstrok", "\u0167" }, - { "twixt", "\u226C" }, - { "twoheadleftarrow", "\u219E" }, - { "twoheadrightarrow", "\u21A0" }, - { "Uacute", "\u00DA" }, - { "uacute", "\u00FA" }, - { "Uarr", "\u219F" }, - { "uArr", "\u21D1" }, - { "uarr", "\u2191" }, - { "Uarrocir", "\u2949" }, - { "Ubrcy", "\u040E" }, - { "ubrcy", "\u045E" }, - { "Ubreve", "\u016C" }, - { "ubreve", "\u016D" }, - { "Ucirc", "\u00DB" }, - { "ucirc", "\u00FB" }, - { "Ucy", "\u0423" }, - { "ucy", "\u0443" }, - { "udarr", "\u21C5" }, - { "Udblac", "\u0170" }, - { "udblac", "\u0171" }, - { "udhar", "\u296E" }, - { "ufisht", "\u297E" }, - { "Ufr", "\uD835\uDD18" }, - { "ufr", "\uD835\uDD32" }, - { "Ugrave", "\u00D9" }, - { "ugrave", "\u00F9" }, - { "uHar", "\u2963" }, - { "uharl", "\u21BF" }, - { "uharr", "\u21BE" }, - { "uhblk", "\u2580" }, - { "ulcorn", "\u231C" }, - { "ulcorner", "\u231C" }, - { "ulcrop", "\u230F" }, - { "ultri", "\u25F8" }, - { "Umacr", "\u016A" }, - { "umacr", "\u016B" }, - { "uml", "\u00A8" }, - { "UnderBar", "\u005F" }, - { "UnderBrace", "\u23DF" }, - { "UnderBracket", "\u23B5" }, - { "UnderParenthesis", "\u23DD" }, - { "Union", "\u22C3" }, - { "UnionPlus", "\u228E" }, - { "Uogon", "\u0172" }, - { "uogon", "\u0173" }, - { "Uopf", "\uD835\uDD4C" }, - { "uopf", "\uD835\uDD66" }, - { "UpArrow", "\u2191" }, - { "Uparrow", "\u21D1" }, - { "uparrow", "\u2191" }, - { "UpArrowBar", "\u2912" }, - { "UpArrowDownArrow", "\u21C5" }, - { "UpDownArrow", "\u2195" }, - { "Updownarrow", "\u21D5" }, - { "updownarrow", "\u2195" }, - { "UpEquilibrium", "\u296E" }, - { "upharpoonleft", "\u21BF" }, - { "upharpoonright", "\u21BE" }, - { "uplus", "\u228E" }, - { "UpperLeftArrow", "\u2196" }, - { "UpperRightArrow", "\u2197" }, - { "Upsi", "\u03D2" }, - { "upsi", "\u03C5" }, - { "upsih", "\u03D2" }, - { "Upsilon", "\u03A5" }, - { "upsilon", "\u03C5" }, - { "UpTee", "\u22A5" }, - { "UpTeeArrow", "\u21A5" }, - { "upuparrows", "\u21C8" }, - { "urcorn", "\u231D" }, - { "urcorner", "\u231D" }, - { "urcrop", "\u230E" }, - { "Uring", "\u016E" }, - { "uring", "\u016F" }, - { "urtri", "\u25F9" }, - { "Uscr", "\uD835\uDCB0" }, - { "uscr", "\uD835\uDCCA" }, - { "utdot", "\u22F0" }, - { "Utilde", "\u0168" }, - { "utilde", "\u0169" }, - { "utri", "\u25B5" }, - { "utrif", "\u25B4" }, - { "uuarr", "\u21C8" }, - { "Uuml", "\u00DC" }, - { "uuml", "\u00FC" }, - { "uwangle", "\u29A7" }, - { "vangrt", "\u299C" }, - { "varepsilon", "\u03F5" }, - { "varkappa", "\u03F0" }, - { "varnothing", "\u2205" }, - { "varphi", "\u03D5" }, - { "varpi", "\u03D6" }, - { "varpropto", "\u221D" }, - { "vArr", "\u21D5" }, - { "varr", "\u2195" }, - { "varrho", "\u03F1" }, - { "varsigma", "\u03C2" }, - { "varsubsetneq", "\u228A\uFE00" }, - { "varsubsetneqq", "\u2ACB\uFE00" }, - { "varsupsetneq", "\u228B\uFE00" }, - { "varsupsetneqq", "\u2ACC\uFE00" }, - { "vartheta", "\u03D1" }, - { "vartriangleleft", "\u22B2" }, - { "vartriangleright", "\u22B3" }, - { "Vbar", "\u2AEB" }, - { "vBar", "\u2AE8" }, - { "vBarv", "\u2AE9" }, - { "Vcy", "\u0412" }, - { "vcy", "\u0432" }, - { "VDash", "\u22AB" }, - { "Vdash", "\u22A9" }, - { "vDash", "\u22A8" }, - { "vdash", "\u22A2" }, - { "Vdashl", "\u2AE6" }, - { "Vee", "\u22C1" }, - { "vee", "\u2228" }, - { "veebar", "\u22BB" }, - { "veeeq", "\u225A" }, - { "vellip", "\u22EE" }, - { "Verbar", "\u2016" }, - { "verbar", "\u007C" }, - { "Vert", "\u2016" }, - { "vert", "\u007C" }, - { "VerticalBar", "\u2223" }, - { "VerticalLine", "\u007C" }, - { "VerticalSeparator", "\u2758" }, - { "VerticalTilde", "\u2240" }, - { "VeryThinSpace", "\u200A" }, - { "Vfr", "\uD835\uDD19" }, - { "vfr", "\uD835\uDD33" }, - { "vltri", "\u22B2" }, - { "vnsub", "\u2282\u20D2" }, - { "vnsup", "\u2283\u20D2" }, - { "Vopf", "\uD835\uDD4D" }, - { "vopf", "\uD835\uDD67" }, - { "vprop", "\u221D" }, - { "vrtri", "\u22B3" }, - { "Vscr", "\uD835\uDCB1" }, - { "vscr", "\uD835\uDCCB" }, - { "vsubnE", "\u2ACB\uFE00" }, - { "vsubne", "\u228A\uFE00" }, - { "vsupnE", "\u2ACC\uFE00" }, - { "vsupne", "\u228B\uFE00" }, - { "Vvdash", "\u22AA" }, - { "vzigzag", "\u299A" }, - { "Wcirc", "\u0174" }, - { "wcirc", "\u0175" }, - { "wedbar", "\u2A5F" }, - { "Wedge", "\u22C0" }, - { "wedge", "\u2227" }, - { "wedgeq", "\u2259" }, - { "weierp", "\u2118" }, - { "Wfr", "\uD835\uDD1A" }, - { "wfr", "\uD835\uDD34" }, - { "Wopf", "\uD835\uDD4E" }, - { "wopf", "\uD835\uDD68" }, - { "wp", "\u2118" }, - { "wr", "\u2240" }, - { "wreath", "\u2240" }, - { "Wscr", "\uD835\uDCB2" }, - { "wscr", "\uD835\uDCCC" }, - { "xcap", "\u22C2" }, - { "xcirc", "\u25EF" }, - { "xcup", "\u22C3" }, - { "xdtri", "\u25BD" }, - { "Xfr", "\uD835\uDD1B" }, - { "xfr", "\uD835\uDD35" }, - { "xhArr", "\u27FA" }, - { "xharr", "\u27F7" }, - { "Xi", "\u039E" }, - { "xi", "\u03BE" }, - { "xlArr", "\u27F8" }, - { "xlarr", "\u27F5" }, - { "xmap", "\u27FC" }, - { "xnis", "\u22FB" }, - { "xodot", "\u2A00" }, - { "Xopf", "\uD835\uDD4F" }, - { "xopf", "\uD835\uDD69" }, - { "xoplus", "\u2A01" }, - { "xotime", "\u2A02" }, - { "xrArr", "\u27F9" }, - { "xrarr", "\u27F6" }, - { "Xscr", "\uD835\uDCB3" }, - { "xscr", "\uD835\uDCCD" }, - { "xsqcup", "\u2A06" }, - { "xuplus", "\u2A04" }, - { "xutri", "\u25B3" }, - { "xvee", "\u22C1" }, - { "xwedge", "\u22C0" }, - { "Yacute", "\u00DD" }, - { "yacute", "\u00FD" }, - { "YAcy", "\u042F" }, - { "yacy", "\u044F" }, - { "Ycirc", "\u0176" }, - { "ycirc", "\u0177" }, - { "Ycy", "\u042B" }, - { "ycy", "\u044B" }, - { "yen", "\u00A5" }, - { "Yfr", "\uD835\uDD1C" }, - { "yfr", "\uD835\uDD36" }, - { "YIcy", "\u0407" }, - { "yicy", "\u0457" }, - { "Yopf", "\uD835\uDD50" }, - { "yopf", "\uD835\uDD6A" }, - { "Yscr", "\uD835\uDCB4" }, - { "yscr", "\uD835\uDCCE" }, - { "YUcy", "\u042E" }, - { "yucy", "\u044E" }, - { "Yuml", "\u0178" }, - { "yuml", "\u00FF" }, - { "Zacute", "\u0179" }, - { "zacute", "\u017A" }, - { "Zcaron", "\u017D" }, - { "zcaron", "\u017E" }, - { "Zcy", "\u0417" }, - { "zcy", "\u0437" }, - { "Zdot", "\u017B" }, - { "zdot", "\u017C" }, - { "zeetrf", "\u2128" }, - { "ZeroWidthSpace", "\u200B" }, - { "Zeta", "\u0396" }, - { "zeta", "\u03B6" }, - { "Zfr", "\u2128" }, - { "zfr", "\uD835\uDD37" }, - { "ZHcy", "\u0416" }, - { "zhcy", "\u0436" }, - { "zigrarr", "\u21DD" }, - { "Zopf", "\u2124" }, - { "zopf", "\uD835\uDD6B" }, - { "Zscr", "\uD835\uDCB5" }, - { "zscr", "\uD835\uDCCF" }, - { "zwj", "\u200D" }, - { "zwnj", "\u200C" } - }; - #endregion - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Helpers/HtmlHelper.cs b/NppMarkdownPanel/Markdig/Helpers/HtmlHelper.cs deleted file mode 100644 index da86ac8..0000000 --- a/NppMarkdownPanel/Markdig/Helpers/HtmlHelper.cs +++ /dev/null @@ -1,650 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Text; - -namespace Markdig.Helpers -{ - /// - /// Helper to parse several HTML tags. - /// - public static class HtmlHelper - { - private static readonly char[] SearchBackAndAmp = { '\\', '&' }; - private static readonly char[] SearchAmp = { '&' }; - private static readonly string[] EscapeUrlsForAscii = new string[128]; - - static HtmlHelper() - { - for (int i = 0; i < EscapeUrlsForAscii.Length; i++) - { - if (i <= 32 || @"""'<>[\]^`{|}~".IndexOf((char)i) >= 0 || i == 127) - { - EscapeUrlsForAscii[i] = $"%{i:X2}"; - } - else if ((char) i == '&') - { - EscapeUrlsForAscii[i] = "&"; - } - } - } - public static string EscapeUrlCharacter(char c) - { - return c < 128 ? EscapeUrlsForAscii[c] : null; - } - - public static bool TryParseHtmlTag(StringSlice text, out string htmlTag) - { - return TryParseHtmlTag(ref text, out htmlTag); - } - - public static bool TryParseHtmlTag(ref StringSlice text, out string htmlTag) - { - var builder = StringBuilderCache.Local(); - var result = TryParseHtmlTag(ref text, builder); - htmlTag = builder.ToString(); - builder.Length = 0; - return result; - } - - public static bool TryParseHtmlTag(ref StringSlice text, StringBuilder builder) - { - if (builder == null) throw new ArgumentNullException(nameof(builder)); - var c = text.CurrentChar; - if (c != '<') - { - return false; - } - c = text.NextChar(); - - builder.Append('<'); - - switch (c) - { - case '/': - return TryParseHtmlCloseTag(ref text, builder); - case '?': - return TryParseHtmlTagProcessingInstruction(ref text, builder); - case '!': - builder.Append(c); - c = text.NextChar(); - if (c == '-') - { - return TryParseHtmlTagHtmlComment(ref text, builder); - } - - if (c == '[') - { - return TryParseHtmlTagCData(ref text, builder); - } - - return TryParseHtmlTagDeclaration(ref text, builder); - } - - return TryParseHtmlTagOpenTag(ref text, builder); - } - - internal static bool TryParseHtmlTagOpenTag(ref StringSlice text, StringBuilder builder) - { - var c = text.CurrentChar; - - // Parse the tagname - if (!c.IsAlpha()) - { - return false; - } - builder.Append(c); - - while (true) - { - c = text.NextChar(); - if (c.IsAlphaNumeric() || c == '-') - { - builder.Append(c); - } - else - { - break; - } - } - - bool hasAttribute = false; - while (true) - { - var hasWhitespaces = false; - // Skip any whitespaces - while (c.IsWhitespace()) - { - builder.Append(c); - c = text.NextChar(); - hasWhitespaces = true; - } - - switch (c) - { - case '\0': - return false; - case '>': - text.NextChar(); - builder.Append(c); - return true; - case '/': - builder.Append('/'); - c = text.NextChar(); - if (c != '>') - { - return false; - } - text.NextChar(); - builder.Append('>'); - return true; - case '=': - - if (!hasAttribute) - { - return false; - } - - builder.Append('='); - - // Skip any spaces after - c = text.NextChar(); - while (c.IsWhitespace()) - { - builder.Append(c); - c = text.NextChar(); - } - - // Parse a quoted string - if (c == '\'' || c == '\"') - { - builder.Append(c); - char openingStringChar = c; - while (true) - { - c = text.NextChar(); - if (c == '\0') - { - return false; - } - if (c != openingStringChar) - { - builder.Append(c); - } - else - { - break; - } - } - builder.Append(c); - c = text.NextChar(); - } - else - { - // Parse until we match a space or a special html character - int matchCount = 0; - while (true) - { - if (c == '\0') - { - return false; - } - if (c == ' ' || c == '\n' || c == '"' || c == '\'' || c == '=' || c == '<' || c == '>' || c == '`') - { - break; - } - matchCount++; - builder.Append(c); - c = text.NextChar(); - } - - // We need at least one char after '=' - if (matchCount == 0) - { - return false; - } - } - - hasAttribute = false; - continue; - default: - if (!hasWhitespaces) - { - return false; - } - - // Parse the attribute name - if (!(c.IsAlpha() || c == '_' || c == ':')) - { - return false; - } - builder.Append(c); - - while (true) - { - c = text.NextChar(); - if (c.IsAlphaNumeric() || c == '_' || c == ':' || c == '.' || c == '-') - { - builder.Append(c); - } - else - { - break; - } - } - - hasAttribute = true; - break; - } - } - } - - private static bool TryParseHtmlTagDeclaration(ref StringSlice text, StringBuilder builder) - { - var c = text.CurrentChar; - bool hasAlpha = false; - while (c.IsAlphaUpper()) - { - builder.Append(c); - c = text.NextChar(); - hasAlpha = true; - } - - if (!hasAlpha || !c.IsWhitespace()) - { - return false; - } - - // Regexp: "\\![A-Z]+\\s+[^>\\x00]*>" - while (true) - { - builder.Append(c); - c = text.NextChar(); - if (c == '\0') - { - return false; - } - - if (c == '>') - { - text.NextChar(); - builder.Append('>'); - return true; - } - } - } - - private static bool TryParseHtmlTagCData(ref StringSlice text, StringBuilder builder) - { - builder.Append('['); - var c = text.NextChar(); - if (c == 'C' && - text.NextChar() == 'D' && - text.NextChar() == 'A' && - text.NextChar() == 'T' && - text.NextChar() == 'A' && - (c = text.NextChar()) == '[') - { - builder.Append("CDATA["); - while (true) - { - var pc = c; - c = text.NextChar(); - if (c == '\0') - { - return false; - } - - if (c == ']' && pc == ']') - { - builder.Append(']'); - c = text.NextChar(); - if (c == '>') - { - builder.Append('>'); - text.NextChar(); - return true; - } - - if (c == '\0') - { - return false; - } - } - builder.Append(c); - } - } - return false; - } - - internal static bool TryParseHtmlCloseTag(ref StringSlice text, StringBuilder builder) - { - // - builder.Append('/'); - - var c = text.NextChar(); - if (!c.IsAlpha()) - { - return false; - } - builder.Append(c); - - bool skipSpaces = false; - while (true) - { - c = text.NextChar(); - if (c == '>') - { - text.NextChar(); - builder.Append('>'); - return true; - } - - if (skipSpaces) - { - if (c != ' ') - { - break; - } - } - else if (c == ' ') - { - skipSpaces = true; - } - else if (!(c.IsAlphaNumeric() || c == '-')) - { - break; - } - - builder.Append(c); - } - return false; - } - - - private static bool TryParseHtmlTagHtmlComment(ref StringSlice text, StringBuilder builder) - { - var c = text.NextChar(); - if (c != '-') - { - return false; - } - builder.Append('-'); - builder.Append('-'); - if (text.PeekChar(1) == '>') - { - return false; - } - - var countHyphen = 0; - while (true) - { - c = text.NextChar(); - if (c == '\0') - { - return false; - } - - if (countHyphen == 2) - { - if (c == '>') - { - builder.Append('>'); - text.NextChar(); - return true; - } - return false; - } - countHyphen = c == '-' ? countHyphen + 1 : 0; - builder.Append(c); - } - } - - private static bool TryParseHtmlTagProcessingInstruction(ref StringSlice text, StringBuilder builder) - { - builder.Append('?'); - var prevChar = '\0'; - while (true) - { - var c = text.NextChar(); - if (c == '\0') - { - return false; - } - - if (c == '>' && prevChar == '?') - { - builder.Append('>'); - text.NextChar(); - return true; - } - prevChar = c; - builder.Append(c); - } - } - - /// - /// Destructively unescape a string: remove backslashes before punctuation or symbol characters. - /// - /// The string data that will be changed by unescaping any punctuation or symbol characters. - /// if set to true [remove back slash]. - /// - public static string Unescape(string text, bool removeBackSlash = true) - { - // Credits: code from CommonMark.NET - // Copyright (c) 2014, Kārlis Gaņģis All rights reserved. - // See license for details: https://github.com/Knagis/CommonMark.NET/blob/master/LICENSE.md - if (string.IsNullOrEmpty(text)) - { - return string.Empty; - } - - // remove backslashes before punctuation chars: - int searchPos = 0; - int lastPos = 0; - char c; - char[] search = removeBackSlash ? SearchBackAndAmp : SearchAmp; - StringBuilder sb = null; - - while ((searchPos = text.IndexOfAny(search, searchPos)) != -1) - { - if (sb == null) - { - sb = StringBuilderCache.Local(); - sb.Length = 0; - } - c = text[searchPos]; - if (removeBackSlash && c == '\\') - { - searchPos++; - - if (text.Length == searchPos) - break; - - c = text[searchPos]; - if (c.IsEscapableSymbol()) - { - sb.Append(text, lastPos, searchPos - lastPos - 1); - lastPos = searchPos; - } - } - else if (c == '&') - { - int entityNameStart; - int entityNameLength; - int numericEntity; - var match = ScanEntity(new StringSlice(text, searchPos, text.Length - 1), out numericEntity, out entityNameStart, out entityNameLength); - if (match == 0) - { - searchPos++; - } - else - { - searchPos += match; - - if (entityNameLength > 0) - { - var namedEntity = new StringSlice(text, entityNameStart, entityNameStart + entityNameLength - 1); - var decoded = EntityHelper.DecodeEntity(namedEntity.ToString()); - if (decoded != null) - { - sb.Append(text, lastPos, searchPos - match - lastPos); - sb.Append(decoded); - lastPos = searchPos; - } - } - else if (numericEntity >= 0) - { - sb.Append(text, lastPos, searchPos - match - lastPos); - if (numericEntity == 0) - { - sb.Append('\0'.EscapeInsecure()); - } - else - { - var decoded = EntityHelper.DecodeEntity(numericEntity); - if (decoded != null) - { - sb.Append(decoded); - } - else - { - sb.Append('\uFFFD'); - } - } - - lastPos = searchPos; - } - } - } - } - - if (sb == null) - return text; - - sb.Append(text, lastPos, text.Length - lastPos); - var result = sb.ToString(); - sb.Length = 0; - return result; - } - - /// - /// Scans an entity. - /// Returns number of chars matched. - /// - public static int ScanEntity(T slice, out int numericEntity, out int namedEntityStart, out int namedEntityLength) where T : ICharIterator - { - // Credits: code from CommonMark.NET - // Copyright (c) 2014, Kārlis Gaņģis All rights reserved. - // See license for details: https://github.com/Knagis/CommonMark.NET/blob/master/LICENSE.md - - /*!re2c - [&] ([#] ([Xx][A-Fa-f0-9]{1,8}|[0-9]{1,8}) |[A-Za-z][A-Za-z0-9]{1,31} ) [;] - { return (p - start); } - .? { return 0; } - */ - - numericEntity = 0; - namedEntityStart = 0; - namedEntityLength = 0; - - if (slice.CurrentChar != '&' || slice.PeekChar(3) == '\0') - { - return 0; - } - - var start = slice.Start; - char c = slice.NextChar(); - int counter = 0; - - if (c == '#') - { - c = slice.PeekChar(); - if (c == 'x' || c == 'X') - { - c = slice.NextChar(); // skip # - // expect 1-8 hex digits starting from pos+3 - while (c != '\0') - { - c = slice.NextChar(); - if (c >= '0' && c <= '9') - { - if (++counter == 9) return 0; - numericEntity = numericEntity*16 + (c - '0'); - continue; - } - else if (c >= 'A' && c <= 'F') - { - if (++counter == 9) return 0; - numericEntity = numericEntity*16 + (c - 'A' + 10); - continue; - } - else if (c >= 'a' && c <= 'f') - { - if (++counter == 9) return 0; - numericEntity = numericEntity*16 + (c - 'a' + 10); - continue; - } - - if (c == ';') - return counter == 0 ? 0 : slice.Start - start + 1; - - return 0; - } - } - else - { - // expect 1-8 digits starting from pos+2 - while (c != '\0') - { - c = slice.NextChar(); - - if (c >= '0' && c <= '9') - { - if (++counter == 9) return 0; - numericEntity = numericEntity*10 + (c - '0'); - continue; - } - - if (c == ';') - return counter == 0 ? 0 : slice.Start - start + 1; - - return 0; - } - } - } - else - { - // expect a letter and 1-31 letters or digits - if (!((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))) - return 0; - - namedEntityStart = slice.Start; - namedEntityLength++; - - while (c != '\0') - { - c = slice.NextChar(); - if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) - { - if (++counter == 32) - return 0; - namedEntityLength++; - continue; - } - - if (c == ';') - { - return counter == 0 ? 0 : slice.Start - start + 1; - } - - return 0; - } - } - - return 0; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Helpers/ICharIterator.cs b/NppMarkdownPanel/Markdig/Helpers/ICharIterator.cs deleted file mode 100644 index 2ea1f32..0000000 --- a/NppMarkdownPanel/Markdig/Helpers/ICharIterator.cs +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace Markdig.Helpers -{ - /// - /// Provides a common interface for iterating characters - /// over a or . - /// - public interface ICharIterator - { - /// - /// Gets the current start character position. - /// - int Start { get; } - - /// - /// Gets the current character. - /// - char CurrentChar { get; } - - /// - /// Gets the end character position. - /// - int End { get; } - - /// - /// Goes to the next character, incrementing the position. - /// - /// The next character. `\0` is end of the iteration. - char NextChar(); - - /// - /// Peeks at the next character, without incrementing the position. - /// - /// - /// The next character. `\0` is end of the iteration. - char PeekChar(int offset = 1); - - /// - /// Gets a value indicating whether this instance is empty. - /// - bool IsEmpty { get; } - - /// - /// Trims whitespaces at the beginning of this slice starting from position. - /// - /// true if it has reaches the end of the iterator - bool TrimStart(); - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Helpers/LineReader.cs b/NppMarkdownPanel/Markdig/Helpers/LineReader.cs deleted file mode 100644 index a5e60a1..0000000 --- a/NppMarkdownPanel/Markdig/Helpers/LineReader.cs +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.IO; -using System.Text; - -namespace Markdig.Helpers -{ - /// - /// A line reader from a that can provide precise source position - /// - public struct LineReader - { - private readonly string text; - - /// - /// Initializes a new instance of the class. - /// - /// - /// bufferSize cannot be <= 0 - public LineReader(string text) - { - if (text == null) throw new ArgumentNullException(nameof(text)); - this.text = text; - SourcePosition = 0; - } - - /// - /// Gets the char position of the line. Valid for the next line before calling . - /// - public int SourcePosition { get; private set; } - - /// - /// Reads a new line from the underlying and update the for the next line. - /// - /// A new line or null if the end of has been reached - public StringSlice? ReadLine() - { - if (SourcePosition >= text.Length) - { - return null; - } - - var startPosition = SourcePosition; - var position = SourcePosition; - var slice = new StringSlice(text, startPosition, startPosition); - for (;position < text.Length; position++) - { - var c = text[position]; - if (c == '\r' || c == '\n') - { - slice.End = position - 1; - if (c == '\r' && position + 1 < text.Length && text[position + 1] == '\n') - { - position++; - } - position++; - SourcePosition = position; - return slice; - } - } - - slice.End = position - 1; - SourcePosition = position; - - return slice; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Helpers/LinkHelper.cs b/NppMarkdownPanel/Markdig/Helpers/LinkHelper.cs deleted file mode 100644 index 6c27dcf..0000000 --- a/NppMarkdownPanel/Markdig/Helpers/LinkHelper.cs +++ /dev/null @@ -1,954 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System; -using System.Runtime.CompilerServices; -using Markdig.Syntax; - -namespace Markdig.Helpers -{ - /// - /// Helpers to parse Markdown links. - /// - public static class LinkHelper - { - public static bool TryParseAutolink(StringSlice text, out string link, out bool isEmail) - { - return TryParseAutolink(ref text, out link, out isEmail); - } - - public static string Urilize(string headingText, bool allowOnlyAscii, bool keepOpeningDigits = false) - { - var headingBuffer = StringBuilderCache.Local(); - bool hasLetter = keepOpeningDigits && headingText.Length > 0 && char.IsLetterOrDigit(headingText[0]); - bool previousIsSpace = false; - for (int i = 0; i < headingText.Length; i++) - { - var c = headingText[i]; - var normalized = allowOnlyAscii ? CharNormalizer.ConvertToAscii(c) : null; - for (int j = 0; j < (normalized?.Length ?? 1); j++) - { - if (normalized != null) - { - c = normalized[j]; - } - - if (char.IsLetter(c)) - { - if (allowOnlyAscii && (c < ' ' || c >= 127)) - { - continue; - } - c = char.IsUpper(c) ? char.ToLowerInvariant(c) : c; - headingBuffer.Append(c); - hasLetter = true; - previousIsSpace = false; - } - else if (hasLetter) - { - if (IsReservedPunctuation(c)) - { - if (previousIsSpace) - { - headingBuffer.Length--; - } - if (headingBuffer[headingBuffer.Length - 1] != c) - { - headingBuffer.Append(c); - } - previousIsSpace = false; - } - else if (c.IsDigit()) - { - headingBuffer.Append(c); - previousIsSpace = false; - } - else if (!previousIsSpace && c.IsWhitespace()) - { - var pc = headingBuffer[headingBuffer.Length - 1]; - if (!IsReservedPunctuation(pc)) - { - headingBuffer.Append('-'); - } - previousIsSpace = true; - } - } - } - } - - // Trim trailing _ - . - while (headingBuffer.Length > 0) - { - var c = headingBuffer[headingBuffer.Length - 1]; - if (IsReservedPunctuation(c)) - { - headingBuffer.Length--; - } - else - { - break; - } - } - - var text = headingBuffer.ToString(); - headingBuffer.Length = 0; - return text; - } - - public static string UrilizeAsGfm(string headingText) - { - // Following https://github.com/jch/html-pipeline/blob/master/lib/html/pipeline/toc_filter.rb - var headingBuffer = StringBuilderCache.Local(); - for (int i = 0; i < headingText.Length; i++) - { - var c = char.ToLowerInvariant(headingText[i]); - if (char.IsLetterOrDigit(c) || c == ' ' || c == '-' || c == '_') - { - headingBuffer.Append(c == ' ' ? '-' : c); - } - } - var result = headingBuffer.ToString(); - headingBuffer.Length = 0; - return result; - } - - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - private static bool IsReservedPunctuation(char c) - { - return c == '_' || c == '-' || c == '.'; - } - - public static bool TryParseAutolink(ref StringSlice text, out string link, out bool isEmail) - { - link = null; - isEmail = false; - - var c = text.CurrentChar; - if (c != '<') - { - return false; - } - - // An absolute URI, for these purposes, consists of a scheme followed by a colon (:) - // followed by zero or more characters other than ASCII whitespace and control characters, <, and >. - // If the URI includes these characters, they must be percent-encoded (e.g. %20 for a space). - // A URI that would end with a full stop (.) is treated instead as ending immediately before the full stop. - - // a scheme is any sequence of 2–32 characters - // beginning with an ASCII letter - // and followed by any combination of ASCII letters, digits, or the symbols plus (”+”), period (”.”), or hyphen (”-”). - - // An email address, for these purposes, is anything that matches the non-normative regex from the HTML5 spec: - // /^ - // [a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+ - // @ - // [a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])? - // (?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/ - - c = text.NextChar(); - - // -1: scan email - // 0: scan uri or email - // +1: scan uri - int state = 0; - - if (!c.IsAlpha()) - { - // We may have an email char? - if (c.IsDigit() || CharHelper.IsEmailUsernameSpecialChar(c)) - { - state = -1; - } - else - { - return false; - } - } - - var builder = StringBuilderCache.Local(); - - // **************************** - // 1. Scan scheme or user email - // **************************** - builder.Append(c); - while (true) - { - c = text.NextChar(); - - // Chars valid for both scheme and email - var isSpecialChar = c == '+' || c == '.' || c == '-'; - var isValidChar = c.IsAlphaNumeric() || isSpecialChar; - if (state <= 0 && CharHelper.IsEmailUsernameSpecialChar(c)) - { - isValidChar = true; - // If this is not a special char valid also for url scheme, then we have an email - if (!isSpecialChar) - { - state = -1; - } - } - - if (isValidChar) - { - // a scheme is any sequence of 2–32 characters - if (state > 0 && builder.Length >= 32) - { - builder.Length = 0; - return false; - } - builder.Append(c); - } - else if (c == ':') - { - if (state < 0 || builder.Length <= 2) - { - builder.Length = 0; - return false; - } - state = 1; - break; - } else if (c == '@') - { - if (state > 0) - { - builder.Length = 0; - return false; - } - state = -1; - break; - } - else - { - builder.Length = 0; - return false; - } - } - - // append ':' or '@' - builder.Append(c); - - if (state < 0) - { - isEmail = true; - - // scan an email - // [a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])? - // (?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/ - bool hasMinus = false; - int domainCharCount = 0; - char pc = '\0'; - while (true) - { - c = text.NextChar(); - if (c == '>') - { - if (domainCharCount == 0 || hasMinus) - { - break; - } - - text.NextChar(); - link = builder.ToString(); - builder.Length = 0; - return true; - } - - if (c.IsAlphaNumeric() || (domainCharCount > 0 && (hasMinus = c == '-'))) - { - domainCharCount++; - if (domainCharCount > 63) - { - break; - } - } - else if (c == '.') - { - if (pc == '.' || pc == '-') - { - break; - } - domainCharCount = 0; - hasMinus = false; - } - else - { - break; - } - builder.Append(c); - pc = c; - } - } - else - { - // scan an uri - // An absolute URI, for these purposes, consists of a scheme followed by a colon (:) - // followed by zero or more characters other than ASCII whitespace and control characters, <, and >. - // If the URI includes these characters, they must be percent-encoded (e.g. %20 for a space). - - while (true) - { - c = text.NextChar(); - if (c == '\0') - { - break; - } - - if (c == '>') - { - text.NextChar(); - link = builder.ToString(); - builder.Length = 0; - return true; - } - - // Chars valid for both scheme and email - if (c > ' ' && c < 127 && c != '<') - { - builder.Append(c); - } - else - { - break; - } - } - } - - builder.Length = 0; - return false; - } - - public static bool TryParseInlineLink(StringSlice text, out string link, out string title) - { - SourceSpan linkSpan; - SourceSpan titleSpan; - return TryParseInlineLink(ref text, out link, out title, out linkSpan, out titleSpan); - } - - public static bool TryParseInlineLink(StringSlice text, out string link, out string title, out SourceSpan linkSpan, out SourceSpan titleSpan) - { - return TryParseInlineLink(ref text, out link, out title, out linkSpan, out titleSpan); - } - - public static bool TryParseInlineLink(ref StringSlice text, out string link, out string title) - { - SourceSpan linkSpan; - SourceSpan titleSpan; - return TryParseInlineLink(ref text, out link, out title, out linkSpan, out titleSpan); - } - - public static bool TryParseInlineLink(ref StringSlice text, out string link, out string title, out SourceSpan linkSpan, out SourceSpan titleSpan) - { - // 1. An inline link consists of a link text followed immediately by a left parenthesis (, - // 2. optional whitespace, TODO: specs: is it whitespace or multiple whitespaces? - // 3. an optional link destination, - // 4. an optional link title separated from the link destination by whitespace, - // 5. optional whitespace, TODO: specs: is it whitespace or multiple whitespaces? - // 6. and a right parenthesis ) - bool isValid = false; - var c = text.CurrentChar; - link = null; - title = null; - - linkSpan = SourceSpan.Empty; - titleSpan = SourceSpan.Empty; - - // 1. An inline link consists of a link text followed immediately by a left parenthesis (, - if (c == '(') - { - text.NextChar(); - text.TrimStart(); - - var pos = text.Start; - if (TryParseUrl(ref text, out link)) - { - linkSpan.Start = pos; - linkSpan.End = text.Start - 1; - if (linkSpan.End < linkSpan.Start) - { - linkSpan = SourceSpan.Empty; - } - - int spaceCount; - text.TrimStart(out spaceCount); - var hasWhiteSpaces = spaceCount > 0; - - c = text.CurrentChar; - if (c == ')') - { - isValid = true; - } - else if (hasWhiteSpaces) - { - c = text.CurrentChar; - pos = text.Start; - if (c == ')') - { - isValid = true; - } - else if (TryParseTitle(ref text, out title)) - { - titleSpan.Start = pos; - titleSpan.End = text.Start - 1; - if (titleSpan.End < titleSpan.Start) - { - titleSpan = SourceSpan.Empty; - } - text.TrimStart(); - c = text.CurrentChar; - - if (c == ')') - { - isValid = true; - } - } - } - } - } - - if (isValid) - { - // Skip ')' - text.NextChar(); - title = title ?? String.Empty; - } - - return isValid; - } - - public static bool TryParseTitle(T text, out string title) where T : ICharIterator - { - return TryParseTitle(ref text, out title); - } - - public static bool TryParseTitle(ref T text, out string title) where T : ICharIterator - { - bool isValid = false; - var buffer = StringBuilderCache.Local(); - buffer.Length = 0; - - // a sequence of zero or more characters between straight double-quote characters ("), including a " character only if it is backslash-escaped, or - // a sequence of zero or more characters between straight single-quote characters ('), including a ' character only if it is backslash-escaped, or - var c = text.CurrentChar; - if (c == '\'' || c == '"' || c == '(') - { - var closingQuote = c == '(' ? ')' : c; - bool hasEscape = false; - // -1: undefined - // 0: has only spaces - // 1: has other characters - int hasOnlyWhiteSpacesSinceLastLine = -1; - while (true) - { - c = text.NextChar(); - - if (c == '\n') - { - if (hasOnlyWhiteSpacesSinceLastLine >= 0) - { - if (hasOnlyWhiteSpacesSinceLastLine == 1) - { - break; - } - hasOnlyWhiteSpacesSinceLastLine = -1; - } - } - - if (c == '\0') - { - break; - } - - if (c == closingQuote) - { - if (hasEscape) - { - buffer.Append(closingQuote); - hasEscape = false; - continue; - } - - // Skip last quote - text.NextChar(); - isValid = true; - break; - } - - if (hasEscape && !c.IsAsciiPunctuation()) - { - buffer.Append('\\'); - } - - if (c == '\\') - { - hasEscape = true; - continue; - } - - hasEscape = false; - - if (c.IsSpaceOrTab()) - { - if (hasOnlyWhiteSpacesSinceLastLine < 0) - { - hasOnlyWhiteSpacesSinceLastLine = 1; - } - } - else if (c != '\n') - { - hasOnlyWhiteSpacesSinceLastLine = 0; - } - - buffer.Append(c); - } - } - - title = isValid ? buffer.ToString() : null; - buffer.Length = 0; - return isValid; - } - - public static bool TryParseUrl(T text, out string link) where T : ICharIterator - { - return TryParseUrl(ref text, out link); - } - - public static bool TryParseUrl(ref T text, out string link, bool isAutoLink = false) where T : ICharIterator - { - bool isValid = false; - var buffer = StringBuilderCache.Local(); - buffer.Length = 0; - - var c = text.CurrentChar; - - // a sequence of zero or more characters between an opening < and a closing > - // that contains no spaces, line breaks, or unescaped < or > characters, or - if (c == '<') - { - bool hasEscape = false; - do - { - c = text.NextChar(); - if (!hasEscape && c == '>') - { - text.NextChar(); - isValid = true; - break; - } - - if (!hasEscape && c == '<') - { - break; - } - - if (hasEscape && !c.IsAsciiPunctuation()) - { - buffer.Append('\\'); - } - - if (c == '\\') - { - hasEscape = true; - continue; - } - - hasEscape = false; - - if (c.IsWhitespace()) // TODO: specs unclear. space is strict or relaxed? (includes tabs?) - { - break; - } - - buffer.Append(c); - - } while (c != '\0'); - } - else - { - // a nonempty sequence of characters that does not include ASCII space or control characters, - // and includes parentheses only if (a) they are backslash-escaped or (b) they are part of a - // balanced pair of unescaped parentheses that is not itself inside a balanced pair of unescaped - // parentheses. - bool hasEscape = false; - int openedParent = 0; - while (true) - { - // Match opening and closing parenthesis - if (c == '(') - { - if (!hasEscape) - { - openedParent++; - } - } - - if (c == ')') - { - if (!hasEscape) - { - openedParent--; - if (openedParent < 0) - { - isValid = true; - break; - } - } - } - - if (hasEscape && !c.IsAsciiPunctuation()) - { - buffer.Append('\\'); - } - - // If we have an escape - if (c == '\\') - { - hasEscape = true; - c = text.NextChar(); - continue; - } - - hasEscape = false; - - if (IsEndOfUri(c, isAutoLink)) - { - isValid = true; - break; - } - - if (isAutoLink) - { - if (c == '&') - { - int entityNameStart; - int entityNameLength; - int entityValue; - if (HtmlHelper.ScanEntity(text, out entityValue, out entityNameStart, out entityNameLength) > 0) - { - isValid = true; - break; - } - } - if (IsTrailingUrlStopCharacter(c) && IsEndOfUri(text.PeekChar(), true)) - { - isValid = true; - break; - } - } - - buffer.Append(c); - - c = text.NextChar(); - } - - if (openedParent > 0) - { - isValid = false; - } - } - - link = isValid ? buffer.ToString() : null; - buffer.Length = 0; - return isValid; - } - - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - private static bool IsTrailingUrlStopCharacter(char c) - { - // Trailing punctuation (specifically, ?, !, ., ,, :, *, _, and ~) will not be considered part of the autolink, though they may be included in the interior of the link: - return c == '?' || c == '!' || c == '.' || c == ',' || c == ':' || c == '*' || c == '*' || c == '_' || c == '~'; - } - - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - private static bool IsEndOfUri(char c, bool isAutoLink) - { - return c == '\0' || c.IsSpaceOrTab() || c.IsControl() || (isAutoLink && c == '<'); // TODO: specs unclear. space is strict or relaxed? (includes tabs?) - } - - public static bool IsValidDomain(string link, int prefixLength) - { - // https://github.github.com/gfm/#extended-www-autolink - // A valid domain consists of alphanumeric characters, underscores (_), hyphens (-) and periods (.). - // There must be at least one period, and no underscores may be present in the last two segments of the domain. - - int segmentCount = 1; - bool segmentHasCharacters = false; - int lastUnderscoreSegment = -1; - - for (int i = prefixLength; i < link.Length; i++) - { - char c = link[i]; - - if (c == '.') // New segment - { - if (!segmentHasCharacters) - return false; - - segmentCount++; - segmentHasCharacters = false; - continue; - } - - if (!c.IsAlphaNumeric()) - { - if (c == '/' || c == '?' || c == '#' || c == ':') // End of domain name - break; - - if (c == '_') - { - lastUnderscoreSegment = segmentCount; - } - else if (c != '-') - { - // An invalid character has been found - return false; - } - } - - segmentHasCharacters = true; - } - - return segmentCount != 1 && // At least one dot was present - segmentHasCharacters && // Last segment has valid characters - segmentCount - lastUnderscoreSegment >= 2; // No underscores are present in the last two segments of the domain - } - - public static bool TryParseLinkReferenceDefinition(T text, out string label, out string url, - out string title) where T : ICharIterator - { - return TryParseLinkReferenceDefinition(ref text, out label, out url, out title); - } - - public static bool TryParseLinkReferenceDefinition(ref T text, out string label, out string url, out string title) - where T : ICharIterator - { - SourceSpan labelSpan; - SourceSpan urlSpan; - SourceSpan titleSpan; - return TryParseLinkReferenceDefinition(ref text, out label, out url, out title, out labelSpan, out urlSpan, - out titleSpan); - } - - public static bool TryParseLinkReferenceDefinition(ref T text, out string label, out string url, out string title, out SourceSpan labelSpan, out SourceSpan urlSpan, out SourceSpan titleSpan) where T : ICharIterator - { - url = null; - title = null; - - urlSpan = SourceSpan.Empty; - titleSpan = SourceSpan.Empty; - - if (!TryParseLabel(ref text, out label, out labelSpan)) - { - return false; - } - - if (text.CurrentChar != ':') - { - label = null; - return false; - } - text.NextChar(); // Skip ':' - - // Skip any whitespace before the url - text.TrimStart(); - - urlSpan.Start = text.Start; - if (!TryParseUrl(ref text, out url) || string.IsNullOrEmpty(url)) - { - return false; - } - urlSpan.End = text.Start - 1; - - var saved = text; - int newLineCount; - var hasWhiteSpaces = CharIteratorHelper.TrimStartAndCountNewLines(ref text, out newLineCount); - var c = text.CurrentChar; - if (c == '\'' || c == '"' || c == '(') - { - titleSpan.Start = text.Start; - if (TryParseTitle(ref text, out title)) - { - titleSpan.End = text.Start - 1; - // If we have a title, it requires a whitespace after the url - if (!hasWhiteSpaces) - { - return false; - } - } - else - { - return false; - } - } - else - { - if (text.CurrentChar == '\0' || newLineCount > 0) - { - return true; - } - } - - // Check that the current line has only trailing spaces - c = text.CurrentChar; - while (c.IsSpaceOrTab()) - { - c = text.NextChar(); - } - - if (c != '\0' && c != '\n') - { - // If we were able to parse the url but the title doesn't end with space, - // we are still returning a valid definition - if (newLineCount > 0 && title != null) - { - text = saved; - title = null; - return true; - } - - label = null; - url = null; - title = null; - return false; - } - - return true; - } - - public static bool TryParseLabel(T lines, out string label) where T : ICharIterator - { - SourceSpan labelSpan; - return TryParseLabel(ref lines, false, out label, out labelSpan); - } - - public static bool TryParseLabel(T lines, out string label, out SourceSpan labelSpan) where T : ICharIterator - { - return TryParseLabel(ref lines, false, out label, out labelSpan); - } - - public static bool TryParseLabel(ref T lines, out string label) where T : ICharIterator - { - SourceSpan labelSpan; - return TryParseLabel(ref lines, false, out label, out labelSpan); - } - - public static bool TryParseLabel(ref T lines, out string label, out SourceSpan labelSpan) where T : ICharIterator - { - return TryParseLabel(ref lines, false, out label, out labelSpan); - } - - public static bool TryParseLabel(ref T lines, bool allowEmpty, out string label, out SourceSpan labelSpan) where T : ICharIterator - { - label = null; - char c = lines.CurrentChar; - labelSpan = SourceSpan.Empty; - if (c != '[') - { - return false; - } - var buffer = StringBuilderCache.Local(); - - var startLabel = -1; - var endLabel = -1; - - bool hasEscape = false; - bool previousWhitespace = true; - bool hasNonWhiteSpace = false; - bool isValid = false; - while (true) - { - c = lines.NextChar(); - if (c == '\0') - { - break; - } - - if (hasEscape) - { - if (c != '[' && c != ']' && c != '\\') - { - break; - } - } - else - { - if (c == '[') - { - break; - } - - if (c == ']') - { - lines.NextChar(); // Skip ] - if (allowEmpty || hasNonWhiteSpace) - { - // Remove trailing spaces - for (int i = buffer.Length - 1; i >= 0; i--) - { - if (!buffer[i].IsWhitespace()) - { - break; - } - buffer.Length = i; - endLabel--; - } - - // Only valid if buffer is less than 1000 characters - if (buffer.Length <= 999) - { - labelSpan.Start = startLabel; - labelSpan.End = endLabel; - if (labelSpan.Start > labelSpan.End) - { - labelSpan = SourceSpan.Empty; - } - - label = buffer.ToString(); - isValid = true; - } - } - break; - } - } - - var isWhitespace = c.IsWhitespace(); - if (isWhitespace) - { - // Replace any whitespace by a single ' ' - c = ' '; - } - - if (!hasEscape && c == '\\') - { - if (startLabel < 0) - { - startLabel = lines.Start; - } - hasEscape = true; - } - else - { - hasEscape = false; - - if (!previousWhitespace || !isWhitespace) - { - if (startLabel < 0) - { - startLabel = lines.Start; - } - endLabel = lines.Start; - buffer.Append(c); - if (!isWhitespace) - { - hasNonWhiteSpace = true; - } - } - } - previousWhitespace = isWhitespace; - } - - buffer.Length = 0; - - return isValid; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Helpers/MethodImplOptionPortable.cs b/NppMarkdownPanel/Markdig/Helpers/MethodImplOptionPortable.cs deleted file mode 100644 index ff65e0a..0000000 --- a/NppMarkdownPanel/Markdig/Helpers/MethodImplOptionPortable.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System.Runtime.CompilerServices; - -namespace Markdig.Helpers -{ - /// - /// Internal helper to allow to declare a method using AggressiveInlining without being .NET 4.0+ - /// - internal static class MethodImplOptionPortable - { - public const MethodImplOptions AggressiveInlining = (MethodImplOptions)256; - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Helpers/ObjectCache.cs b/NppMarkdownPanel/Markdig/Helpers/ObjectCache.cs deleted file mode 100644 index 5f7878f..0000000 --- a/NppMarkdownPanel/Markdig/Helpers/ObjectCache.cs +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System; -using System.Collections.Generic; - -namespace Markdig.Helpers -{ - /// - /// A simple object recycling system. - /// - /// Type of the object to cache - public abstract class ObjectCache where T : class - { - private readonly Stack builders; - - /// - /// Initializes a new instance of the class. - /// - protected ObjectCache() - { - builders = new Stack(4); - } - - /// - /// Clears this cache. - /// - public void Clear() - { - lock (builders) - { - builders.Clear(); - } - } - - /// - /// Gets a new instance. - /// - /// - public T Get() - { - lock (builders) - { - if (builders.Count > 0) - { - return builders.Pop(); - } - } - - return NewInstance(); - } - - /// - /// Releases the specified instance. - /// - /// The instance. - /// if instance is null - public void Release(T instance) - { - if (instance == null) throw new ArgumentNullException(nameof(instance)); - Reset(instance); - lock (builders) - { - builders.Push(instance); - } - } - - /// - /// Creates a new instance of {T} - /// - /// A new instance of {T} - protected abstract T NewInstance(); - - /// - /// Resets the specified instance when is called before storing back to this cache. - /// - /// The instance. - protected abstract void Reset(T instance); - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Helpers/OrderedList.cs b/NppMarkdownPanel/Markdig/Helpers/OrderedList.cs deleted file mode 100644 index 4500e15..0000000 --- a/NppMarkdownPanel/Markdig/Helpers/OrderedList.cs +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System; -using System.Collections.Generic; - -namespace Markdig.Helpers -{ - /// - /// A List that provides methods for inserting/finding before/after. See remarks. - /// - /// Type of the list item - /// - /// We use a typed list and don't use extension methods because it would pollute all list implemts and the top level namespace. - public class OrderedList : List - { - public OrderedList() - { - } - - public OrderedList(IEnumerable collection) : base(collection) - { - } - - public bool InsertBefore(T element) where TElement : T - { - if (element == null) throw new ArgumentNullException(nameof(element)); - for (int i = 0; i < Count; i++) - { - if (this[i] is TElement) - { - Insert(i, element); - return true; - } - } - return false; - } - - public TElement Find() where TElement : T - { - for (int i = 0; i < Count; i++) - { - if (this[i] is TElement) - { - return (TElement)this[i]; - } - } - return default(TElement); - } - - public TElement FindExact() where TElement : T - { - for (int i = 0; i < Count; i++) - { - if (this[i].GetType() == typeof(TElement)) - { - return (TElement)this[i]; - } - } - return default(TElement); - } - - public void AddIfNotAlready() where TElement : class, T, new() - { - if (!Contains()) - { - Add(new TElement()); - } - } - - public void AddIfNotAlready(TElement telement) where TElement : T - { - if (!Contains()) - { - Add(telement); - } - } - - public bool InsertAfter(T element) where TElement : T - { - if (element == null) throw new ArgumentNullException(nameof(element)); - for (int i = 0; i < Count; i++) - { - if (this[i] is TElement) - { - Insert(i + 1, element); - return true; - } - } - return false; - } - - public bool Contains() where TElement : T - { - for (int i = 0; i < Count; i++) - { - if (this[i] is TElement) - { - return true; - } - } - return false; - } - - /// - /// Replaces with . - /// - /// Element type to find in the list - /// Object to replace this element with - /// true if a replacement was made; otherwise false. - public bool Replace(T replacement) where TElement : T - { - for (var i = 0; i < Count; i++) - { - if (this[i] is TElement) - { - RemoveAt(i); - Insert(i, replacement); - return true; - } - } - return false; - } - - /// - /// Replaces with or adds . - /// - /// Element type to find in the list - /// Object to add/replace the found element with - /// true if a replacement was made; otherwise false. - public bool ReplaceOrAdd(T newElement) where TElement : T - { - if (Replace(newElement)) - return true; - - Add(newElement); - return false; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Helpers/StringBuilderCache.cs b/NppMarkdownPanel/Markdig/Helpers/StringBuilderCache.cs deleted file mode 100644 index 7a19ab3..0000000 --- a/NppMarkdownPanel/Markdig/Helpers/StringBuilderCache.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System; -using System.Text; - -namespace Markdig.Helpers -{ - /// - /// An implementation of for - /// - /// - public class StringBuilderCache : DefaultObjectCache - { - /// - /// A StringBuilder that can be used locally in a method body only. - /// - [ThreadStatic] - private static StringBuilder local; - - /// - /// Provides a string builder that can only be used locally in a method. This StringBuilder MUST not be stored. - /// - /// - public static StringBuilder Local() - { - var sb = local ?? (local = new StringBuilder()); - if (sb.Length > 0) - { - sb.Length = 0; - } - return sb; - } - - protected override void Reset(StringBuilder instance) - { - if (instance.Length > 0) - { - instance.Length = 0; - } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Helpers/StringBuilderExtensions.cs b/NppMarkdownPanel/Markdig/Helpers/StringBuilderExtensions.cs deleted file mode 100644 index f1e2dbd..0000000 --- a/NppMarkdownPanel/Markdig/Helpers/StringBuilderExtensions.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System.Text; - -namespace Markdig.Helpers -{ - /// - /// Extensions for StringBuilder with - /// - public static class StringBuilderExtensions - { - /// - /// Appends the specified slice to this instance. - /// - /// The builder. - /// The slice. - public static StringBuilder Append(this StringBuilder builder, StringSlice slice) - { - return builder.Append(slice.Text, slice.Start, slice.Length); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Helpers/StringLine.cs b/NppMarkdownPanel/Markdig/Helpers/StringLine.cs deleted file mode 100644 index 096d726..0000000 --- a/NppMarkdownPanel/Markdig/Helpers/StringLine.cs +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -namespace Markdig.Helpers -{ - /// - /// A struct representing a text line. - /// - public struct StringLine - { - /// - /// Initializes a new instance of the struct. - /// - /// The slice. - public StringLine(ref StringSlice slice) : this() - { - Slice = slice; - } - - /// - /// Initializes a new instance of the struct. - /// - /// The slice. - /// The line. - /// The column. - public StringLine(StringSlice slice, int line, int column, int position) - { - Slice = slice; - Line = line; - Column = column; - Position = position; - } - - /// - /// Initializes a new instance of the struct. - /// - /// The slice. - /// The line. - /// The column. - public StringLine(ref StringSlice slice, int line, int column, int position) - { - Slice = slice; - Line = line; - Column = column; - Position = position; - } - - /// - /// The slice used for this line. - /// - public StringSlice Slice; - - /// - /// The line position. - /// - public int Line; - - /// - /// The position of the start of this line within the original source code - /// - public int Position; - - /// - /// The column position. - /// - public int Column; - - /// - /// Performs an implicit conversion from to . - /// - /// The line. - /// - /// The result of the conversion. - /// - public static implicit operator StringSlice(StringLine line) - { - return line.Slice; - } - - public override string ToString() - { - return Slice.ToString(); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Helpers/StringLineGroup.cs b/NppMarkdownPanel/Markdig/Helpers/StringLineGroup.cs deleted file mode 100644 index 8f8a660..0000000 --- a/NppMarkdownPanel/Markdig/Helpers/StringLineGroup.cs +++ /dev/null @@ -1,333 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics; -using System.Runtime.CompilerServices; -using Markdig.Extensions.Tables; - -namespace Markdig.Helpers -{ - /// - /// A group of . - /// - /// - public struct StringLineGroup : IEnumerable - { - /// - /// Initializes a new instance of the class. - /// - /// - public StringLineGroup(int capacity) - { - if (capacity <= 0) throw new ArgumentOutOfRangeException(nameof(capacity)); - Lines = new StringLine[capacity]; - Count = 0; - } - - /// - /// Initializes a new instance of the class. - /// - /// The text. - /// - public StringLineGroup(string text) - { - if (text == null) throw new ArgumentNullException(nameof(text)); - Lines = new StringLine[1]; - Count = 0; - Add(new StringSlice(text)); - } - - /// - /// Gets the lines. - /// - public StringLine[] Lines { get; private set; } - - /// - /// Gets the number of lines. - /// - public int Count { get; private set; } - - /// - /// Clears this instance. - /// - public void Clear() - { - Array.Clear(Lines, 0, Lines.Length); - Count = 0; - } - - /// - /// Removes the line at the specified index. - /// - /// The index. - public void RemoveAt(int index) - { - if (Count - 1 == index) - { - Count--; - } - else - { - Array.Copy(Lines, index + 1, Lines, index, Count - index - 1); - Lines[Count - 1] = new StringLine(); - Count--; - } - } - - /// - /// Adds the specified line to this instance. - /// - /// The line. - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public void Add(ref StringLine line) - { - if (Count == Lines.Length) IncreaseCapacity(); - Lines[Count++] = line; - } - - /// - /// Adds the specified slice to this instance. - /// - /// The slice. - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public void Add(StringSlice slice) - { - if (Count == Lines.Length) IncreaseCapacity(); - Lines[Count++] = new StringLine(ref slice); - } - - public override string ToString() - { - return ToSlice().ToString(); - } - - /// - /// Converts the lines to a single by concatenating the lines. - /// - /// The position of the `\n` line offsets from the beginning of the returned slice. - /// A single slice concatenating the lines of this instance - public StringSlice ToSlice(List lineOffsets = null) - { - // Optimization case when no lines - if (Count == 0) - { - return new StringSlice(string.Empty); - } - - // Optimization case for a single line. - if (Count == 1) - { - if (lineOffsets != null) - { - lineOffsets.Add(new LineOffset(Lines[0].Position, Lines[0].Column, Lines[0].Slice.Start - Lines[0].Position, Lines[0].Slice.Start, Lines[0].Slice.End + 1)); - } - return Lines[0]; - } - - // Else use a builder - var builder = StringBuilderCache.Local(); - int previousStartOfLine = 0; - for (int i = 0; i < Count; i++) - { - if (i > 0) - { - if (lineOffsets != null) - { - lineOffsets.Add(new LineOffset(Lines[i - 1].Position, Lines[i - 1].Column, Lines[i - 1].Slice.Start - Lines[i - 1].Position, previousStartOfLine, builder.Length)); - } - builder.Append('\n'); - previousStartOfLine = builder.Length; - } - if (!Lines[i].Slice.IsEmpty) - { - builder.Append(Lines[i].Slice.Text, Lines[i].Slice.Start, Lines[i].Slice.Length); - } - } - if (lineOffsets != null) - { - lineOffsets.Add(new LineOffset(Lines[Count - 1].Position, Lines[Count - 1].Column, Lines[Count - 1].Slice.Start - Lines[Count - 1].Position, previousStartOfLine, builder.Length)); - } - var str = builder.ToString(); - builder.Length = 0; - return new StringSlice(str); - } - - /// - /// Converts this instance into a . - /// - /// - public Iterator ToCharIterator() - { - return new Iterator(this); - } - - /// - /// Trims each lines of the specified . - /// - public void Trim() - { - for (int i = 0; i < Count; i++) - { - Lines[i].Slice.Trim(); - } - } - - IEnumerator IEnumerable.GetEnumerator() - { - return Lines.GetEnumerator(); - } - - private void IncreaseCapacity() - { - var newItems = new StringLine[Lines.Length * 2]; - if (Count > 0) - { - Array.Copy(Lines, 0, newItems, 0, Count); - } - Lines = newItems; - } - - /// - /// The iterator used to iterate other the lines. - /// - /// - public struct Iterator : ICharIterator - { - private readonly StringLineGroup _lines; - private int _offset; - - public Iterator(StringLineGroup lines) - { - this._lines = lines; - Start = -1; - _offset = -1; - SliceIndex = 0; - CurrentChar = '\0'; - End = -2; - for (int i = 0; i < lines.Count; i++) - { - End += lines.Lines[i].Slice.Length + 1; // Add chars - } - NextChar(); - } - - public int Start { get; private set; } - - public char CurrentChar { get; private set; } - - public int End { get; private set; } - - public bool IsEmpty => Start > End; - - public int SliceIndex { get; private set; } - - public StringLineGroup Remaining() - { - var lines = _lines; - if (CurrentChar == '\0') - { - lines.Clear(); - } - else - { - for (int i = SliceIndex - 1; i >= 0; i--) - { - lines.RemoveAt(i); - } - - if (lines.Count > 0 && _offset > 0) - { - lines.Lines[0].Column += _offset; - lines.Lines[0].Slice.Start += _offset; - } - } - - return lines; - } - - public char NextChar() - { - Start++; - _offset++; - if (Start <= End) - { - var slice = (StringSlice)_lines.Lines[SliceIndex]; - if (_offset < slice.Length) - { - CurrentChar = slice[slice.Start + _offset]; - } - else - { - CurrentChar = '\n'; - SliceIndex++; - _offset = -1; - } - } - else - { - CurrentChar = '\0'; - Start = End + 1; - SliceIndex = _lines.Count; - _offset--; - } - return CurrentChar; - } - - public char PeekChar(int offset = 1) - { - if (offset < 0) throw new ArgumentOutOfRangeException("Negative offset are not supported for StringLineGroup", nameof(offset)); - - if (Start + offset > End) - { - return '\0'; - } - - var slice = (StringSlice)_lines.Lines[SliceIndex]; - if (_offset + offset >= slice.Length) - { - return '\n'; - } - - return slice[slice.Start + _offset + offset]; - } - - public bool TrimStart() - { - var c = CurrentChar; - bool hasSpaces = false; - while (c.IsWhitespace()) - { - hasSpaces = true; - c = NextChar(); - } - return hasSpaces; - } - } - - public struct LineOffset - { - public LineOffset(int linePosition, int column, int offset, int start, int end) - { - LinePosition = linePosition; - Column = column; - Offset = offset; - Start = start; - End = end; - } - - public readonly int LinePosition; - - public readonly int Column; - - public readonly int Offset; - - public readonly int Start; - - public readonly int End; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Helpers/StringSlice.cs b/NppMarkdownPanel/Markdig/Helpers/StringSlice.cs deleted file mode 100644 index 04c49f1..0000000 --- a/NppMarkdownPanel/Markdig/Helpers/StringSlice.cs +++ /dev/null @@ -1,375 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Runtime.CompilerServices; - -namespace Markdig.Helpers -{ - /// - /// A lightweight struct that represents a slice of a string. - /// - /// - public struct StringSlice : ICharIterator - { - /// - /// An empty string slice. - /// - public static readonly StringSlice Empty = new StringSlice(string.Empty); - - /// - /// Initializes a new instance of the struct. - /// - /// The text. - public StringSlice(string text) - { - Text = text; - Start = 0; - End = (Text?.Length ?? 0) - 1; - } - - /// - /// Initializes a new instance of the struct. - /// - /// The text. - /// The start. - /// The end. - /// - public StringSlice(string text, int start, int end) - { - if (text == null) throw new ArgumentNullException(nameof(text)); - Text = text; - Start = start; - End = end; - } - - /// - /// The text of this slice. - /// - public readonly string Text; - - /// - /// Gets or sets the start position within . - /// - public int Start { get; set; } - - /// - /// Gets or sets the end position (inclusive) within . - /// - public int End { get; set; } - - /// - /// Gets the length. - /// - public int Length => End - Start + 1; - - /// - /// Gets the current character. - /// - public char CurrentChar => Start <= End ? this[Start] : '\0'; - - /// - /// Gets a value indicating whether this instance is empty. - /// - public bool IsEmpty => Start > End; - - /// - /// Gets the at the specified index. - /// - /// The index. - /// A character in the slice at the specified index (not from but from the begining of the slice) - public char this[int index] => Text[index]; - - /// - /// Goes to the next character, incrementing the position. - /// - /// - /// The next character. `\0` is end of the iteration. - /// - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public char NextChar() - { - Start++; - if (Start > End) - { - Start = End + 1; - return '\0'; - } - return Text[Start]; - } - - /// - /// Peeks a character at the specified offset from the current position - /// inside the range and , returns `\0` if outside this range. - /// - /// The offset. - /// The character at offset, returns `\0` if none. - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public char PeekChar(int offset = 1) - { - var index = Start + offset; - return index >= Start && index <= End ? Text[index] : (char) 0; - } - - /// - /// Peeks a character at the specified offset from the current beginning of the string, without taking into account and - /// - /// The character at offset, returns `\0` if none. - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public char PeekCharAbsolute(int index) - { - return index >= 0 && index < Text.Length ? Text[index] : (char)0; - } - - /// - /// Peeks a character at the specified offset from the current begining of the slice - /// without using the range or , returns `\0` if outside the . - /// - /// The offset. - /// The character at offset, returns `\0` if none. - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public char PeekCharExtra(int offset) - { - var index = Start + offset; - return index >= 0 && index < Text.Length ? Text[index] : (char)0; - } - - /// - /// Matches the specified text. - /// - /// The text. - /// The offset. - /// true if the text matches; false otherwise - public bool Match(string text, int offset = 0) - { - return Match(text, End, offset); - } - - /// - /// Matches the specified text. - /// - /// The text. - /// The end. - /// The offset. - /// true if the text matches; false otherwise - public bool Match(string text, int end, int offset) - { - var index = Start + offset; - int i = 0; - for (; index <= end && i < text.Length; i++, index++) - { - if (text[i] != Text[index]) - { - return false; - } - } - - return i == text.Length; - } - - /// - /// Expect spaces until a end of line. Return false otherwise. - /// - /// true if whitespaces where matched until a end of line - public bool SkipSpacesToEndOfLineOrEndOfDocument() - { - for (int i = Start; i <= End; i++) - { - var c = Text[i]; - if (c.IsWhitespace()) - { - if (c == '\0' || c == '\n' || (c == '\r' && i + 1 <= End && Text[i + 1] != '\n')) - { - return true; - } - continue; - } - return false; - } - return true; - } - - /// - /// Matches the specified text using lowercase comparison. - /// - /// The text. - /// The offset. - /// true if the text matches; false otherwise - public bool MatchLowercase(string text, int offset = 0) - { - return MatchLowercase(text, End, offset); - } - - /// - /// Matches the specified text using lowercase comparison. - /// - /// The text. - /// The end. - /// The offset. - /// true if the text matches; false otherwise - public bool MatchLowercase(string text, int end, int offset) - { - var index = Start + offset; - int i = 0; - for (; index <= end && i < text.Length; i++, index++) - { - if (text[i] != char.ToLowerInvariant(Text[index])) - { - return false; - } - } - - return i == text.Length; - } - - /// - /// Searches the specified text within this slice. - /// - /// The text. - /// The offset. - /// true if ignore case - /// true if the text was found; false otherwise - public int IndexOf(string text, int offset = 0, bool ignoreCase = false) - { - var end = End - text.Length + 1; - if (ignoreCase) - { - for (int i = Start + offset; i <= end; i++) - { - if (MatchLowercase(text, End, i - Start)) - { - return i; ; - } - } - } - else - { - for (int i = Start + offset; i <= end; i++) - { - if (Match(text, End, i - Start)) - { - return i; ; - } - } - } - return -1; - } - - /// - /// Searches for the specified character within this slice. - /// - /// A value >= 0 if the character was found, otherwise < 0 - public int IndexOf(char c) - { - for (int i = Start; i <= End; i++) - { - if (Text[i] == c) - { - return i; - } - } - return -1; - } - - /// - /// Trims whitespaces at the beginning of this slice starting from position. - /// - /// - /// true if it has reaches the end of the iterator - /// - public bool TrimStart() - { - // Strip leading spaces - var start = Start; - for (; Start <= End; Start++) - { - if (!Text[Start].IsWhitespace()) - { - break; - } - } - return start != Start; - } - - /// - /// Trims whitespaces at the beginning of this slice starting from position. - /// - /// The number of spaces trimmed. - public void TrimStart(out int spaceCount) - { - spaceCount = 0; - // Strip leading spaces - for (; Start <= End; Start++) - { - if (!Text[Start].IsWhitespace()) - { - break; - } - spaceCount++; - } - } - - /// - /// Trims whitespaces at the end of this slice, starting from position. - /// - /// - public bool TrimEnd() - { - for (; Start <= End; End--) - { - if (!Text[End].IsWhitespace()) - { - break; - } - } - return IsEmpty; - } - - /// - /// Trims whitespaces from both the start and end of this slice. - /// - public void Trim() - { - TrimStart(); - TrimEnd(); - } - - /// - /// Returns a that represents this instance. - /// - /// - /// A that represents this instance. - /// - public override string ToString() - { - if (Text != null && Start <= End) - { - var length = Length; - if (Start == 0 && Text.Length == length) - { - return Text; - } - - return Text.Substring(Start, length); - } - return string.Empty; - } - - /// - /// Determines whether this slice is empty or made only of whitespaces. - /// - /// true if this slice is empty or made only of whitespaces; false otherwise - public bool IsEmptyOrWhitespace() - { - for (int i = Start; i <= End; i++) - { - if (!Text[i].IsWhitespace()) - { - return false; - } - } - return true; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Helpers/ThrowHelper.cs b/NppMarkdownPanel/Markdig/Helpers/ThrowHelper.cs deleted file mode 100644 index 256a295..0000000 --- a/NppMarkdownPanel/Markdig/Helpers/ThrowHelper.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System; -using System.Diagnostics; - -namespace Markdig.Helpers -{ - /// - /// Inspired by CoreLib, taken from https://github.com/MihaZupan/SharpCollections, cc @MihaZupan - /// - internal static class ThrowHelper - { - public static void ThrowArgumentNullException(ExceptionArgument argument) - { - throw new ArgumentNullException(GetArgumentName(argument)); - } - - public static void ThrowArgumentException(ExceptionArgument argument, ExceptionReason reason) - { - throw new ArgumentException(GetArgumentName(argument), GetExceptionReason(reason)); - } - - public static void ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionReason reason) - { - throw new ArgumentOutOfRangeException(GetArgumentName(argument), GetExceptionReason(reason)); - } - - public static void ThrowIndexOutOfRangeException() - { - throw new IndexOutOfRangeException(); - } - - private static string GetArgumentName(ExceptionArgument argument) - { - switch (argument) - { - case ExceptionArgument.key: - case ExceptionArgument.input: - case ExceptionArgument.value: - case ExceptionArgument.length: - case ExceptionArgument.text: - return argument.ToString(); - - case ExceptionArgument.offsetLength: - return "offset and length"; - - default: - Debug.Assert(false, "The enum value is not defined, please check the ExceptionArgument Enum."); - return ""; - } - } - private static string GetExceptionReason(ExceptionReason reason) - { - switch (reason) - { - case ExceptionReason.String_Empty: - return "String must not be empty."; - - case ExceptionReason.SmallCapacity: - return "Capacity was less than the current size."; - - case ExceptionReason.InvalidOffsetLength: - return "Offset and length must refer to a position in the string."; - - case ExceptionReason.DuplicateKey: - return "The given key is already present in the dictionary."; - - default: - Debug.Assert(false, "The enum value is not defined, please check the ExceptionReason Enum."); - return ""; - } - } - } - - internal enum ExceptionArgument - { - key, - input, - value, - length, - offsetLength, - text - } - - internal enum ExceptionReason - { - String_Empty, - SmallCapacity, - InvalidOffsetLength, - DuplicateKey, - } -} diff --git a/NppMarkdownPanel/Markdig/IMarkdownExtension.cs b/NppMarkdownPanel/Markdig/IMarkdownExtension.cs deleted file mode 100644 index 6c404ad..0000000 --- a/NppMarkdownPanel/Markdig/IMarkdownExtension.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Renderers; - -namespace Markdig -{ - /// - /// Base interface for an extension. - /// - public interface IMarkdownExtension - { - /// - /// Setups this extension for the specified pipeline. - /// - /// The pipeline. - void Setup(MarkdownPipelineBuilder pipeline); - - /// - /// Setups this extension for the specified renderer. - /// - /// The pipeline used to parse the document. - /// The renderer. - void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer); - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Markdown.cs b/NppMarkdownPanel/Markdig/Markdown.cs deleted file mode 100644 index d09ac80..0000000 --- a/NppMarkdownPanel/Markdig/Markdown.cs +++ /dev/null @@ -1,214 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System; -using System.IO; -using System.Reflection; -using Markdig.Extensions.SelfPipeline; -using Markdig.Parsers; -using Markdig.Renderers; -using Markdig.Renderers.Normalize; -using Markdig.Syntax; - -namespace Markdig -{ - /// - /// Provides methods for parsing a Markdown string to a syntax tree and converting it to other formats. - /// - public static partial class Markdown - { -#if NETSTANDARD_11 - public static readonly string Version = typeof(Markdown).GetTypeInfo().Assembly.GetCustomAttribute().Version; -#else - public static readonly string Version = ((AssemblyFileVersionAttribute) typeof(Markdown).Assembly.GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false)[0]).Version; -#endif - - /// - /// Normalizes the specified markdown to a normalized markdown text. - /// - /// The markdown. - /// The normalize options - /// The pipeline. - /// A parser context used for the parsing. - /// A normalized markdown text. - public static string Normalize(string markdown, NormalizeOptions options = null, MarkdownPipeline pipeline = null, MarkdownParserContext context = null) - { - var writer = new StringWriter(); - Normalize(markdown, writer, options, pipeline, context); - return writer.ToString(); - } - - /// - /// Normalizes the specified markdown to a normalized markdown text. - /// - /// The markdown. - /// The destination that will receive the result of the conversion. - /// The normalize options - /// The pipeline. - /// A parser context used for the parsing. - /// A normalized markdown text. - public static MarkdownDocument Normalize(string markdown, TextWriter writer, NormalizeOptions options = null, MarkdownPipeline pipeline = null, MarkdownParserContext context = null) - { - pipeline = pipeline ?? new MarkdownPipelineBuilder().Build(); - pipeline = CheckForSelfPipeline(pipeline, markdown); - - // We override the renderer with our own writer - var renderer = new NormalizeRenderer(writer, options); - pipeline.Setup(renderer); - - var document = Parse(markdown, pipeline, context); - renderer.Render(document); - writer.Flush(); - - return document; - } - - /// - /// Converts a Markdown string to HTML. - /// - /// A Markdown text. - /// The pipeline used for the conversion. - /// The result of the conversion - /// if markdown variable is null - public static string ToHtml(string markdown, MarkdownPipeline pipeline = null) - { - if (markdown == null) throw new ArgumentNullException(nameof(markdown)); - var writer = new StringWriter(); - ToHtml(markdown, writer, pipeline); - return writer.ToString(); - } - - /// - /// Converts a Markdown string to HTML and output to the specified writer. - /// - /// A Markdown text. - /// The destination that will receive the result of the conversion. - /// The pipeline used for the conversion. - /// A parser context used for the parsing. - /// The Markdown document that has been parsed - /// if reader or writer variable are null - public static MarkdownDocument ToHtml(string markdown, TextWriter writer, MarkdownPipeline pipeline = null, MarkdownParserContext context = null) - { - if (markdown == null) throw new ArgumentNullException(nameof(markdown)); - if (writer == null) throw new ArgumentNullException(nameof(writer)); - pipeline = pipeline ?? new MarkdownPipelineBuilder().Build(); - pipeline = CheckForSelfPipeline(pipeline, markdown); - - // We override the renderer with our own writer - var renderer = new HtmlRenderer(writer); - pipeline.Setup(renderer); - - var document = Parse(markdown, pipeline, context); - renderer.Render(document); - writer.Flush(); - - return document; - } - - /// - /// Converts a Markdown string using a custom . - /// - /// A Markdown text. - /// The renderer to convert Markdown to. - /// The pipeline used for the conversion. - /// A parser context used for the parsing. - /// if markdown or writer variable are null - public static object Convert(string markdown, IMarkdownRenderer renderer, MarkdownPipeline pipeline = null, MarkdownParserContext context = null) - { - if (markdown == null) throw new ArgumentNullException(nameof(markdown)); - if (renderer == null) throw new ArgumentNullException(nameof(renderer)); - pipeline = pipeline ?? new MarkdownPipelineBuilder().Build(); - - pipeline = CheckForSelfPipeline(pipeline, markdown); - var document = Parse(markdown, pipeline, context); - pipeline.Setup(renderer); - return renderer.Render(document); - } - - /// - /// Parses the specified markdown into an AST - /// - /// The markdown text. - /// An AST Markdown document - /// if markdown variable is null - public static MarkdownDocument Parse(string markdown) - { - if (markdown == null) throw new ArgumentNullException(nameof(markdown)); - return Parse(markdown, null); - } - - /// - /// Parses the specified markdown into an AST - /// - /// The markdown text. - /// The pipeline used for the parsing. - /// A parser context used for the parsing. - /// An AST Markdown document - /// if markdown variable is null - public static MarkdownDocument Parse(string markdown, MarkdownPipeline pipeline, MarkdownParserContext context = null) - { - if (markdown == null) throw new ArgumentNullException(nameof(markdown)); - pipeline = pipeline ?? new MarkdownPipelineBuilder().Build(); - - pipeline = CheckForSelfPipeline(pipeline, markdown); - return MarkdownParser.Parse(markdown, pipeline, context); - } - - private static MarkdownPipeline CheckForSelfPipeline(MarkdownPipeline pipeline, string markdown) - { - var selfPipeline = pipeline.Extensions.Find(); - if (selfPipeline != null) - { - return selfPipeline.CreatePipelineFromInput(markdown); - } - return pipeline; - } - - /// - /// Converts a Markdown string to Plain text and output to the specified writer. - /// - /// A Markdown text. - /// The destination that will receive the result of the conversion. - /// The pipeline used for the conversion. - /// A parser context used for the parsing. - /// The Markdown document that has been parsed - /// if reader or writer variable are null - public static MarkdownDocument ToPlainText(string markdown, TextWriter writer, MarkdownPipeline pipeline = null, MarkdownParserContext context = null) - { - if (markdown == null) throw new ArgumentNullException(nameof(markdown)); - if (writer == null) throw new ArgumentNullException(nameof(writer)); - pipeline = pipeline ?? new MarkdownPipelineBuilder().Build(); - pipeline = CheckForSelfPipeline(pipeline, markdown); - - // We override the renderer with our own writer - var renderer = new HtmlRenderer(writer) - { - EnableHtmlForBlock = false, - EnableHtmlForInline = false - }; - pipeline.Setup(renderer); - - var document = Parse(markdown, pipeline, context); - renderer.Render(document); - writer.Flush(); - - return document; - } - - /// - /// Converts a Markdown string to HTML. - /// - /// A Markdown text. - /// The pipeline used for the conversion. - /// A parser context used for the parsing. - /// The result of the conversion - /// if markdown variable is null - public static string ToPlainText(string markdown, MarkdownPipeline pipeline = null, MarkdownParserContext context = null) - { - if (markdown == null) throw new ArgumentNullException(nameof(markdown)); - var writer = new StringWriter(); - ToPlainText(markdown, writer, pipeline, context); - return writer.ToString(); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/MarkdownExtensions.cs b/NppMarkdownPanel/Markdig/MarkdownExtensions.cs deleted file mode 100644 index e2a4c06..0000000 --- a/NppMarkdownPanel/Markdig/MarkdownExtensions.cs +++ /dev/null @@ -1,620 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using Markdig.Extensions.Abbreviations; -using Markdig.Extensions.AutoIdentifiers; -using Markdig.Extensions.AutoLinks; -using Markdig.Extensions.Bootstrap; -using Markdig.Extensions.Citations; -using Markdig.Extensions.CustomContainers; -using Markdig.Extensions.DefinitionLists; -using Markdig.Extensions.Diagrams; -using Markdig.Extensions.Emoji; -using Markdig.Extensions.EmphasisExtras; -using Markdig.Extensions.Figures; -using Markdig.Extensions.Footers; -using Markdig.Extensions.Footnotes; -using Markdig.Extensions.GenericAttributes; -using Markdig.Extensions.Hardlines; -using Markdig.Extensions.JiraLinks; -using Markdig.Extensions.ListExtras; -using Markdig.Extensions.Mathematics; -using Markdig.Extensions.MediaLinks; -using Markdig.Extensions.NoRefLinks; -using Markdig.Extensions.PragmaLines; -using Markdig.Extensions.SelfPipeline; -using Markdig.Extensions.SmartyPants; -using Markdig.Extensions.NonAsciiNoEscape; -using Markdig.Extensions.Tables; -using Markdig.Extensions.TaskLists; -using Markdig.Extensions.TextRenderer; -using Markdig.Extensions.Yaml; -using Markdig.Parsers; -using Markdig.Parsers.Inlines; -using Markdig.Extensions.Globalization; - -namespace Markdig -{ - /// - /// Provides extension methods for to enable several Markdown extensions. - /// - public static class MarkdownExtensions - { - /// - /// Adds the specified extension to the extensions collection. - /// - /// The type of the extension. - /// The instance of - public static MarkdownPipelineBuilder Use(this MarkdownPipelineBuilder pipeline) where TExtension : class, IMarkdownExtension, new() - { - pipeline.Extensions.AddIfNotAlready(); - return pipeline; - } - - /// - /// Adds the specified extension instance to the extensions collection. - /// - /// The pipeline. - /// The instance of the extension to be added. - /// The type of the extension. - /// The modified pipeline - public static MarkdownPipelineBuilder Use(this MarkdownPipelineBuilder pipeline, TExtension extension) where TExtension : class, IMarkdownExtension - { - pipeline.Extensions.AddIfNotAlready(extension); - return pipeline; - } - - /// - /// Uses all extensions except the BootStrap, Emoji, SmartyPants and soft line as hard line breaks extensions. - /// - /// The pipeline. - /// The modified pipeline - public static MarkdownPipelineBuilder UseAdvancedExtensions(this MarkdownPipelineBuilder pipeline) - { - return pipeline - .UseAbbreviations() - .UseAutoIdentifiers() - .UseCitations() - .UseCustomContainers() - .UseDefinitionLists() - .UseEmphasisExtras() - .UseFigures() - .UseFooters() - .UseFootnotes() - .UseGridTables() - .UseMathematics() - .UseMediaLinks() - .UsePipeTables() - .UseListExtras() - .UseTaskLists() - .UseDiagrams() - .UseAutoLinks() - .UseGenericAttributes(); // Must be last as it is one parser that is modifying other parsers - } - - /// - /// Uses this extension to enable autolinks from text `http://`, `https://`, `ftp://`, `mailto:`, `www.xxx.yyy` - /// - /// The pipeline. - /// The modified pipeline - public static MarkdownPipelineBuilder UseAutoLinks(this MarkdownPipelineBuilder pipeline, string validPreviousCharacters = AutoLinkParser.DefaultValidPreviousCharacters) - { - pipeline.Extensions.ReplaceOrAdd(new AutoLinkExtension(validPreviousCharacters)); - return pipeline; - } - - /// - /// Uses this extension to disable URI escape with % characters for non-US-ASCII characters in order to workaround a bug under IE/Edge with local file links containing non US-ASCII chars. DO NOT USE OTHERWISE. - /// - /// The pipeline. - /// The modified pipeline - public static MarkdownPipelineBuilder UseNonAsciiNoEscape(this MarkdownPipelineBuilder pipeline) - { - pipeline.Extensions.AddIfNotAlready(); - return pipeline; - } - - /// - /// Uses YAML frontmatter extension that will parse a YAML frontmatter into the MarkdownDocument. Note that they are not rendered by any default HTML renderer. - /// - /// The pipeline. - /// The modified pipeline - public static MarkdownPipelineBuilder UseYamlFrontMatter(this MarkdownPipelineBuilder pipeline) - { - pipeline.Extensions.AddIfNotAlready(); - return pipeline; - } - - /// - /// Uses the self pipeline extension that will detect the pipeline to use from the markdown input that contains a special tag. See - /// - /// The pipeline. - /// The default tag to use to match the self pipeline configuration. By default, , meaning that the HTML tag will be <--markdig:extensions--> - /// The default extensions to configure if no pipeline setup was found from the Markdown document - /// The modified pipeline - public static MarkdownPipelineBuilder UseSelfPipeline(this MarkdownPipelineBuilder pipeline, string defaultTag = SelfPipelineExtension.DefaultTag, string defaultExtensions = null) - { - if (pipeline.Extensions.Count != 0) - { - throw new InvalidOperationException("The SelfPipeline extension cannot be used with other extensions"); - } - - pipeline.Extensions.Add(new SelfPipelineExtension(defaultTag, defaultExtensions)); - return pipeline; - } - - /// - /// Uses pragma lines to output span with an id containing the line number (pragma-line#line_number_zero_based`) - /// - /// The pipeline. - /// The modified pipeline - public static MarkdownPipelineBuilder UsePragmaLines(this MarkdownPipelineBuilder pipeline) - { - pipeline.Extensions.AddIfNotAlready(); - return pipeline; - } - - /// - /// Uses the diagrams extension - /// - /// The pipeline. - /// The modified pipeline - public static MarkdownPipelineBuilder UseDiagrams(this MarkdownPipelineBuilder pipeline) - { - pipeline.Extensions.AddIfNotAlready(); - return pipeline; - } - - /// - /// Uses precise source code location (useful for syntax highlighting). - /// - /// The pipeline. - /// The modified pipeline - public static MarkdownPipelineBuilder UsePreciseSourceLocation(this MarkdownPipelineBuilder pipeline) - { - pipeline.PreciseSourceLocation = true; - return pipeline; - } - - /// - /// Uses the task list extension. - /// - /// The pipeline. - /// The modified pipeline - public static MarkdownPipelineBuilder UseTaskLists(this MarkdownPipelineBuilder pipeline) - { - pipeline.Extensions.AddIfNotAlready(); - return pipeline; - } - - /// - /// Uses the custom container extension. - /// - /// The pipeline. - /// The modified pipeline - public static MarkdownPipelineBuilder UseCustomContainers(this MarkdownPipelineBuilder pipeline) - { - pipeline.Extensions.AddIfNotAlready(); - return pipeline; - } - - /// - /// Uses the media extension. - /// - /// The pipeline. - /// The options. - /// - /// The modified pipeline - /// - public static MarkdownPipelineBuilder UseMediaLinks(this MarkdownPipelineBuilder pipeline, MediaOptions options = null) - { - if (!pipeline.Extensions.Contains()) - { - pipeline.Extensions.Add(new MediaLinkExtension(options)); - } - return pipeline; - } - - /// - /// Uses the auto-identifier extension. - /// - /// The pipeline. - /// The options. - /// - /// The modified pipeline - /// - public static MarkdownPipelineBuilder UseAutoIdentifiers(this MarkdownPipelineBuilder pipeline, AutoIdentifierOptions options = AutoIdentifierOptions.Default) - { - if (!pipeline.Extensions.Contains()) - { - pipeline.Extensions.Add(new AutoIdentifierExtension(options)); - } - return pipeline; - } - - /// - /// Uses the SmartyPants extension. - /// - /// The pipeline. - /// The options. - /// - /// The modified pipeline - /// - public static MarkdownPipelineBuilder UseSmartyPants(this MarkdownPipelineBuilder pipeline, SmartyPantOptions options = null) - { - if (!pipeline.Extensions.Contains()) - { - pipeline.Extensions.Add(new SmartyPantsExtension(options)); - } - return pipeline; - } - - /// - /// Uses the bootstrap extension. - /// - /// The pipeline. - /// The modified pipeline - public static MarkdownPipelineBuilder UseBootstrap(this MarkdownPipelineBuilder pipeline) - { - pipeline.Extensions.AddIfNotAlready(); - return pipeline; - } - - /// - /// Uses the math extension. - /// - /// The pipeline. - /// The modified pipeline - public static MarkdownPipelineBuilder UseMathematics(this MarkdownPipelineBuilder pipeline) - { - pipeline.Extensions.AddIfNotAlready(); - return pipeline; - } - - /// - /// Uses the figure extension. - /// - /// The pipeline. - /// The modified pipeline - public static MarkdownPipelineBuilder UseFigures(this MarkdownPipelineBuilder pipeline) - { - pipeline.Extensions.AddIfNotAlready(); - return pipeline; - } - - /// - /// Uses the custom abbreviation extension. - /// - /// The pipeline. - /// The modified pipeline - public static MarkdownPipelineBuilder UseAbbreviations(this MarkdownPipelineBuilder pipeline) - { - pipeline.Extensions.AddIfNotAlready(); - return pipeline; - } - - /// - /// Uses the definition lists extension. - /// - /// The pipeline. - /// The modified pipeline - public static MarkdownPipelineBuilder UseDefinitionLists(this MarkdownPipelineBuilder pipeline) - { - pipeline.Extensions.AddIfNotAlready(); - return pipeline; - } - - /// - /// Uses the pipe table extension. - /// - /// The pipeline. - /// The options. - /// - /// The modified pipeline - /// - public static MarkdownPipelineBuilder UsePipeTables(this MarkdownPipelineBuilder pipeline, PipeTableOptions options = null) - { - if (!pipeline.Extensions.Contains()) - { - pipeline.Extensions.Add(new PipeTableExtension(options)); - } - return pipeline; - } - - /// - /// Uses the grid table extension. - /// - /// The pipeline. - /// The modified pipeline - public static MarkdownPipelineBuilder UseGridTables(this MarkdownPipelineBuilder pipeline) - { - pipeline.Extensions.AddIfNotAlready(); - return pipeline; - } - - - /// - /// Uses the cite extension. - /// - /// The pipeline. - /// The modified pipeline - public static MarkdownPipelineBuilder UseCitations(this MarkdownPipelineBuilder pipeline) - { - pipeline.Extensions.AddIfNotAlready(); - return pipeline; - } - - /// - /// Uses the footer extension. - /// - /// The pipeline. - /// The modified pipeline - public static MarkdownPipelineBuilder UseFooters(this MarkdownPipelineBuilder pipeline) - { - pipeline.Extensions.AddIfNotAlready(); - return pipeline; - } - - /// - /// Uses the footnotes extension. - /// - /// The pipeline. - /// The modified pipeline - public static MarkdownPipelineBuilder UseFootnotes(this MarkdownPipelineBuilder pipeline) - { - pipeline.Extensions.AddIfNotAlready(); - return pipeline; - } - - /// - /// Uses the softline break as hardline break extension - /// - /// The pipeline. - /// The modified pipeline - public static MarkdownPipelineBuilder UseSoftlineBreakAsHardlineBreak(this MarkdownPipelineBuilder pipeline) - { - pipeline.Extensions.AddIfNotAlready(); - return pipeline; - } - - /// - /// Uses the strikethrough superscript, subscript, inserted and marked text extensions. - /// - /// The pipeline. - /// The options to enable. - /// - /// The modified pipeline - /// - public static MarkdownPipelineBuilder UseEmphasisExtras(this MarkdownPipelineBuilder pipeline, EmphasisExtraOptions options = EmphasisExtraOptions.Default) - { - if (!pipeline.Extensions.Contains()) - { - pipeline.Extensions.Add(new EmphasisExtraExtension(options)); - } - return pipeline; - } - - /// - /// Uses the list extra extension to add support for `a.`, `A.`, `i.` and `I.` ordered list items. - /// - /// The pipeline. - /// - /// The modified pipeline - /// - public static MarkdownPipelineBuilder UseListExtras(this MarkdownPipelineBuilder pipeline) - { - pipeline.Extensions.AddIfNotAlready(); - return pipeline; - } - - /// - /// Uses the generic attributes extension. - /// - /// The pipeline. - /// The modified pipeline - public static MarkdownPipelineBuilder UseGenericAttributes(this MarkdownPipelineBuilder pipeline) - { - pipeline.Extensions.AddIfNotAlready(); - return pipeline; - } - - /// - /// Uses the emoji and smiley extension. - /// - /// The pipeline. - /// Enable smiley in addition to Emoji, true by default. - /// The modified pipeline - public static MarkdownPipelineBuilder UseEmojiAndSmiley(this MarkdownPipelineBuilder pipeline, bool enableSmiley = true) - { - if (!pipeline.Extensions.Contains()) - { - pipeline.Extensions.Add(new EmojiExtension(enableSmiley)); - } - return pipeline; - } - - /// - /// Add rel=nofollow to all links rendered to HTML. - /// - /// - /// - public static MarkdownPipelineBuilder UseNoFollowLinks(this MarkdownPipelineBuilder pipeline) - { - pipeline.Extensions.AddIfNotAlready(); - return pipeline; - } - - /// - /// Automatically link references to JIRA issues - /// - /// The pipeline - /// Set of required options - /// The modified pipeline - public static MarkdownPipelineBuilder UseJiraLinks(this MarkdownPipelineBuilder pipeline, JiraLinkOptions options) - { - if (!pipeline.Extensions.Contains()) - { - pipeline.Extensions.Add(new JiraLinkExtension(options)); - } - return pipeline; - } - - /// - /// Adds support for right-to-left content by adding appropriate html attribtues. - /// - /// The pipeline - /// The modified pipeline - public static MarkdownPipelineBuilder UseGlobalization(this MarkdownPipelineBuilder pipeline) - { - pipeline.Extensions.AddIfNotAlready(); - return pipeline; - } - - /// - /// This will disable the HTML support in the markdown processor (for constraint/safe parsing). - /// - /// The pipeline. - /// The modified pipeline - public static MarkdownPipelineBuilder DisableHtml(this MarkdownPipelineBuilder pipeline) - { - var parser = pipeline.BlockParsers.Find(); - if (parser != null) - { - pipeline.BlockParsers.Remove(parser); - } - - var inlineParser = pipeline.InlineParsers.Find(); - if (inlineParser != null) - { - inlineParser.EnableHtmlParsing = false; - } - return pipeline; - } - - /// - /// Configures the pipeline using a string that defines the extensions to activate. - /// - /// The pipeline (e.g: advanced for , pipetables+gridtables for and - /// The extensions to activate as a string - /// The modified pipeline - public static MarkdownPipelineBuilder Configure(this MarkdownPipelineBuilder pipeline, string extensions) - { - if (extensions == null) - { - return pipeline; - } - - // TODO: the extension string should come from the extension itself instead of this hardcoded switch case. - - foreach (var extension in extensions.Split(new[] { '+' }, StringSplitOptions.RemoveEmptyEntries)) - { - switch (extension.ToLowerInvariant()) - { - case "common": - break; - case "advanced": - pipeline.UseAdvancedExtensions(); - break; - case "pipetables": - pipeline.UsePipeTables(); - break; - case "emphasisextras": - pipeline.UseEmphasisExtras(); - break; - case "listextras": - pipeline.UseListExtras(); - break; - case "hardlinebreak": - pipeline.UseSoftlineBreakAsHardlineBreak(); - break; - case "footnotes": - pipeline.UseFootnotes(); - break; - case "footers": - pipeline.UseFooters(); - break; - case "citations": - pipeline.UseCitations(); - break; - case "attributes": - pipeline.UseGenericAttributes(); - break; - case "gridtables": - pipeline.UseGridTables(); - break; - case "abbreviations": - pipeline.UseAbbreviations(); - break; - case "emojis": - pipeline.UseEmojiAndSmiley(); - break; - case "definitionlists": - pipeline.UseDefinitionLists(); - break; - case "customcontainers": - pipeline.UseCustomContainers(); - break; - case "figures": - pipeline.UseFigures(); - break; - case "mathematics": - pipeline.UseMathematics(); - break; - case "bootstrap": - pipeline.UseBootstrap(); - break; - case "medialinks": - pipeline.UseMediaLinks(); - break; - case "smartypants": - pipeline.UseSmartyPants(); - break; - case "autoidentifiers": - pipeline.UseAutoIdentifiers(); - break; - case "tasklists": - pipeline.UseTaskLists(); - break; - case "diagrams": - pipeline.UseDiagrams(); - break; - case "nofollowlinks": - pipeline.UseNoFollowLinks(); - break; - case "nohtml": - pipeline.DisableHtml(); - break; - case "yaml": - pipeline.UseYamlFrontMatter(); - break; - case "nonascii-noescape": - pipeline.UseNonAsciiNoEscape(); - break; - case "autolinks": - pipeline.UseAutoLinks(); - break; - case "globalization": - pipeline.UseGlobalization(); - break; - default: - throw new ArgumentException($"Invalid extension `{extension}` from `{extensions}`", nameof(extensions)); - } - } - return pipeline; - } - - /// - /// Configures the string to be used for line-endings, when writing. - /// - /// The pipeline. - /// The string to be used for line-endings. - /// The modified pipeline - public static MarkdownPipelineBuilder ConfigureNewLine(this MarkdownPipelineBuilder pipeline, string newLine) - { - pipeline.Use(new ConfigureNewLineExtension(newLine)); - return pipeline; - } - } -} diff --git a/NppMarkdownPanel/Markdig/MarkdownParserContext.cs b/NppMarkdownPanel/Markdig/MarkdownParserContext.cs deleted file mode 100644 index aa326ee..0000000 --- a/NppMarkdownPanel/Markdig/MarkdownParserContext.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Collections.Generic; - -namespace Markdig -{ - /// - /// Provides a context that can be used as part of parsing Markdown documents. - /// - public sealed class MarkdownParserContext - { - /// - /// Gets or sets the context property collection. - /// - public Dictionary Properties { get; } - - /// - /// Initializes a new instance of the class. - /// - public MarkdownParserContext() - { - Properties = new Dictionary(); - } - } -} diff --git a/NppMarkdownPanel/Markdig/MarkdownPipeline.cs b/NppMarkdownPanel/Markdig/MarkdownPipeline.cs deleted file mode 100644 index 8cb56b5..0000000 --- a/NppMarkdownPanel/Markdig/MarkdownPipeline.cs +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System; -using System.Collections.ObjectModel; -using System.IO; -using Markdig.Helpers; -using Markdig.Parsers; -using Markdig.Renderers; - -namespace Markdig -{ - /// - /// This class is the Markdown pipeline build from a . - /// - public class MarkdownPipeline - { - // This class is immutable - - /// - /// Initializes a new instance of the class. - /// - internal MarkdownPipeline(OrderedList extensions, BlockParserList blockParsers, InlineParserList inlineParsers, StringBuilderCache cache, TextWriter debugLog, ProcessDocumentDelegate documentProcessed) - { - if (blockParsers == null) throw new ArgumentNullException(nameof(blockParsers)); - if (inlineParsers == null) throw new ArgumentNullException(nameof(inlineParsers)); - // Add all default parsers - Extensions = extensions; - BlockParsers = blockParsers; - InlineParsers = inlineParsers; - StringBuilderCache = cache; - DebugLog = debugLog; - DocumentProcessed = documentProcessed; - } - - internal bool PreciseSourceLocation { get; set; } - - /// - /// The read-only list of extensions used to build this pipeline. - /// - public OrderedList Extensions { get; } - - internal BlockParserList BlockParsers { get; } - - internal InlineParserList InlineParsers { get; } - - internal StringBuilderCache StringBuilderCache { get; } - - // TODO: Move the log to a better place - internal TextWriter DebugLog { get; } - - internal ProcessDocumentDelegate DocumentProcessed; - - /// - /// Allows to setup a . - /// - /// The markdown renderer to setup - public void Setup(IMarkdownRenderer renderer) - { - if (renderer == null) throw new ArgumentNullException(nameof(renderer)); - foreach (var extension in Extensions) - { - extension.Setup(this, renderer); - } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/MarkdownPipelineBuilder.cs b/NppMarkdownPanel/Markdig/MarkdownPipelineBuilder.cs deleted file mode 100644 index c6d975c..0000000 --- a/NppMarkdownPanel/Markdig/MarkdownPipelineBuilder.cs +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System; -using System.IO; -using Markdig.Helpers; -using Markdig.Parsers; -using Markdig.Parsers.Inlines; -using Markdig.Renderers; - -namespace Markdig -{ - /// - /// This class allows to modify the pipeline to parse and render a Markdown document. - /// - /// NOTE: A pipeline is not thread-safe. - public class MarkdownPipelineBuilder - { - private MarkdownPipeline pipeline; - - /// - /// Initializes a new instance of the class. - /// - public MarkdownPipelineBuilder() - { - // Add all default parsers - BlockParsers = new OrderedList() - { - new ThematicBreakParser(), - new HeadingBlockParser(), - new QuoteBlockParser(), - new ListBlockParser(), - - new HtmlBlockParser(), - new FencedCodeBlockParser(), - new IndentedCodeBlockParser(), - new ParagraphBlockParser(), - }; - - InlineParsers = new OrderedList() - { - new HtmlEntityParser(), - new LinkInlineParser(), - new EscapeInlineParser(), - new EmphasisInlineParser(), - new CodeInlineParser(), - new AutolineInlineParser(), - new LineBreakInlineParser(), - }; - - Extensions = new OrderedList(); - - StringBuilderCache = new StringBuilderCache(); - } - - /// - /// Gets the block parsers. - /// - public OrderedList BlockParsers { get; private set; } - - /// - /// Gets the inline parsers. - /// - public OrderedList InlineParsers { get; private set; } - - /// - /// Gets the register extensions. - /// - public OrderedList Extensions { get; } - - /// - /// Gets or sets the string builder cache used by the parsers. - /// - public StringBuilderCache StringBuilderCache { get; set; } - - /// - /// Gets or sets a value indicating whether to enable precise source location (slower parsing but accurate position for block and inline elements) - /// - public bool PreciseSourceLocation { get; set; } - - /// - /// Gets or sets the debug log. - /// - public TextWriter DebugLog { get; set; } - - /// - /// Occurs when a document has been processed after the method. - /// - public event ProcessDocumentDelegate DocumentProcessed; - - internal ProcessDocumentDelegate GetDocumentProcessed => DocumentProcessed; - - /// - /// Builds a pipeline from this instance. Once the pipeline is build, it cannot be modified. - /// - /// An extension cannot be null - public MarkdownPipeline Build() - { - if (pipeline != null) - { - return pipeline; - } - - // TODO: Review the whole initialization process for extensions - // - It does not prevent a user to modify the pipeline after it has been used - // - a pipeline is not thread safe. - // We should find a proper way to make the pipeline safely modifiable/freezable (PipelineBuilder -> Pipeline) - - // Allow extensions to modify existing BlockParsers, InlineParsers and Renderer - foreach (var extension in Extensions) - { - if (extension == null) - { - throw new InvalidOperationException("An extension cannot be null"); - } - extension.Setup(this); - } - - pipeline = new MarkdownPipeline( - new OrderedList(Extensions), - new BlockParserList(BlockParsers), - new InlineParserList(InlineParsers), - StringBuilderCache, - DebugLog, - GetDocumentProcessed) - { - PreciseSourceLocation = PreciseSourceLocation - }; - return pipeline; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/BlockParser.cs b/NppMarkdownPanel/Markdig/Parsers/BlockParser.cs deleted file mode 100644 index 010a288..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/BlockParser.cs +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax; - -namespace Markdig.Parsers -{ - /// - /// Delegates called when processing a block - /// - public delegate void ProcessBlockDelegate(BlockProcessor processor, Block block); - - /// - /// Base class for a parser of a - /// - /// - public abstract class BlockParser : ParserBase, IBlockParser - { - /// - /// Determines whether the specified char is an opening character. - /// - /// The character. - /// true if the specified char is an opening character. - public bool HasOpeningCharacter(char c) - { - if (OpeningCharacters != null) - { - for (int i = 0; i < OpeningCharacters.Length; i++) - { - if (OpeningCharacters[i] == c) - { - return true; - } - } - } - return false; - } - - // TODO: Add comment - public event ProcessBlockDelegate Closed; - - internal ProcessBlockDelegate GetClosedEvent => Closed; - - /// - /// Determines whether this instance can interrupt the specified block being processed. - /// - /// The parser processor. - /// The block being processed. - /// true if this parser can interrupt the specified block being processed. - public virtual bool CanInterrupt(BlockProcessor processor, Block block) - { - // By default, all blocks can interrupt a ParagraphBlock except: - // - Setext heading - // - Indented code block - // - HTML blocks - return true; - } - - /// - /// Tries to match a block opening. - /// - /// The parser processor. - /// The result of the match - public abstract BlockState TryOpen(BlockProcessor processor); - - /// - /// Tries to continue matching a block already opened. - /// - /// The parser processor. - /// The block already opened. - /// The result of the match. By default, don't expect any newline - public virtual BlockState TryContinue(BlockProcessor processor, Block block) - { - // By default we don't expect any newline - return BlockState.None; - } - - /// - /// Called when a block matched by this parser is being closed (to allow final computation on the block). - /// - /// The parser processor. - /// The block being closed. - /// true to keep the block; false to remove it. True by default. - public virtual bool Close(BlockProcessor processor, Block block) - { - // By default keep the block - return true; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/BlockParserList.cs b/NppMarkdownPanel/Markdig/Parsers/BlockParserList.cs deleted file mode 100644 index ad7ef78..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/BlockParserList.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.Collections.Generic; - -namespace Markdig.Parsers -{ - /// - /// A List of . - /// - /// - public class BlockParserList : ParserList - { - /// - /// Initializes a new instance of the class. - /// - /// The parsers. - public BlockParserList(IEnumerable parsers) : base(parsers) - { - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/BlockProcessor.cs b/NppMarkdownPanel/Markdig/Parsers/BlockProcessor.cs deleted file mode 100644 index d8d94ab..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/BlockProcessor.cs +++ /dev/null @@ -1,896 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System; -using System.Collections.Generic; -using System.Diagnostics; -using Markdig.Helpers; -using Markdig.Syntax; - -namespace Markdig.Parsers -{ - /// - /// The block processor. - /// - public class BlockProcessor - { - private BlockProcessor root; - private int currentStackIndex; - private readonly BlockParserStateCache parserStateCache; - private int originalLineStart = 0; - - private BlockProcessor(BlockProcessor root) - { - // These properties are not changing between a parent and a children BlockProcessor - this.root = root; - this.parserStateCache = root.parserStateCache; - StringBuilders = root.StringBuilders; - Document = root.Document; - Parsers = root.Parsers; - - // These properties are local to a state - OpenedBlocks = new List(); - NewBlocks = new Stack(); - } - - /// - /// Initializes a new instance of the class. - /// - /// The string builders cache. - /// The document to build blocks into. - /// The list of parsers. - /// - /// - public BlockProcessor(StringBuilderCache stringBuilders, MarkdownDocument document, BlockParserList parsers, MarkdownParserContext context) - { - if (stringBuilders == null) throw new ArgumentNullException(nameof(stringBuilders)); - if (document == null) throw new ArgumentNullException(nameof(document)); - if (parsers == null) throw new ArgumentNullException(nameof(parsers)); - parserStateCache = new BlockParserStateCache(this); - StringBuilders = stringBuilders; - Document = document; - document.IsOpen = true; - Parsers = parsers; - Context = context; - OpenedBlocks = new List(); - NewBlocks = new Stack(); - root = this; - Open(document); - } - - /// - /// Gets the new blocks to push. A is required to push new blocks that it creates to this property. - /// - public Stack NewBlocks { get; } - - /// - /// Gets the list of configured with this parser state. - /// - public BlockParserList Parsers { get; } - - /// - /// Gets the parser context or null if none is available. - /// - public MarkdownParserContext Context { get; } - - /// - /// Gets the current active container. - /// - public ContainerBlock CurrentContainer { get; private set; } - - /// - /// Gets the last block that is opened. - /// - public Block CurrentBlock { get; private set; } - - /// - /// Gets the last block that is created. - /// - public Block LastBlock { get; private set; } - - /// - /// Gets the next block in a . - /// - public Block NextContinue => currentStackIndex + 1 < OpenedBlocks.Count ? OpenedBlocks[currentStackIndex + 1] : null; - - /// - /// Gets the root document. - /// - public MarkdownDocument Document { get; } - - /// - /// The current line being processed. - /// - public StringSlice Line; - - /// - /// Gets or sets the current line start position. - /// - public int CurrentLineStartPosition { get; private set; } - - /// - /// Gets the index of the line in the source text. - /// - public int LineIndex { get; set; } - - /// - /// Gets a value indicating whether the line is blank (valid only after has been called). - /// - public bool IsBlankLine => CurrentChar == '\0'; - - /// - /// Gets the current character being processed. - /// - public char CurrentChar => Line.CurrentChar; - - /// - /// Gets or sets the column. - /// - public int Column { get; set; } - - /// - /// Gets the position of the current character in the line being processed. - /// - public int Start => Line.Start; - - /// - /// Gets the current indent position (number of columns between the previous indent and the current position). - /// - public int Indent => Column - ColumnBeforeIndent; - - /// - /// Gets a value indicating whether a code indentation is at the beginning of the line being processed. - /// - public bool IsCodeIndent => Indent >= 4; - - /// - /// Gets the column position before the indent occured. - /// - public int ColumnBeforeIndent { get; private set; } - - /// - /// Gets the character position before the indent occured. - /// - public int StartBeforeIndent { get; private set; } - - /// - /// Gets the cache of string builders. - /// - public StringBuilderCache StringBuilders { get; } - - /// - /// Gets the current stack of being processed. - /// - private List OpenedBlocks { get; } - - /// - /// Gets or sets a value indicating whether to continue processing the current line. - /// - private bool ContinueProcessingLine { get; set; } - - /// - /// Get the current Container that is currently opened - /// - /// The current Container that is currently opened - public ContainerBlock GetCurrentContainerOpened() - { - var container = CurrentContainer; - while (container != null && !container.IsOpen) - { - container = container.Parent; - } - - return container; - } - - /// - /// Returns the next character in the line being processed. Update and . - /// - /// The next character or `\0` if end of line is reached - public char NextChar() - { - var c = Line.CurrentChar; - if (c == '\t') - { - Column = CharHelper.AddTab(Column); - } - else - { - Column++; - } - return Line.NextChar(); - } - - /// - /// Returns the next character in the line taking into space taken by tabs. Update and . - /// - public void NextColumn() - { - var c = Line.CurrentChar; - // If we are accross a tab, we should just add 1 column - if (c == '\t' && CharHelper.IsAcrossTab(Column)) - { - Column++; - } - else - { - Line.NextChar(); - Column++; - } - } - - /// - /// Peeks a character at the specified offset from the current position in the line. - /// - /// The offset. - /// A character peeked at the specified offset - public char PeekChar(int offset) - { - return Line.PeekChar(offset); - } - - /// - /// Restarts the indent from the current position. - /// - public void RestartIndent() - { - StartBeforeIndent = Start; - ColumnBeforeIndent = Column; - } - - /// - /// Parses the indentation from the current position in the line, updating , - /// , and accordingly - /// taking into account space taken by tabs. - /// - public void ParseIndent() - { - var c = CurrentChar; - var previousStartBeforeIndent = StartBeforeIndent; - var startBeforeIndent = Start; - var previousColumnBeforeIndent = ColumnBeforeIndent; - var columnBeforeIndent = Column; - while (c !='\0') - { - if (c == '\t') - { - Column = CharHelper.AddTab(Column); - } - else if (c == ' ') - { - Column++; - } - else - { - break; - } - c = Line.NextChar(); - } - if (columnBeforeIndent == Column) - { - StartBeforeIndent = previousStartBeforeIndent; - ColumnBeforeIndent = previousColumnBeforeIndent; - } - else - { - StartBeforeIndent = startBeforeIndent; - ColumnBeforeIndent = columnBeforeIndent; - } - } - - /// - /// Moves to the position to the specified column position, taking into account spaces in tabs. - /// - /// The new column position to move the cursor to. - public void GoToColumn(int newColumn) - { - // Optimized path when we are moving above the previous start of indent - if (newColumn >= ColumnBeforeIndent) - { - Line.Start = StartBeforeIndent; - Column = ColumnBeforeIndent; - } - else - { - Line.Start = originalLineStart; - Column = 0; - ColumnBeforeIndent = 0; - StartBeforeIndent = originalLineStart; - } - for (; Line.Start <= Line.End && Column < newColumn; Line.Start++) - { - var c = Line.Text[Line.Start]; - if (c == '\t') - { - Column = CharHelper.AddTab(Column); - } - else - { - if (!c.IsSpaceOrTab()) - { - ColumnBeforeIndent = Column + 1; - StartBeforeIndent = Line.Start + 1; - } - - Column++; - } - } - if (Column > newColumn) - { - Column = newColumn; - if (Line.Start > 0) - { - Line.Start--; - } - } - } - - /// - /// Unwind any previous indent from the current character back to the first space. - /// - public void UnwindAllIndents() - { - // Find the previous first space on the current line - var previousStart = Line.Start; - for (; Line.Start > originalLineStart; Line.Start--) - { - var c = Line.PeekCharAbsolute(Line.Start - 1); - if (c == 0) - { - break; - } - if (!c.IsSpaceOrTab()) - { - break; - } - } - var targetStart = Line.Start; - // Nothing changed? Early exit - if (previousStart == targetStart) - { - return; - } - - // TODO: factorize the following code with what is done with GoToColumn - - // If we have found the first space, we need to recalculate the correct column - Line.Start = originalLineStart; - Column = 0; - ColumnBeforeIndent = 0; - StartBeforeIndent = originalLineStart; - - for (; Line.Start < targetStart; Line.Start++) - { - var c = Line.Text[Line.Start]; - if (c == '\t') - { - Column = CharHelper.AddTab(Column); - } - else - { - if (!c.IsSpaceOrTab()) - { - ColumnBeforeIndent = Column + 1; - StartBeforeIndent = Line.Start + 1; - } - - Column++; - } - } - - // Reset the indent - ColumnBeforeIndent = Column; - StartBeforeIndent = Start; - } - - /// - /// Moves to the position to the code indent ( + 4 spaces). - /// - /// The column offset to apply to this indent. - public void GoToCodeIndent(int columnOffset = 0) - { - GoToColumn(ColumnBeforeIndent + 4 + columnOffset); - } - - /// - /// Opens the specified block. - /// - /// The block. - /// - /// The block must be opened - public void Open(Block block) - { - if (block == null) throw new ArgumentNullException(nameof(block)); - if (!block.IsOpen) throw new ArgumentException("The block must be opened", nameof(block)); - OpenedBlocks.Add(block); - } - - /// - /// Force closing the specified block. - /// - /// The block. - public void Close(Block block) - { - // If we close a block, we close all blocks above - for (int i = OpenedBlocks.Count - 1; i >= 0; i--) - { - if (OpenedBlocks[i] == block) - { - for (int j = OpenedBlocks.Count - 1; j >= i; j--) - { - Close(j); - } - break; - } - } - } - - /// - /// Discards the specified block from the stack, remove from its parent. - /// - /// The block. - public void Discard(Block block) - { - for (int i = OpenedBlocks.Count - 1; i >= 1; i--) - { - if (OpenedBlocks[i] == block) - { - block.Parent.Remove(block); - OpenedBlocks.RemoveAt(i); - break; - } - } - } - - /// - /// Processes a new line. - /// - /// The new line. - public void ProcessLine(StringSlice newLine) - { - CurrentLineStartPosition = newLine.Start; - - Document.LineStartIndexes?.Add(CurrentLineStartPosition); - - ContinueProcessingLine = true; - - ResetLine(newLine); - - TryContinueBlocks(); - - // If the line was not entirely processed by pending blocks, try to process it with any new block - TryOpenBlocks(); - - // Close blocks that are no longer opened - CloseAll(false); - - LineIndex++; - } - - public BlockProcessor CreateChild() - { - var newState = parserStateCache.Get(); - return newState; - } - - public void ReleaseChild() - { - if (this == root) - { - throw new InvalidOperationException("Cannot release the root parser state"); - } - parserStateCache.Release(this); - } - - internal bool IsOpen(Block block) - { - return OpenedBlocks.Contains(block); - } - - /// - /// Closes a block at the specified index. - /// - /// The index. - private void Close(int index) - { - var block = OpenedBlocks[index]; - // If the pending object is removed, we need to remove it from the parent container - if (block.Parser != null) - { - if (!block.Parser.Close(this, block)) - { - block.Parent?.Remove(block); - } - else - { - // Invoke the Closed event - var blockClosed = block.Parser.GetClosedEvent; - blockClosed?.Invoke(this, block); - } - } - OpenedBlocks.RemoveAt(index); - } - - /// - /// Closes all the blocks opened. - /// - /// if set to true [force]. - internal void CloseAll(bool force) - { - // Close any previous blocks not opened - for (int i = OpenedBlocks.Count - 1; i >= 1; i--) - { - var block = OpenedBlocks[i]; - - // Stop on the first open block - if (!force && block.IsOpen) - { - break; - } - Close(i); - } - UpdateLastBlockAndContainer(); - } - - /// - /// Mark all blocks in the stack as opened. - /// - private void OpenAll() - { - for (int i = 1; i < OpenedBlocks.Count; i++) - { - OpenedBlocks[i].IsOpen = true; - } - } - - /// - /// Updates the and . - /// - /// Index of a block in a stack considered as the last block to update from. - private void UpdateLastBlockAndContainer(int stackIndex = -1) - { - currentStackIndex = stackIndex < 0 ? OpenedBlocks.Count - 1 : stackIndex; - CurrentBlock = null; - LastBlock = null; - for (int i = OpenedBlocks.Count - 1; i >= 0; i--) - { - var block = OpenedBlocks[i]; - if (CurrentBlock == null) - { - CurrentBlock = block; - } - - var container = block as ContainerBlock; - if (container != null) - { - CurrentContainer = container; - LastBlock = CurrentContainer.LastChild; - break; - } - } - } - - /// - /// Tries to continue matching existing opened . - /// - /// - /// A pending parser cannot add a new block when it is not the last pending block - /// or - /// The NewBlocks is not empty. This is happening if a LeafBlock is not the last to be pushed - /// - private void TryContinueBlocks() - { - // Set all blocks non opened. - // They will be marked as open in the following loop - for (int i = 1; i < OpenedBlocks.Count; i++) - { - OpenedBlocks[i].IsOpen = false; - } - - // Process any current block potentially opened - for (int i = 1; i < OpenedBlocks.Count; i++) - { - var block = OpenedBlocks[i]; - - ParseIndent(); - - // If we have a paragraph block, we want to try to match other blocks before trying the Paragraph - if (block is ParagraphBlock) - { - break; - } - - // Else tries to match the Default with the current line - var parser = block.Parser; - - - // If we have a discard, we can remove it from the current state - UpdateLastBlockAndContainer(i); - var result = parser.TryContinue(this, block); - if (result == BlockState.Skip) - { - continue; - } - - if (result == BlockState.None) - { - break; - } - - RestartIndent(); - - // In case the BlockParser has modified the BlockProcessor we are iterating on - if (i >= OpenedBlocks.Count) - { - i = OpenedBlocks.Count - 1; - } - - // If a parser is adding a block, it must be the last of the list - if ((i + 1) < OpenedBlocks.Count && NewBlocks.Count > 0) - { - throw new InvalidOperationException("A pending parser cannot add a new block when it is not the last pending block"); - } - - // If we have a leaf block - var leaf = block as LeafBlock; - if (leaf != null && NewBlocks.Count == 0) - { - ContinueProcessingLine = false; - if (!result.IsDiscard()) - { - leaf.AppendLine(ref Line, Column, LineIndex, CurrentLineStartPosition); - } - } - - // A block is open only if it has a Continue state. - // otherwise it is a Break state, and we don't keep it opened - block.IsOpen = result == BlockState.Continue || result == BlockState.ContinueDiscard; - - if (result == BlockState.BreakDiscard) - { - ContinueProcessingLine = false; - break; - } - - bool isLast = i == OpenedBlocks.Count - 1; - if (ContinueProcessingLine) - { - ProcessNewBlocks(result, false); - } - if (isLast || !ContinueProcessingLine) - { - break; - } - } - } - - /// - /// First phase of the process, try to open new blocks. - /// - private void TryOpenBlocks() - { - int previousStart = -1; - while (ContinueProcessingLine) - { - // Security check so that the parser can't go into a crazy infinite loop if one extension is messing - if (previousStart == Start) - { - throw new InvalidOperationException($"The parser is in an invalid infinite loop while trying to parse blocks at line [{LineIndex}] with line [{Line}]"); - } - previousStart = Start; - - // Eat indent spaces before checking the character - ParseIndent(); - - var parsers = Parsers.GetParsersForOpeningCharacter(CurrentChar); - var globalParsers = Parsers.GlobalParsers; - - if (parsers != null) - { - if (TryOpenBlocks(parsers)) - { - RestartIndent(); - continue; - } - } - - if (globalParsers != null && ContinueProcessingLine) - { - if (TryOpenBlocks(globalParsers)) - { - RestartIndent(); - continue; - } - } - - break; - } - } - - /// - /// Tries to open new blocks using the specified list of - /// - /// The parsers. - /// true to continue processing the current line - private bool TryOpenBlocks(BlockParser[] parsers) - { - for (int j = 0; j < parsers.Length; j++) - { - var blockParser = parsers[j]; - if (Line.IsEmpty) - { - ContinueProcessingLine = false; - break; - } - - // UpdateLastBlockAndContainer the state of CurrentBlock and LastContainer - UpdateLastBlockAndContainer(); - - // If a block parser cannot interrupt a paragraph, and the last block is a paragraph - // we can skip this parser - - var lastBlock = CurrentBlock; - if (!blockParser.CanInterrupt(this, lastBlock)) - { - continue; - } - - bool isLazyParagraph = blockParser is ParagraphBlockParser && lastBlock is ParagraphBlock; - - var result = isLazyParagraph - ? blockParser.TryContinue(this, lastBlock) - : blockParser.TryOpen(this); - - if (result == BlockState.None) - { - // If we have reached a blank line after trying to parse a paragraph - // we can ignore it - if (isLazyParagraph && IsBlankLine) - { - ContinueProcessingLine = false; - break; - } - continue; - } - - // Special case for paragraph - UpdateLastBlockAndContainer(); - - var paragraph = CurrentBlock as ParagraphBlock; - if (isLazyParagraph && paragraph != null) - { - Debug.Assert(NewBlocks.Count == 0); - - if (!result.IsDiscard()) - { - paragraph.AppendLine(ref Line, Column, LineIndex, CurrentLineStartPosition); - } - - // We have just found a lazy continuation for a paragraph, early exit - // Mark all block opened after a lazy continuation - OpenAll(); - - ContinueProcessingLine = false; - break; - } - - // Nothing found but the BlockParser may instruct to break, so early exit - if (NewBlocks.Count == 0 && result == BlockState.BreakDiscard) - { - ContinueProcessingLine = false; - break; - } - - // If we have a container, we can retry to match against all types of block. - ProcessNewBlocks(result, true); - return ContinueProcessingLine; - - // We have a leaf node, we can stop - } - return false; - } - - /// - /// Processes any new blocks that have been pushed to . - /// - /// The last result of matching. - /// if set to true the processing of a new block will close existing opened blocks]. - /// The NewBlocks is not empty. This is happening if a LeafBlock is not the last to be pushed - private void ProcessNewBlocks(BlockState result, bool allowClosing) - { - var newBlocks = NewBlocks; - while (newBlocks.Count > 0) - { - var block = newBlocks.Pop(); - - if (block.Parser == null) - { - throw new InvalidOperationException($"The new block [{block.GetType()}] must have a valid Parser property"); - } - - block.Line = LineIndex; - - // If we have a leaf block - var leaf = block as LeafBlock; - if (leaf != null) - { - if (!result.IsDiscard()) - { - leaf.AppendLine(ref Line, Column, LineIndex, CurrentLineStartPosition); - } - - if (newBlocks.Count > 0) - { - throw new InvalidOperationException( - "The NewBlocks is not empty. This is happening if a LeafBlock is not the last to be pushed"); - } - } - - if (allowClosing) - { - // Close any previous blocks not opened - CloseAll(false); - } - - // If previous block is a container, add the new block as a children of the previous block - if (block.Parent == null) - { - UpdateLastBlockAndContainer(); - CurrentContainer.Add(block); - } - - block.IsOpen = result.IsContinue(); - - // Add a block BlockProcessor to the stack (and leave it opened) - OpenedBlocks.Add(block); - - if (leaf != null) - { - ContinueProcessingLine = false; - return; - } - } - - ContinueProcessingLine = !result.IsDiscard(); - } - - private void ResetLine(StringSlice newLine) - { - Line = newLine; - Column = 0; - ColumnBeforeIndent = 0; - StartBeforeIndent = Start; - originalLineStart = newLine.Start; - } - - private void Reset() - { - Line = StringSlice.Empty; - Column = 0; - ColumnBeforeIndent = 0; - StartBeforeIndent = 0; - OpenedBlocks.Clear(); - NewBlocks.Clear(); - } - - private class BlockParserStateCache : ObjectCache - { - private readonly BlockProcessor root; - - public BlockParserStateCache(BlockProcessor root) - { - this.root = root; - } - - protected override BlockProcessor NewInstance() - { - return new BlockProcessor(root); - } - - protected override void Reset(BlockProcessor instance) - { - instance.Reset(); - } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/BlockState.cs b/NppMarkdownPanel/Markdig/Parsers/BlockState.cs deleted file mode 100644 index 5ad5e3f..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/BlockState.cs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace Markdig.Parsers -{ - /// - /// Defines the result of parsing a line for a . - /// - public enum BlockState - { - /// - /// A line is not accepted by this parser. - /// - None, - - /// - /// The parser is skipped. - /// - Skip, - - /// - /// The parser accepts a line and instruct to continue. - /// - Continue, - - /// - /// The parser accepts a line, instruct to continue but discard the line (not stored on the block) - /// - ContinueDiscard, - - /// - /// The parser is ending a block, instruct to stop and keep the line being processed. - /// - Break, - - /// - /// The parser is ending a block, instruct to stop and discard the line being processed. - /// - BreakDiscard - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/BlockStateExtensions.cs b/NppMarkdownPanel/Markdig/Parsers/BlockStateExtensions.cs deleted file mode 100644 index ee0e796..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/BlockStateExtensions.cs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System.Runtime.CompilerServices; -using Markdig.Helpers; - -namespace Markdig.Parsers -{ - /// - /// Extensions used by . - /// - public static class BlockStateExtensions - { - /// - /// Determines whether this is discarded. - /// - /// State of the block. - /// true if the block state is in discard state - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public static bool IsDiscard(this BlockState blockState) - { - return blockState == BlockState.ContinueDiscard || blockState == BlockState.BreakDiscard; - } - - /// - /// Determines whether this is in a continue state. - /// - /// State of the block. - /// true if the block state is in continue state - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public static bool IsContinue(this BlockState blockState) - { - return blockState == BlockState.Continue || blockState == BlockState.ContinueDiscard; - } - - /// - /// Determines whether this is in a break state. - /// - /// State of the block. - /// true if the block state is in break state - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public static bool IsBreak(this BlockState blockState) - { - return blockState == BlockState.Break || blockState == BlockState.BreakDiscard; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/FencedBlockParserBase.cs b/NppMarkdownPanel/Markdig/Parsers/FencedBlockParserBase.cs deleted file mode 100644 index 109152a..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/FencedBlockParserBase.cs +++ /dev/null @@ -1,231 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using Markdig.Helpers; -using Markdig.Renderers.Html; -using Markdig.Syntax; - -namespace Markdig.Parsers -{ - public abstract class FencedBlockParserBase : BlockParser, IAttributesParseable - { - /// - /// Delegate used to parse the string on the first line after the fenced code block special characters (usually ` or ~) - /// - /// The parser processor. - /// The being processed line. - /// The fenced code block. - /// true if parsing of the line is successfull; false otherwise - public delegate bool InfoParserDelegate(BlockProcessor state, ref StringSlice line, IFencedBlock fenced); - - - /// - /// Gets or sets the information parser. - /// - public InfoParserDelegate InfoParser { get; set; } - - /// - /// A delegates that allows to process attached attributes - /// - public TryParseAttributesDelegate TryParseAttributes { get; set; } - } - - /// - /// Base parser for fenced blocks (opened by 3 or more character delimiters on a first line, and closed by at least the same number of delimiters) - /// - /// - public abstract class FencedBlockParserBase : FencedBlockParserBase where T : Block, IFencedBlock - { - - /// - /// Initializes a new instance of the class. - /// - protected FencedBlockParserBase() - { - InfoParser = DefaultInfoParser; - MinimumMatchCount = 3; - MaximumMatchCount = Int32.MaxValue; - } - - /// - /// Gets or sets the language prefix (default is "language-") - /// - public string InfoPrefix { get; set; } - - public int MinimumMatchCount { get; set; } - - public int MaximumMatchCount { get; set; } - - /// - /// The default parser for the information after the fenced code block special characters (usually ` or ~) - /// - /// The parser processor. - /// The line. - /// The fenced code block. - /// true if parsing of the line is successfull; false otherwise - public static bool DefaultInfoParser(BlockProcessor state, ref StringSlice line, - IFencedBlock fenced) - { - string infoString; - string argString = null; - - var c = line.CurrentChar; - // An info string cannot contain any backsticks - int firstSpace = -1; - for (int i = line.Start; i <= line.End; i++) - { - c = line.Text[i]; - if (c == '`') - { - return false; - } - - if (firstSpace < 0 && c.IsSpaceOrTab()) - { - firstSpace = i; - } - } - - if (firstSpace > 0) - { - infoString = line.Text.Substring(line.Start, firstSpace - line.Start).Trim(); - - // Skip any spaces after info string - firstSpace++; - while (firstSpace <= line.End) - { - c = line[firstSpace]; - if (c.IsSpaceOrTab()) - { - firstSpace++; - } - else - { - break; - } - } - - argString = line.Text.Substring(firstSpace, line.End - firstSpace + 1).Trim(); - } - else - { - infoString = line.ToString().Trim(); - } - - fenced.Info = HtmlHelper.Unescape(infoString); - fenced.Arguments = HtmlHelper.Unescape(argString); - - return true; - } - - public override BlockState TryOpen(BlockProcessor processor) - { - // We expect no indentation for a fenced code block. - if (processor.IsCodeIndent) - { - return BlockState.None; - } - - var startPosition = processor.Start; - - // Match fenced char - int count = 0; - var line = processor.Line; - char c = line.CurrentChar; - var matchChar = c; - while (c != '\0') - { - if (c != matchChar) - { - break; - } - count++; - c = line.NextChar(); - } - - // A fenced codeblock requires at least 3 opening chars - if (count < MinimumMatchCount || count > MaximumMatchCount) - { - return BlockState.None; - } - - // specs spaces: Is space and tabs? or only spaces? Use space and tab for this case - line.TrimStart(); - - var fenced = CreateFencedBlock(processor); - { - fenced.Column = processor.Column; - fenced.FencedChar = matchChar; - fenced.FencedCharCount = count; - fenced.Span.Start = startPosition; - fenced.Span.End = line.Start; - }; - - // Try to parse any attached attributes - if (TryParseAttributes != null) - { - TryParseAttributes(processor, ref line, fenced); - } - - // If the info parser was not successfull, early exit - if (InfoParser != null && !InfoParser(processor, ref line, fenced)) - { - return BlockState.None; - } - - // Add the language as an attribute by default - if (!string.IsNullOrEmpty(fenced.Info)) - { - if (string.IsNullOrEmpty(InfoPrefix)) - { - fenced.GetAttributes().AddClass(fenced.Info); - } - else - { - fenced.GetAttributes().AddClass(InfoPrefix + fenced.Info); - } - } - - // Store the number of matched string into the context - processor.NewBlocks.Push(fenced); - - // Discard the current line as it is already parsed - return BlockState.ContinueDiscard; - } - - protected abstract T CreateFencedBlock(BlockProcessor processor); - - public override BlockState TryContinue(BlockProcessor processor, Block block) - { - var fence = (IFencedBlock)block; - var count = fence.FencedCharCount; - var matchChar = fence.FencedChar; - var c = processor.CurrentChar; - - // Match if we have a closing fence - var line = processor.Line; - while (c == matchChar) - { - c = line.NextChar(); - count--; - } - - // If we have a closing fence, close it and discard the current line - // The line must contain only fence opening character followed only by whitespaces. - if (count <=0 && !processor.IsCodeIndent && (c == '\0' || c.IsWhitespace()) && line.TrimEnd()) - { - block.UpdateSpanEnd(line.Start - 1); - - // Don't keep the last line - return BlockState.BreakDiscard; - } - - // Reset the indentation to the column before the indent - processor.GoToColumn(processor.ColumnBeforeIndent); - - return BlockState.Continue; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/FencedCodeBlockParser.cs b/NppMarkdownPanel/Markdig/Parsers/FencedCodeBlockParser.cs deleted file mode 100644 index 1cc2d8e..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/FencedCodeBlockParser.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Helpers; -using Markdig.Syntax; - -namespace Markdig.Parsers -{ - /// - /// Parser for a . - /// - /// - public class FencedCodeBlockParser : FencedBlockParserBase - { - public const string DefaultInfoPrefix = "language-"; - - /// - /// Initializes a new instance of the class. - /// - public FencedCodeBlockParser() - { - OpeningCharacters = new[] {'`', '~'}; - InfoPrefix = DefaultInfoPrefix; - } - - protected override FencedCodeBlock CreateFencedBlock(BlockProcessor processor) - { - return new FencedCodeBlock(this) {IndentCount = processor.Indent}; - } - - public override BlockState TryContinue(BlockProcessor processor, Block block) - { - var result = base.TryContinue(processor, block); - if (result == BlockState.Continue) - { - var fence = (FencedCodeBlock)block; - // Remove any indent spaces - var c = processor.CurrentChar; - var indentCount = fence.IndentCount; - while (indentCount > 0 && c.IsSpace()) - { - indentCount--; - c = processor.NextChar(); - } - } - - return result; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/HeadingBlockParser.cs b/NppMarkdownPanel/Markdig/Parsers/HeadingBlockParser.cs deleted file mode 100644 index bb9b23d..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/HeadingBlockParser.cs +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System.Diagnostics; -using Markdig.Helpers; -using Markdig.Syntax; - -namespace Markdig.Parsers -{ - /// - /// Block parser for a . - /// - /// - public class HeadingBlockParser : BlockParser, IAttributesParseable - { - - /// - /// Initializes a new instance of the class. - /// - public HeadingBlockParser() - { - OpeningCharacters = new[] {'#'}; - } - - /// - /// Gets or sets the max count of the leading unescaped # characters - /// - public int MaxLeadingCount { get; set; } = 6; - - /// - /// A delegates that allows to process attached attributes after # - /// - public TryParseAttributesDelegate TryParseAttributes { get; set; } - - public override BlockState TryOpen(BlockProcessor processor) - { - // If we are in a CodeIndent, early exit - if (processor.IsCodeIndent) - { - return BlockState.None; - } - - // 4.2 ATX headings - // An ATX heading consists of a string of characters, parsed as inline content, - // between an opening sequence of 1–6(configurable) unescaped # characters and an optional - // closing sequence of any number of unescaped # characters. The opening sequence - // of # characters must be followed by a space or by the end of line. The optional - // closing sequence of #s must be preceded by a space and may be followed by spaces - // only. The opening # character may be indented 0-3 spaces. The raw contents of - // the heading are stripped of leading and trailing spaces before being parsed as - // inline content. The heading level is equal to the number of # characters in the - // opening sequence. - var column = processor.Column; - var line = processor.Line; - var sourcePosition = line.Start; - var c = line.CurrentChar; - var matchingChar = c; - - Debug.Assert(MaxLeadingCount > 0); - int leadingCount = 0; - while (c != '\0' && leadingCount <= MaxLeadingCount) - { - if (c != matchingChar) - { - break; - } - c = line.NextChar(); - leadingCount++; - } - - // A space is required after leading # - if (leadingCount > 0 && leadingCount <= MaxLeadingCount && (c.IsSpaceOrTab() || c == '\0')) - { - // Move to the content - var headingBlock = new HeadingBlock(this) - { - HeaderChar = matchingChar, - Level = leadingCount, - Column = column, - Span = { Start = sourcePosition } - }; - processor.NewBlocks.Push(headingBlock); - processor.GoToColumn(column + leadingCount + 1); - - // Gives a chance to parse attributes - if (TryParseAttributes != null) - { - TryParseAttributes(processor, ref processor.Line, headingBlock); - } - - // The optional closing sequence of #s must be preceded by a space and may be followed by spaces only. - int endState = 0; - int countClosingTags = 0; - for (int i = processor.Line.End; i >= processor.Line.Start - 1; i--) // Go up to Start - 1 in order to match the space after the first ### - { - c = processor.Line.Text[i]; - if (endState == 0) - { - if (c.IsSpaceOrTab()) - { - continue; - } - endState = 1; - } - if (endState == 1) - { - if (c == matchingChar) - { - countClosingTags++; - continue; - } - - if (countClosingTags > 0) - { - if (c.IsSpaceOrTab()) - { - processor.Line.End = i - 1; - } - break; - } - else - { - break; - } - } - } - - // Setup the source end position of this element - headingBlock.Span.End = processor.Line.End; - - // We expect a single line, so don't continue - return BlockState.Break; - } - - // Else we don't have an header - return BlockState.None; - } - - public override bool Close(BlockProcessor processor, Block block) - { - var heading = (HeadingBlock)block; - heading.Lines.Trim(); - return true; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/HtmlBlockParser.cs b/NppMarkdownPanel/Markdig/Parsers/HtmlBlockParser.cs deleted file mode 100644 index 33b3478..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/HtmlBlockParser.cs +++ /dev/null @@ -1,352 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System; -using Markdig.Helpers; -using Markdig.Syntax; - -namespace Markdig.Parsers -{ - /// - /// Block parser for a . - /// - /// - public class HtmlBlockParser : BlockParser - { - /// - /// Initializes a new instance of the class. - /// - public HtmlBlockParser() - { - OpeningCharacters = new[] { '<' }; - } - - public override BlockState TryOpen(BlockProcessor processor) - { - var result = MatchStart(processor); - - // An end-tag can occur on the same line, so we try to parse it here - if (result == BlockState.Continue) - { - result = MatchEnd(processor, (HtmlBlock) processor.NewBlocks.Peek()); - } - return result; - } - - public override BlockState TryContinue(BlockProcessor processor, Block block) - { - var htmlBlock = (HtmlBlock) block; - return MatchEnd(processor, htmlBlock); - } - - private BlockState MatchStart(BlockProcessor state) - { - if (state.IsCodeIndent) - { - return BlockState.None; - } - - var line = state.Line; - var startPosition = line.Start; - line.NextChar(); - var result = TryParseTagType16(state, line, state.ColumnBeforeIndent, startPosition); - - // HTML blocks of type 7 cannot interrupt a paragraph: - if (result == BlockState.None && !(state.CurrentBlock is ParagraphBlock)) - { - result = TryParseTagType7(state, line, state.ColumnBeforeIndent, startPosition); - } - return result; - } - - private BlockState TryParseTagType7(BlockProcessor state, StringSlice line, int startColumn, int startPosition) - { - var builder = StringBuilderCache.Local(); - var c = line.CurrentChar; - var result = BlockState.None; - if ((c == '/' && HtmlHelper.TryParseHtmlCloseTag(ref line, builder)) || HtmlHelper.TryParseHtmlTagOpenTag(ref line, builder)) - { - // Must be followed by whitespace only - bool hasOnlySpaces = true; - c = line.CurrentChar; - while (true) - { - if (c == '\0') - { - break; - } - if (!c.IsWhitespace()) - { - hasOnlySpaces = false; - break; - } - c = line.NextChar(); - } - - if (hasOnlySpaces) - { - result = CreateHtmlBlock(state, HtmlBlockType.NonInterruptingBlock, startColumn, startPosition); - } - } - - builder.Length = 0; - return result; - } - - private BlockState TryParseTagType16(BlockProcessor state, StringSlice line, int startColumn, int startPosition) - { - char c; - c = line.CurrentChar; - if (c == '!') - { - c = line.NextChar(); - if (c == '-' && line.PeekChar(1) == '-') - { - return CreateHtmlBlock(state, HtmlBlockType.Comment, startColumn, startPosition); // group 2 - } - if (c.IsAlphaUpper()) - { - return CreateHtmlBlock(state, HtmlBlockType.DocumentType, startColumn, startPosition); // group 4 - } - if (c == '[' && line.Match("CDATA[", 1)) - { - return CreateHtmlBlock(state, HtmlBlockType.CData, startColumn, startPosition); // group 5 - } - - return BlockState.None; - } - - if (c == '?') - { - return CreateHtmlBlock(state, HtmlBlockType.ProcessingInstruction, startColumn, startPosition); // group 3 - } - - var hasLeadingClose = c == '/'; - if (hasLeadingClose) - { - c = line.NextChar(); - } - - var tag = new char[10]; - var count = 0; - for (; count < tag.Length; count++) - { - if (!c.IsAlphaNumeric()) - { - break; - } - tag[count] = Char.ToLowerInvariant(c); - c = line.NextChar(); - } - - if ( - !(c == '>' || (!hasLeadingClose && c == '/' && line.PeekChar(1) == '>') || c.IsWhitespace() || - c == '\0')) - { - return BlockState.None; - } - - if (count == 0) - { - return BlockState.None; - } - - var tagName = new string(tag, 0, count); - var tagIndex = Array.BinarySearch(HtmlTags, tagName, StringComparer.Ordinal); - if (tagIndex < 0) - { - return BlockState.None; - } - - // Cannot start with = 0) - { - htmlBlock.UpdateSpanEnd(index + EndOfComment.Length); - result = BlockState.Break; - } - break; - case HtmlBlockType.CData: - index = line.IndexOf(EndOfCDATA); - if (index >= 0) - { - htmlBlock.UpdateSpanEnd(index + EndOfCDATA.Length); - result = BlockState.Break; - } - break; - case HtmlBlockType.ProcessingInstruction: - index = line.IndexOf(EndOfProcessingInstruction); - if (index >= 0) - { - htmlBlock.UpdateSpanEnd(index + EndOfProcessingInstruction.Length); - result = BlockState.Break; - } - break; - case HtmlBlockType.DocumentType: - index = line.IndexOf('>'); - if (index >= 0) - { - htmlBlock.UpdateSpanEnd(index + 1); - result = BlockState.Break; - } - break; - case HtmlBlockType.ScriptPreOrStyle: - index = line.IndexOf("", 0, true); - if (index >= 0) - { - htmlBlock.UpdateSpanEnd(index + "".Length); - result = BlockState.Break; - } - else - { - index = line.IndexOf("", 0, true); - if (index >= 0) - { - htmlBlock.UpdateSpanEnd(index + "".Length); - result = BlockState.Break; - } - else - { - index = line.IndexOf("", 0, true); - if (index >= 0) - { - htmlBlock.UpdateSpanEnd(index + "".Length); - result = BlockState.Break; - } - } - } - break; - case HtmlBlockType.InterruptingBlock: - if (state.IsBlankLine) - { - result = BlockState.BreakDiscard; - } - break; - case HtmlBlockType.NonInterruptingBlock: - if (state.IsBlankLine) - { - result = BlockState.BreakDiscard; - } - break; - } - - // Update only if we don't have a break discard - if (result != BlockState.BreakDiscard) - { - htmlBlock.Span.End = line.End; - } - - return result; - } - - private BlockState CreateHtmlBlock(BlockProcessor state, HtmlBlockType type, int startColumn, int startPosition) - { - state.NewBlocks.Push(new HtmlBlock(this) - { - Column = startColumn, - Type = type, - // By default, setup to the end of line - Span = new SourceSpan(startPosition, startPosition + state.Line.End) - }); - return BlockState.Continue; - } - - private static readonly string[] HtmlTags = - { - "address", // 0 - "article", // 1 - "aside", // 2 - "base", // 3 - "basefont", // 4 - "blockquote", // 5 - "body", // 6 - "caption", // 7 - "center", // 8 - "col", // 9 - "colgroup", // 10 - "dd", // 11 - "details", // 12 - "dialog", // 13 - "dir", // 14 - "div", // 15 - "dl", // 16 - "dt", // 17 - "fieldset", // 18 - "figcaption", // 19 - "figure", // 20 - "footer", // 21 - "form", // 22 - "frame", // 23 - "frameset", // 24 - "h1", // 25 - "h2", // 26 - "h3", // 27 - "h4", // 28 - "h5", // 29 - "h6", // 30 - "head", // 31 - "header", // 32 - "hr", // 33 - "html", // 34 - "iframe", // 35 - "legend", // 36 - "li", // 37 - "link", // 38 - "main", // 39 - "menu", // 40 - "menuitem", // 41 - "meta", // 42 - "nav", // 43 - "noframes", // 44 - "ol", // 45 - "optgroup", // 46 - "option", // 47 - "p", // 48 - "param", // 49 - "pre", // 50 <=== special group 1 - "script", // 51 <=== special group 1 - "section", // 52 - "source", // 53 - "style", // 54 <=== special group 1 - "summary", // 55 - "table", // 56 - "tbody", // 57 - "td", // 58 - "tfoot", // 59 - "th", // 60 - "thead", // 61 - "title", // 62 - "tr", // 63 - "track", // 64 - "ul", // 65 - }; - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/IAttributesParseable.cs b/NppMarkdownPanel/Markdig/Parsers/IAttributesParseable.cs deleted file mode 100644 index f9b69c4..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/IAttributesParseable.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Helpers; -using Markdig.Syntax; - -namespace Markdig.Parsers -{ - /// - /// A delegates that allows to porcess attached attributes at time. - /// - /// The processor. - /// The slice to look for attached attributes. - /// The block. - /// true if attributes were found; otherwise false - public delegate bool TryParseAttributesDelegate( - BlockProcessor processor, ref StringSlice slice, IBlock block); - - /// - /// An interface used to tag that supports parsing - /// - public interface IAttributesParseable - { - /// - /// A delegates that allows to process attached attributes - /// - TryParseAttributesDelegate TryParseAttributes { get; set; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/IBlockParser.cs b/NppMarkdownPanel/Markdig/Parsers/IBlockParser.cs deleted file mode 100644 index 76fa6e2..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/IBlockParser.cs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax; - -namespace Markdig.Parsers -{ - /// - /// Base interface for a . - /// - /// - /// - public interface IBlockParser : IMarkdownParser - { - /// - /// Determines whether this instance can interrupt the specified block being processed. - /// - /// The parser processor. - /// The block being processed. - /// true if this parser can interrupt the specified block being processed. - bool CanInterrupt(TProcessor processor, Block block); - - /// - /// Tries to match a block opening. - /// - /// The parser processor. - /// The result of the match - BlockState TryOpen(TProcessor processor); - - /// - /// Tries to continue matching a block already opened. - /// - /// The parser processor. - /// The block already opened. - /// The result of the match. By default, don't expect any newline - BlockState TryContinue(TProcessor processor, Block block); - - /// - /// Called when a block matched by this parser is being closed (to allow final computation on the block). - /// - /// The parser processor. - /// The block being closed. - /// true to keep the block; false to remove it. True by default. - bool Close(TProcessor processor, Block block); - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/IInlineParser.cs b/NppMarkdownPanel/Markdig/Parsers/IInlineParser.cs deleted file mode 100644 index dc4c968..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/IInlineParser.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Helpers; - -namespace Markdig.Parsers -{ - /// - /// Base interface for parsing an . - /// - /// - /// - public interface IInlineParser : IMarkdownParser - { - /// - /// Tries to match the specified slice. - /// - /// The parser processor. - /// The text slice. - /// true if this parser found a match; false otherwise - bool Match(InlineProcessor processor, ref StringSlice slice); - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/IMarkdownParser.cs b/NppMarkdownPanel/Markdig/Parsers/IMarkdownParser.cs deleted file mode 100644 index 1660507..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/IMarkdownParser.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -namespace Markdig.Parsers -{ - /// - /// Base interface for a block or inline parser. - /// - /// The type of processor. - public interface IMarkdownParser - { - /// - /// Gets the opening characters this parser will be triggered if the character is found. - /// - char[] OpeningCharacters { get; } - - /// - /// Initializes this parser with the specified parser processor. - /// - void Initialize(); - - /// - /// Gets the index of this parser in or . - /// - int Index { get; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/IPostInlineProcessor.cs b/NppMarkdownPanel/Markdig/Parsers/IPostInlineProcessor.cs deleted file mode 100644 index 2646a16..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/IPostInlineProcessor.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax.Inlines; - -namespace Markdig.Parsers -{ - /// - /// A procesor called at the end of processing all inlines. - /// - public interface IPostInlineProcessor - { - /// - /// Processes the delimiters. - /// - /// The parser state. - /// The root inline. - /// The last child. - /// Index of this delimiter processor. - /// - /// true to continue to the next delimiter processor; - /// false to stop the process (in case a processor is perfoming sub-sequent processor itself) - bool PostProcess(InlineProcessor state, Inline root, Inline lastChild, int postInlineProcessorIndex, bool isFinalProcessing); - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/IndentedCodeBlockParser.cs b/NppMarkdownPanel/Markdig/Parsers/IndentedCodeBlockParser.cs deleted file mode 100644 index 048fcf7..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/IndentedCodeBlockParser.cs +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax; - -namespace Markdig.Parsers -{ - /// - /// Block parser for an indented . - /// - /// - public class IndentedCodeBlockParser : BlockParser - { - public override bool CanInterrupt(BlockProcessor processor, Block block) - { - return !(block is ParagraphBlock); - } - - public override BlockState TryOpen(BlockProcessor processor) - { - var result = TryContinue(processor, null); - if (result == BlockState.Continue) - { - // Save the column where we need to go back - var column = processor.Column; - - // Unwind all indents all spaces before in order to calculate correct span - processor.UnwindAllIndents(); - - processor.NewBlocks.Push(new CodeBlock(this) - { - Column = processor.Column, - Span = new SourceSpan(processor.Start, processor.Line.End) - }); - - // Go back to the correct column - processor.GoToColumn(column); - } - return result; - } - - public override BlockState TryContinue(BlockProcessor processor, Block block) - { - if (!processor.IsCodeIndent || processor.IsBlankLine) - { - if (block == null || !processor.IsBlankLine) - { - return BlockState.None; - } - } - - // If we don't have a blank line, we reset to the indent - if (processor.Indent > 4) - { - processor.GoToCodeIndent(); - } - if (block != null) - { - block.UpdateSpanEnd(processor.Line.End); - } - return BlockState.Continue; - } - - public override bool Close(BlockProcessor processor, Block block) - { - var codeBlock = (CodeBlock)block; - if (codeBlock != null) - { - // Remove any trailing blankline - for (int i = codeBlock.Lines.Count - 1; i >= 0; i--) - { - if (codeBlock.Lines.Lines[i].Slice.IsEmpty) - { - codeBlock.Lines.RemoveAt(i); - } - else - { - break; - } - } - } - return true; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/InlineParser.cs b/NppMarkdownPanel/Markdig/Parsers/InlineParser.cs deleted file mode 100644 index ace5dac..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/InlineParser.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Helpers; - -namespace Markdig.Parsers -{ - /// - /// Base class for parsing an . - /// - /// - public abstract class InlineParser : ParserBase, IInlineParser - { - /// - /// Tries to match the specified slice. - /// - /// The parser processor. - /// The text slice. - /// true if this parser found a match; false otherwise - public abstract bool Match(InlineProcessor processor, ref StringSlice slice); - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/InlineParserList.cs b/NppMarkdownPanel/Markdig/Parsers/InlineParserList.cs deleted file mode 100644 index 6f92eb0..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/InlineParserList.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System.Collections.Generic; - -namespace Markdig.Parsers -{ - /// - /// A list of . - /// - /// - public class InlineParserList : ParserList - { - public InlineParserList(IEnumerable parsers) : base(parsers) - { - // Prepare the list of post inline processors - var postInlineProcessors = new List(); - foreach (var parser in this) - { - var delimProcessor = parser as IPostInlineProcessor; - if (delimProcessor != null) - { - postInlineProcessors.Add(delimProcessor); - } - } - PostInlineProcessors = postInlineProcessors.ToArray(); - } - - /// - /// Gets the registered post inline processors. - /// - public IPostInlineProcessor[] PostInlineProcessors { get; private set; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/InlineProcessor.cs b/NppMarkdownPanel/Markdig/Parsers/InlineProcessor.cs deleted file mode 100644 index d61f693..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/InlineProcessor.cs +++ /dev/null @@ -1,333 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System; -using System.Collections.Generic; -using System.IO; -using Markdig.Helpers; -using Markdig.Parsers.Inlines; -using Markdig.Syntax; -using Markdig.Syntax.Inlines; - -namespace Markdig.Parsers -{ - /// - /// A delegate called at inline processing stage. - /// - /// The processor. - /// The inline being processed. - public delegate void ProcessInlineDelegate(InlineProcessor processor, Inline inline); - - /// - /// The inline parser state used by all . - /// - public class InlineProcessor - { - private readonly List lineOffsets; - private int previousSliceOffset; - private int previousLineIndexForSliceOffset; - - /// - /// Initializes a new instance of the class. - /// - /// The string builders. - /// The document. - /// The parsers. - /// The inline created event. - /// - /// - public InlineProcessor(StringBuilderCache stringBuilders, MarkdownDocument document, InlineParserList parsers, bool preciseSourcelocation, MarkdownParserContext context) - { - if (stringBuilders == null) throw new ArgumentNullException(nameof(stringBuilders)); - if (document == null) throw new ArgumentNullException(nameof(document)); - if (parsers == null) throw new ArgumentNullException(nameof(parsers)); - StringBuilders = stringBuilders; - Document = document; - Parsers = parsers; - Context = context; - PreciseSourceLocation = preciseSourcelocation; - lineOffsets = new List(); - ParserStates = new object[Parsers.Count]; - LiteralInlineParser = new LiteralInlineParser(); - } - - /// - /// Gets the current block being proessed. - /// - public LeafBlock Block { get; private set; } - - /// - /// Gets a value indicating whether to provide precise source location. - /// - public bool PreciseSourceLocation { get; } - - /// - /// Gets or sets the new block to replace the block being processed. - /// - public Block BlockNew { get; set; } - - /// - /// Gets or sets the current inline. Used by to return a new inline if match was successfull - /// - public Inline Inline { get; set; } - - /// - /// Gets the root container of the current . - /// - public ContainerInline Root { get; internal set; } - - /// - /// Gets the list of inline parsers. - /// - public InlineParserList Parsers { get; } - - /// - /// Gets the parser context or null if none is available. - /// - public MarkdownParserContext Context { get; } - - /// - /// Gets the root document. - /// - public MarkdownDocument Document { get; } - - /// - /// Gets the cache string builders. - /// - public StringBuilderCache StringBuilders { get; } - - /// - /// Gets or sets the index of the line from the begining of the document being processed. - /// - public int LineIndex { get; private set; } - - /// - /// Gets the parser states that can be used by using their property. - /// - public object[] ParserStates { get; } - - /// - /// Gets or sets the debug log writer. No log if null. - /// - public TextWriter DebugLog { get; set; } - - /// - /// Gets the literal inline parser. - /// - public LiteralInlineParser LiteralInlineParser { get; } - - - public int GetSourcePosition(int sliceOffset) - { - int column; - int lineIndex; - return GetSourcePosition(sliceOffset, out lineIndex, out column); - } - - public SourceSpan GetSourcePositionFromLocalSpan(SourceSpan span) - { - if (span.IsEmpty) - { - return SourceSpan.Empty; - } - - int column; - int lineIndex; - return new SourceSpan(GetSourcePosition(span.Start, out lineIndex, out column), GetSourcePosition(span.End, out lineIndex, out column)); - } - - /// - /// Gets the source position for the specified offset within the current slice. - /// - /// The slice offset. - /// The source position - public int GetSourcePosition(int sliceOffset, out int lineIndex, out int column) - { - column = 0; - lineIndex = sliceOffset >= previousSliceOffset ? previousLineIndexForSliceOffset : 0; - int position = 0; - if (PreciseSourceLocation) - { - for (; lineIndex < lineOffsets.Count; lineIndex++) - { - var lineOffset = lineOffsets[lineIndex]; - if (sliceOffset <= lineOffset.End) - { - // Use the beginning of the line as a previous slice offset - // (since it is on the same line) - previousSliceOffset = lineOffsets[lineIndex].Start; - var delta = sliceOffset - previousSliceOffset; - column = lineOffsets[lineIndex].Column + delta; - position = lineOffset.LinePosition + delta + lineOffsets[lineIndex].Offset; - previousLineIndexForSliceOffset = lineIndex; - - // Return an absolute line index - lineIndex = lineIndex + LineIndex; - break; - } - } - } - return position; - } - - /// - /// Processes the inline of the specified . - /// - /// The leaf block. - public void ProcessInlineLeaf(LeafBlock leafBlock) - { - if (leafBlock == null) throw new ArgumentNullException(nameof(leafBlock)); - - // clear parser states - Array.Clear(ParserStates, 0, ParserStates.Length); - - Root = new ContainerInline() { IsClosed = false }; - leafBlock.Inline = Root; - Inline = null; - Block = leafBlock; - BlockNew = null; - LineIndex = leafBlock.Line; - - previousSliceOffset = 0; - previousLineIndexForSliceOffset = 0; - lineOffsets.Clear(); - var text = leafBlock.Lines.ToSlice(lineOffsets); - leafBlock.Lines = new StringLineGroup(); - - int previousStart = -1; - - while (!text.IsEmpty) - { - // Security check so that the parser can't go into a crazy infinite loop if one extension is messing - if (previousStart == text.Start) - { - throw new InvalidOperationException($"The parser is in an invalid infinite loop while trying to parse inlines for block [{leafBlock.GetType().Name}] at position ({leafBlock.ToPositionText()}"); - } - previousStart = text.Start; - - var c = text.CurrentChar; - - var textSaved = text; - var parsers = Parsers.GetParsersForOpeningCharacter(c); - if (parsers != null) - { - for (int i = 0; i < parsers.Length; i++) - { - text = textSaved; - if (parsers[i].Match(this, ref text)) - { - goto done; - } - } - } - parsers = Parsers.GlobalParsers; - if (parsers != null) - { - for (int i = 0; i < parsers.Length; i++) - { - text = textSaved; - if (parsers[i].Match(this, ref text)) - { - goto done; - } - } - } - - text = textSaved; - // Else match using the default literal inline parser - LiteralInlineParser.Match(this, ref text); - - done: - var nextInline = Inline; - if (nextInline != null) - { - if (nextInline.Parent == null) - { - // Get deepest container - var container = FindLastContainer(); - if (!ReferenceEquals(container, nextInline)) - { - container.AppendChild(nextInline); - } - - if (container == Root) - { - if (container.Span.IsEmpty) - { - container.Span = nextInline.Span; - } - container.Span.End = nextInline.Span.End; - } - - } - } - else - { - // Get deepest container - var container = FindLastContainer(); - - Inline = container.LastChild is LeafInline ? container.LastChild : container; - if (Inline == Root) - { - Inline = null; - } - } - - //if (DebugLog != null) - //{ - // DebugLog.WriteLine($"** Dump: char '{c}"); - // leafBlock.Inline.DumpTo(DebugLog); - //} - } - - Inline = null; - //if (DebugLog != null) - //{ - // DebugLog.WriteLine("** Dump before Emphasis:"); - // leafBlock.Inline.DumpTo(DebugLog); - //} - - // PostProcess all inlines - PostProcessInlines(0, Root, null, true); - - //TransformDelimitersToLiterals(); - - //if (DebugLog != null) - //{ - // DebugLog.WriteLine(); - // DebugLog.WriteLine("** Dump after Emphasis:"); - // leafBlock.Inline.DumpTo(DebugLog); - //} - } - - public void PostProcessInlines(int startingIndex, Inline root, Inline lastChild, bool isFinalProcessing) - { - for (int i = startingIndex; i < Parsers.PostInlineProcessors.Length; i++) - { - var postInlineProcessor = Parsers.PostInlineProcessors[i]; - if (!postInlineProcessor.PostProcess(this, root, lastChild, i, isFinalProcessing)) - { - break; - } - } - } - - private ContainerInline FindLastContainer() - { - var container = Block.Inline; - while (true) - { - var nextContainer = container.LastChild as ContainerInline; - if (nextContainer != null && !nextContainer.IsClosed) - { - container = nextContainer; - } - else - { - break; - } - } - return container; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/Inlines/AutolineInlineParser.cs b/NppMarkdownPanel/Markdig/Parsers/Inlines/AutolineInlineParser.cs deleted file mode 100644 index 308dc6b..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/Inlines/AutolineInlineParser.cs +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Helpers; -using Markdig.Syntax; -using Markdig.Syntax.Inlines; - -namespace Markdig.Parsers.Inlines -{ - /// - /// An inline parser for parsing . - /// - /// - public class AutolineInlineParser : InlineParser - { - /// - /// Initializes a new instance of the class. - /// - public AutolineInlineParser() - { - OpeningCharacters = new[] {'<'}; - EnableHtmlParsing = true; - } - - /// - /// Gets or sets a value indicating whether to enable HTML parsing. Default is true - /// - public bool EnableHtmlParsing { get; set; } - - public override bool Match(InlineProcessor processor, ref StringSlice slice) - { - string link; - bool isEmail; - var saved = slice; - int line; - int column; - if (LinkHelper.TryParseAutolink(ref slice, out link, out isEmail)) - { - processor.Inline = new AutolinkInline() - { - IsEmail = isEmail, - Url = link, - Span = new SourceSpan(processor.GetSourcePosition(saved.Start, out line, out column), processor.GetSourcePosition(slice.Start - 1)), - Line = line, - Column = column - }; - } - else if (EnableHtmlParsing) - { - slice = saved; - string htmlTag; - if (!HtmlHelper.TryParseHtmlTag(ref slice, out htmlTag)) - { - return false; - } - - processor.Inline = new HtmlInline() - { - Tag = htmlTag, - Span = new SourceSpan(processor.GetSourcePosition(saved.Start, out line, out column), processor.GetSourcePosition(slice.Start - 1)), - Line = line, - Column = column - }; - } - else - { - return false; - } - - return true; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/Inlines/CodeInlineParser.cs b/NppMarkdownPanel/Markdig/Parsers/Inlines/CodeInlineParser.cs deleted file mode 100644 index 441fad8..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/Inlines/CodeInlineParser.cs +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Helpers; -using Markdig.Syntax; -using Markdig.Syntax.Inlines; - -namespace Markdig.Parsers.Inlines -{ - /// - /// An inline parser for a . - /// - /// - public class CodeInlineParser : InlineParser - { - /// - /// Initializes a new instance of the class. - /// - public CodeInlineParser() - { - OpeningCharacters = new[] { '`' }; - } - - public override bool Match(InlineProcessor processor, ref StringSlice slice) - { - int openSticks = 0; - var match = slice.CurrentChar; - if (slice.PeekCharExtra(-1) == match) - { - return false; - } - - var startPosition = slice.Start; - - // Match the opened sticks - var c = slice.CurrentChar; - while (c == match) - { - openSticks++; - c = slice.NextChar(); - } - - bool isMatching = false; - - var builder = processor.StringBuilders.Get(); - int closeSticks = 0; - - // A backtick string is a string of one or more backtick characters (`) that is neither preceded nor followed by a backtick. - // A code span begins with a backtick string and ends with a backtick string of equal length. - // The contents of the code span are the characters between the two backtick strings, with leading and trailing spaces and line endings removed, and whitespace collapsed to single spaces. - var pc = ' '; - - int newLinesFound = 0; - while (c != '\0') - { - // Transform '\n' into a single space - if (c == '\n') - { - newLinesFound++; - c = ' '; - } - - if (c != match && (c != ' ' || pc != ' ')) - { - builder.Append(c); - } - else - { - while (c == match) - { - closeSticks++; - pc = c; - c = slice.NextChar(); - } - - if (openSticks == closeSticks) - { - break; - } - } - - if (closeSticks > 0) - { - builder.Append(match, closeSticks); - closeSticks = 0; - } - else - { - pc = c; - c = slice.NextChar(); - } - } - - if (closeSticks == openSticks) - { - // Remove trailing space - if (builder.Length > 0) - { - if (builder[builder.Length - 1].IsWhitespace()) - { - builder.Length--; - } - } - int line; - int column; - processor.Inline = new CodeInline() - { - Delimiter = match, - Content = builder.ToString(), - Span = new SourceSpan(processor.GetSourcePosition(startPosition, out line, out column), processor.GetSourcePosition(slice.Start - 1)), - Line = line, - Column = column - }; - isMatching = true; - } - - // Release the builder if not used - processor.StringBuilders.Release(builder); - return isMatching; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/Inlines/EmphasisDescriptor.cs b/NppMarkdownPanel/Markdig/Parsers/Inlines/EmphasisDescriptor.cs deleted file mode 100644 index 5c76d64..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/Inlines/EmphasisDescriptor.cs +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; - -namespace Markdig.Parsers.Inlines -{ - /// - /// Descriptor for an emphasis. - /// - public class EmphasisDescriptor - { - /// - /// Initializes a new instance of the class. - /// - /// The character used for this emphasis. - /// The minimum number of character. - /// The maximum number of characters. - /// if set to true the emphasis can be used inside a word. - public EmphasisDescriptor(char character, int minimumCount, int maximumCount, bool enableWithinWord) - { - if (minimumCount < 1) throw new ArgumentOutOfRangeException(nameof(minimumCount), "minimumCount must be >= 1"); - if (maximumCount < 1) throw new ArgumentOutOfRangeException(nameof(maximumCount), "maximumCount must be >= 1"); - if (minimumCount > maximumCount) throw new ArgumentOutOfRangeException(nameof(minimumCount), "minimumCount must be <= maximumCount"); - - Character = character; - MinimumCount = minimumCount; - MaximumCount = maximumCount; - EnableWithinWord = enableWithinWord; - } - - /// - /// The character of this emphasis. - /// - public readonly char Character; - - /// - /// The minimum number of character this emphasis is expected to have (must be >=1) - /// - public readonly int MinimumCount; - - /// - /// The maximum number of character this emphasis is expected to have (must be >=1 and >= minumunCount) - /// - public readonly int MaximumCount; - - /// - /// This emphasis can be used within a word. - /// - public readonly bool EnableWithinWord; - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/Inlines/EmphasisInlineParser.cs b/NppMarkdownPanel/Markdig/Parsers/Inlines/EmphasisInlineParser.cs deleted file mode 100644 index d51b2d0..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/Inlines/EmphasisInlineParser.cs +++ /dev/null @@ -1,415 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using Markdig.Helpers; -using Markdig.Renderers.Html; -using Markdig.Syntax; -using Markdig.Syntax.Inlines; - -namespace Markdig.Parsers.Inlines -{ - /// - /// An inline parser for . - /// - /// - /// - public class EmphasisInlineParser : InlineParser, IPostInlineProcessor - { - private CharacterMap emphasisMap; - private readonly DelimitersObjectCache inlinesCache = new DelimitersObjectCache(); - - [Obsolete("Use TryCreateEmphasisInlineDelegate instead", error: false)] - public delegate EmphasisInline CreateEmphasisInlineDelegate(char emphasisChar, bool isStrong); - public delegate EmphasisInline TryCreateEmphasisInlineDelegate(char emphasisChar, int delimiterCount); - - /// - /// Initializes a new instance of the class. - /// - public EmphasisInlineParser() - { - EmphasisDescriptors = new List() - { - new EmphasisDescriptor('*', 1, 2, true), - new EmphasisDescriptor('_', 1, 2, false) - }; - } - - /// - /// Gets the emphasis descriptors. - /// - public List EmphasisDescriptors { get; } - - /// - /// Determines whether this parser is using the specified character as an emphasis delimiter. - /// - /// The character to look for. - /// true if this parser is using the specified character as an emphasis delimiter; otherwise false - public bool HasEmphasisChar(char c) - { - foreach (var emphasis in EmphasisDescriptors) - { - if (emphasis.Character == c) - { - return true; - } - } - return false; - } - - /// - /// Gets or sets the create emphasis inline delegate (allowing to create a different emphasis inline class) - /// - [Obsolete("Use TryCreateEmphasisInlineList instead", error: false)] - public CreateEmphasisInlineDelegate CreateEmphasisInline { get; set; } - public readonly List TryCreateEmphasisInlineList = new List(); - - public override void Initialize() - { - OpeningCharacters = new char[EmphasisDescriptors.Count]; - - var tempMap = new List>(); - for (int i = 0; i < EmphasisDescriptors.Count; i++) - { - var emphasis = EmphasisDescriptors[i]; - if (Array.IndexOf(OpeningCharacters, emphasis.Character) >= 0) - { - throw new InvalidOperationException( - $"The character `{emphasis.Character}` is already used by another emphasis descriptor"); - } - - OpeningCharacters[i] = emphasis.Character; - - tempMap.Add(new KeyValuePair(emphasis.Character, emphasis)); - } - - emphasisMap = new CharacterMap(tempMap); - } - - public bool PostProcess(InlineProcessor state, Inline root, Inline lastChild, int postInlineProcessorIndex, bool isFinalProcessing) - { - if (!(root is ContainerInline container)) - { - return true; - } - - List delimiters = null; - if (container is EmphasisDelimiterInline emphasisDelimiter) - { - delimiters = inlinesCache.Get(); - delimiters.Add(emphasisDelimiter); - } - - // Move current_position forward in the delimiter stack (if needed) until - // we find the first potential closer with delimiter * or _. (This will be the potential closer closest to the beginning of the input – the first one in parse order.) - var child = container.LastChild; - while (child != null) - { - if (child == lastChild) - { - break; - } - if (child is EmphasisDelimiterInline delimiter) - { - if (delimiters == null) - { - delimiters = inlinesCache.Get(); - } - delimiters.Add(delimiter); - } - var subContainer = child as ContainerInline; - child = subContainer?.LastChild; - } - - if (delimiters != null) - { - ProcessEmphasis(state, delimiters); - inlinesCache.Release(delimiters); - } - return true; - } - - public override bool Match(InlineProcessor processor, ref StringSlice slice) - { - // First, some definitions. - // A delimiter run is a sequence of one or more delimiter characters that is not preceded or followed by the same delimiter character - // The amount of delimiter characters in the delimiter run may exceed emphasisDesc.MaximumCount, as that is handeled in `ProcessEmphasis` - - var delimiterChar = slice.CurrentChar; - var emphasisDesc = emphasisMap[delimiterChar]; - - char pc = (char)0; - if (processor.Inline is HtmlEntityInline htmlEntityInline) - { - if (htmlEntityInline.Transcoded.Length > 0) - { - pc = htmlEntityInline.Transcoded[htmlEntityInline.Transcoded.End]; - } - } - if (pc == 0) - { - pc = slice.PeekCharExtra(-1); - if (pc == delimiterChar && slice.PeekCharExtra(-2) != '\\') - { - // If we get here, we determined that either: - // a) there weren't enough delimiters in the delimiter run to satisfy the MinimumCount condition - // b) the previous character couldn't open/close - return false; - } - } - var startPosition = slice.Start; - - int delimiterCount = 0; - char c; - do - { - delimiterCount++; - c = slice.NextChar(); - } while (c == delimiterChar); - - - // If the emphasis doesn't have the minimum required character - if (delimiterCount < emphasisDesc.MinimumCount) - { - return false; - } - - // The following character is actually an entity, we need to decode it - if (HtmlEntityParser.TryParse(ref slice, out string htmlString, out int htmlLength)) - { - c = htmlString[0]; - } - - // Calculate Open-Close for current character - CharHelper.CheckOpenCloseDelimiter(pc, c, emphasisDesc.EnableWithinWord, out bool canOpen, out bool canClose); - - // We have potentially an open or close emphasis - if (canOpen || canClose) - { - var delimiterType = DelimiterType.Undefined; - if (canOpen) delimiterType |= DelimiterType.Open; - if (canClose) delimiterType |= DelimiterType.Close; - - var delimiter = new EmphasisDelimiterInline(this, emphasisDesc) - { - DelimiterCount = delimiterCount, - Type = delimiterType, - Span = new SourceSpan(processor.GetSourcePosition(startPosition, out int line, out int column), processor.GetSourcePosition(slice.Start - 1)), - Column = column, - Line = line, - }; - - processor.Inline = delimiter; - return true; - } - - // We don't have an emphasis - return false; - } - - private void ProcessEmphasis(InlineProcessor processor, List delimiters) - { - // The following method is inspired by the "An algorithm for parsing nested emphasis and links" - // at the end of the CommonMark specs. - - // TODO: Benchmark difference between using List and LinkedList here since there could be a few Remove calls - - // Move current_position forward in the delimiter stack (if needed) until - // we find the first potential closer with delimiter * or _. (This will be the potential closer closest to the beginning of the input – the first one in parse order.) - for (int i = 0; i < delimiters.Count; i++) - { - var closeDelimiter = delimiters[i]; - // Skip delimiters not supported by this instance - EmphasisDescriptor emphasisDesc = emphasisMap[closeDelimiter.DelimiterChar]; - if (emphasisDesc == null) - { - continue; - } - - if ((closeDelimiter.Type & DelimiterType.Close) != 0 && closeDelimiter.DelimiterCount >= emphasisDesc.MinimumCount) - { - while (true) - { - // Now, look back in the stack (staying above stack_bottom and the openers_bottom for this delimiter type) - // for the first matching potential opener (“matching” means same delimiter). - EmphasisDelimiterInline openDelimiter = null; - int openDelimiterIndex = -1; - for (int j = i - 1; j >= 0; j--) - { - var previousOpenDelimiter = delimiters[j]; - - var isOddMatch = ((closeDelimiter.Type & DelimiterType.Open) != 0 || - (previousOpenDelimiter.Type & DelimiterType.Close) != 0) && - previousOpenDelimiter.DelimiterCount != closeDelimiter.DelimiterCount && - (previousOpenDelimiter.DelimiterCount + closeDelimiter.DelimiterCount) % 3 == 0; - - if (previousOpenDelimiter.DelimiterChar == closeDelimiter.DelimiterChar && - (previousOpenDelimiter.Type & DelimiterType.Open) != 0 && - previousOpenDelimiter.DelimiterCount >= emphasisDesc.MinimumCount && !isOddMatch) - { - openDelimiter = previousOpenDelimiter; - openDelimiterIndex = j; - break; - } - } - - if (openDelimiter != null) - { - process_delims: - Debug.Assert(openDelimiter.DelimiterCount >= emphasisDesc.MinimumCount, "Extra emphasis should have been discarded by now"); - Debug.Assert(closeDelimiter.DelimiterCount >= emphasisDesc.MinimumCount, "Extra emphasis should have been discarded by now"); - int delimiterDelta = Math.Min(Math.Min(openDelimiter.DelimiterCount, closeDelimiter.DelimiterCount), emphasisDesc.MaximumCount); - - // Insert an emph or strong emph node accordingly, after the text node corresponding to the opener. - EmphasisInline emphasis = null; - { - if (delimiterDelta <= 2) // We can try using the legacy delegate - { - #pragma warning disable CS0618 // Support fields marked as obsolete - emphasis = CreateEmphasisInline?.Invoke(closeDelimiter.DelimiterChar, isStrong: delimiterDelta == 2); - #pragma warning restore CS0618 // Support fields marked as obsolete - } - if (emphasis == null) - { - // Go in backwards order to give priority to newer delegates - for (int delegateIndex = TryCreateEmphasisInlineList.Count - 1; delegateIndex >= 0; delegateIndex--) - { - emphasis = TryCreateEmphasisInlineList[delegateIndex].Invoke(closeDelimiter.DelimiterChar, delimiterDelta); - if (emphasis != null) break; - } - - if (emphasis == null) - { - emphasis = new EmphasisInline() - { - DelimiterChar = closeDelimiter.DelimiterChar, - DelimiterCount = delimiterDelta - }; - } - } - } - Debug.Assert(emphasis != null); - - // Update position for emphasis - var openDelimitercount = openDelimiter.DelimiterCount; - var closeDelimitercount = closeDelimiter.DelimiterCount; - - emphasis.Span.Start = openDelimiter.Span.Start; - emphasis.Line = openDelimiter.Line; - emphasis.Column = openDelimiter.Column; - emphasis.Span.End = closeDelimiter.Span.End - closeDelimitercount + delimiterDelta; - - openDelimiter.Span.Start += delimiterDelta; - openDelimiter.Column += delimiterDelta; - closeDelimiter.Span.Start += delimiterDelta; - closeDelimiter.Column += delimiterDelta; - - openDelimiter.DelimiterCount -= delimiterDelta; - closeDelimiter.DelimiterCount -= delimiterDelta; - - var embracer = (ContainerInline)openDelimiter; - - // Copy attributes attached to delimiter to the emphasis - var attributes = closeDelimiter.TryGetAttributes(); - if (attributes != null) - { - emphasis.SetAttributes(attributes); - } - - // Embrace all delimiters - embracer.EmbraceChildrenBy(emphasis); - - // Remove any intermediate emphasis - for (int k = i - 1; k >= openDelimiterIndex + 1; k--) - { - var literalDelimiter = delimiters[k]; - literalDelimiter.ReplaceBy(literalDelimiter.AsLiteralInline()); - delimiters.RemoveAt(k); - i--; - } - - if (closeDelimiter.DelimiterCount == 0) - { - var newParent = openDelimiter.DelimiterCount > 0 ? emphasis : emphasis.Parent; - closeDelimiter.MoveChildrenAfter(newParent); - closeDelimiter.Remove(); - delimiters.RemoveAt(i); - i--; - - // Remove the open delimiter if it is also empty - if (openDelimiter.DelimiterCount == 0) - { - openDelimiter.MoveChildrenAfter(openDelimiter); - openDelimiter.Remove(); - delimiters.RemoveAt(openDelimiterIndex); - i--; - } - break; - } - - // The current delimiters are matching - if (openDelimiter.DelimiterCount >= emphasisDesc.MinimumCount) - { - goto process_delims; - } - else if (openDelimiter.DelimiterCount > 0) - { - // There are still delimiter characters left, there's just not enough of them - openDelimiter.ReplaceBy(openDelimiter.AsLiteralInline()); - delimiters.RemoveAt(openDelimiterIndex); - i--; - } - else - { - // Remove the open delimiter if it is also empty - var firstChild = openDelimiter.FirstChild; - firstChild.Remove(); - openDelimiter.ReplaceBy(firstChild); - firstChild.IsClosed = true; - closeDelimiter.Remove(); - firstChild.InsertAfter(closeDelimiter); - delimiters.RemoveAt(openDelimiterIndex); - i--; - } - } - else if ((closeDelimiter.Type & DelimiterType.Open) == 0) - { - closeDelimiter.ReplaceBy(closeDelimiter.AsLiteralInline()); - delimiters.RemoveAt(i); - i--; - break; - } - else - { - break; - } - } - } - } - - // Any delimiters left must be literal - for (int i = 0; i < delimiters.Count; i++) - { - var delimiter = delimiters[i]; - delimiter.ReplaceBy(delimiter.AsLiteralInline()); - } - delimiters.Clear(); - } - - public class DelimitersObjectCache : ObjectCache> - { - protected override List NewInstance() - { - return new List(4); - } - - protected override void Reset(List instance) - { - instance.Clear(); - } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/Inlines/EscapeInlineParser.cs b/NppMarkdownPanel/Markdig/Parsers/Inlines/EscapeInlineParser.cs deleted file mode 100644 index 15b5ad6..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/Inlines/EscapeInlineParser.cs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Helpers; -using Markdig.Syntax.Inlines; - -namespace Markdig.Parsers.Inlines -{ - /// - /// An inline parser for escape characters. - /// - /// - public class EscapeInlineParser : InlineParser - { - public EscapeInlineParser() - { - OpeningCharacters = new[] {'\\'}; - } - - public override bool Match(InlineProcessor processor, ref StringSlice slice) - { - var startPosition = slice.Start; - // Go to escape character - var c = slice.NextChar(); - int line; - int column; - if (c.IsAsciiPunctuation()) - { - processor.Inline = new LiteralInline() - { - Content = new StringSlice(slice.Text, slice.Start, slice.Start), - Span = { Start = processor.GetSourcePosition(startPosition, out line, out column) }, - Line = line, - Column = column, - IsFirstCharacterEscaped = true, - }; - processor.Inline.Span.End = processor.Inline.Span.Start + 1; - slice.NextChar(); - return true; - } - - // A backslash at the end of the line is a [hard line break]: - if (c == '\n') - { - processor.Inline = new LineBreakInline() - { - IsHard = true, - IsBackslash = true, - Span = { Start = processor.GetSourcePosition(startPosition, out line, out column) }, - Line = line, - Column = column - }; - processor.Inline.Span.End = processor.Inline.Span.Start + 1; - slice.NextChar(); - return true; - } - return false; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/Inlines/HtmlEntityParser.cs b/NppMarkdownPanel/Markdig/Parsers/Inlines/HtmlEntityParser.cs deleted file mode 100644 index c1fe9c7..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/Inlines/HtmlEntityParser.cs +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.Text; -using Markdig.Helpers; -using Markdig.Syntax; -using Markdig.Syntax.Inlines; - -namespace Markdig.Parsers.Inlines -{ - /// - /// An inline parser for HTML entities. - /// - /// - public class HtmlEntityParser : InlineParser - { - /// - /// Initializes a new instance of the class. - /// - public HtmlEntityParser() - { - OpeningCharacters = new[] {'&'}; - } - - - public static bool TryParse(ref StringSlice slice, out string literal, out int match) - { - literal = null; - int entityNameStart; - int entityNameLength; - int entityValue; - match = HtmlHelper.ScanEntity(slice, out entityValue, out entityNameStart, out entityNameLength); - if (match == 0) - { - return false; - } - - if (entityNameLength > 0) - { - literal = EntityHelper.DecodeEntity(new StringSlice(slice.Text, entityNameStart, entityNameStart + entityNameLength - 1).ToString()); - } - else if (entityValue >= 0) - { - literal = (entityValue == 0 ? null : EntityHelper.DecodeEntity(entityValue)) ?? CharHelper.ZeroSafeString; - } - return literal != null; - } - - public override bool Match(InlineProcessor processor, ref StringSlice slice) - { - int match; - string literal; - if (!TryParse(ref slice, out literal, out match)) - { - return false; - } - - var startPosition = slice.Start; - - if (literal != null) - { - var matched = slice; - matched.End = slice.Start + match - 1; - int line; - int column; - processor.Inline = new HtmlEntityInline() - { - Original = matched, - Transcoded = new StringSlice(literal), - Span = new SourceSpan(processor.GetSourcePosition(startPosition, out line, out column), processor.GetSourcePosition(matched.End)), - Line = line, - Column = column - }; - slice.Start = slice.Start + match; - return true; - } - - return false; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/Inlines/LineBreakInlineParser.cs b/NppMarkdownPanel/Markdig/Parsers/Inlines/LineBreakInlineParser.cs deleted file mode 100644 index a905583..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/Inlines/LineBreakInlineParser.cs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Helpers; -using Markdig.Syntax; -using Markdig.Syntax.Inlines; - -namespace Markdig.Parsers.Inlines -{ - /// - /// An inline parser for . - /// - /// - public class LineBreakInlineParser : InlineParser - { - /// - /// Initializes a new instance of the class. - /// - public LineBreakInlineParser() - { - OpeningCharacters = new[] {'\n'}; - } - - /// - /// Gets or sets a value indicating whether to interpret softline breaks as hardline breaks. Default is false - /// - public bool EnableSoftAsHard { get; set; } - - public override bool Match(InlineProcessor processor, ref StringSlice slice) - { - // Hard line breaks are for separating inline content within a block. Neither syntax for hard line breaks works at the end of a paragraph or other block element: - if (!(processor.Block is ParagraphBlock)) - { - return false; - } - - var startPosition = slice.Start; - var hasDoubleSpacesBefore = slice.PeekCharExtra(-1).IsSpace() && slice.PeekCharExtra(-2).IsSpace(); - slice.NextChar(); // Skip \n - - int line; - int column; - processor.Inline = new LineBreakInline - { - Span = { Start = processor.GetSourcePosition(startPosition, out line, out column)}, - IsHard = EnableSoftAsHard || (slice.Start != 0 && hasDoubleSpacesBefore), - Line = line, - Column = column - }; - processor.Inline.Span.End = processor.Inline.Span.Start; - return true; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/Inlines/LinkInlineParser.cs b/NppMarkdownPanel/Markdig/Parsers/Inlines/LinkInlineParser.cs deleted file mode 100644 index fb4c67e..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/Inlines/LinkInlineParser.cs +++ /dev/null @@ -1,345 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Helpers; -using Markdig.Syntax; -using Markdig.Syntax.Inlines; - -namespace Markdig.Parsers.Inlines -{ - /// - /// An inline parser for . - /// - /// - public class LinkInlineParser : InlineParser - { - /// - /// Initializes a new instance of the class. - /// - public LinkInlineParser() - { - OpeningCharacters = new[] {'[', ']', '!'}; - } - - public override bool Match(InlineProcessor processor, ref StringSlice slice) - { - // The following methods are inspired by the "An algorithm for parsing nested emphasis and links" - // at the end of the CommonMark specs. - - var c = slice.CurrentChar; - - int line; - int column; - var startPosition = processor.GetSourcePosition(slice.Start, out line, out column); - - bool isImage = false; - if (c == '!') - { - isImage = true; - c = slice.NextChar(); - if (c != '[') - { - return false; - } - } - - switch (c) - { - case '[': - // If this is not an image, we may have a reference link shortcut - // so we try to resolve it here - var saved = slice; - string label; - - SourceSpan labelSpan; - // If the label is followed by either a ( or a [, this is not a shortcut - if (LinkHelper.TryParseLabel(ref slice, out label, out labelSpan)) - { - if (!processor.Document.ContainsLinkReferenceDefinition(label)) - { - label = null; - } - } - slice = saved; - - // Else we insert a LinkDelimiter - slice.NextChar(); - processor.Inline = new LinkDelimiterInline(this) - { - Type = DelimiterType.Open, - Label = label, - LabelSpan = processor.GetSourcePositionFromLocalSpan(labelSpan), - IsImage = isImage, - Span = new SourceSpan(startPosition, processor.GetSourcePosition(slice.Start - 1)), - Line = line, - Column = column - }; - return true; - - case ']': - slice.NextChar(); - if (processor.Inline != null) - { - if (TryProcessLinkOrImage(processor, ref slice)) - { - return true; - } - } - - // If we don’t find one, we return a literal slice node ]. - // (Done after by the LiteralInline parser) - return false; - } - - // We don't have an emphasis - return false; - } - - private bool ProcessLinkReference(InlineProcessor state, string label, bool isShortcut, SourceSpan labelSpan, LinkDelimiterInline parent, int endPosition) - { - bool isValidLink = false; - LinkReferenceDefinition linkRef; - if (state.Document.TryGetLinkReferenceDefinition(label, out linkRef)) - { - Inline link = null; - // Try to use a callback directly defined on the LinkReferenceDefinition - if (linkRef.CreateLinkInline != null) - { - link = linkRef.CreateLinkInline(state, linkRef, parent.FirstChild); - } - - // Create a default link if the callback was not found - if (link == null) - { - // Inline Link - link = new LinkInline() - { - Url = HtmlHelper.Unescape(linkRef.Url), - Title = HtmlHelper.Unescape(linkRef.Title), - Label = label, - LabelSpan = labelSpan, - UrlSpan = linkRef.UrlSpan, - IsImage = parent.IsImage, - IsShortcut = isShortcut, - Reference = linkRef, - Span = new SourceSpan(parent.Span.Start, endPosition), - Line = parent.Line, - Column = parent.Column, - }; - } - - var containerLink = link as ContainerInline; - if (containerLink != null) - { - var child = parent.FirstChild; - if (child == null) - { - child = new LiteralInline() - { - Content = StringSlice.Empty, - IsClosed = true, - // Not exact but we leave it like this - Span = parent.Span, - Line = parent.Line, - Column = parent.Column, - }; - containerLink.AppendChild(child); - } - else - { - // Insert all child into the link - while (child != null) - { - var next = child.NextSibling; - child.Remove(); - containerLink.AppendChild(child); - child = next; - } - } - } - - link.IsClosed = true; - - // Process emphasis delimiters - state.PostProcessInlines(0, link, null, false); - - state.Inline = link; - isValidLink = true; - } - //else - //{ - // // Else output a literal, leave it opened as we may have literals after - // // that could be append to this one - // var literal = new LiteralInline() - // { - // ContentBuilder = processor.StringBuilders.Get().Append('[').Append(label).Append(']') - // }; - // processor.Inline = literal; - //} - return isValidLink; - } - - private bool TryProcessLinkOrImage(InlineProcessor inlineState, ref StringSlice text) - { - LinkDelimiterInline openParent = null; - foreach (var parent in inlineState.Inline.FindParentOfType()) - { - openParent = parent; - break; - } - - if (openParent != null) - { - // If we do find one, but it’s not active, - // we remove the inactive delimiter from the stack, - // and return a literal text node ]. - if (!openParent.IsActive) - { - inlineState.Inline = new LiteralInline() - { - Content = new StringSlice("["), - Span = openParent.Span, - Line = openParent.Line, - Column = openParent.Column, - }; - openParent.ReplaceBy(inlineState.Inline); - return false; - } - - // If we find one and it’s active, - // then we parse ahead to see if we have - // an inline link/image, reference link/image, - // compact reference link/image, - // or shortcut reference link/image - var parentDelimiter = openParent.Parent; - var savedText = text; - switch (text.CurrentChar) - { - case '(': - string url; - string title; - SourceSpan linkSpan; - SourceSpan titleSpan; - if (LinkHelper.TryParseInlineLink(ref text, out url, out title, out linkSpan, out titleSpan)) - { - // Inline Link - var link = new LinkInline() - { - Url = HtmlHelper.Unescape(url), - Title = HtmlHelper.Unescape(title), - IsImage = openParent.IsImage, - LabelSpan = openParent.LabelSpan, - UrlSpan = inlineState.GetSourcePositionFromLocalSpan(linkSpan), - TitleSpan = inlineState.GetSourcePositionFromLocalSpan(titleSpan), - Span = new SourceSpan(openParent.Span.Start, inlineState.GetSourcePosition(text.Start -1)), - Line = openParent.Line, - Column = openParent.Column, - }; - - openParent.ReplaceBy(link); - // Notifies processor as we are creating an inline locally - inlineState.Inline = link; - - // Process emphasis delimiters - inlineState.PostProcessInlines(0, link, null, false); - - // If we have a link (and not an image), - // we also set all [ delimiters before the opening delimiter to inactive. - // (This will prevent us from getting links within links.) - if (!openParent.IsImage) - { - MarkParentAsInactive(parentDelimiter); - } - - link.IsClosed = true; - - return true; - } - - text = savedText; - goto default; - default: - var labelSpan = SourceSpan.Empty; - string label = null; - bool isLabelSpanLocal = true; - - bool isShortcut = false; - // Handle Collapsed links - if (text.CurrentChar == '[') - { - if (text.PeekChar(1) == ']') - { - label = openParent.Label; - labelSpan = openParent.LabelSpan; - isLabelSpanLocal = false; - text.NextChar(); // Skip [ - text.NextChar(); // Skip ] - } - } - else - { - label = openParent.Label; - isShortcut = true; - } - - if (label != null || LinkHelper.TryParseLabel(ref text, true, out label, out labelSpan)) - { - if (isLabelSpanLocal) - { - labelSpan = inlineState.GetSourcePositionFromLocalSpan(labelSpan); - } - - if (ProcessLinkReference(inlineState, label, isShortcut, labelSpan, openParent, inlineState.GetSourcePosition(text.Start - 1))) - { - // Remove the open parent - openParent.Remove(); - if (!openParent.IsImage) - { - MarkParentAsInactive(parentDelimiter); - } - } - else - { - return false; - } - return true; - } - break; - } - - // We have a nested [ ] - // firstParent.Remove(); - // The opening [ will be transformed to a literal followed by all the childrens of the [ - - var literal = new LiteralInline() - { - Span = openParent.Span, - Content = new StringSlice(openParent.IsImage ? "![" : "[") - }; - - inlineState.Inline = openParent.ReplaceBy(literal); - return false; - } - - return false; - } - - private void MarkParentAsInactive(Inline inline) - { - if (inline == null) - { - return; - } - - foreach (var parent in inline.FindParentOfType()) - { - if (parent.IsImage) - { - break; - } - - parent.IsActive = false; - } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/Inlines/LiteralInlineParser.cs b/NppMarkdownPanel/Markdig/Parsers/Inlines/LiteralInlineParser.cs deleted file mode 100644 index 89361ca..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/Inlines/LiteralInlineParser.cs +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Helpers; -using Markdig.Syntax; -using Markdig.Syntax.Inlines; - -namespace Markdig.Parsers.Inlines -{ - /// - /// An inline parser for parsing . - /// - /// - public sealed class LiteralInlineParser : InlineParser - { - public delegate void PostMatchDelegate(InlineProcessor processor, ref StringSlice slice); - - /// - /// We don't expect the LiteralInlineParser to be instantiated a end-user, as it is part - /// of the default parser pipeline (and should always be the last), working as a literal character - /// collector. - /// - public LiteralInlineParser() - { - } - - /// - /// Gets or sets the post match delegate called after the inline has been processed. - /// - public PostMatchDelegate PostMatch { get; set; } - - public override bool Match(InlineProcessor processor, ref StringSlice slice) - { - var text = slice.Text; - - int line; - int column; - var startPosition = processor.GetSourcePosition(slice.Start, out line, out column); - - // Sligthly faster to perform our own search for opening characters - var nextStart = processor.Parsers.IndexOfOpeningCharacter(text, slice.Start + 1, slice.End); - //var nextStart = str.IndexOfAny(processor.SpecialCharacters, slice.Start + 1, slice.Length - 1); - int length; - - if (nextStart < 0) - { - nextStart = slice.End + 1; - length = nextStart - slice.Start; - } - else - { - // Remove line endings if the next char is a new line - length = nextStart - slice.Start; - if (text[nextStart] == '\n') - { - int end = nextStart - 1; - while (length > 0 && text[end].IsSpace()) - { - length--; - end--; - } - } - } - - // The LiteralInlineParser is always matching (at least an empty string) - var endPosition = slice.Start + length - 1; - - var previousInline = processor.Inline as LiteralInline; - if (previousInline != null && ReferenceEquals(previousInline.Content.Text, slice.Text) && - previousInline.Content.End + 1 == slice.Start) - { - previousInline.Content.End = endPosition; - previousInline.Span.End = processor.GetSourcePosition(endPosition); - } - else - { - // Create a new LiteralInline only if it is not empty - var newSlice = length > 0 ? new StringSlice(slice.Text, slice.Start, endPosition) : StringSlice.Empty; - if (!newSlice.IsEmpty) - { - processor.Inline = new LiteralInline() - { - Content = length > 0 ? newSlice : StringSlice.Empty, - Span = new SourceSpan(startPosition, processor.GetSourcePosition(endPosition)), - Line = line, - Column = column, - }; - } - } - - slice.Start = nextStart; - - // Call only PostMatch if necessary - if (processor.Inline is LiteralInline) - { - PostMatch?.Invoke(processor, ref slice); - } - - return true; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/ListBlockParser.cs b/NppMarkdownPanel/Markdig/Parsers/ListBlockParser.cs deleted file mode 100644 index cbaec5e..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/ListBlockParser.cs +++ /dev/null @@ -1,374 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System; -using System.Collections.Generic; -using Markdig.Helpers; -using Markdig.Syntax; - -namespace Markdig.Parsers -{ - /// - /// A parser for a list block and list item block. - /// - /// - public class ListBlockParser : BlockParser - { - private CharacterMap mapItemParsers; - - /// - /// Initializes a new instance of the class. - /// - public ListBlockParser() - { - ItemParsers = new OrderedList() - { - new UnorderedListItemParser(), - new NumberedListItemParser() - }; - } - - /// - /// Gets the parsers for items. - /// - public OrderedList ItemParsers { get; } - - public override void Initialize() - { - var tempMap = new Dictionary(); - - foreach (var itemParser in ItemParsers) - { - if (itemParser.OpeningCharacters == null) - { - throw new InvalidOperationException($"The list item parser of type [{itemParser.GetType()}] cannot have OpeningCharacters to null. It must define a list of valid opening characters"); - } - - foreach (var openingCharacter in itemParser.OpeningCharacters) - { - if (tempMap.ContainsKey(openingCharacter)) - { - throw new InvalidOperationException( - $"A list item parser with the same opening character `{openingCharacter}` is already registered"); - } - tempMap.Add(openingCharacter, itemParser); - } - } - mapItemParsers = new CharacterMap(tempMap); - } - - public override BlockState TryOpen(BlockProcessor processor) - { - // When both a thematic break and a list item are possible - // interpretations of a line, the thematic break takes precedence - var thematicParser = ThematicBreakParser.Default; - if (thematicParser.HasOpeningCharacter(processor.CurrentChar)) - { - var result = thematicParser.TryOpen(processor); - if (result.IsBreak()) - { - return result; - } - } - - return TryParseListItem(processor, null); - } - - public override BlockState TryContinue(BlockProcessor processor, Block block) - { - if (block is ListBlock && processor.NextContinue is ListItemBlock) - { - // We try to match only on item block if the ListBlock - return BlockState.Skip; - } - - // When both a thematic break and a list item are possible - // interpretations of a line, the thematic break takes precedence - BlockState result; - var thematicParser = ThematicBreakParser.Default; - if (!(processor.LastBlock is FencedCodeBlock) && thematicParser.HasOpeningCharacter(processor.CurrentChar)) - { - result = thematicParser.TryOpen(processor); - if (result.IsBreak()) - { - // TODO: We remove the thematic break, as it will be created later, but this is inefficient, try to find another way - processor.NewBlocks.Pop(); - return BlockState.None; - } - } - - // 5.2 List items - // TODO: Check with specs, it is not clear that list marker or bullet marker must be followed by at least 1 space - - // If we have already a ListItemBlock, we are going to try to append to it - var listItem = block as ListItemBlock; - result = BlockState.None; - if (listItem != null) - { - result = TryContinueListItem(processor, listItem); - } - - if (result == BlockState.None) - { - result = TryParseListItem(processor, block); - } - - return result; - } - - private BlockState TryContinueListItem(BlockProcessor state, ListItemBlock listItem) - { - var list = (ListBlock)listItem.Parent; - - // Allow all blanks lines if the last block is a fenced code block - // Allow 1 blank line inside a list - // If > 1 blank line, terminate this list - var isBlankLine = state.IsBlankLine; - - var isCurrentBlockBreakable = state.CurrentBlock != null && state.CurrentBlock.IsBreakable; - if (isBlankLine) - { - if (isCurrentBlockBreakable) - { - if (!(state.NextContinue is ListBlock)) - { - list.CountAllBlankLines++; - listItem.Add(new BlankLineBlock()); - } - list.CountBlankLinesReset++; - } - - if (list.CountBlankLinesReset == 1 && listItem.ColumnWidth < 0) - { - state.Close(listItem); - - // Leave the list open - list.IsOpen = true; - return BlockState.Continue; - } - - // Update list-item source end position - listItem.UpdateSpanEnd(state.Line.End); - - return BlockState.Continue; - } - - list.CountBlankLinesReset = 0; - - int columWidth = listItem.ColumnWidth; - if (columWidth < 0) - { - columWidth = -columWidth; - } - - if (state.Indent >= columWidth) - { - if (state.Indent > columWidth && state.IsCodeIndent) - { - state.GoToColumn(state.ColumnBeforeIndent + columWidth); - } - - // Update list-item source end position - listItem.UpdateSpanEnd(state.Line.End); - - return BlockState.Continue; - } - - return BlockState.None; - } - - private BlockState TryParseListItem(BlockProcessor state, Block block) - { - // If we have a code indent and we are not in a ListItem, early exit - if (!(block is ListItemBlock) && state.IsCodeIndent) - { - return BlockState.None; - } - - var currentListItem = block as ListItemBlock; - var currentParent = block as ListBlock ?? (ListBlock)currentListItem?.Parent; - - var initColumnBeforeIndent = state.ColumnBeforeIndent; - var initColumn = state.Column; - var sourcePosition = state.Start; - var sourceEndPosition = state.Line.End; - - var c = state.CurrentChar; - var itemParser = mapItemParsers[c]; - bool isOrdered = itemParser is OrderedListItemParser; - if (itemParser == null) - { - return BlockState.None; - } - - // Try to parse the list item - ListInfo listInfo; - if (!itemParser.TryParse(state, currentParent?.BulletType ?? '\0', out listInfo)) - { - // Reset to an a start position - state.GoToColumn(initColumn); - return BlockState.None; - } - - // Gets the current character after a succesfull parsing of the list information - c = state.CurrentChar; - - // Item starting with a blank line - int columnWidth; - - // Do we have a blank line right after the bullet? - if (c == '\0') - { - // Use a negative number to store the number of expected chars - columnWidth = -(state.Column - initColumnBeforeIndent + 1); - } - else - { - if (!c.IsSpaceOrTab()) - { - state.GoToColumn(initColumn); - return BlockState.None; - } - - // Parse the following indent - state.RestartIndent(); - var columnBeforeIndent = state.Column; - state.ParseIndent(); - - // We expect at most 4 columns after - // If we have more, we reset the position - if (state.Indent > 4) - { - state.GoToColumn(columnBeforeIndent + 1); - } - - // Number of spaces required for the following content to be part of this list item - // If the list item starts with a blank line, the number of spaces - // following the list marker doesn't change the required indentation - columnWidth = (state.IsBlankLine ? columnBeforeIndent : state.Column) - initColumnBeforeIndent; - } - - // Starts/continue the list unless: - // - an empty list item follows a paragraph - // - an ordered list is not starting by '1' - var isPreviousParagraph = (block ?? state.LastBlock) is ParagraphBlock; - if (isPreviousParagraph) - { - var isOpen = state.IsOpen(block ?? state.LastBlock); - if (state.IsBlankLine || (isOpen && listInfo.BulletType == '1' && listInfo.OrderedStart != "1")) - { - state.GoToColumn(initColumn); - return BlockState.None; - } - } - - int.TryParse(listInfo.OrderedStart, out int order); - var newListItem = new ListItemBlock(this) - { - Column = initColumn, - ColumnWidth = columnWidth, - Order = order, - Span = new SourceSpan(sourcePosition, sourceEndPosition) - }; - state.NewBlocks.Push(newListItem); - - if (currentParent != null) - { - // If we have a new list item, close the previous one - if (currentListItem != null) - { - state.Close(currentListItem); - } - - // Reset the list if it is a new list or a new type of bullet - if (currentParent.IsOrdered != isOrdered || - currentParent.OrderedDelimiter != listInfo.OrderedDelimiter || - currentParent.BulletType != listInfo.BulletType) - { - state.Close(currentParent); - currentParent = null; - } - } - - if (currentParent == null) - { - var newList = new ListBlock(this) - { - Column = initColumn, - Span = new SourceSpan(sourcePosition, sourceEndPosition), - IsOrdered = isOrdered, - BulletType = listInfo.BulletType, - OrderedDelimiter = listInfo.OrderedDelimiter, - DefaultOrderedStart = listInfo.DefaultOrderedStart, - OrderedStart = listInfo.OrderedStart, - }; - state.NewBlocks.Push(newList); - } - - return BlockState.Continue; - } - - public override bool Close(BlockProcessor processor, Block blockToClose) - { - var listBlock = blockToClose as ListBlock; - - // Process only if we have blank lines - if (listBlock == null || listBlock.CountAllBlankLines <= 0) - { - return true; - } - - // TODO: This code is UGLY and WAY TOO LONG, simplify! - bool isLastListItem = true; - for (int listIndex = listBlock.Count - 1; listIndex >= 0; listIndex--) - { - var block = listBlock[listIndex]; - var listItem = (ListItemBlock) block; - bool isLastElement = true; - for (int i = listItem.Count - 1; i >= 0; i--) - { - var item = listItem[i]; - if (item is BlankLineBlock) - { - if ((isLastElement && listIndex < listBlock.Count - 1) || (listItem.Count > 2 && (i > 0 && i < (listItem.Count - 1)))) - { - listBlock.IsLoose = true; - } - - if (isLastElement && isLastListItem) - { - // Inform the outer list that we have a blank line - var parentListItemBlock = listBlock.Parent as ListItemBlock; - if (parentListItemBlock != null) - { - var parentList = (ListBlock) parentListItemBlock.Parent; - - parentList.CountAllBlankLines++; - parentListItemBlock.Add(new BlankLineBlock()); - } - } - - listItem.RemoveAt(i); - - // If we have remove all blank lines, we can exit - listBlock.CountAllBlankLines--; - if (listBlock.CountAllBlankLines == 0) - { - break; - } - } - isLastElement = false; - } - isLastListItem = false; - } - - //// Update end-position for the list - //if (listBlock.Count > 0) - //{ - // listBlock.Span.End = listBlock[listBlock.Count - 1].Span.End; - //} - - return true; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/ListInfo.cs b/NppMarkdownPanel/Markdig/Parsers/ListInfo.cs deleted file mode 100644 index f7b475d..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/ListInfo.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace Markdig.Parsers -{ - /// - /// Defines list information returned when trying to parse a list item with - /// - public struct ListInfo - { - /// - /// Initializes a new instance of the struct. - /// - /// Type of the bullet (e.g: '1', 'a', 'A', 'i', 'I'). - public ListInfo(char bulletType) - { - BulletType = bulletType; - OrderedStart = null; - OrderedDelimiter = (char)0; - DefaultOrderedStart = null; - } - - /// - /// Initializes a new instance of the struct. - /// - /// Type of the bullet (e.g: '1', 'a', 'A', 'i', 'I') - /// The string used as a starting sequence for an ordered list. - /// The ordered delimiter found when parsing this list (e.g: the character `)` after `1)`) - /// The default string used as a starting sequence for the ordered list (e.g: '1' for an numbered ordered list) - public ListInfo(char bulletType, string orderedStart, char orderedDelimiter, string defaultOrderedStart) - { - BulletType = bulletType; - OrderedStart = orderedStart; - OrderedDelimiter = orderedDelimiter; - DefaultOrderedStart = defaultOrderedStart; - } - - /// - /// Gets or sets the type of the bullet (e.g: '1', 'a', 'A', 'i', 'I'). - /// - public char BulletType { get; set; } - - /// - /// Gets or sets the string used as a starting sequence for an ordered list - /// - public string OrderedStart { get; set; } - - /// - /// Gets or sets the ordered delimiter found when parsing this list (e.g: the character `)` after `1)`) - /// - public char OrderedDelimiter { get; set; } - - /// - /// Gets or sets default string used as a starting sequence for the ordered list (e.g: '1' for an numbered ordered list) - /// - public string DefaultOrderedStart { get; set; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/ListItemParser.cs b/NppMarkdownPanel/Markdig/Parsers/ListItemParser.cs deleted file mode 100644 index c2060d3..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/ListItemParser.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace Markdig.Parsers -{ - /// - /// A parser base class for a list item. - /// - public abstract class ListItemParser - { - /// - /// Defines the characters that are used for detecting this list item. - /// - public char[] OpeningCharacters { get; protected set; } - - /// - /// Tries to parse the current input as a list item for this particular instance. - /// - /// The block processor - /// The type of the current bullet type - /// The result of parsing - /// true if parsing was sucessfull; false otherwise - public abstract bool TryParse(BlockProcessor state, char pendingBulletType, out ListInfo result); - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/MarkdownParser.cs b/NppMarkdownPanel/Markdig/Parsers/MarkdownParser.cs deleted file mode 100644 index 7ad8c41..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/MarkdownParser.cs +++ /dev/null @@ -1,220 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using Markdig.Helpers; -using Markdig.Syntax; - -namespace Markdig.Parsers -{ - /// - /// Delegates called when processing a document - /// - /// The markdown document. - public delegate void ProcessDocumentDelegate(MarkdownDocument document); - - /// - /// The Markdown parser. - /// - public sealed class MarkdownParser - { - private readonly BlockProcessor blockProcessor; - private readonly InlineProcessor inlineProcessor; - private readonly MarkdownDocument document; - private readonly ProcessDocumentDelegate documentProcessed; - private readonly bool preciseSourceLocation; - - private LineReader lineReader; - - /// - /// Initializes a new instance of the class. - /// - /// The reader. - /// The pipeline. - /// A parser context used for the parsing. - /// - /// - private MarkdownParser(string text, MarkdownPipeline pipeline, MarkdownParserContext context) - { - if (text == null) throw new ArgumentNullException(nameof(text)); - if (pipeline == null) throw new ArgumentNullException(nameof(pipeline)); - text = FixupZero(text); - lineReader = new LineReader(text); - preciseSourceLocation = pipeline.PreciseSourceLocation; - - // Initialize the pipeline - var stringBuilderCache = pipeline.StringBuilderCache ?? new StringBuilderCache(); - - document = new MarkdownDocument(); - - // Initialize the block parsers - blockProcessor = new BlockProcessor(stringBuilderCache, document, pipeline.BlockParsers, context); - - // Initialize the inline parsers - inlineProcessor = new InlineProcessor(stringBuilderCache, document, pipeline.InlineParsers, pipeline.PreciseSourceLocation, context) - { - DebugLog = pipeline.DebugLog - }; - - documentProcessed = pipeline.DocumentProcessed; - } - - /// - /// Parses the specified markdown into an AST - /// - /// A Markdown text - /// The pipeline used for the parsing. - /// A parser context used for the parsing. - /// An AST Markdown document - /// if reader variable is null - public static MarkdownDocument Parse(string text, MarkdownPipeline pipeline = null, MarkdownParserContext context = null) - { - if (text == null) throw new ArgumentNullException(nameof(text)); - pipeline = pipeline ?? new MarkdownPipelineBuilder().Build(); - - // Perform the parsing - var markdownParser = new MarkdownParser(text, pipeline, context); - return markdownParser.Parse(); - } - - /// - /// Parses the current into a Markdown . - /// - /// A document instance - private MarkdownDocument Parse() - { - if (preciseSourceLocation) - document.LineStartIndexes = new List(); - - ProcessBlocks(); - ProcessInlines(); - - // At this point the LineIndex is the same as the number of lines in the document - document.LineCount = blockProcessor.LineIndex; - - // Allow to call a hook after processing a document - documentProcessed?.Invoke(document); - return document; - } - - private void ProcessBlocks() - { - while (true) - { - // Get the precise position of the begining of the line - var lineText = lineReader.ReadLine(); - - // If this is the end of file and the last line is empty - if (lineText == null) - { - break; - } - blockProcessor.ProcessLine(lineText.Value); - } - blockProcessor.CloseAll(true); - } - - /// - /// Fixups the zero character by replacing it to a secure character (Section 2.3 Insecure characters, CommonMark specs) - /// - /// The text to secure. - private string FixupZero(string text) - { - return text.Replace('\0', CharHelper.ZeroSafeChar); - } - - private class ContainerItemCache : DefaultObjectCache - { - protected override void Reset(ContainerItem instance) - { - instance.Container = null; - instance.Index = 0; - } - } - - private void ProcessInlines() - { - // "stackless" processor - var cache = new ContainerItemCache(); - var blocks = new Stack(); - - // TODO: Use an ObjectCache for ContainerItem - blocks.Push(new ContainerItem(document)); - document.OnProcessInlinesBegin(inlineProcessor); - while (blocks.Count > 0) - { - process_new_block: - var item = blocks.Peek(); - var container = item.Container; - - for (; item.Index < container.Count; item.Index++) - { - var block = container[item.Index]; - if (block is LeafBlock leafBlock) - { - leafBlock.OnProcessInlinesBegin(inlineProcessor); - if (leafBlock.ProcessInlines) - { - inlineProcessor.ProcessInlineLeaf(leafBlock); - if (leafBlock.RemoveAfterProcessInlines) - { - container.RemoveAt(item.Index); - item.Index--; - } - else if (inlineProcessor.BlockNew != null) - { - container[item.Index] = inlineProcessor.BlockNew; - } - } - leafBlock.OnProcessInlinesEnd(inlineProcessor); - } - else if (block is ContainerBlock) - { - var newContainer = (ContainerBlock) block; - // If we need to remove it - if (newContainer.RemoveAfterProcessInlines) - { - container.RemoveAt(item.Index); - } - else - { - // Else we have processed it - item.Index++; - } - var newItem = cache.Get(); - newItem.Container = (ContainerBlock)block; - block.OnProcessInlinesBegin(inlineProcessor); - newItem.Index = 0; - blocks.Push(newItem); - goto process_new_block; - } - } - item = blocks.Pop(); - container = item.Container; - container.OnProcessInlinesEnd(inlineProcessor); - - cache.Release(item); - } - } - - private class ContainerItem - { - public ContainerItem() - { - } - - public ContainerItem(ContainerBlock container) - { - Container = container; - } - - public ContainerBlock Container; - - public int Index; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/NumberedListItemParser.cs b/NppMarkdownPanel/Markdig/Parsers/NumberedListItemParser.cs deleted file mode 100644 index 38d2477..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/NumberedListItemParser.cs +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Helpers; - -namespace Markdig.Parsers -{ - /// - /// The default parser for parsing numbered list item (e.g: 1) or 1.) - /// - /// - public class NumberedListItemParser : OrderedListItemParser - { - /// - /// Initializes a new instance of the class. - /// - public NumberedListItemParser() - { - OpeningCharacters = new char[10]; - for (int i = 0; i < 10; i++) - { - OpeningCharacters[i] = (char) ('0' + i); - } - } - - public override bool TryParse(BlockProcessor state, char pendingBulletType, out ListInfo result) - { - result = new ListInfo(); - var c = state.CurrentChar; - - int countDigit = 0; - int startChar = -1; - int endChar = 0; - while (c.IsDigit()) - { - endChar = state.Start; - // Trim left 0 - if (startChar < 0 && c != '0') - { - startChar = endChar; - } - c = state.NextChar(); - countDigit++; - } - if (startChar < 0) - { - startChar = endChar; - } - - // Note that ordered list start numbers must be nine digits or less: - char orderedDelimiter; - if (countDigit > 9 || !TryParseDelimiter(state, out orderedDelimiter)) - { - return false; - } - - result.OrderedStart = state.Line.Text.Substring(startChar, endChar - startChar + 1); - result.OrderedDelimiter = orderedDelimiter; - result.BulletType = '1'; - result.DefaultOrderedStart = "1"; - return true; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/OrderedListItemParser.cs b/NppMarkdownPanel/Markdig/Parsers/OrderedListItemParser.cs deleted file mode 100644 index 20c57d1..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/OrderedListItemParser.cs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace Markdig.Parsers -{ - /// - /// Base class for an ordered list item parser. - /// - /// - public abstract class OrderedListItemParser : ListItemParser - { - /// - /// Initializes a new instance of the class. - /// - protected OrderedListItemParser() - { - OrderedDelimiters = new[] { '.', ')' }; - } - - /// - /// Gets or sets the ordered delimiters used after a digit/number (by default `.` and `)`) - /// - public char[] OrderedDelimiters { get; set; } - - /// - /// Utility method that tries to parse the delimiter coming after an ordered list start (e.g: the `)` after `1)`). - /// - /// The state. - /// The ordered delimiter found if this method is successful. - /// true if parsing was successful; false otherwise. - protected bool TryParseDelimiter(BlockProcessor state, out char orderedDelimiter) - { - // Check if we have an ordered delimiter - orderedDelimiter = state.CurrentChar; - for (int i = 0; i < OrderedDelimiters.Length; i++) - { - if (OrderedDelimiters[i] == orderedDelimiter) - { - state.NextChar(); - return true; - } - } - return false; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/ParagraphBlockParser.cs b/NppMarkdownPanel/Markdig/Parsers/ParagraphBlockParser.cs deleted file mode 100644 index a3f0e52..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/ParagraphBlockParser.cs +++ /dev/null @@ -1,180 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Helpers; -using Markdig.Syntax; - -namespace Markdig.Parsers -{ - /// - /// Block parser for a . - /// - /// - public class ParagraphBlockParser : BlockParser - { - public override BlockState TryOpen(BlockProcessor processor) - { - if (processor.IsBlankLine) - { - return BlockState.None; - } - - // We continue trying to match by default - processor.NewBlocks.Push(new ParagraphBlock(this) - { - Column = processor.Column, - Span = new SourceSpan(processor.Line.Start, processor.Line.End) - }); - return BlockState.Continue; - } - - public override BlockState TryContinue(BlockProcessor processor, Block block) - { - if (processor.IsBlankLine) - { - return BlockState.BreakDiscard; - } - - if (!processor.IsCodeIndent && !(block.Parent is QuoteBlock)) - { - return TryParseSetexHeading(processor, block); - } - - block.UpdateSpanEnd(processor.Line.End); - return BlockState.Continue; - } - - public override bool Close(BlockProcessor processor, Block block) - { - var paragraph = block as ParagraphBlock; - if (paragraph != null) - { - TryMatchLinkReferenceDefinition(ref paragraph.Lines, processor); - - // If Paragraph is empty, we can discard it - if (paragraph.Lines.Count == 0) - { - return false; - } - - var lineCount = paragraph.Lines.Count; - for (int i = 0; i < lineCount; i++) - { - paragraph.Lines.Lines[i].Slice.TrimStart(); - } - if (lineCount > 0) - { - paragraph.Lines.Lines[lineCount - 1].Slice.TrimEnd(); - } - } - - return true; - } - - private BlockState TryParseSetexHeading(BlockProcessor state, Block block) - { - var paragraph = (ParagraphBlock) block; - var headingChar = (char)0; - bool checkForSpaces = false; - var line = state.Line; - var c = line.CurrentChar; - while (c != '\0') - { - if (headingChar == 0) - { - if (c == '=' || c == '-') - { - headingChar = c; - continue; - } - break; - } - - if (checkForSpaces) - { - if (!c.IsSpaceOrTab()) - { - headingChar = (char)0; - break; - } - } - else if (c != headingChar) - { - if (c.IsSpaceOrTab()) - { - checkForSpaces = true; - } - else - { - headingChar = (char)0; - break; - } - } - c = line.NextChar(); - } - - if (headingChar != 0) - { - // We dicard the paragraph that will be transformed to a heading - state.Discard(paragraph); - - // If we matched a LinkReferenceDefinition before matching the heading, and the remaining - // lines are empty, we can early exit and remove the paragraph - if (!(TryMatchLinkReferenceDefinition(ref paragraph.Lines, state) && paragraph.Lines.Count == 0)) - { - var level = headingChar == '=' ? 1 : 2; - - var heading = new HeadingBlock(this) - { - Column = paragraph.Column, - Span = new SourceSpan(paragraph.Span.Start, line.Start), - Level = level, - Lines = paragraph.Lines, - }; - heading.Lines.Trim(); - - // Remove the paragraph as a pending block - state.NewBlocks.Push(heading); - } - return BlockState.BreakDiscard; - } - - block.UpdateSpanEnd(state.Line.End); - - return BlockState.Continue; - } - - private bool TryMatchLinkReferenceDefinition(ref StringLineGroup lines, BlockProcessor state) - { - bool atLeastOneFound = false; - - while (true) - { - // If we have found a LinkReferenceDefinition, we can discard the previous paragraph - var iterator = lines.ToCharIterator(); - if (LinkReferenceDefinition.TryParse(ref iterator, out LinkReferenceDefinition linkReferenceDefinition)) - { - state.Document.SetLinkReferenceDefinition(linkReferenceDefinition.Label, linkReferenceDefinition); - atLeastOneFound = true; - - // Correct the locations of each field - linkReferenceDefinition.Line = lines.Lines[0].Line; - int startPosition = lines.Lines[0].Slice.Start; - - linkReferenceDefinition.Span = linkReferenceDefinition.Span .MoveForward(startPosition); - linkReferenceDefinition.LabelSpan = linkReferenceDefinition.LabelSpan .MoveForward(startPosition); - linkReferenceDefinition.UrlSpan = linkReferenceDefinition.UrlSpan .MoveForward(startPosition); - linkReferenceDefinition.TitleSpan = linkReferenceDefinition.TitleSpan .MoveForward(startPosition); - - lines = iterator.Remaining(); - } - else - { - break; - } - } - - return atLeastOneFound; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/ParserBase.cs b/NppMarkdownPanel/Markdig/Parsers/ParserBase.cs deleted file mode 100644 index dbe9d81..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/ParserBase.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace Markdig.Parsers -{ - /// - /// Base class for a or . - /// - /// Type of the parser processor - /// - public abstract class ParserBase : IMarkdownParser - { - /// - /// Gets the opening characters this parser will be triggered if the character is found. - /// - public char[] OpeningCharacters { get; set; } - - /// - /// Initializes this parser with the specified parser processor. - /// - public virtual void Initialize() - { - } - - /// - /// Gets the index of this parser in or . - /// - public int Index { get; internal set; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/ParserList.cs b/NppMarkdownPanel/Markdig/Parsers/ParserList.cs deleted file mode 100644 index fcbbfa0..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/ParserList.cs +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System; -using System.Collections.Generic; -using System.Runtime.CompilerServices; -using Markdig.Helpers; - -namespace Markdig.Parsers -{ - /// - /// Base class for a list of parsers. - /// - /// Type of the parser - /// The type of the parser state. - /// - public abstract class ParserList : OrderedList where T : ParserBase - { - private readonly CharacterMap charMap; - private readonly T[] globalParsers; - - protected ParserList(IEnumerable parsersArg) : base(parsersArg) - { - var charCounter = new Dictionary(); - int globalCounter = 0; - - for (int i = 0; i < Count; i++) - { - var parser = this[i]; - if (parser == null) - { - throw new InvalidOperationException("Unexpected null parser found"); - } - - parser.Initialize(); - parser.Index = i; - if (parser.OpeningCharacters != null && parser.OpeningCharacters.Length != 0) - { - foreach (var openingChar in parser.OpeningCharacters) - { - if (!charCounter.ContainsKey(openingChar)) - { - charCounter[openingChar] = 0; - } - charCounter[openingChar]++; - } - } - else - { - globalCounter++; - } - } - - if (globalCounter > 0) - { - globalParsers = new T[globalCounter]; - } - - var tempCharMap = new Dictionary(); - foreach (var parser in this) - { - if (parser.OpeningCharacters != null && parser.OpeningCharacters.Length != 0) - { - foreach (var openingChar in parser.OpeningCharacters) - { - T[] parsers; - if (!tempCharMap.TryGetValue(openingChar, out parsers)) - { - parsers = new T[charCounter[openingChar]]; - tempCharMap[openingChar] = parsers; - } - - var index = parsers.Length - charCounter[openingChar]; - parsers[index] = parser; - charCounter[openingChar]--; - } - } - else - { - globalParsers[globalParsers.Length - globalCounter] = parser; - globalCounter--; - } - } - - charMap = new CharacterMap(tempCharMap); - } - - /// - /// Gets the list of global parsers (that don't have any opening characters defined) - /// - public T[] GlobalParsers => globalParsers; - - /// - /// Gets all the opening characters defined. - /// - public char[] OpeningCharacters => charMap.OpeningCharacters; - - /// - /// Gets the list of parsers valid for the specified opening character. - /// - /// The opening character. - /// A list of parsers valid for the specified opening character or null if no parsers registered. - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public T[] GetParsersForOpeningCharacter(char openingChar) - { - return charMap[openingChar]; - } - - /// - /// Searches for an opening character from a registered parser in the specified string. - /// - /// The text. - /// The start. - /// The end. - /// Index position within the string of the first opening character found in the specified text; if not found, returns -1 - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public int IndexOfOpeningCharacter(string text, int start, int end) - { - return charMap.IndexOfOpeningCharacter(text, start, end); - } - - /// - /// Initializes this instance with specified parser state. - /// - /// - /// Unexpected null parser found - /// or - /// - private void Initialize() - { - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/QuoteBlockParser.cs b/NppMarkdownPanel/Markdig/Parsers/QuoteBlockParser.cs deleted file mode 100644 index 29b83bb..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/QuoteBlockParser.cs +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Helpers; -using Markdig.Syntax; - -namespace Markdig.Parsers -{ - /// - /// A block parser for a . - /// - /// - public class QuoteBlockParser : BlockParser - { - /// - /// Initializes a new instance of the class. - /// - public QuoteBlockParser() - { - OpeningCharacters = new[] {'>'}; - } - - public override BlockState TryOpen(BlockProcessor processor) - { - if (processor.IsCodeIndent) - { - return BlockState.None; - } - - var column = processor.Column; - var sourcePosition = processor.Start; - - // 5.1 Block quotes - // A block quote marker consists of 0-3 spaces of initial indent, plus (a) the character > together with a following space, or (b) a single character > not followed by a space. - var quoteChar = processor.CurrentChar; - var c = processor.NextChar(); - if (c.IsSpaceOrTab()) - { - processor.NextColumn(); - } - processor.NewBlocks.Push(new QuoteBlock(this) - { - QuoteChar = quoteChar, - Column = column, - Span = new SourceSpan(sourcePosition, processor.Line.End), - }); - return BlockState.Continue; - } - - public override BlockState TryContinue(BlockProcessor processor, Block block) - { - if (processor.IsCodeIndent) - { - return BlockState.None; - } - - var quote = (QuoteBlock) block; - - // 5.1 Block quotes - // A block quote marker consists of 0-3 spaces of initial indent, plus (a) the character > together with a following space, or (b) a single character > not followed by a space. - var c = processor.CurrentChar; - if (c != quote.QuoteChar) - { - return processor.IsBlankLine ? BlockState.BreakDiscard : BlockState.None; - } - - c = processor.NextChar(); // Skip opening char - if (c.IsSpace()) - { - processor.NextChar(); // Skip following space - } - - block.UpdateSpanEnd(processor.Line.End); - return BlockState.Continue; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/ThematicBreakParser.cs b/NppMarkdownPanel/Markdig/Parsers/ThematicBreakParser.cs deleted file mode 100644 index f0f45fe..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/ThematicBreakParser.cs +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Helpers; -using Markdig.Syntax; - -namespace Markdig.Parsers -{ - /// - /// A block parser for a . - /// - /// - public class ThematicBreakParser : BlockParser - { - /// - /// A singleton instance used by other parsers. - /// - public static readonly ThematicBreakParser Default = new ThematicBreakParser(); - - /// - /// Initializes a new instance of the class. - /// - public ThematicBreakParser() - { - OpeningCharacters = new[] {'-', '_', '*'}; - } - - public override BlockState TryOpen(BlockProcessor processor) - { - if (processor.IsCodeIndent) - { - return BlockState.None; - } - - var startPosition = processor.Start; - - var line = processor.Line; - - // 4.1 Thematic breaks - // A line consisting of 0-3 spaces of indentation, followed by a sequence of three or more matching -, _, or * characters, each followed optionally by any number of spaces - int breakCharCount = 0; - var breakChar = line.CurrentChar; - bool hasSpacesSinceLastMatch = false; - bool hasInnerSpaces = false; - var c = breakChar; - while (c != '\0') - { - if (c == breakChar) - { - if (hasSpacesSinceLastMatch) - { - hasInnerSpaces = true; - } - - breakCharCount++; - } - else if (c.IsSpaceOrTab()) - { - hasSpacesSinceLastMatch = true; - } - else - { - return BlockState.None; - } - - c = line.NextChar(); - } - - // If it as less than 3 chars or it is a setex heading and we are already in a paragraph, let the paragraph handle it - var previousParagraph = processor.CurrentBlock as ParagraphBlock; - - var isSetexHeading = previousParagraph != null && breakChar == '-' && !hasInnerSpaces; - if (isSetexHeading) - { - var parent = previousParagraph.Parent; - if (parent is QuoteBlock || (parent is ListItemBlock && previousParagraph.Column != processor.Column)) - { - isSetexHeading = false; - } - } - - if (breakCharCount < 3 || isSetexHeading) - { - return BlockState.None; - } - - // Push a new block - processor.NewBlocks.Push(new ThematicBreakBlock(this) - { - Column = processor.Column, - Span = new SourceSpan(startPosition, line.End), - ThematicChar = breakChar, - ThematicCharCount = breakCharCount - }); - return BlockState.BreakDiscard; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Parsers/UnorderedListItemParser.cs b/NppMarkdownPanel/Markdig/Parsers/UnorderedListItemParser.cs deleted file mode 100644 index a2ea94c..0000000 --- a/NppMarkdownPanel/Markdig/Parsers/UnorderedListItemParser.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -namespace Markdig.Parsers -{ - /// - /// The default parser used to parse unordered list item (-, +, *) - /// - /// - public class UnorderedListItemParser : ListItemParser - { - /// - /// Initializes a new instance of the class. - /// - public UnorderedListItemParser() - { - OpeningCharacters = new [] {'-', '+', '*'}; - } - - public override bool TryParse(BlockProcessor state, char pendingBulletType, out ListInfo result) - { - result = new ListInfo(state.CurrentChar); - state.NextChar(); - return true; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Html/CodeBlockRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Html/CodeBlockRenderer.cs deleted file mode 100644 index 2cd0465..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Html/CodeBlockRenderer.cs +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Collections.Generic; -using Markdig.Parsers; -using Markdig.Syntax; - -namespace Markdig.Renderers.Html -{ - /// - /// An HTML renderer for a and . - /// - /// - public class CodeBlockRenderer : HtmlObjectRenderer - { - /// - /// Initializes a new instance of the class. - /// - public CodeBlockRenderer() - { - BlocksAsDiv = new HashSet(StringComparer.OrdinalIgnoreCase); - } - - public bool OutputAttributesOnPre { get; set; } - - /// - /// Gets a map of fenced code block infos that should be rendered as div blocks instead of pre/code blocks. - /// - public HashSet BlocksAsDiv { get; } - - protected override void Write(HtmlRenderer renderer, CodeBlock obj) - { - renderer.EnsureLine(); - - var fencedCodeBlock = obj as FencedCodeBlock; - if (fencedCodeBlock?.Info != null && BlocksAsDiv.Contains(fencedCodeBlock.Info)) - { - var infoPrefix = (obj.Parser as FencedCodeBlockParser)?.InfoPrefix ?? - FencedCodeBlockParser.DefaultInfoPrefix; - - // We are replacing the HTML attribute `language-mylang` by `mylang` only for a div block - // NOTE that we are allocating a closure here - - if (renderer.EnableHtmlForBlock) - { - renderer.Write(" cls.StartsWith(infoPrefix) ? cls.Substring(infoPrefix.Length) : cls) - .Write(">"); - } - - renderer.WriteLeafRawLines(obj, true, true, true); - - if (renderer.EnableHtmlForBlock) - { - renderer.WriteLine(""); - } - - } - else - { - if (renderer.EnableHtmlForBlock) - { - renderer.Write(""); - } - - renderer.WriteLeafRawLines(obj, true, true); - - if (renderer.EnableHtmlForBlock) - { - renderer.WriteLine(""); - } - } - - renderer.EnsureLine(); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Html/HeadingRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Html/HeadingRenderer.cs deleted file mode 100644 index 9e574e3..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Html/HeadingRenderer.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System.Globalization; -using Markdig.Syntax; - -namespace Markdig.Renderers.Html -{ - /// - /// An HTML renderer for a . - /// - /// - public class HeadingRenderer : HtmlObjectRenderer - { - private static readonly string[] HeadingTexts = { - "h1", - "h2", - "h3", - "h4", - "h5", - "h6", - }; - - protected override void Write(HtmlRenderer renderer, HeadingBlock obj) - { - var headingText = obj.Level > 0 && obj.Level <= 6 - ? HeadingTexts[obj.Level - 1] - : ""); - } - - renderer.WriteLeafInline(obj); - - if (renderer.EnableHtmlForBlock) - { - renderer.Write(""); - } - - renderer.EnsureLine(); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Html/HtmlAttributes.cs b/NppMarkdownPanel/Markdig/Renderers/Html/HtmlAttributes.cs deleted file mode 100644 index 2307979..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Html/HtmlAttributes.cs +++ /dev/null @@ -1,192 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System; -using System.Collections.Generic; -using System.Globalization; -using Markdig.Syntax; - -namespace Markdig.Renderers.Html -{ - /// - /// Attached HTML attributes to a . - /// - public class HtmlAttributes : MarkdownObject - { - /// - /// Initializes a new instance of the class. - /// - public HtmlAttributes() - { - } - - /// - /// Gets or sets the HTML id/identifier. May be null. - /// - public string Id { get; set; } - - /// - /// Gets or sets the CSS classes attached. May be null. - /// - public List Classes { get; set; } - - /// - /// Gets or sets the additional properties. May be null. - /// - public List> Properties { get; set; } - - /// - /// Adds a CSS class. - /// - /// The css class name. - public void AddClass(string name) - { - if (name == null) throw new ArgumentNullException(nameof(name)); - if (Classes == null) - { - Classes = new List(2); - // Use half list compare to default capacity (4), as we don't expect lots of classes - } - - if (!Classes.Contains(name)) - { - Classes.Add(name); - } - } - - /// - /// Adds a property. - /// - /// The name. - /// The value. - public void AddProperty(string name, string value) - { - if (name == null) throw new ArgumentNullException(nameof(name)); - if (Properties == null) - { - Properties = new List>(2); // Use half list compare to default capacity (4), as we don't expect lots of classes - } - Properties.Add(new KeyValuePair(name, value)); - } - - /// - /// Adds the specified property only if it does not already exist. - /// - /// The name. - /// The value. - public void AddPropertyIfNotExist(string name, object value) - { - if (name == null) throw new ArgumentNullException(nameof(name)); - if (Properties == null) - { - Properties = new List>(4) {new KeyValuePair(name, value == null ? null : Convert.ToString(value, CultureInfo.InvariantCulture))}; - } - else - { - // Check that there is not already a property with the same key - bool copyProp = true; - for (int i = 0; i < Properties.Count; i++) - { - var againstProp = Properties[i]; - if (againstProp.Key == name) - { - copyProp = false; - break; - } - } - if (copyProp) - { - Properties.Add(new KeyValuePair(name, value == null ? null : Convert.ToString(value, CultureInfo.InvariantCulture))); - } - } - } - - /// - /// Copies/merge the values from this instance to the specified instance. - /// - /// The HTML attributes. - /// If set to true it will merge properties to the target htmlAttributes. Default is false - /// If set to true it will try to share Classes and Properties if destination don't have them, otherwise it will make a copy. Default is true - /// - public void CopyTo(HtmlAttributes htmlAttributes, bool mergeIdAndProperties = false, bool shared = true) - { - if (htmlAttributes == null) throw new ArgumentNullException(nameof(htmlAttributes)); - // Add html htmlAttributes to the object - if (!mergeIdAndProperties || Id != null) - { - htmlAttributes.Id = Id; - } - if (htmlAttributes.Classes == null) - { - htmlAttributes.Classes = shared ? Classes : Classes != null ? new List(Classes) : null; - } - else if (Classes != null) - { - htmlAttributes.Classes.AddRange(Classes); - } - - if (htmlAttributes.Properties == null) - { - htmlAttributes.Properties = shared ? Properties : Properties != null ? new List>(Properties) : null; - } - else if (Properties != null) - { - if (mergeIdAndProperties) - { - foreach (var prop in Properties) - { - htmlAttributes.AddPropertyIfNotExist(prop.Key, prop.Value); - } - } - else - { - htmlAttributes.Properties.AddRange(Properties); - } - } - } - } - - /// - /// Extensions for a to allow accessing - /// - public static class HtmlAttributesExtensions - { - private static readonly object Key = typeof (HtmlAttributes); - - /// - /// Tries the get stored on a . - /// - /// The markdown object. - /// The attached html attributes or null if not found - public static HtmlAttributes TryGetAttributes(this IMarkdownObject obj) - { - return obj.GetData(Key) as HtmlAttributes; - } - - /// - /// Gets or creates the stored on a - /// - /// The markdown object. - /// The attached html attributes - public static HtmlAttributes GetAttributes(this IMarkdownObject obj) - { - var attributes = obj.GetData(Key) as HtmlAttributes; - if (attributes == null) - { - attributes = new HtmlAttributes(); - obj.SetAttributes(attributes); - } - return attributes; - } - - /// - /// Sets to the - /// - /// The markdown object. - /// The attributes to attach. - public static void SetAttributes(this IMarkdownObject obj, HtmlAttributes attributes) - { - obj.SetData(Key, attributes); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Html/HtmlBlockRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Html/HtmlBlockRenderer.cs deleted file mode 100644 index 574ae03..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Html/HtmlBlockRenderer.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax; - -namespace Markdig.Renderers.Html -{ - /// - /// A HTML renderer for a . - /// - /// - public class HtmlBlockRenderer : HtmlObjectRenderer - { - protected override void Write(HtmlRenderer renderer, HtmlBlock obj) - { - renderer.WriteLeafRawLines(obj, true, false); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Html/HtmlObjectRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Html/HtmlObjectRenderer.cs deleted file mode 100644 index 24c1862..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Html/HtmlObjectRenderer.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax; - -namespace Markdig.Renderers.Html -{ - /// - /// A base class for HTML rendering and Markdown objects. - /// - /// The type of the object. - /// - public abstract class HtmlObjectRenderer : MarkdownObjectRenderer where TObject : MarkdownObject - { - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Html/Inlines/AutolinkInlineRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Html/Inlines/AutolinkInlineRenderer.cs deleted file mode 100644 index 8c01954..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Html/Inlines/AutolinkInlineRenderer.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax.Inlines; - -namespace Markdig.Renderers.Html.Inlines -{ - /// - /// A HTML renderer for an . - /// - /// - public class AutolinkInlineRenderer : HtmlObjectRenderer - { - /// - /// Gets or sets a value indicating whether to always add rel="nofollow" for links or not. - /// - public bool AutoRelNoFollow { get; set; } - - protected override void Write(HtmlRenderer renderer, AutolinkInline obj) - { - if (renderer.EnableHtmlForInline) - { - renderer.Write(""); - } - - renderer.WriteEscape(obj.Url); - - if (renderer.EnableHtmlForInline) - { - renderer.Write(""); - } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Html/Inlines/CodeInlineRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Html/Inlines/CodeInlineRenderer.cs deleted file mode 100644 index 044bb53..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Html/Inlines/CodeInlineRenderer.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax.Inlines; - -namespace Markdig.Renderers.Html.Inlines -{ - /// - /// A HTML renderer for a . - /// - /// - public class CodeInlineRenderer : HtmlObjectRenderer - { - protected override void Write(HtmlRenderer renderer, CodeInline obj) - { - if (renderer.EnableHtmlForInline) - { - renderer.Write(""); - } - renderer.WriteEscape(obj.Content); - if (renderer.EnableHtmlForInline) - { - renderer.Write(""); - } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Html/Inlines/DelimiterInlineRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Html/Inlines/DelimiterInlineRenderer.cs deleted file mode 100644 index d056b49..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Html/Inlines/DelimiterInlineRenderer.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax.Inlines; - -namespace Markdig.Renderers.Html.Inlines -{ - /// - /// A HTML renderer for a . - /// - /// - public class DelimiterInlineRenderer : HtmlObjectRenderer - { - protected override void Write(HtmlRenderer renderer, DelimiterInline obj) - { - renderer.WriteEscape(obj.ToLiteral()); - renderer.WriteChildren(obj); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Html/Inlines/EmphasisInlineRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Html/Inlines/EmphasisInlineRenderer.cs deleted file mode 100644 index 8dd1dda..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Html/Inlines/EmphasisInlineRenderer.cs +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax.Inlines; -using System.Diagnostics; - -namespace Markdig.Renderers.Html.Inlines -{ - /// - /// A HTML renderer for an . - /// - /// - public class EmphasisInlineRenderer : HtmlObjectRenderer - { - /// - /// Delegates to get the tag associated to an object. - /// - /// The object. - /// The HTML tag associated to this object - public delegate string GetTagDelegate(EmphasisInline obj); - - /// - /// Initializes a new instance of the class. - /// - public EmphasisInlineRenderer() - { - GetTag = GetDefaultTag; - } - - /// - /// Gets or sets the GetTag delegate. - /// - public GetTagDelegate GetTag { get; set; } - - protected override void Write(HtmlRenderer renderer, EmphasisInline obj) - { - string tag = null; - if (renderer.EnableHtmlForInline) - { - tag = GetTag(obj); - renderer.Write("<").Write(tag).WriteAttributes(obj).Write(">"); - } - renderer.WriteChildren(obj); - if (renderer.EnableHtmlForInline) - { - renderer.Write(""); - } - } - - /// - /// Gets the default HTML tag for ** and __ emphasis. - /// - /// The object. - /// - public string GetDefaultTag(EmphasisInline obj) - { - if (obj.DelimiterChar == '*' || obj.DelimiterChar == '_') - { - Debug.Assert(obj.DelimiterCount <= 2); - return obj.DelimiterCount == 2 ? "strong" : "em"; - } - return null; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Html/Inlines/HtmlEntityInlineRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Html/Inlines/HtmlEntityInlineRenderer.cs deleted file mode 100644 index b1a8103..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Html/Inlines/HtmlEntityInlineRenderer.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax.Inlines; - -namespace Markdig.Renderers.Html.Inlines -{ - /// - /// A HTML renderer for a . - /// - /// - public class HtmlEntityInlineRenderer : HtmlObjectRenderer - { - protected override void Write(HtmlRenderer renderer, HtmlEntityInline obj) - { - renderer.WriteEscape(obj.Transcoded); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Html/Inlines/HtmlInlineRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Html/Inlines/HtmlInlineRenderer.cs deleted file mode 100644 index 5775c67..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Html/Inlines/HtmlInlineRenderer.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax.Inlines; - -namespace Markdig.Renderers.Html.Inlines -{ - /// - /// A HTML renderer for a . - /// - /// - public class HtmlInlineRenderer : HtmlObjectRenderer - { - protected override void Write(HtmlRenderer renderer, HtmlInline obj) - { - if (renderer.EnableHtmlForInline) - { - renderer.Write(obj.Tag); - } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Html/Inlines/LineBreakInlineRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Html/Inlines/LineBreakInlineRenderer.cs deleted file mode 100644 index 9c5b55f..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Html/Inlines/LineBreakInlineRenderer.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax.Inlines; - -namespace Markdig.Renderers.Html.Inlines -{ - /// - /// A HTML renderer for a . - /// - /// - public class LineBreakInlineRenderer : HtmlObjectRenderer - { - /// - /// Gets or sets a value indicating whether to render this softline break as a HTML hardline break tag (<br />) - /// - public bool RenderAsHardlineBreak { get; set; } - - protected override void Write(HtmlRenderer renderer, LineBreakInline obj) - { - if (renderer.EnableHtmlForInline) - { - if (obj.IsHard || RenderAsHardlineBreak) - { - renderer.WriteLine("
"); - } - } - - renderer.EnsureLine(); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Html/Inlines/LinkInlineRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Html/Inlines/LinkInlineRenderer.cs deleted file mode 100644 index c0bef90..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Html/Inlines/LinkInlineRenderer.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax.Inlines; - -namespace Markdig.Renderers.Html.Inlines -{ - /// - /// A HTML renderer for a . - /// - /// - public class LinkInlineRenderer : HtmlObjectRenderer - { - /// - /// Gets or sets a value indicating whether to always add rel="nofollow" for links or not. - /// - public bool AutoRelNoFollow { get; set; } - - protected override void Write(HtmlRenderer renderer, LinkInline link) - { - if (renderer.EnableHtmlForInline) - { - renderer.Write(link.IsImage ? "\"");"); - } - } - else - { - if (renderer.EnableHtmlForInline) - { - if (AutoRelNoFollow) - { - renderer.Write(" rel=\"nofollow\""); - } - renderer.Write(">"); - } - renderer.WriteChildren(link); - if (renderer.EnableHtmlForInline) - { - renderer.Write(""); - } - } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Html/Inlines/LiteralInlineRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Html/Inlines/LiteralInlineRenderer.cs deleted file mode 100644 index 03ccdc8..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Html/Inlines/LiteralInlineRenderer.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax.Inlines; - -namespace Markdig.Renderers.Html.Inlines -{ - /// - /// A HTML renderer for a . - /// - /// - public class LiteralInlineRenderer : HtmlObjectRenderer - { - protected override void Write(HtmlRenderer renderer, LiteralInline obj) - { - renderer.WriteEscape(ref obj.Content); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Html/ListRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Html/ListRenderer.cs deleted file mode 100644 index d9017b3..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Html/ListRenderer.cs +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System.Globalization; -using Markdig.Syntax; - -namespace Markdig.Renderers.Html -{ - /// - /// A HTML renderer for a . - /// - /// - public class ListRenderer : HtmlObjectRenderer - { - protected override void Write(HtmlRenderer renderer, ListBlock listBlock) - { - renderer.EnsureLine(); - if (renderer.EnableHtmlForBlock) - { - if (listBlock.IsOrdered) - { - renderer.Write(""); - } - else - { - renderer.Write(""); - } - } - - foreach (var item in listBlock) - { - var listItem = (ListItemBlock)item; - var previousImplicit = renderer.ImplicitParagraph; - renderer.ImplicitParagraph = !listBlock.IsLoose; - - renderer.EnsureLine(); - if (renderer.EnableHtmlForBlock) - { - renderer.Write(""); - } - - renderer.WriteChildren(listItem); - - if (renderer.EnableHtmlForBlock) - { - renderer.WriteLine(""); - } - - renderer.EnsureLine(); - renderer.ImplicitParagraph = previousImplicit; - } - - if (renderer.EnableHtmlForBlock) - { - renderer.WriteLine(listBlock.IsOrdered ? "" : ""); - } - - renderer.EnsureLine(); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Html/ParagraphRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Html/ParagraphRenderer.cs deleted file mode 100644 index 51507fd..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Html/ParagraphRenderer.cs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax; - -namespace Markdig.Renderers.Html -{ - /// - /// A HTML renderer for a . - /// - /// - public class ParagraphRenderer : HtmlObjectRenderer - { - protected override void Write(HtmlRenderer renderer, ParagraphBlock obj) - { - if (!renderer.ImplicitParagraph && renderer.EnableHtmlForBlock) - { - if (!renderer.IsFirstInContainer) - { - renderer.EnsureLine(); - } - - renderer.Write(""); - } - renderer.WriteLeafInline(obj); - if (!renderer.ImplicitParagraph) - { - if(renderer.EnableHtmlForBlock) - { - renderer.WriteLine("

"); - } - - renderer.EnsureLine(); - } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Html/QuoteBlockRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Html/QuoteBlockRenderer.cs deleted file mode 100644 index f526541..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Html/QuoteBlockRenderer.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax; - -namespace Markdig.Renderers.Html -{ - /// - /// A HTML renderer for a . - /// - /// - public class QuoteBlockRenderer : HtmlObjectRenderer - { - protected override void Write(HtmlRenderer renderer, QuoteBlock obj) - { - renderer.EnsureLine(); - if (renderer.EnableHtmlForBlock) - { - renderer.Write(""); - } - var savedImplicitParagraph = renderer.ImplicitParagraph; - renderer.ImplicitParagraph = false; - renderer.WriteChildren(obj); - renderer.ImplicitParagraph = savedImplicitParagraph; - if (renderer.EnableHtmlForBlock) - { - renderer.WriteLine(""); - } - renderer.EnsureLine(); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Html/ThematicBreakRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Html/ThematicBreakRenderer.cs deleted file mode 100644 index ac836da..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Html/ThematicBreakRenderer.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax; - -namespace Markdig.Renderers.Html -{ - /// - /// A HTML renderer for a . - /// - /// - public class ThematicBreakRenderer : HtmlObjectRenderer - { - protected override void Write(HtmlRenderer renderer, ThematicBreakBlock obj) - { - if (renderer.EnableHtmlForBlock) - { - renderer.Write(""); - } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/HtmlRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/HtmlRenderer.cs deleted file mode 100644 index 9e8a541..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/HtmlRenderer.cs +++ /dev/null @@ -1,364 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.IO; -using System.Runtime.CompilerServices; -using System.Text; -using Markdig.Helpers; -using Markdig.Renderers.Html; -using Markdig.Renderers.Html.Inlines; -using Markdig.Syntax; - -namespace Markdig.Renderers -{ - /// - /// Default HTML renderer for a Markdown object. - /// - /// - public class HtmlRenderer : TextRendererBase - { - /// - /// Initializes a new instance of the class. - /// - /// The writer. - public HtmlRenderer(TextWriter writer) : base(writer) - { - // Default block renderers - ObjectRenderers.Add(new CodeBlockRenderer()); - ObjectRenderers.Add(new ListRenderer()); - ObjectRenderers.Add(new HeadingRenderer()); - ObjectRenderers.Add(new HtmlBlockRenderer()); - ObjectRenderers.Add(new ParagraphRenderer()); - ObjectRenderers.Add(new QuoteBlockRenderer()); - ObjectRenderers.Add(new ThematicBreakRenderer()); - - // Default inline renderers - ObjectRenderers.Add(new AutolinkInlineRenderer()); - ObjectRenderers.Add(new CodeInlineRenderer()); - ObjectRenderers.Add(new DelimiterInlineRenderer()); - ObjectRenderers.Add(new EmphasisInlineRenderer()); - ObjectRenderers.Add(new LineBreakInlineRenderer()); - ObjectRenderers.Add(new HtmlInlineRenderer()); - ObjectRenderers.Add(new HtmlEntityInlineRenderer()); - ObjectRenderers.Add(new LinkInlineRenderer()); - ObjectRenderers.Add(new LiteralInlineRenderer()); - - EnableHtmlForBlock = true; - EnableHtmlForInline = true; - EnableHtmlEscape = true; - } - - /// - /// Gets or sets a value indicating whether to output HTML tags when rendering. See remarks. - /// - /// - /// This is used by some renderers to disable HTML tags when rendering some inline elements (for image links). - /// - public bool EnableHtmlForInline { get; set; } - - /// - /// Gets or sets a value indicating whether to output HTML tags when rendering. See remarks. - /// - /// - /// This is used by some renderers to disable HTML tags when rendering some block elements (for image links). - /// - public bool EnableHtmlForBlock { get; set; } - - public bool EnableHtmlEscape { get; set; } - - /// - /// Gets or sets a value indicating whether to use implicit paragraph (optional <p>) - /// - public bool ImplicitParagraph { get; set; } - - public bool UseNonAsciiNoEscape { get; set; } - - /// - /// Gets a value to use as the base url for all relative links - /// - public Uri BaseUrl { get; set; } - - /// - /// Allows links to be rewritten - /// - public Func LinkRewriter { get; set; } - - /// - /// Writes the content escaped for HTML. - /// - /// The content. - /// This instance - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public HtmlRenderer WriteEscape(string content) - { - if (string.IsNullOrEmpty(content)) - return this; - - WriteEscape(content, 0, content.Length); - return this; - } - - /// - /// Writes the content escaped for HTML. - /// - /// The slice. - /// Only escape < and & - /// This instance - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public HtmlRenderer WriteEscape(ref StringSlice slice, bool softEscape = false) - { - if (slice.Start > slice.End) - { - return this; - } - return WriteEscape(slice.Text, slice.Start, slice.Length, softEscape); - } - - /// - /// Writes the content escaped for HTML. - /// - /// The slice. - /// Only escape < and & - /// This instance - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public HtmlRenderer WriteEscape(StringSlice slice, bool softEscape = false) - { - return WriteEscape(ref slice, softEscape); - } - - /// - /// Writes the content escaped for HTML. - /// - /// The content. - /// The offset. - /// The length. - /// Only escape < and & - /// This instance - public HtmlRenderer WriteEscape(string content, int offset, int length, bool softEscape = false) - { - if (string.IsNullOrEmpty(content) || length == 0) - return this; - - var end = offset + length; - int previousOffset = offset; - for (;offset < end; offset++) - { - switch (content[offset]) - { - case '<': - Write(content, previousOffset, offset - previousOffset); - if (EnableHtmlEscape) - { - Write("<"); - } - previousOffset = offset + 1; - break; - case '>': - if (!softEscape) - { - Write(content, previousOffset, offset - previousOffset); - if (EnableHtmlEscape) - { - Write(">"); - } - previousOffset = offset + 1; - } - break; - case '&': - Write(content, previousOffset, offset - previousOffset); - if (EnableHtmlEscape) - { - Write("&"); - } - previousOffset = offset + 1; - break; - case '"': - if (!softEscape) - { - Write(content, previousOffset, offset - previousOffset); - if (EnableHtmlEscape) - { - Write("""); - } - previousOffset = offset + 1; - } - break; - } - } - - Write(content, previousOffset, end - previousOffset); - return this; - } - - /// - /// Writes the URL escaped for HTML. - /// - /// The content. - /// This instance - public HtmlRenderer WriteEscapeUrl(string content) - { - if (content == null) - return this; - - if (BaseUrl != null && !Uri.TryCreate(content, UriKind.Absolute, out Uri _)) - { - content = new Uri(BaseUrl, content).AbsoluteUri; - } - - if (LinkRewriter != null) - { - content = LinkRewriter(content); - } - - int previousPosition = 0; - int length = content.Length; - - for (var i = 0; i < length; i++) - { - var c = content[i]; - - if (c < 128) - { - var escape = HtmlHelper.EscapeUrlCharacter(c); - if (escape != null) - { - Write(content, previousPosition, i - previousPosition); - previousPosition = i + 1; - Write(escape); - } - } - else - { - Write(content, previousPosition, i - previousPosition); - previousPosition = i + 1; - - // Special case for Edge/IE workaround for MarkdownEditor, don't escape non-ASCII chars to make image links working - if (UseNonAsciiNoEscape) - { - Write(c); - } - else - { - byte[] bytes; - if (c >= '\ud800' && c <= '\udfff' && previousPosition < length) - { - bytes = Encoding.UTF8.GetBytes(new[] { c, content[previousPosition] }); - // Skip next char as it is decoded above - i++; - previousPosition = i + 1; - } - else - { - bytes = Encoding.UTF8.GetBytes(new[] { c }); - } - for (var j = 0; j < bytes.Length; j++) - { - Write($"%{bytes[j]:X2}"); - } - } - } - } - - Write(content, previousPosition, length - previousPosition); - return this; - } - - /// - /// Writes the attached on the specified . - /// - /// The object. - /// - public HtmlRenderer WriteAttributes(MarkdownObject obj) - { - if (obj == null) throw new ArgumentNullException(nameof(obj)); - return WriteAttributes(obj.TryGetAttributes()); - } - - /// - /// Writes the specified . - /// - /// The attributes to render. - /// A class filter used to transform a class into another class at writing time - /// This instance - public HtmlRenderer WriteAttributes(HtmlAttributes attributes, Func classFilter = null) - { - if (attributes == null) - { - return this; - } - - if (attributes.Id != null) - { - Write(" id=\"").WriteEscape(attributes.Id).Write("\""); - } - - if (attributes.Classes != null && attributes.Classes.Count > 0) - { - Write(" class=\""); - for (int i = 0; i < attributes.Classes.Count; i++) - { - var cssClass = attributes.Classes[i]; - if (i > 0) - { - Write(" "); - } - WriteEscape(classFilter != null ? classFilter(cssClass) : cssClass); - } - Write("\""); - } - - if (attributes.Properties != null && attributes.Properties.Count > 0) - { - foreach (var property in attributes.Properties) - { - Write(" ").Write(property.Key); - Write("=").Write("\""); - WriteEscape(property.Value ?? ""); - Write("\""); - } - } - - return this; - } - - /// - /// Writes the lines of a - /// - /// The leaf block. - /// if set to true write end of lines. - /// if set to true escape the content for HTML - /// Only escape < and & - /// This instance - public HtmlRenderer WriteLeafRawLines(LeafBlock leafBlock, bool writeEndOfLines, bool escape, bool softEscape = false) - { - if (leafBlock == null) throw new ArgumentNullException(nameof(leafBlock)); - if (leafBlock.Lines.Lines != null) - { - var lines = leafBlock.Lines; - var slices = lines.Lines; - for (int i = 0; i < lines.Count; i++) - { - if (!writeEndOfLines && i > 0) - { - WriteLine(); - } - if (escape) - { - WriteEscape(ref slices[i].Slice, softEscape); - } - else - { - Write(ref slices[i].Slice); - } - if (writeEndOfLines) - { - WriteLine(); - } - } - } - return this; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/IMarkdownObjectRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/IMarkdownObjectRenderer.cs deleted file mode 100644 index e7241bc..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/IMarkdownObjectRenderer.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Syntax; - -namespace Markdig.Renderers -{ - /// - /// Base interface for the renderer of a . - /// - public interface IMarkdownObjectRenderer - { - /// - /// Accepts the specified . - /// - /// The renderer. - /// The Markdown object. - /// true If this renderer is accepting to render the specified Markdown object - bool Accept(RendererBase renderer, MarkdownObject obj); - - /// - /// Writes the specified to the . - /// - /// The renderer. - /// The object to render. - void Write(RendererBase renderer, MarkdownObject objectToRender); - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/IMarkdownRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/IMarkdownRenderer.cs deleted file mode 100644 index 9ef0077..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/IMarkdownRenderer.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using Markdig.Syntax; -using Markdig.Syntax.Inlines; - -namespace Markdig.Renderers -{ - /// - /// Base interface for a renderer for a Markdown . - /// - public interface IMarkdownRenderer - { - /// - /// Occurs when before writing an object. - /// - event Action ObjectWriteBefore; - - /// - /// Occurs when after writing an object. - /// - event Action ObjectWriteAfter; - - /// - /// Gets the object renderers that will render and elements. - /// - ObjectRendererCollection ObjectRenderers { get; } - - /// - /// Renders the specified markdown object. - /// - /// The markdown object. - /// The result of the rendering. - object Render(MarkdownObject markdownObject); - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/MarkdownObjectRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/MarkdownObjectRenderer.cs deleted file mode 100644 index f136b57..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/MarkdownObjectRenderer.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Helpers; -using Markdig.Syntax; - -namespace Markdig.Renderers -{ - /// - /// A base class for rendering and Markdown objects. - /// - /// The type of the renderer. - /// The type of the object. - /// - public abstract class MarkdownObjectRenderer : IMarkdownObjectRenderer where TRenderer : RendererBase where TObject : MarkdownObject - { - protected MarkdownObjectRenderer() - { - TryWriters = new OrderedList(); - } - - public delegate bool TryWriteDelegate(TRenderer renderer, TObject obj); - - public virtual bool Accept(RendererBase renderer, MarkdownObject obj) - { - return obj is TObject; - } - - public virtual void Write(RendererBase renderer, MarkdownObject obj) - { - var htmlRenderer = (TRenderer)renderer; - var typedObj = (TObject)obj; - - // Try processing - for (int i = 0; i < TryWriters.Count; i++) - { - var tryWriter = TryWriters[i]; - if (tryWriter(htmlRenderer, typedObj)) - { - return; - } - } - - Write(htmlRenderer, typedObj); - } - - /// - /// Gets the optional writers attached to this instance. - /// - public OrderedList TryWriters { get; } - - /// - /// Writes the specified Markdown object to the renderer. - /// - /// The renderer. - /// The markdown object. - protected abstract void Write(TRenderer renderer, TObject obj); - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Normalize/CodeBlockRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Normalize/CodeBlockRenderer.cs deleted file mode 100644 index 88ff325..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Normalize/CodeBlockRenderer.cs +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Renderers.Html; -using Markdig.Syntax; - -namespace Markdig.Renderers.Normalize -{ - /// - /// An Normalize renderer for a and . - /// - /// - public class CodeBlockRenderer : NormalizeObjectRenderer - { - public bool OutputAttributesOnPre { get; set; } - - protected override void Write(NormalizeRenderer renderer, CodeBlock obj) - { - var fencedCodeBlock = obj as FencedCodeBlock; - if (fencedCodeBlock != null) - { - var opening = new string(fencedCodeBlock.FencedChar, fencedCodeBlock.FencedCharCount); - renderer.Write(opening); - if (fencedCodeBlock.Info != null) - { - renderer.Write(fencedCodeBlock.Info); - } - if (!string.IsNullOrEmpty(fencedCodeBlock.Arguments)) - { - renderer.Write(" ").Write(fencedCodeBlock.Arguments); - } - - /* TODO do we need this causes a empty space and would render html attributes to markdown. - var attributes = obj.TryGetAttributes(); - if (attributes != null) - { - renderer.Write(" "); - renderer.Write(attributes); - } - */ - renderer.WriteLine(); - - renderer.WriteLeafRawLines(obj, true); - renderer.Write(opening); - } - else - { - renderer.WriteLeafRawLines(obj, false, true); - } - - renderer.FinishBlock(renderer.Options.EmptyLineAfterCodeBlock); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Normalize/HeadingRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Normalize/HeadingRenderer.cs deleted file mode 100644 index 21e961e..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Normalize/HeadingRenderer.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System.Globalization; -using Markdig.Syntax; - -namespace Markdig.Renderers.Normalize -{ - /// - /// An Normalize renderer for a . - /// - /// - public class HeadingRenderer : NormalizeObjectRenderer - { - private static readonly string[] HeadingTexts = { - "#", - "##", - "###", - "####", - "#####", - "######", - }; - - protected override void Write(NormalizeRenderer renderer, HeadingBlock obj) - { - var headingText = obj.Level > 0 && obj.Level <= 6 - ? HeadingTexts[obj.Level - 1] - : new string('#', obj.Level); - - renderer.Write(headingText).Write(' '); - renderer.WriteLeafInline(obj); - - renderer.FinishBlock(renderer.Options.EmptyLineAfterHeading); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Normalize/HtmlBlockRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Normalize/HtmlBlockRenderer.cs deleted file mode 100644 index 0cc59dc..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Normalize/HtmlBlockRenderer.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Syntax; - -namespace Markdig.Renderers.Normalize -{ - public class HtmlBlockRenderer : NormalizeObjectRenderer - { - protected override void Write(NormalizeRenderer renderer, HtmlBlock obj) - { - renderer.WriteLeafRawLines(obj, true, false); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/AutolinkInlineRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/AutolinkInlineRenderer.cs deleted file mode 100644 index 6dede81..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/AutolinkInlineRenderer.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax.Inlines; - -namespace Markdig.Renderers.Normalize.Inlines -{ - /// - /// A Normalize renderer for an . - /// - /// - public class AutolinkInlineRenderer : NormalizeObjectRenderer - { - protected override void Write(NormalizeRenderer renderer, AutolinkInline obj) - { - renderer.Write('<').Write(obj.Url).Write('>'); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/CodeInlineRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/CodeInlineRenderer.cs deleted file mode 100644 index e213fe9..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/CodeInlineRenderer.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax.Inlines; - -namespace Markdig.Renderers.Normalize.Inlines -{ - /// - /// A Normalize renderer for a . - /// - /// - public class CodeInlineRenderer : NormalizeObjectRenderer - { - protected override void Write(NormalizeRenderer renderer, CodeInline obj) - { - var delimiter = obj.Content.Contains(obj.Delimiter + "") ? new string(obj.Delimiter, 2) : obj.Delimiter + ""; - - renderer.Write(delimiter); - renderer.Write(obj.Content); - renderer.Write(delimiter); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/DelimiterInlineRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/DelimiterInlineRenderer.cs deleted file mode 100644 index 54709ea..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/DelimiterInlineRenderer.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax.Inlines; - -namespace Markdig.Renderers.Normalize.Inlines -{ - /// - /// A Normalize renderer for a . - /// - /// - public class DelimiterInlineRenderer : NormalizeObjectRenderer - { - protected override void Write(NormalizeRenderer renderer, DelimiterInline obj) - { - renderer.Write(obj.ToLiteral()); - renderer.WriteChildren(obj); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/EmphasisInlineRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/EmphasisInlineRenderer.cs deleted file mode 100644 index a258ffd..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/EmphasisInlineRenderer.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax.Inlines; - -namespace Markdig.Renderers.Normalize.Inlines -{ - /// - /// A Normalize renderer for an . - /// - /// - public class EmphasisInlineRenderer : NormalizeObjectRenderer - { - protected override void Write(NormalizeRenderer renderer, EmphasisInline obj) - { - var emphasisText = new string(obj.DelimiterChar, obj.DelimiterCount); - renderer.Write(emphasisText); - renderer.WriteChildren(obj); - renderer.Write(emphasisText); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/LineBreakInlineRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/LineBreakInlineRenderer.cs deleted file mode 100644 index e72da85..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/LineBreakInlineRenderer.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax.Inlines; - -namespace Markdig.Renderers.Normalize.Inlines -{ - /// - /// A Normalize renderer for a . - /// - /// - public class LineBreakInlineRenderer : NormalizeObjectRenderer - { - /// - /// Gets or sets a value indicating whether to render this softline break as a Normalize hardline break tag (<br />) - /// - public bool RenderAsHardlineBreak { get; set; } - - protected override void Write(NormalizeRenderer renderer, LineBreakInline obj) - { - if (obj.IsHard) - { - renderer.Write(obj.IsBackslash ? "\\" : " "); - } - renderer.WriteLine(); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/LinkInlineRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/LinkInlineRenderer.cs deleted file mode 100644 index 6b12ea8..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/LinkInlineRenderer.cs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax.Inlines; - -namespace Markdig.Renderers.Normalize.Inlines -{ - /// - /// A Normalize renderer for a . - /// - /// - public class LinkInlineRenderer : NormalizeObjectRenderer - { - protected override void Write(NormalizeRenderer renderer, LinkInline link) - { - if (link.IsImage) - { - renderer.Write('!'); - } - renderer.Write('['); - renderer.WriteChildren(link); - renderer.Write(']'); - - if (link.Label != null) - { - - var literal = link.FirstChild as LiteralInline; - if (literal != null && literal.Content.Match(link.Label) && literal.Content.Length == link.Label.Length) - { - // collapsed reference and shortcut links - if (!link.IsShortcut) - { - renderer.Write("[]"); - } - } - else - { - // full link - renderer.Write('[').Write(link.Label).Write(']'); - } - } - else - { - if (!string.IsNullOrEmpty(link.Url)) - { - renderer.Write('(').Write(link.Url); - - if (!string.IsNullOrEmpty(link.Title)) - { - renderer.Write(" \""); - renderer.Write(link.Title.Replace(@"""", @"\""")); - renderer.Write("\""); - } - - renderer.Write(')'); - } - } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/LiteralInlineRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/LiteralInlineRenderer.cs deleted file mode 100644 index 0e06ec7..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/LiteralInlineRenderer.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Helpers; -using Markdig.Syntax.Inlines; - -namespace Markdig.Renderers.Normalize.Inlines -{ - /// - /// A Normalize renderer for a . - /// - /// - public class LiteralInlineRenderer : NormalizeObjectRenderer - { - protected override void Write(NormalizeRenderer renderer, LiteralInline obj) - { - if (obj.IsFirstCharacterEscaped && obj.Content.Length > 0 && obj.Content[obj.Content.Start].IsAsciiPunctuation()) - { - renderer.Write('\\'); - } - renderer.Write(ref obj.Content); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/NormalizeHtmlEntityInlineRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/NormalizeHtmlEntityInlineRenderer.cs deleted file mode 100644 index 54ea1c5..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/NormalizeHtmlEntityInlineRenderer.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax.Inlines; - -namespace Markdig.Renderers.Normalize.Inlines -{ - /// - /// A Normalize renderer for a . - /// - public class NormalizeHtmlEntityInlineRenderer : NormalizeObjectRenderer - { - protected override void Write(NormalizeRenderer renderer, HtmlEntityInline obj) - { - renderer.Write(obj.Original); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/NormalizeHtmlInlineRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/NormalizeHtmlInlineRenderer.cs deleted file mode 100644 index 33bc853..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Normalize/Inlines/NormalizeHtmlInlineRenderer.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax.Inlines; - -namespace Markdig.Renderers.Normalize.Inlines -{ - /// - /// A Normalize renderer for a . - /// - public class NormalizeHtmlInlineRenderer : NormalizeObjectRenderer - { - protected override void Write(NormalizeRenderer renderer, HtmlInline obj) - { - renderer.Write(obj.Tag); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Normalize/LinkReferenceDefinitionGroupRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Normalize/LinkReferenceDefinitionGroupRenderer.cs deleted file mode 100644 index 8d1a7ca..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Normalize/LinkReferenceDefinitionGroupRenderer.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using Markdig.Syntax; - -namespace Markdig.Renderers.Normalize -{ - public class LinkReferenceDefinitionGroupRenderer : NormalizeObjectRenderer - { - protected override void Write(NormalizeRenderer renderer, LinkReferenceDefinitionGroup obj) - { - renderer.EnsureLine(); - renderer.WriteChildren(obj); - renderer.FinishBlock(false); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Normalize/LinkReferenceDefinitionRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Normalize/LinkReferenceDefinitionRenderer.cs deleted file mode 100644 index a5152d3..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Normalize/LinkReferenceDefinitionRenderer.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax; - -namespace Markdig.Renderers.Normalize -{ - public class LinkReferenceDefinitionRenderer : NormalizeObjectRenderer - { - protected override void Write(NormalizeRenderer renderer, LinkReferenceDefinition linkDef) - { - renderer.EnsureLine(); - renderer.Write('['); - renderer.Write(linkDef.Label); - renderer.Write("]: "); - - renderer.Write(linkDef.Url); - - if (linkDef.Title != null) - { - renderer.Write(" \""); - renderer.Write(linkDef.Title.Replace("\"", "\\\"")); - renderer.Write('"'); - } - renderer.FinishBlock(false); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Normalize/ListRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Normalize/ListRenderer.cs deleted file mode 100644 index f487d93..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Normalize/ListRenderer.cs +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System.Globalization; -using Markdig.Syntax; - -namespace Markdig.Renderers.Normalize -{ - /// - /// A Normalize renderer for a . - /// - /// - public class ListRenderer : NormalizeObjectRenderer - { - protected override void Write(NormalizeRenderer renderer, ListBlock listBlock) - { - renderer.EnsureLine(); - var compact = renderer.CompactParagraph; - renderer.CompactParagraph = !listBlock.IsLoose; - if (listBlock.IsOrdered) - { - int index = 0; - if (listBlock.OrderedStart != null) - { - switch (listBlock.BulletType) - { - case '1': - int.TryParse(listBlock.OrderedStart, out index); - break; - } - } - for (var i = 0; i < listBlock.Count; i++) - { - var item = listBlock[i]; - var listItem = (ListItemBlock) item; - renderer.EnsureLine(); - - renderer.Write(index.ToString(CultureInfo.InvariantCulture)); - renderer.Write(listBlock.OrderedDelimiter); - renderer.Write(' '); - renderer.PushIndent(new string(' ', IntLog10Fast(index) + 3)); - renderer.WriteChildren(listItem); - renderer.PopIndent(); - switch (listBlock.BulletType) - { - case '1': - index++; - break; - } - if (i + 1 < listBlock.Count && listBlock.IsLoose) - { - renderer.EnsureLine(); - renderer.WriteLine(); - } - } - } - else - { - for (var i = 0; i < listBlock.Count; i++) - { - var item = listBlock[i]; - var listItem = (ListItemBlock) item; - renderer.EnsureLine(); - renderer.Write(renderer.Options.ListItemCharacter ?? listBlock.BulletType); - renderer.Write(' '); - renderer.PushIndent(" "); - renderer.WriteChildren(listItem); - renderer.PopIndent(); - if (i + 1 < listBlock.Count && listBlock.IsLoose) - { - renderer.EnsureLine(); - renderer.WriteLine(); - } - } - } - renderer.CompactParagraph = compact; - - renderer.FinishBlock(true); - } - - - private static int IntLog10Fast(int input) => - (input < 10) ? 0 : - (input < 100) ? 1 : - (input < 1000) ? 2 : - (input < 10000) ? 3 : - (input < 100000) ? 4 : - (input < 1000000) ? 5 : - (input < 10000000) ? 6 : - (input < 100000000) ? 7 : - (input < 1000000000) ? 8 : 9; - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Normalize/NormalizeObjectRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Normalize/NormalizeObjectRenderer.cs deleted file mode 100644 index f24daef..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Normalize/NormalizeObjectRenderer.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax; - -namespace Markdig.Renderers.Normalize -{ - /// - /// A base class for Normalize rendering and Markdown objects. - /// - /// The type of the object. - /// - public abstract class NormalizeObjectRenderer : MarkdownObjectRenderer where TObject : MarkdownObject - { - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Normalize/NormalizeOptions.cs b/NppMarkdownPanel/Markdig/Renderers/Normalize/NormalizeOptions.cs deleted file mode 100644 index 7e82655..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Normalize/NormalizeOptions.cs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -namespace Markdig.Renderers.Normalize -{ - /// - /// Defines the options used by - /// - public class NormalizeOptions - { - /// - /// Initialize a new instance of - /// - public NormalizeOptions() - { - SpaceAfterQuoteBlock = true; - EmptyLineAfterCodeBlock = true; - EmptyLineAfterHeading = true; - EmptyLineAfterThematicBreak = true; - ExpandAutoLinks = true; - ListItemCharacter = null; - } - - /// - /// Adds a space after a QuoteBlock >. Default is true - /// - public bool SpaceAfterQuoteBlock { get; set; } - - /// - /// Adds an empty line after a code block (fenced and tabbed). Default is true - /// - public bool EmptyLineAfterCodeBlock { get; set; } - - /// - /// Adds an empty line after an heading. Default is true - /// - public bool EmptyLineAfterHeading { get; set; } - - /// - /// Adds an empty line after an thematic break. Default is true - /// - public bool EmptyLineAfterThematicBreak { get; set; } - - /// - /// The bullet character used for list items. Default is null leaving the original bullet character as-is. - /// - public char? ListItemCharacter { get; set; } - - /// - /// Expands AutoLinks to the normal inline representation. Default is true - /// - public bool ExpandAutoLinks { get; set; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Normalize/NormalizeRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Normalize/NormalizeRenderer.cs deleted file mode 100644 index dcb3643..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Normalize/NormalizeRenderer.cs +++ /dev/null @@ -1,161 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.IO; -using Markdig.Syntax; -using Markdig.Renderers.Normalize.Inlines; - -namespace Markdig.Renderers.Normalize -{ - /// - /// Default HTML renderer for a Markdown object. - /// - /// - public class NormalizeRenderer : TextRendererBase - { - /// - /// Initializes a new instance of the class. - /// - /// The writer. - /// The normalize options - public NormalizeRenderer(TextWriter writer, NormalizeOptions options = null) : base(writer) - { - Options = options ?? new NormalizeOptions(); - // Default block renderers - ObjectRenderers.Add(new CodeBlockRenderer()); - ObjectRenderers.Add(new ListRenderer()); - ObjectRenderers.Add(new HeadingRenderer()); - ObjectRenderers.Add(new HtmlBlockRenderer()); - ObjectRenderers.Add(new ParagraphRenderer()); - ObjectRenderers.Add(new QuoteBlockRenderer()); - ObjectRenderers.Add(new ThematicBreakRenderer()); - ObjectRenderers.Add(new LinkReferenceDefinitionGroupRenderer()); - ObjectRenderers.Add(new LinkReferenceDefinitionRenderer()); - - // Default inline renderers - ObjectRenderers.Add(new AutolinkInlineRenderer()); - ObjectRenderers.Add(new CodeInlineRenderer()); - ObjectRenderers.Add(new DelimiterInlineRenderer()); - ObjectRenderers.Add(new EmphasisInlineRenderer()); - ObjectRenderers.Add(new LineBreakInlineRenderer()); - ObjectRenderers.Add(new NormalizeHtmlInlineRenderer()); - ObjectRenderers.Add(new NormalizeHtmlEntityInlineRenderer()); - ObjectRenderers.Add(new LinkInlineRenderer()); - ObjectRenderers.Add(new LiteralInlineRenderer()); - } - - public NormalizeOptions Options { get; } - - public bool CompactParagraph { get; set; } - - public void FinishBlock(bool emptyLine) - { - if (!IsLastInContainer) - { - WriteLine(); - if (emptyLine) - { - WriteLine(); - } - } - } - - ///// - ///// Writes the attached on the specified . - ///// - ///// The object. - ///// - //public NormalizeRenderer WriteAttributes(MarkdownObject obj) - //{ - // if (obj == null) throw new ArgumentNullException(nameof(obj)); - // return WriteAttributes(obj.TryGetAttributes()); - //} - - ///// - ///// Writes the specified . - ///// - ///// The attributes to render. - ///// This instance - //public NormalizeRenderer WriteAttributes(HtmlAttributes attributes) - //{ - // if (attributes == null) - // { - // return this; - // } - - // if (attributes.Id != null) - // { - // Write(" id=\"").WriteEscape(attributes.Id).Write("\""); - // } - - // if (attributes.Classes != null && attributes.Classes.Count > 0) - // { - // Write(" class=\""); - // for (int i = 0; i < attributes.Classes.Count; i++) - // { - // var cssClass = attributes.Classes[i]; - // if (i > 0) - // { - // Write(" "); - // } - // WriteEscape(cssClass); - // } - // Write("\""); - // } - - // if (attributes.Properties != null && attributes.Properties.Count > 0) - // { - // foreach (var property in attributes.Properties) - // { - // Write(" ").Write(property.Key); - // if (property.Value != null) - // { - // Write("=").Write("\""); - // WriteEscape(property.Value); - // Write("\""); - // } - // } - // } - - // return this; - //} - - /// - /// Writes the lines of a - /// - /// The leaf block. - /// if set to true write end of lines. - /// This instance - public NormalizeRenderer WriteLeafRawLines(LeafBlock leafBlock, bool writeEndOfLines, bool indent = false) - { - if (leafBlock == null) throw new ArgumentNullException(nameof(leafBlock)); - if (leafBlock.Lines.Lines != null) - { - var lines = leafBlock.Lines; - var slices = lines.Lines; - for (int i = 0; i < lines.Count; i++) - { - if (!writeEndOfLines && i > 0) - { - WriteLine(); - } - - if (indent) - { - Write(" "); - } - - Write(ref slices[i].Slice); - - if (writeEndOfLines) - { - WriteLine(); - } - } - } - return this; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Normalize/ParagraphRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Normalize/ParagraphRenderer.cs deleted file mode 100644 index 0632f91..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Normalize/ParagraphRenderer.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax; - -namespace Markdig.Renderers.Normalize -{ - /// - /// A Normalize renderer for a . - /// - /// - public class ParagraphRenderer : NormalizeObjectRenderer - { - protected override void Write(NormalizeRenderer renderer, ParagraphBlock obj) - { - renderer.WriteLeafInline(obj); - renderer.FinishBlock(!renderer.CompactParagraph); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Normalize/QuoteBlockRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Normalize/QuoteBlockRenderer.cs deleted file mode 100644 index 422db3e..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Normalize/QuoteBlockRenderer.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax; - -namespace Markdig.Renderers.Normalize -{ - /// - /// A Normalize renderer for a . - /// - /// - public class QuoteBlockRenderer : NormalizeObjectRenderer - { - protected override void Write(NormalizeRenderer renderer, QuoteBlock obj) - { - var quoteIndent = renderer.Options.SpaceAfterQuoteBlock ? obj.QuoteChar + " " : obj.QuoteChar.ToString(); - renderer.PushIndent(quoteIndent); - renderer.WriteChildren(obj); - renderer.PopIndent(); - - renderer.FinishBlock(true); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/Normalize/ThematicBreakRenderer.cs b/NppMarkdownPanel/Markdig/Renderers/Normalize/ThematicBreakRenderer.cs deleted file mode 100644 index edcc41c..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/Normalize/ThematicBreakRenderer.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Syntax; - -namespace Markdig.Renderers.Normalize -{ - /// - /// A Normalize renderer for a . - /// - /// - public class ThematicBreakRenderer : NormalizeObjectRenderer - { - protected override void Write(NormalizeRenderer renderer, ThematicBreakBlock obj) - { - renderer.WriteLine(new string(obj.ThematicChar, obj.ThematicCharCount)); - - renderer.FinishBlock(renderer.Options.EmptyLineAfterThematicBreak); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/ObjectRendererCollection.cs b/NppMarkdownPanel/Markdig/Renderers/ObjectRendererCollection.cs deleted file mode 100644 index 24989d7..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/ObjectRendererCollection.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Helpers; - -namespace Markdig.Renderers -{ - /// - /// A collection of . - /// - /// - public class ObjectRendererCollection : OrderedList - { - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/RendererBase.cs b/NppMarkdownPanel/Markdig/Renderers/RendererBase.cs deleted file mode 100644 index 857fe8c..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/RendererBase.cs +++ /dev/null @@ -1,165 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System; -using System.Collections.Generic; -using Markdig.Syntax; -using Markdig.Syntax.Inlines; - -namespace Markdig.Renderers -{ - /// - /// Base class for a . - /// - /// - public abstract class RendererBase : IMarkdownRenderer - { - private readonly Dictionary renderersPerType; - private IMarkdownObjectRenderer previousRenderer; - private Type previousObjectType; - - /// - /// Initializes a new instance of the class. - /// - protected RendererBase() - { - ObjectRenderers = new ObjectRendererCollection(); - renderersPerType = new Dictionary(); - } - - public ObjectRendererCollection ObjectRenderers { get; } - - public abstract object Render(MarkdownObject markdownObject); - - public bool IsFirstInContainer { get; private set; } - - public bool IsLastInContainer { get; private set; } - - /// - /// Occurs when before writing an object. - /// - public event Action ObjectWriteBefore; - - /// - /// Occurs when after writing an object. - /// - public event Action ObjectWriteAfter; - - /// - /// Writes the children of the specified . - /// - /// The container block. - public void WriteChildren(ContainerBlock containerBlock) - { - if (containerBlock == null) - { - return; - } - - var children = containerBlock; - for (int i = 0; i < children.Count; i++) - { - var saveIsFirstInContainer = IsFirstInContainer; - var saveIsLastInContainer = IsLastInContainer; - - IsFirstInContainer = i == 0; - IsLastInContainer = i + 1 == children.Count; - Write(children[i]); - - IsFirstInContainer = saveIsFirstInContainer; - IsLastInContainer = saveIsLastInContainer; - } - } - - /// - /// Writes the children of the specified . - /// - /// The container inline. - public void WriteChildren(ContainerInline containerInline) - { - if (containerInline == null) - { - return; - } - - bool isFirst = true; - var inline = containerInline.FirstChild; - while (inline != null) - { - var saveIsFirstInContainer = IsFirstInContainer; - var saveIsLastInContainer = IsLastInContainer; - IsFirstInContainer = isFirst; - IsLastInContainer = inline.NextSibling == null; - - Write(inline); - inline = inline.NextSibling; - - IsFirstInContainer = saveIsFirstInContainer; - IsLastInContainer = saveIsLastInContainer; - - isFirst = false; - } - } - - /// - /// Writes the specified Markdown object. - /// - /// A MarkdownObject type - /// The Markdown object to write to this renderer. - public void Write(T obj) where T : MarkdownObject - { - if (obj == null) - { - return; - } - - var objectType = obj.GetType(); - - // Calls before writing an object - var writeBefore = ObjectWriteBefore; - writeBefore?.Invoke(this, obj); - - // Handle regular renderers - IMarkdownObjectRenderer renderer = previousObjectType == objectType ? previousRenderer : null; - if (renderer == null && !renderersPerType.TryGetValue(objectType, out renderer)) - { - for (int i = 0; i < ObjectRenderers.Count; i++) - { - var testRenderer = ObjectRenderers[i]; - if (testRenderer.Accept(this, obj)) - { - renderersPerType[objectType] = renderer = testRenderer; - break; - } - } - } - if (renderer != null) - { - renderer.Write(this, obj); - } - else - { - var containerBlock = obj as ContainerBlock; - if (containerBlock != null) - { - WriteChildren(containerBlock); - } - else - { - var containerInline = obj as ContainerInline; - if (containerInline != null) - { - WriteChildren(containerInline); - } - } - } - - previousObjectType = objectType; - previousRenderer = renderer; - - // Calls after writing an object - var writeAfter = ObjectWriteAfter; - writeAfter?.Invoke(this, obj); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Renderers/TextRendererBase.cs b/NppMarkdownPanel/Markdig/Renderers/TextRendererBase.cs deleted file mode 100644 index 8c24758..0000000 --- a/NppMarkdownPanel/Markdig/Renderers/TextRendererBase.cs +++ /dev/null @@ -1,264 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System; -using System.Collections.Generic; -using System.IO; -using System.Runtime.CompilerServices; -using Markdig.Helpers; -using Markdig.Syntax; -using Markdig.Syntax.Inlines; - -namespace Markdig.Renderers -{ - /// - /// A text based . - /// - /// - public abstract class TextRendererBase : RendererBase - { - private TextWriter writer; - - /// - /// Initializes a new instance of the class. - /// - /// The writer. - /// - protected TextRendererBase(TextWriter writer) - { - if (writer == null) throw new ArgumentNullException(nameof(writer)); - this.Writer = writer; - // By default we output a newline with '\n' only even on Windows platforms - Writer.NewLine = "\n"; - } - - /// - /// Gets or sets the writer. - /// - /// if the value is null - public TextWriter Writer - { - get { return writer; } - set - { - if (value == null) - { - throw new ArgumentNullException(nameof(value)); - } - - writer = value; - } - } - - /// - /// Renders the specified markdown object (returns the as a render object). - /// - /// The markdown object. - /// - public override object Render(MarkdownObject markdownObject) - { - Write(markdownObject); - return Writer; - } - } - - /// - /// Typed . - /// - /// Type of the renderer - /// - public abstract class TextRendererBase : TextRendererBase where T : TextRendererBase - { - private bool previousWasLine; - private char[] buffer; - private readonly List indents; - - /// - /// Initializes a new instance of the class. - /// - /// The writer. - protected TextRendererBase(TextWriter writer) : base(writer) - { - buffer = new char[1024]; - // We assume that we are starting as if we had previously a newline - previousWasLine = true; - indents = new List(); - } - - /// - /// Ensures a newline. - /// - /// This instance - public T EnsureLine() - { - if (!previousWasLine) - { - WriteLine(); - } - return (T)this; - } - - public void PushIndent(string indent) - { - if (indent == null) throw new ArgumentNullException(nameof(indent)); - indents.Add(indent); - } - - public void PopIndent() - { - // TODO: Check - indents.RemoveAt(indents.Count - 1); - } - - private void WriteIndent() - { - if (previousWasLine) - { - previousWasLine = false; - for (int i = 0; i < indents.Count; i++) - { - Writer.Write(indents[i]); - } - } - } - - - /// - /// Writes the specified content. - /// - /// The content. - /// This instance - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public T Write(string content) - { - WriteIndent(); - previousWasLine = false; - Writer.Write(content); - return (T) this; - } - - /// - /// Writes the specified slice. - /// - /// The slice. - /// This instance - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public T Write(ref StringSlice slice) - { - if (slice.Start > slice.End) - { - return (T) this; - } - return Write(slice.Text, slice.Start, slice.Length); - } - - /// - /// Writes the specified slice. - /// - /// The slice. - /// This instance - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public T Write(StringSlice slice) - { - return Write(ref slice); - } - - /// - /// Writes the specified character. - /// - /// The content. - /// This instance - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public T Write(char content) - { - WriteIndent(); - previousWasLine = content == '\n'; - Writer.Write(content); - return (T) this; - } - - /// - /// Writes the specified content. - /// - /// The content. - /// The offset. - /// The length. - /// This instance - public T Write(string content, int offset, int length) - { - if (content == null) - { - return (T) this; - } - - WriteIndent(); - previousWasLine = false; - if (offset == 0 && content.Length == length) - { - Writer.Write(content); - } - else - { - if (length > buffer.Length) - { - buffer = content.ToCharArray(); - Writer.Write(buffer, offset, length); - } - else - { - content.CopyTo(offset, buffer, 0, length); - Writer.Write(buffer, 0, length); - } - } - return (T) this; - } - - /// - /// Writes a newline. - /// - /// This instance - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public T WriteLine() - { - WriteIndent(); - Writer.WriteLine(); - previousWasLine = true; - return (T) this; - } - - /// - /// Writes a content followed by a newline. - /// - /// The content. - /// This instance - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public T WriteLine(string content) - { - WriteIndent(); - previousWasLine = true; - Writer.WriteLine(content); - return (T) this; - } - - /// - /// Writes the inlines of a leaf inline. - /// - /// The leaf block. - /// This instance - [MethodImpl(MethodImplOptionPortable.AggressiveInlining)] - public T WriteLeafInline(LeafBlock leafBlock) - { - if (leafBlock == null) throw new ArgumentNullException(nameof(leafBlock)); - var inline = (Inline) leafBlock.Inline; - if (inline != null) - { - while (inline != null) - { - Write(inline); - inline = inline.NextSibling; - } - } - return (T) this; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/BlankLineBlock.cs b/NppMarkdownPanel/Markdig/Syntax/BlankLineBlock.cs deleted file mode 100644 index 06fda43..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/BlankLineBlock.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -namespace Markdig.Syntax -{ - /// - /// A blank line, used internally by some parsers to store blank lines in a container. They are removed before the end of the document. - /// - /// - public sealed class BlankLineBlock : Block - { - /// - /// Initializes a new instance of the class. - /// - public BlankLineBlock() : base(null) - { - // A blankline is never opened - IsOpen = false; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/Block.cs b/NppMarkdownPanel/Markdig/Syntax/Block.cs deleted file mode 100644 index a0c0570..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/Block.cs +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System; -using Markdig.Parsers; - -namespace Markdig.Syntax -{ - /// - /// Base class for a block structure. Either a or a . - /// - /// - public abstract class Block : MarkdownObject, IBlock - { - /// - /// Initializes a new instance of the class. - /// - /// The parser used to create this block. - protected Block(BlockParser parser) - { - Parser = parser; - IsOpen = true; - IsBreakable = true; - } - - /// - /// Gets the parent of this container. May be null. - /// - public ContainerBlock Parent { get; internal set; } - - /// - /// Gets the parser associated to this instance. - /// - public BlockParser Parser { get; } - - /// - /// Gets or sets a value indicating whether this instance is still open. - /// - public bool IsOpen { get; set; } - - /// - /// Gets or sets a value indicating whether this block is breakable. Default is true. - /// - public bool IsBreakable { get; set; } - - /// - /// Gets or sets a value indicating whether this block must be removed from its container after inlines have been processed. - /// - public bool RemoveAfterProcessInlines { get; set; } - - /// - /// Occurs when the process of inlines begin. - /// - public event ProcessInlineDelegate ProcessInlinesBegin; - - /// - /// Occurs when the process of inlines ends for this instance. - /// - public event ProcessInlineDelegate ProcessInlinesEnd; - - /// - /// Called when the process of inlines begin. - /// - /// The inline parser state. - internal void OnProcessInlinesBegin(InlineProcessor state) - { - ProcessInlinesBegin?.Invoke(state, null); - } - - /// - /// Called when the process of inlines ends. - /// - /// The inline parser state. - internal void OnProcessInlinesEnd(InlineProcessor state) - { - ProcessInlinesEnd?.Invoke(state, null); - } - - public void UpdateSpanEnd(int spanEnd) - { - // Update parent spans - var parent = this; - while (parent != null) - { - if (spanEnd > parent.Span.End) - { - parent.Span.End = spanEnd; - } - parent = parent.Parent; - } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/BlockExtensions.cs b/NppMarkdownPanel/Markdig/Syntax/BlockExtensions.cs deleted file mode 100644 index 0c80017..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/BlockExtensions.cs +++ /dev/null @@ -1,138 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -namespace Markdig.Syntax -{ - /// - /// Extensions for - /// - public static class BlockExtensions - { - // TODO: Add test for this code - - public static Block FindBlockAtPosition(this Block rootBlock, int position) - { - var contains = rootBlock.CompareToPosition(position) == 0; - var blocks = rootBlock as ContainerBlock; - if (blocks == null || blocks.Count == 0 || !contains) - { - return contains ? rootBlock : null; - } - - var lowerIndex = 0; - var upperIndex = blocks.Count - 1; - - // binary search on lines - Block block = null; - while (lowerIndex <= upperIndex) - { - int midIndex = (upperIndex - lowerIndex) / 2 + lowerIndex; - block = blocks[midIndex]; - int comparison = block.CompareToPosition(position); - if (comparison == 0) - { - break; - } - - block = null; - if (comparison < 0) - lowerIndex = midIndex + 1; - else - upperIndex = midIndex - 1; - } - - if (block == null) - { - return rootBlock; - } - - // Recursively go deep into the block - return FindBlockAtPosition(block, position); - } - - - public static int FindClosestLine(this MarkdownDocument root, int line) - { - var closestBlock = root.FindClosestBlock(line); - return closestBlock?.Line ?? 0; - } - - public static Block FindClosestBlock(this Block rootBlock, int line) - { - var blocks = rootBlock as ContainerBlock; - if (blocks == null || blocks.Count == 0) - { - return rootBlock.Line == line ? rootBlock : null; - } - - var lowerIndex = 0; - var upperIndex = blocks.Count - 1; - - // binary search on lines - while (lowerIndex <= upperIndex) - { - int midIndex = (upperIndex - lowerIndex) / 2 + lowerIndex; - var block = blocks[midIndex]; - int comparison = block.Line.CompareTo(line); - if (comparison == 0) - { - return block; - } - if (comparison < 0) - lowerIndex = midIndex + 1; - else - upperIndex = midIndex - 1; - } - - // If we are between two lines, try to find the best spot - if (lowerIndex > 0 && lowerIndex < blocks.Count) - { - var prevBlock = blocks[lowerIndex - 1].FindClosestBlock(line) ?? blocks[lowerIndex - 1]; - var nextBlock = blocks[lowerIndex].FindClosestBlock(line) ?? blocks[lowerIndex]; - - if (prevBlock.Line == line) - { - return prevBlock; - } - - if (nextBlock.Line == line) - { - return nextBlock; - } - - // we calculate the position of the current line relative to the line found and previous line - var prevLine = prevBlock.Line; - var nextLine = nextBlock.Line; - - var middle = (line - prevLine) * 1.0 / (nextLine - prevLine); - // If relative position < 0.5, we select the previous line, otherwise we select the line found - return middle < 0.5 ? prevBlock : nextBlock; - } - - if (lowerIndex == 0) - { - var prevBlock = blocks[lowerIndex].FindClosestBlock(line) ?? blocks[lowerIndex]; - return prevBlock; - } - - if (lowerIndex == blocks.Count) - { - var prevBlock = blocks[lowerIndex - 1].FindClosestBlock(line) ?? blocks[lowerIndex - 1]; - return prevBlock; - } - - return null; - } - - - public static bool ContainsPosition(this Block block, int position) - { - return CompareToPosition(block, position) == 0; - } - - public static int CompareToPosition(this Block block, int position) - { - return position < block.Span.Start ? 1 : position > block.Span.End + 1 ? -1 : 0; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/CharIteratorHelper.cs b/NppMarkdownPanel/Markdig/Syntax/CharIteratorHelper.cs deleted file mode 100644 index cb54178..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/CharIteratorHelper.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Markdig.Helpers; - -namespace Markdig.Syntax -{ - /// - /// Helpers for the class. - /// - public static class CharIteratorHelper - { - public static bool TrimStartAndCountNewLines(ref T iterator, out int countNewLines) where T : ICharIterator - { - countNewLines = 0; - var c = iterator.CurrentChar; - bool hasWhitespaces = false; - while (c.IsWhitespace()) - { - if (c == '\n') - { - countNewLines++; - } - hasWhitespaces = true; - c = iterator.NextChar(); - } - return hasWhitespaces; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/CodeBlock.cs b/NppMarkdownPanel/Markdig/Syntax/CodeBlock.cs deleted file mode 100644 index 450d5f1..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/CodeBlock.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Parsers; - -namespace Markdig.Syntax -{ - /// - /// Repressents an indented code block. - /// - /// - /// Related to CommonMark spec: 4.4 Indented code blocks - /// - public class CodeBlock : LeafBlock - { - /// - /// Initializes a new instance of the class. - /// - /// The parser. - public CodeBlock(BlockParser parser) : base(parser) - { - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/ContainerBlock.cs b/NppMarkdownPanel/Markdig/Syntax/ContainerBlock.cs deleted file mode 100644 index 74c5f00..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/ContainerBlock.cs +++ /dev/null @@ -1,279 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics; -using System.Runtime.InteropServices; -using Markdig.Helpers; -using Markdig.Parsers; - -namespace Markdig.Syntax -{ - /// - /// A base class for container blocks. - /// - /// - [DebuggerDisplay("{GetType().Name} Count = {Count}")] - public abstract class ContainerBlock : Block, IList - { - private Block[] children; - - /// - /// Initializes a new instance of the class. - /// - /// The parser used to create this block. - protected ContainerBlock(BlockParser parser) : base(parser) - { - children = ArrayHelper.Empty; - } - - /// - /// Gets the last child. - /// - public Block LastChild => Count > 0 ? children[Count - 1] : null; - - /// - /// Specialize enumerator. - /// - /// - public Enumerator GetEnumerator() - { - return new Enumerator(this); - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - - public void Add(Block item) - { - if (item == null) throw new ArgumentNullException(nameof(item)); - if (item.Parent != null) - { - throw new ArgumentException("Cannot add this block as it as already attached to another container (block.Parent != null)"); - } - - if (Count == children.Length) - { - EnsureCapacity(Count + 1); - } - children[Count++] = item; - item.Parent = this; - - UpdateSpanEnd(item.Span.End); - } - - private void EnsureCapacity(int min) - { - if (children.Length < min) - { - int num = (children.Length == 0) ? 4 : (children.Length * 2); - if (num < min) - { - num = min; - } - - var destinationArray = new Block[num]; - if (Count > 0) - { - Array.Copy(children, 0, destinationArray, 0, Count); - } - children = destinationArray; - } - } - - public void Clear() - { - for (int i = 0; i < Count; i++) - { - children[i].Parent = null; - children[i] = null; - } - } - - public bool Contains(Block item) - { - if (item == null) throw new ArgumentNullException(nameof(item)); - for (int i = 0; i < Count; i++) - { - if (children[i] == item) - { - return true; - } - } - return false; - } - - public void CopyTo(Block[] array, int arrayIndex) - { - Array.Copy(children, 0, array, arrayIndex, Count); - } - - public bool Remove(Block item) - { - if (item == null) throw new ArgumentNullException(nameof(item)); - for (int i = Count - 1; i >= 0; i--) - { - if (children[i] == item) - { - RemoveAt(i); - return true; - } - } - return false; - } - - public int Count { get; private set; } - - public bool IsReadOnly => false; - - public int IndexOf(Block item) - { - if (item == null) throw new ArgumentNullException(nameof(item)); - for (int i = 0; i < Count; i++) - { - if (children[i] == item) - { - return i; - } - } - return -1; - } - - public void Insert(int index, Block item) - { - if (item == null) throw new ArgumentNullException(nameof(item)); - if (item.Parent != null) - { - throw new ArgumentException("Cannot add this block as it as already attached to another container (block.Parent != null)"); - } - if (Count == children.Length) - { - EnsureCapacity(Count + 1); - } - if (index < Count) - { - Array.Copy(children, index, children, index + 1, Count - index); - } - children[index] = item; - Count++; - item.Parent = this; - } - - public void RemoveAt(int index) - { - if (index < 0 || index >= Count) throw new ArgumentOutOfRangeException(nameof(index)); - Count--; - // previous children - var item = children[index]; - item.Parent = null; - if (index < Count) - { - Array.Copy(children, index + 1, children, index, Count - index); - } - children[Count] = null; - } - - public Block this[int index] - { - get - { - if (index < 0 || index >= Count) throw new ArgumentOutOfRangeException(nameof(index)); - return children[index]; - } - set - { - if (index < 0 || index >= Count) throw new ArgumentOutOfRangeException(nameof(index)); - children[index] = value; - } - } - - public void Sort(IComparer comparer) - { - if (comparer == null) throw new ArgumentNullException(nameof(comparer)); - Array.Sort(children, 0, Count, comparer); - } - - public void Sort(Comparison comparison) - { - if (comparison == null) throw new ArgumentNullException(nameof(comparison)); - Array.Sort(children, 0, Count, new BlockComparer(comparison)); - } - - #region Nested type: Enumerator - - [StructLayout(LayoutKind.Sequential)] - public struct Enumerator : IEnumerator - { - private readonly ContainerBlock block; - private int index; - private Block current; - - internal Enumerator(ContainerBlock block) - { - this.block = block; - index = 0; - current = null; - } - - public Block Current => current; - - object IEnumerator.Current => Current; - - - public void Dispose() - { - } - - public bool MoveNext() - { - if (index < block.Count) - { - current = block[index]; - index++; - return true; - } - return MoveNextRare(); - } - - private bool MoveNextRare() - { - index = block.Count + 1; - current = null; - return false; - } - - void IEnumerator.Reset() - { - index = 0; - current = null; - } - } - - #endregion - - private sealed class BlockComparer : IComparer - { - private readonly Comparison comparison; - - public BlockComparer(Comparison comparison) - { - this.comparison = comparison; - } - - public int Compare(Block x, Block y) - { - return comparison(x, y); - } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/FencedCodeBlock.cs b/NppMarkdownPanel/Markdig/Syntax/FencedCodeBlock.cs deleted file mode 100644 index ba90c42..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/FencedCodeBlock.cs +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Parsers; - -namespace Markdig.Syntax -{ - /// - /// Repressents a fenced code block. - /// - /// - /// Related to CommonMark spec: 4.5 Fenced code blocks - /// - public class FencedCodeBlock : CodeBlock, IFencedBlock - { - /// - /// Initializes a new instance of the class. - /// - /// The parser. - public FencedCodeBlock(BlockParser parser) : base(parser) - { - // Fenced code blocks are not breakable, unless - // we reach: - // - a fenced line terminator - // - the closing of the container that is holding this fenced block - IsBreakable = false; - } - - /// - /// Gets or sets the language parsed after the first line of - /// the fenced code block. May be null. - /// - public string Info { get; set; } - - /// - /// Gets or sets the arguments after the . - /// May be null. - /// - public string Arguments { get; set; } - - /// - /// Gets or sets the fenced character count used to open this fenced code block. - /// - public int FencedCharCount { get; set; } - - /// - /// Gets or sets the fenced character used to open and close this fenced code block. - /// - public char FencedChar { get; set; } - - /// - /// Gets or sets the indent count when the fenced code block was indented - /// and we need to remove up to indent count chars spaces from the begining of a line. - /// - internal int IndentCount { get; set; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/HeadingBlock.cs b/NppMarkdownPanel/Markdig/Syntax/HeadingBlock.cs deleted file mode 100644 index c97c472..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/HeadingBlock.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System.Diagnostics; -using Markdig.Parsers; - -namespace Markdig.Syntax -{ - /// - /// Repressents a heading. - /// - [DebuggerDisplay("{GetType().Name} Line: {Line}, {Lines} Level: {Level}")] - public class HeadingBlock : LeafBlock - { - /// - /// Initializes a new instance of the class. - /// - /// The parser. - public HeadingBlock(BlockParser parser) : base(parser) - { - ProcessInlines = true; - } - - /// - /// Gets or sets the header character used to defines this heading (usually #) - /// - public char HeaderChar { get; set; } - - /// - /// Gets or sets the level of heading (starting at 1 for the lowest level). - /// - public int Level { get; set; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/HtmlBlock.cs b/NppMarkdownPanel/Markdig/Syntax/HtmlBlock.cs deleted file mode 100644 index f6a68ab..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/HtmlBlock.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Parsers; - -namespace Markdig.Syntax -{ - /// - /// Represents a group of lines that is treated as raw HTML (and will not be escaped in HTML output). - /// - /// - public class HtmlBlock : LeafBlock - { - /// - /// Initializes a new instance of the class. - /// - /// The parser. - public HtmlBlock(BlockParser parser) : base(parser) - { - } - - /// - /// Gets or sets the type of block. - /// - public HtmlBlockType Type { get; set; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/HtmlBlockType.cs b/NppMarkdownPanel/Markdig/Syntax/HtmlBlockType.cs deleted file mode 100644 index 3fb9abd..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/HtmlBlockType.cs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -namespace Markdig.Syntax -{ - /// - /// Defines the type of - /// - public enum HtmlBlockType - { - /// - /// A SGML document type starting by <!LETTER. - /// - DocumentType, - - /// - /// A raw CDATA sequence. - /// - CData, - - /// - /// A HTML comment. - /// - Comment, - - /// - /// A SGM processing instruction tag <? - /// - ProcessingInstruction, - - /// - /// A script pre or style tag. - /// - ScriptPreOrStyle, - - /// - /// An HTML interrupting block - /// - InterruptingBlock, - - /// - /// An HTML non-interrupting block - /// - NonInterruptingBlock - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/IBlock.cs b/NppMarkdownPanel/Markdig/Syntax/IBlock.cs deleted file mode 100644 index bbb86b2..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/IBlock.cs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System; -using Markdig.Parsers; - -namespace Markdig.Syntax -{ - /// - /// Base interface for a block structure. Either a or a . - /// - /// - public interface IBlock : IMarkdownObject - { - /// - /// Gets or sets the text column this instance was declared (zero-based). - /// - int Column { get; set; } - - /// - /// Gets or sets the text line this instance was declared (zero-based). - /// - int Line { get; set; } - - /// - /// Gets the parent of this container. May be null. - /// - ContainerBlock Parent { get; } - - /// - /// Gets the parser associated to this instance. - /// - BlockParser Parser { get; } - - /// - /// Gets or sets a value indicating whether this instance is still open. - /// - bool IsOpen { get; set; } - - /// - /// Gets or sets a value indicating whether this block is breakable. Default is true. - /// - bool IsBreakable { get; set; } - - /// - /// Gets or sets a value indicating whether this block must be removed from its container after inlines have been processed. - /// - bool RemoveAfterProcessInlines { get; set; } - - /// - /// Occurs when the process of inlines begin. - /// - event ProcessInlineDelegate ProcessInlinesBegin; - - /// - /// Occurs when the process of inlines ends for this instance. - /// - event ProcessInlineDelegate ProcessInlinesEnd; - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/IFencedBlock.cs b/NppMarkdownPanel/Markdig/Syntax/IFencedBlock.cs deleted file mode 100644 index 60cb20f..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/IFencedBlock.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace Markdig.Syntax -{ - /// - /// A common interface for fenced block (e.g: or ) - /// - public interface IFencedBlock : IBlock - { - /// - /// Gets or sets the language parsed after the first line of - /// the fenced code block. May be null. - /// - string Info { get; set; } - - /// - /// Gets or sets the arguments after the . - /// May be null. - /// - string Arguments { get; set; } - - /// - /// Gets or sets the fenced character count used to open this fenced code block. - /// - int FencedCharCount { get; set; } - - /// - /// Gets or sets the fenced character used to open and close this fenced code block. - /// - char FencedChar { get; set; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/IMarkdownObject.cs b/NppMarkdownPanel/Markdig/Syntax/IMarkdownObject.cs deleted file mode 100644 index b54ffbd..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/IMarkdownObject.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -namespace Markdig.Syntax -{ - /// - /// Base interface for a the Markdown syntax tree - /// - public interface IMarkdownObject - { - /// - /// Stores a key/value pair for this instance. - /// - /// The key. - /// The value. - /// if key is null - void SetData(object key, object value); - - /// - /// Determines whether this instance contains the specified key data. - /// - /// The key. - /// true if a data with the key is stored - /// if key is null - bool ContainsData(object key); - - /// - /// Gets the associated data for the specified key. - /// - /// The key. - /// The associated data or null if none - /// if key is null - object GetData(object key); - - /// - /// Removes the associated data for the specified key. - /// - /// The key. - /// true if the data was removed; false otherwise - /// - bool RemoveData(object key); - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/Inlines/AutolinkInline.cs b/NppMarkdownPanel/Markdig/Syntax/Inlines/AutolinkInline.cs deleted file mode 100644 index c617467..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/Inlines/AutolinkInline.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.Diagnostics; - -namespace Markdig.Syntax.Inlines -{ - /// - /// An autolink (Section 6.7 CommonMark specs) - /// - /// - [DebuggerDisplay("<{Url}>")] - public class AutolinkInline : LeafInline - { - /// - /// Gets or sets a value indicating whether this instance is an email link. - /// - public bool IsEmail { get; set; } - - /// - /// Gets or sets the URL of this link. - /// - public string Url { get; set; } - - public override string ToString() - { - return Url; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/Inlines/CodeInline.cs b/NppMarkdownPanel/Markdig/Syntax/Inlines/CodeInline.cs deleted file mode 100644 index 1dbfe8b..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/Inlines/CodeInline.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.Diagnostics; - -namespace Markdig.Syntax.Inlines -{ - /// - /// Represents a code span (Section 6.3 CommonMark specs) - /// - /// - [DebuggerDisplay("`{Content}`")] - public class CodeInline : LeafInline - { - /// - /// Gets or sets the delimiter character used by this code inline. - /// - public char Delimiter { get; set; } - - /// - /// Gets or sets the content of the span. - /// - public string Content { get; set; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/Inlines/ContainerInline.cs b/NppMarkdownPanel/Markdig/Syntax/Inlines/ContainerInline.cs deleted file mode 100644 index 2f5099b..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/Inlines/ContainerInline.cs +++ /dev/null @@ -1,275 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System; -using System.Collections; -using System.Collections.Generic; -using System.IO; - -namespace Markdig.Syntax.Inlines -{ - /// - /// A base class for container for . - /// - /// - public class ContainerInline : Inline, IEnumerable - { - /// - /// Gets the first child. - /// - public Inline FirstChild { get; private set; } - - /// - /// Gets the last child. - /// - public Inline LastChild { get; private set; } - - /// - /// Clears this instance by removing all its children. - /// - public void Clear() - { - var child = LastChild; - while (child != null) - { - child.Parent = null; - child = child.PreviousSibling; - } - FirstChild = null; - LastChild = null; - } - - /// - /// Appends a child to this container. - /// - /// The child to append to this container.. - /// This instance - /// If child is null - /// Inline has already a parent - public virtual ContainerInline AppendChild(Inline child) - { - if (child == null) throw new ArgumentNullException(nameof(child)); - if (child.Parent != null) - { - throw new ArgumentException("Inline has already a parent", nameof(child)); - } - - if (FirstChild == null) - { - FirstChild = child; - LastChild = child; - child.Parent = this; - } - else - { - LastChild.InsertAfter(child); - } - return this; - } - - /// - /// Checks if this instance contains the specified child. - /// - /// The child to find. - /// true if this instance contains the specified child; false otherwise - public bool ContainsChild(Inline childToFind) - { - var child = FirstChild; - while (child != null) - { - var next = child.NextSibling; - if (child == childToFind) - { - return true; - } - child = next; - } - return false; - } - - /// - /// Finds all the descendants. - /// - /// Type of the descendants to find - /// An enumeration of T - public IEnumerable FindDescendants() where T : Inline - { - // Fast-path an empty container to avoid allocating a Stack - if (LastChild == null) yield break; - - Stack stack = new Stack(); - - var child = LastChild; - while (child != null) - { - stack.Push(child); - child = child.PreviousSibling; - } - - while (stack.Count > 0) - { - child = stack.Pop(); - - if (child is T childT) - { - yield return childT; - } - - if (child is ContainerInline containerInline) - { - child = containerInline.LastChild; - while (child != null) - { - stack.Push(child); - child = child.PreviousSibling; - } - } - } - } - - /// - /// Moves all the children of this container after the specified inline. - /// - /// The parent. - public void MoveChildrenAfter(Inline parent) - { - if (parent == null) throw new ArgumentNullException(nameof(parent)); - var child = FirstChild; - var nextSibliing = parent; - while (child != null) - { - var next = child.NextSibling; - // TODO: optimize this - child.Remove(); - nextSibliing.InsertAfter(child); - nextSibliing = child; - child = next; - } - } - - /// - /// Embraces this instance by the specified container. - /// - /// The container to use to embrace this instance. - /// If the container is null - public void EmbraceChildrenBy(ContainerInline container) - { - if (container == null) throw new ArgumentNullException(nameof(container)); - var child = FirstChild; - while (child != null) - { - var next = child.NextSibling; - // TODO: optimize this - child.Remove(); - container.AppendChild(child); - child = next; - } - AppendChild(container); - } - - protected override void OnChildInsert(Inline child) - { - // A child is inserted before the FirstChild - if (child.PreviousSibling == null && child.NextSibling == FirstChild) - { - FirstChild = child; - } - else if (child.NextSibling == null && child.PreviousSibling == LastChild) - { - LastChild = child; - } - - if (LastChild == null) - { - LastChild = FirstChild; - } - else if (FirstChild == null) - { - FirstChild = LastChild; - } - } - - protected override void OnChildRemove(Inline child) - { - if (child == FirstChild) - { - if (FirstChild == LastChild) - { - FirstChild = null; - LastChild = null; - } - else - { - FirstChild = child.NextSibling ?? LastChild; - } - } - else if (child == LastChild) - { - LastChild = child.PreviousSibling ?? FirstChild; - } - } - - protected override void DumpChildTo(TextWriter writer, int level) - { - if (FirstChild != null) - { - level++; - FirstChild.DumpTo(writer, level); - } - } - - public struct Enumerator : IEnumerator - { - private readonly ContainerInline container; - private Inline currentChild; - private Inline nextChild; - - public Enumerator(ContainerInline container) : this() - { - if (container == null) throw new ArgumentNullException(nameof(container)); - this.container = container; - currentChild = nextChild = container.FirstChild; - } - - public Inline Current => currentChild; - - object IEnumerator.Current => Current; - - public void Dispose() - { - } - - public bool MoveNext() - { - currentChild = nextChild; - if (currentChild != null) - { - nextChild = currentChild.NextSibling; - return true; - } - nextChild = null; - return false; - } - - public void Reset() - { - currentChild = nextChild = container.FirstChild; - } - } - - public Enumerator GetEnumerator() - { - return new Enumerator(this); - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/Inlines/DelimiterInline.cs b/NppMarkdownPanel/Markdig/Syntax/Inlines/DelimiterInline.cs deleted file mode 100644 index 1e29241..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/Inlines/DelimiterInline.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System; -using System.Diagnostics; -using Markdig.Helpers; -using Markdig.Parsers; - -namespace Markdig.Syntax.Inlines -{ - /// - /// Internal delimiter used by some parsers (e.g emphasis, tables). - /// - /// - [DebuggerDisplay("{ToLiteral()} {Type}")] - public abstract class DelimiterInline : ContainerInline - { - protected DelimiterInline(InlineParser parser) - { - if (parser == null) throw new ArgumentNullException(nameof(parser)); - Parser = parser; - IsActive = true; - } - - /// - /// Gets the parser. - /// - public InlineParser Parser { get; } - - /// - /// Gets or sets the type of this delimiter. - /// - public DelimiterType Type { get; set; } - - /// - /// Gets or sets a value indicating whether this instance is active. - /// - public bool IsActive { get; set; } - - /// - /// Converts this delimiter to a literal. - /// - /// The string representation of this delimiter - public abstract string ToLiteral(); - - public void ReplaceByLiteral() - { - var literalInline = new LiteralInline() - { - Content = new StringSlice(ToLiteral()), - Span = Span, - Line = Line, - Column = Column, - IsClosed = true - }; - ReplaceBy(literalInline); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/Inlines/DelimiterType.cs b/NppMarkdownPanel/Markdig/Syntax/Inlines/DelimiterType.cs deleted file mode 100644 index f3bd1c9..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/Inlines/DelimiterType.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System; - -namespace Markdig.Syntax.Inlines -{ - /// - /// Gets the type of a . - /// - [Flags] - public enum DelimiterType - { - /// - /// An undefined open or close delimiter. - /// - Undefined, - - /// - /// An open delimiter. - /// - Open, - - /// - /// A close delimiter. - /// - Close, - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/Inlines/EmphasisDelimiterInline.cs b/NppMarkdownPanel/Markdig/Syntax/Inlines/EmphasisDelimiterInline.cs deleted file mode 100644 index 2427d77..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/Inlines/EmphasisDelimiterInline.cs +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using Markdig.Helpers; -using Markdig.Parsers; -using Markdig.Parsers.Inlines; - -namespace Markdig.Syntax.Inlines -{ - /// - /// A delimiter used for parsing emphasis. - /// - /// - public class EmphasisDelimiterInline : DelimiterInline - { - /// - /// Initializes a new instance of the class. - /// - /// The parser. - /// The descriptor. - /// - public EmphasisDelimiterInline(InlineParser parser, EmphasisDescriptor descriptor) : base(parser) - { - Descriptor = descriptor ?? throw new ArgumentNullException(nameof(descriptor)); - DelimiterChar = descriptor.Character; - } - - /// - /// Gets the descriptor for this emphasis. - /// - public EmphasisDescriptor Descriptor { get; } - - /// - /// The delimiter character found. - /// - public char DelimiterChar { get; } - - /// - /// The number of delimiter characters found for this delimiter. - /// - public int DelimiterCount { get; set; } - - public override string ToLiteral() - { - return DelimiterCount > 0 ? new string(DelimiterChar, DelimiterCount) : string.Empty; - } - - public LiteralInline AsLiteralInline() - { - return new LiteralInline() - { - Content = new StringSlice(ToLiteral()), - IsClosed = true, - Span = Span, - Line = Line, - Column = Column - }; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/Inlines/EmphasisInline.cs b/NppMarkdownPanel/Markdig/Syntax/Inlines/EmphasisInline.cs deleted file mode 100644 index 1fa6c1f..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/Inlines/EmphasisInline.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Diagnostics; - -namespace Markdig.Syntax.Inlines -{ - /// - /// An emphasis and strong emphasis (Section 6.4 CommonMark specs). - /// - /// - [DebuggerDisplay("{DelimiterChar} Count: {DelimiterCount}")] - public class EmphasisInline : ContainerInline - { - /// - /// Gets or sets the delimiter character of this emphasis. - /// - public char DelimiterChar { get; set; } - - /// - /// Gets or sets a value indicating whether this is strong. - /// Marked obsolete as EmphasisInline can now be represented by more than two delimiter characters - /// - [Obsolete("Use `DelimiterCount == 2` instead", error: false)] - public bool IsDouble - { - get => DelimiterCount == 2; - set => DelimiterCount = value ? 2 : 1; - } - - /// - /// Gets or sets the number of delimiter characters for this emphasis. - /// - public int DelimiterCount { get; set; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/Inlines/HtmlEntityInline.cs b/NppMarkdownPanel/Markdig/Syntax/Inlines/HtmlEntityInline.cs deleted file mode 100644 index 59e5935..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/Inlines/HtmlEntityInline.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System.Diagnostics; -using Markdig.Helpers; - -namespace Markdig.Syntax.Inlines -{ - /// - /// An entity HTML. - /// - /// - [DebuggerDisplay("{Original} -> {Transcoded}")] - public class HtmlEntityInline : LeafInline - { - /// - /// Gets or sets the original HTML entity name - /// - public StringSlice Original { get; set; } - - /// - /// Gets or sets the transcoded literal that will be used for output - /// - public StringSlice Transcoded { get; set; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/Inlines/HtmlInline.cs b/NppMarkdownPanel/Markdig/Syntax/Inlines/HtmlInline.cs deleted file mode 100644 index ae3faf7..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/Inlines/HtmlInline.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.Diagnostics; - -namespace Markdig.Syntax.Inlines -{ - /// - /// A Raw HTML (Section 6.8 CommonMark specs). - /// - /// - [DebuggerDisplay("{Tag}")] - public class HtmlInline : LeafInline - { - /// - /// Gets or sets the full declaration of this tag. - /// - public string Tag { get; set; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/Inlines/IInline.cs b/NppMarkdownPanel/Markdig/Syntax/Inlines/IInline.cs deleted file mode 100644 index 489642e..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/Inlines/IInline.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -namespace Markdig.Syntax.Inlines -{ - /// - /// Base interface for all syntax tree inlines. - /// - /// - public interface IInline : IMarkdownObject - { - /// - /// Gets the parent container of this inline. - /// - ContainerInline Parent { get; } - - /// - /// Gets the previous inline. - /// - Inline PreviousSibling { get; } - - /// - /// Gets the next sibling inline. - /// - Inline NextSibling { get; } - - /// - /// Gets or sets a value indicating whether this instance is closed. - /// - bool IsClosed { get; set; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/Inlines/Inline.cs b/NppMarkdownPanel/Markdig/Syntax/Inlines/Inline.cs deleted file mode 100644 index 43311fd..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/Inlines/Inline.cs +++ /dev/null @@ -1,293 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System; -using System.Collections.Generic; -using System.IO; -using Markdig.Parsers; - -namespace Markdig.Syntax.Inlines -{ - /// - /// Base class for all syntax tree inlines. - /// - /// - public abstract class Inline : MarkdownObject, IInline - { - /// - /// Gets the parent container of this inline. - /// - public ContainerInline Parent { get; internal set; } - - /// - /// Gets the previous inline. - /// - public Inline PreviousSibling { get; private set; } - - /// - /// Gets the next sibling inline. - /// - public Inline NextSibling { get; internal set; } - - /// - /// Gets or sets a value indicating whether this instance is closed. - /// - public bool IsClosed { get; set; } - - /// - /// Inserts the specified inline after this instance. - /// - /// The inline to insert after this instance. - /// - /// Inline has already a parent - public void InsertAfter(Inline next) - { - if (next == null) throw new ArgumentNullException(nameof(next)); - if (next.Parent != null) - { - throw new ArgumentException("Inline has already a parent", nameof(next)); - } - - var previousNext = NextSibling; - if (previousNext != null) - { - previousNext.PreviousSibling = next; - } - - next.PreviousSibling = this; - next.NextSibling = previousNext; - NextSibling = next; - - if (Parent != null) - { - Parent.OnChildInsert(next); - next.Parent = Parent; - } - } - - /// - /// Inserts the specified inline before this instance. - /// - /// The inlnie previous to insert before this instance. - /// - /// Inline has already a parent - public void InsertBefore(Inline previous) - { - if (previous == null) throw new ArgumentNullException(nameof(previous)); - if (previous.Parent != null) - { - throw new ArgumentException("Inline has already a parent", nameof(previous)); - } - - var previousSibling = PreviousSibling; - if (previousSibling != null) - { - previousSibling.NextSibling = previous; - } - - PreviousSibling = previous; - previous.NextSibling = this; - - if (Parent != null) - { - Parent.OnChildInsert(previous); - previous.Parent = Parent; - } - } - - /// - /// Removes this instance from the current list and its parent - /// - public void Remove() - { - if (PreviousSibling != null) - { - PreviousSibling.NextSibling = NextSibling; - } - - if (NextSibling != null) - { - NextSibling.PreviousSibling = PreviousSibling; - } - - if (Parent != null) - { - Parent.OnChildRemove(this); - - PreviousSibling = null; - NextSibling = null; - Parent = null; - } - } - - /// - /// Replaces this inline by the specified inline. - /// - /// The inline. - /// if set to true the children of this instance are copied to the specified inline. - /// The last children - /// If inlnie is null - public Inline ReplaceBy(Inline inline, bool copyChildren = true) - { - if (inline == null) throw new ArgumentNullException(nameof(inline)); - - // Save sibling - var parent = Parent; - var previousSibling = PreviousSibling; - var nextSibling = NextSibling; - Remove(); - - if (previousSibling != null) - { - previousSibling.InsertAfter(inline); - } - else if (nextSibling != null) - { - nextSibling.InsertBefore(inline); - } - else if (parent != null) - { - parent.AppendChild(inline); - } - - var container = this as ContainerInline; - if (copyChildren && container != null) - { - var newContainer = inline as ContainerInline; - // Don't append to a closed container - if (newContainer != null && newContainer.IsClosed) - { - newContainer = null; - } - // TODO: This part is not efficient as it is using child.Remove() - // We need a method to quickly move all children without having to mess Next/Prev sibling - var child = container.FirstChild; - var lastChild = inline; - while (child != null) - { - var nextChild = child.NextSibling; - child.Remove(); - if (newContainer != null) - { - newContainer.AppendChild(child); - } - else - { - lastChild.InsertAfter(child); - } - lastChild = child; - child = nextChild; - } - - return lastChild; - } - - return inline; - } - - /// - /// Determines whether this instance contains a parent of the specified type. - /// - /// Type of the parent to check - /// true if this instance contains a parent of the specified type; false otherwise - public bool ContainsParentOfType() where T : Inline - { - var inline = this; - while (inline != null) - { - var delimiter = inline as T; - if (delimiter != null) - { - return true; - } - inline = inline.Parent; - } - return false; - } - - /// - /// Iterates on parents of the specified type. - /// - /// Type of the parent to iterate over - /// An enumeration on the parents of the specified type - public IEnumerable FindParentOfType() where T : Inline - { - var inline = this; - while (inline != null) - { - var delimiter = inline as T; - if (delimiter != null) - { - yield return delimiter; - } - inline = inline.Parent; - } - } - - public Inline FindBestParent() - { - var current = this; - - while (current.Parent != null || current.PreviousSibling != null) - { - if (current.Parent != null) - { - current = current.Parent; - continue; - } - - current = current.PreviousSibling; - } - - return current; - } - - protected virtual void OnChildRemove(Inline child) - { - - } - - protected virtual void OnChildInsert(Inline child) - { - } - - /// - /// Dumps this instance to . - /// - /// The writer. - /// - public void DumpTo(TextWriter writer) - { - if (writer == null) throw new ArgumentNullException(nameof(writer)); - DumpTo(writer, 0); - } - - /// - /// Dumps this instance to . - /// - /// The writer. - /// The level of indent. - /// if writer is null - public void DumpTo(TextWriter writer, int level) - { - if (writer == null) throw new ArgumentNullException(nameof(writer)); - for (int i = 0; i < level; i++) - { - writer.Write(' '); - } - - writer.WriteLine("-> " + this.GetType().Name + " = " + this); - - DumpChildTo(writer, level + 1); - - if (NextSibling != null) - { - NextSibling.DumpTo(writer, level); - } - } - - protected virtual void DumpChildTo(TextWriter writer, int level) - { - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/Inlines/LeafInline.cs b/NppMarkdownPanel/Markdig/Syntax/Inlines/LeafInline.cs deleted file mode 100644 index 37c0382..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/Inlines/LeafInline.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -namespace Markdig.Syntax.Inlines -{ - /// - /// A base class for a leaf inline. - /// - /// - public abstract class LeafInline : Inline - { - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/Inlines/LineBreakInline.cs b/NppMarkdownPanel/Markdig/Syntax/Inlines/LineBreakInline.cs deleted file mode 100644 index 0372ef6..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/Inlines/LineBreakInline.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -namespace Markdig.Syntax.Inlines -{ - /// - /// A base class for a line break. - /// - /// - public class LineBreakInline : LeafInline - { - public bool IsHard { get; set; } - - public bool IsBackslash { get; set; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/Inlines/LinkDelimiterInline.cs b/NppMarkdownPanel/Markdig/Syntax/Inlines/LinkDelimiterInline.cs deleted file mode 100644 index de0d169..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/Inlines/LinkDelimiterInline.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Parsers; - -namespace Markdig.Syntax.Inlines -{ - /// - /// A delimiter for a link. - /// - /// - public class LinkDelimiterInline : DelimiterInline - { - public LinkDelimiterInline(InlineParser parser) : base(parser) - { - } - - /// - /// Gets or sets a value indicating whether this delimiter is an image link. - /// - public bool IsImage { get; set; } - - /// - /// Gets or sets the label of this link. - /// - public string Label { get; set; } - - /// - /// The label span - /// - public SourceSpan LabelSpan; - - public override string ToLiteral() - { - return IsImage ? "![" : "["; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/Inlines/LinkInline.cs b/NppMarkdownPanel/Markdig/Syntax/Inlines/LinkInline.cs deleted file mode 100644 index 88ffc5b..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/Inlines/LinkInline.cs +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.Diagnostics; - -namespace Markdig.Syntax.Inlines -{ - /// - /// A Link inline (Section 6.5 CommonMark specs) - /// - /// - [DebuggerDisplay("Url: {Url} Title: {Title} Image: {IsImage}")] - public class LinkInline : ContainerInline - { - /// - /// A delegate to use if it is setup on this instance to allow late binding - /// of a Url. - /// - /// - public delegate string GetUrlDelegate(); - - /// - /// Initializes a new instance of the class. - /// - public LinkInline() - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The URL. - /// The title. - public LinkInline(string url, string title) - { - Url = url; - Title = title; - } - - /// - /// Gets or sets the URL. - /// - public string Url { get; set; } - - /// - /// Gets or sets the GetDynamicUrl delegate. If this property is set, - /// it is used instead of to get the Url from this instance. - /// - public GetUrlDelegate GetDynamicUrl { get; set; } - - /// - /// Gets or sets the title. - /// - public string Title { get; set; } - - /// - /// Gets or sets the label. - /// - public string Label { get; set; } - - /// - /// Gets or sets a value indicating whether this instance is an image link. - /// - public bool IsImage { get; set; } - - /// - /// Gets or sets a boolean indicating if this link is a shortcut link to a - /// - public bool IsShortcut { get; set; } - - /// - /// Gets or sets a boolean indicating whether the inline link was parsed using markdown syntax or was automatic recognized. - /// - public bool IsAutoLink { get; set; } - - /// - /// Gets or sets the reference this link is attached to. May be null. - /// - public LinkReferenceDefinition Reference { get; set; } - - /// - /// The URL source span. - /// - public SourceSpan? UrlSpan; - - /// - /// The title source span. - /// - public SourceSpan? TitleSpan; - - /// - /// The label span - /// - public SourceSpan? LabelSpan; - } -} diff --git a/NppMarkdownPanel/Markdig/Syntax/Inlines/LiteralInline.cs b/NppMarkdownPanel/Markdig/Syntax/Inlines/LiteralInline.cs deleted file mode 100644 index 46c4be2..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/Inlines/LiteralInline.cs +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System; -using System.Diagnostics; -using Markdig.Helpers; -using Markdig.Parsers; - -namespace Markdig.Syntax.Inlines -{ - /// - /// A literal inline. - /// - /// - [DebuggerDisplay("{Content}")] - public class LiteralInline : LeafInline - { - /// - /// Initializes a new instance of the class. - /// - public LiteralInline() - { - Content = new StringSlice(null); - } - - /// - /// Initializes a new instance of the class. - /// - /// The content. - public LiteralInline(StringSlice content) - { - Content = content; - } - - /// - /// Initializes a new instance of the class. - /// - /// The text. - /// - public LiteralInline(string text) - { - if (text == null) throw new ArgumentNullException(nameof(text)); - Content = new StringSlice(text); - } - - /// - /// The content as a . - /// - public StringSlice Content; - - /// - /// A boolean indicating whether the first character of this literal is escaped by `\`. - /// - public bool IsFirstCharacterEscaped { get; set; } - - public override string ToString() - { - return Content.ToString(); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/LeafBlock.cs b/NppMarkdownPanel/Markdig/Syntax/LeafBlock.cs deleted file mode 100644 index 5906141..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/LeafBlock.cs +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System.Diagnostics; -using Markdig.Helpers; -using Markdig.Parsers; -using Markdig.Syntax.Inlines; - -namespace Markdig.Syntax -{ - /// - /// Base class for all leaf blocks. - /// - /// - [DebuggerDisplay("{GetType().Name} Line: {Line}, {Lines}")] - public abstract class LeafBlock : Block - { - /// - /// Initializes a new instance of the class. - /// - /// The parser used to create this block. - protected LeafBlock(BlockParser parser) : base(parser) - { - } - - /// - /// Gets or sets the string lines accumulated for this leaf block. - /// May be null after process inlines have occured. - /// - public StringLineGroup Lines; - - /// - /// Gets or sets the inline syntax tree (may be null). - /// - public ContainerInline Inline { get; set; } - - /// - /// Gets or sets a value indicating whether must be processed - /// as inline into the property. - /// - public bool ProcessInlines { get; set; } - - /// - /// Appends the specified line to this instance. - /// - /// The slice. - /// The column. - /// The line. - /// - public void AppendLine(ref StringSlice slice, int column, int line, int sourceLinePosition) - { - if (Lines.Lines == null) - { - Lines = new StringLineGroup(4); - } - - var stringLine = new StringLine(ref slice, line, column, sourceLinePosition); - // Regular case, we are not in the middle of a tab - if (slice.CurrentChar != '\t' || !CharHelper.IsAcrossTab(column)) - { - Lines.Add(ref stringLine); - } - else - { - // We need to expand tabs to spaces - var builder = StringBuilderCache.Local(); - for (int i = column; i < CharHelper.AddTab(column); i++) - { - builder.Append(' '); - } - builder.Append(slice.Text, slice.Start + 1, slice.Length - 1); - stringLine.Slice = new StringSlice(builder.ToString()); - Lines.Add(ref stringLine); - } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/LinkReferenceDefinition.cs b/NppMarkdownPanel/Markdig/Syntax/LinkReferenceDefinition.cs deleted file mode 100644 index 44f17e6..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/LinkReferenceDefinition.cs +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Helpers; -using Markdig.Parsers; -using Markdig.Syntax.Inlines; - -namespace Markdig.Syntax -{ - /// - /// A link reference definition (Section 4.7 CommonMark specs) - /// - /// - public class LinkReferenceDefinition : LeafBlock - { - /// - /// Creates an inline link for the specified . - /// - /// State of the inline. - /// The link reference. - /// The child. - /// An inline link or null to use the default implementation - public delegate Inline CreateLinkInlineDelegate(InlineProcessor inlineState, LinkReferenceDefinition linkRef, Inline child = null); - - /// - /// Initializes a new instance of the class. - /// - public LinkReferenceDefinition() : base(null) - { - IsOpen = false; - } - - /// - /// Initializes a new instance of the class. - /// - /// The label. - /// The URL. - /// The title. - public LinkReferenceDefinition(string label, string url, string title) : this() - { - Label = label; - Url = url; - Title = title; - } - - /// - /// Gets or sets the label. - /// - public string Label { get; set; } - - /// - /// Gets or sets the URL. - /// - public string Url { get; set; } - - /// - /// Gets or sets the title. - /// - public string Title { get; set; } - - /// - /// The label span - /// - public SourceSpan LabelSpan; - - /// - /// The URL span - /// - public SourceSpan UrlSpan; - - /// - /// The title span - /// - public SourceSpan TitleSpan; - - - /// - /// Gets or sets the create link inline callback for this instance. - /// - /// - /// This callback is called when an inline link is matching this reference definition. - /// - public CreateLinkInlineDelegate CreateLinkInline { get; set; } - - /// - /// Tries to the parse the specified text into a definition. - /// - /// Type of the text - /// The text. - /// The block. - /// true if parsing is successful; false otherwise - public static bool TryParse(ref T text, out LinkReferenceDefinition block) where T : ICharIterator - { - block = null; - string label; - string url; - string title; - SourceSpan labelSpan; - SourceSpan urlSpan; - SourceSpan titleSpan; - - var startSpan = text.Start; - - if (!LinkHelper.TryParseLinkReferenceDefinition(ref text, out label, out url, out title, out labelSpan, out urlSpan, out titleSpan)) - { - return false; - } - - block = new LinkReferenceDefinition(label, url, title) - { - LabelSpan = labelSpan, - UrlSpan = urlSpan, - TitleSpan = titleSpan, - Span = new SourceSpan(startSpan, titleSpan.End > 0 ? titleSpan.End: urlSpan.End) - }; - return true; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/LinkReferenceDefinitionExtensions.cs b/NppMarkdownPanel/Markdig/Syntax/LinkReferenceDefinitionExtensions.cs deleted file mode 100644 index abfa3d5..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/LinkReferenceDefinitionExtensions.cs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System; -using System.Collections.Generic; - -namespace Markdig.Syntax -{ - /// - /// Extension methods for accessing attached at the document level. - /// - public static class LinkReferenceDefinitionExtensions - { - private static readonly object DocumentKey = typeof(LinkReferenceDefinitionGroup); - - public static bool ContainsLinkReferenceDefinition(this MarkdownDocument document, string label) - { - if (label == null) throw new ArgumentNullException(nameof(label)); - var references = document.GetData(DocumentKey) as LinkReferenceDefinitionGroup; - if (references == null) - { - return false; - } - return references.Links.ContainsKey(label); - } - - public static void SetLinkReferenceDefinition(this MarkdownDocument document, string label, LinkReferenceDefinition linkReferenceDefinition) - { - if (label == null) throw new ArgumentNullException(nameof(label)); - var references = document.GetLinkReferenceDefinitions(); - references.Set(label, linkReferenceDefinition); - } - - public static bool TryGetLinkReferenceDefinition(this MarkdownDocument document, string label, out LinkReferenceDefinition linkReferenceDefinition) - { - if (label == null) throw new ArgumentNullException(nameof(label)); - linkReferenceDefinition = null; - var references = document.GetData(DocumentKey) as LinkReferenceDefinitionGroup; - if (references == null) - { - return false; - } - return references.TryGet(label, out linkReferenceDefinition); - } - - public static LinkReferenceDefinitionGroup GetLinkReferenceDefinitions(this MarkdownDocument document) - { - var references = document.GetData(DocumentKey) as LinkReferenceDefinitionGroup; - if (references == null) - { - references = new LinkReferenceDefinitionGroup(); - document.SetData(DocumentKey, references); - document.Add(references); - } - return references; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/LinkReferenceDefinitionGroup.cs b/NppMarkdownPanel/Markdig/Syntax/LinkReferenceDefinitionGroup.cs deleted file mode 100644 index f702b92..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/LinkReferenceDefinitionGroup.cs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Collections.Generic; - -namespace Markdig.Syntax -{ - /// - /// Contains all the found in a document. - /// - /// - public class LinkReferenceDefinitionGroup : ContainerBlock - { - /// - /// Initializes a new instance of the class. - /// - public LinkReferenceDefinitionGroup() : base(null) - { - Links = new Dictionary(StringComparer.OrdinalIgnoreCase); - } - - /// - /// Gets an association between a label and the corresponding - /// - public Dictionary Links { get; } - - public void Set(string label, LinkReferenceDefinition link) - { - if (link == null) throw new ArgumentNullException(nameof(link)); - if (!Contains(link)) - { - Add(link); - if (!Links.ContainsKey(label)) - { - Links[label] = link; - } - } - } - - public bool TryGet(string label, out LinkReferenceDefinition link) - { - return Links.TryGetValue(label, out link); - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/ListBlock.cs b/NppMarkdownPanel/Markdig/Syntax/ListBlock.cs deleted file mode 100644 index a494d66..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/ListBlock.cs +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Parsers; - -namespace Markdig.Syntax -{ - /// - /// A list (Section 5.3 CommonMark specs) - /// - /// - public class ListBlock : ContainerBlock - { - /// - /// Initializes a new instance of the class. - /// - /// The parser used to create this block. - public ListBlock(BlockParser parser) : base(parser) - { - } - - /// - /// Gets or sets a value indicating whether the list is ordered. - /// - public bool IsOrdered { get; set; } - - /// - /// Gets or sets the bullet character used by this list. - /// - public char BulletType { get; set; } - - /// - /// Gets or sets the ordered start number (valid when is true) - /// - public string OrderedStart { get; set; } - - /// - /// Gets or sets the default ordered start ("1" for BulletType = '1') - /// - public string DefaultOrderedStart { get; set; } - - /// - /// Gets or sets the ordered delimiter character (usually `.` or `)`) found after an ordered list item. - /// - public char OrderedDelimiter { get; set; } - - /// - /// Gets or sets a value indicating whether this instance is loose. - /// - public bool IsLoose { get; set; } - - internal int CountAllBlankLines { get; set; } - - internal int CountBlankLinesReset { get; set; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/ListItemBlock.cs b/NppMarkdownPanel/Markdig/Syntax/ListItemBlock.cs deleted file mode 100644 index d086a73..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/ListItemBlock.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Parsers; - -namespace Markdig.Syntax -{ - /// - /// A list item (Section 5.2 CommonMark specs) - /// - /// - public class ListItemBlock : ContainerBlock - { - /// - /// Initializes a new instance of the class. - /// - /// The parser used to create this block. - public ListItemBlock(BlockParser parser) : base(parser) - { - } - - internal int ColumnWidth { get; set; } - - /// - /// The number defined for this in an ordered list - /// - public int Order { get; set; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/MarkdownDocument.cs b/NppMarkdownPanel/Markdig/Syntax/MarkdownDocument.cs deleted file mode 100644 index f0853e2..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/MarkdownDocument.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System.Collections.Generic; - -namespace Markdig.Syntax -{ - /// - /// The root Markdown document. - /// - /// - public class MarkdownDocument : ContainerBlock - { - /// - /// Initializes a new instance of the class. - /// - public MarkdownDocument() : base(null) - { - } - - /// - /// Gets the number of lines in this - /// - public int LineCount; - - /// - /// Gets a list of zero-based indexes of line beginnings in the source span - /// Available if is used, otherwise null - /// - public List LineStartIndexes; - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/MarkdownObject.cs b/NppMarkdownPanel/Markdig/Syntax/MarkdownObject.cs deleted file mode 100644 index 484bc40..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/MarkdownObject.cs +++ /dev/null @@ -1,177 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System; - -namespace Markdig.Syntax -{ - /// - /// Base implementation for a the Markdown syntax tree. - /// - public abstract class MarkdownObject : IMarkdownObject - { - protected MarkdownObject() - { - Span = SourceSpan.Empty; - } - - /// - /// The attached datas. Use internally a simple array instead of a Dictionary{Object,Object} - /// as we expect less than 5~10 entries, usually typically 1 (HtmlAttributes) - /// so it will gives faster access than a Dictionary, and lower memory occupation - /// - private DataEntry[] attachedDatas; - private int count; - - /// - /// Gets or sets the text column this instance was declared (zero-based). - /// - public int Column { get; set; } - - /// - /// Gets or sets the text line this instance was declared (zero-based). - /// - public int Line { get; set; } - - /// - /// The source span - /// - public SourceSpan Span; - - /// - /// Gets a string of the location in the text. - /// - /// - public string ToPositionText() - { - return $"${Line}, {Column}, {Span.Start}-{Span.End}"; - } - - /// - /// Stores a key/value pair for this instance. - /// - /// The key. - /// The value. - /// if key is null - public void SetData(object key, object value) - { - if (key == null) throw new ArgumentNullException(nameof(key)); - if (attachedDatas == null) - { - attachedDatas = new DataEntry[1]; - } - else - { - for (int i = 0; i < count; i++) - { - if (attachedDatas[i].Key == key) - { - attachedDatas[i].Value = value; - return; - } - } - if (count == attachedDatas.Length) - { - var temp = new DataEntry[attachedDatas.Length + 1]; - Array.Copy(attachedDatas, 0, temp, 0, count); - attachedDatas = temp; - } - } - attachedDatas[count] = new DataEntry(key, value); - count++; - } - - /// - /// Determines whether this instance contains the specified key data. - /// - /// The key. - /// true if a data with the key is stored - /// if key is null - public bool ContainsData(object key) - { - if (key == null) throw new ArgumentNullException(nameof(key)); - if (attachedDatas == null) - { - return false; - } - - for (int i = 0; i < count; i++) - { - if (attachedDatas[i].Key == key) - { - return true; - } - } - return false; - } - - /// - /// Gets the associated data for the specified key. - /// - /// The key. - /// The associated data or null if none - /// if key is null - public object GetData(object key) - { - if (key == null) throw new ArgumentNullException(nameof(key)); - if (attachedDatas == null) - { - return null; - } - for (int i = 0; i < count; i++) - { - if (attachedDatas[i].Key == key) - { - return attachedDatas[i].Value; - } - } - return null; - } - - /// - /// Removes the associated data for the specified key. - /// - /// The key. - /// true if the data was removed; false otherwise - /// - public bool RemoveData(object key) - { - if (key == null) throw new ArgumentNullException(nameof(key)); - if (attachedDatas == null) - { - return true; - } - - for (int i = 0; i < count; i++) - { - if (attachedDatas[i].Key == key) - { - if (i < count - 1) - { - Array.Copy(attachedDatas, i + 1, attachedDatas, i, count - i - 1); - } - count--; - attachedDatas[count] = new DataEntry(); - return true; - } - } - return false; - } - - /// - /// Store a Key/Value pair. - /// - private struct DataEntry - { - public DataEntry(object key, object value) - { - Key = key; - Value = value; - } - - public readonly object Key; - - public object Value; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/MarkdownObjectExtensions.cs b/NppMarkdownPanel/Markdig/Syntax/MarkdownObjectExtensions.cs deleted file mode 100644 index 3e82bbb..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/MarkdownObjectExtensions.cs +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.Collections.Generic; -using Markdig.Syntax.Inlines; - -namespace Markdig.Syntax -{ - /// - /// Extensions for visiting or - /// - public static class MarkdownObjectExtensions - { - /// - /// Iterates over the descendant elements for the specified markdown element, including and . - /// The descendant elements are returned in DFS-like order. - /// - /// The markdown object. - /// An iteration over the descendant elements - public static IEnumerable Descendants(this MarkdownObject markdownObject) - { - // Fast-path an object with no children to avoid allocating Stack objects - if (!(markdownObject is ContainerBlock) && !(markdownObject is ContainerInline)) yield break; - - // TODO: A single Stack<(MarkdownObject block, bool push)> when ValueTuples are available - Stack stack = new Stack(); - Stack pushStack = new Stack(); - - stack.Push(markdownObject); - pushStack.Push(false); - - while (stack.Count > 0) - { - var block = stack.Pop(); - if (pushStack.Pop()) yield return block; - if (block is ContainerBlock containerBlock) - { - int subBlockIndex = containerBlock.Count; - while (subBlockIndex-- > 0) - { - var subBlock = containerBlock[subBlockIndex]; - if (subBlock is LeafBlock leafBlock) - { - if (leafBlock.Inline != null) - { - stack.Push(leafBlock.Inline); - pushStack.Push(false); - } - } - stack.Push(subBlock); - pushStack.Push(true); - } - } - else if (block is ContainerInline containerInline) - { - var child = containerInline.LastChild; - while (child != null) - { - stack.Push(child); - pushStack.Push(true); - child = child.PreviousSibling; - } - } - } - } - - /// - /// Iterates over the descendant elements for the specified markdown element and filters by the type {T}. - /// - /// Type to use for filtering the descendants - /// The inline markdown object. - /// - /// An iteration over the descendant elements - /// - public static IEnumerable Descendants(this ContainerInline inline) where T : Inline - => inline.FindDescendants(); - - /// - /// Iterates over the descendant elements for the specified markdown element and filters by the type {T}. - /// - /// Type to use for filtering the descendants - /// The markdown object. - /// - /// An iteration over the descendant elements - /// - public static IEnumerable Descendants(this ContainerBlock block) where T : Block - { - // Fast-path an empty container to avoid allocating a Stack - if (block.Count == 0) yield break; - - Stack stack = new Stack(); - - int childrenCount = block.Count; - while (childrenCount-- > 0) - { - stack.Push(block[childrenCount]); - } - - while (stack.Count > 0) - { - var subBlock = stack.Pop(); - if (subBlock is T subBlockT) - { - yield return subBlockT; - } - - if (subBlock is ContainerBlock subBlockContainer) - { - childrenCount = subBlockContainer.Count; - while (childrenCount-- > 0) - { - stack.Push(subBlockContainer[childrenCount]); - } - } - } - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/ParagraphBlock.cs b/NppMarkdownPanel/Markdig/Syntax/ParagraphBlock.cs deleted file mode 100644 index 3079a52..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/ParagraphBlock.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Parsers; - -namespace Markdig.Syntax -{ - /// - /// Repressents a paragraph. - /// - /// - /// Related to CommonMark spec: 4.8 Paragraphs - /// - public class ParagraphBlock : LeafBlock - { - /// - /// Initializes a new instance of the class. - /// - public ParagraphBlock() : this(null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The parser used to create this block. - public ParagraphBlock(BlockParser parser) : base(parser) - { - // Inlines are processed for a paragraph - ProcessInlines = true; - } - - public int LastLine => Line + Lines.Count - 1; - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/QuoteBlock.cs b/NppMarkdownPanel/Markdig/Syntax/QuoteBlock.cs deleted file mode 100644 index 01f2dda..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/QuoteBlock.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Parsers; - -namespace Markdig.Syntax -{ - /// - /// A block quote (Section 5.1 CommonMark specs) - /// - /// - public class QuoteBlock : ContainerBlock - { - /// - /// Initializes a new instance of the class. - /// - /// The parser used to create this block. - public QuoteBlock(BlockParser parser) : base(parser) - { - } - - /// - /// Gets or sets the quote character (usually `>`) - /// - public char QuoteChar { get; set; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/SourceSpan.cs b/NppMarkdownPanel/Markdig/Syntax/SourceSpan.cs deleted file mode 100644 index e4b449a..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/SourceSpan.cs +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; - -namespace Markdig.Syntax -{ - /// - /// A span of text. - /// - public struct SourceSpan : IEquatable - { - public static readonly SourceSpan Empty = new SourceSpan(0, -1); - - /// - /// Initializes a new instance of the struct. - /// - /// The start. - /// The end. - public SourceSpan(int start, int end) - { - Start = start; - End = end; - } - - /// - /// Gets or sets the starting character position from the original text source. - /// Note that for inline elements, this is only valid if is setup on the pipeline. - /// - public int Start { get; set; } - - /// - /// Gets or sets the ending character position from the original text source. - /// Note that for inline elements, this is only valid if is setup on the pipeline. - /// - public int End { get; set; } - - /// - /// Gets the character length of this element within the original source code. - /// - public int Length => End - Start + 1; - - public bool IsEmpty => Start > End; - - public SourceSpan MoveForward(int count) - { - return new SourceSpan(Start + count, End + count); - } - - public bool Equals(SourceSpan other) - { - return Start == other.Start && End == other.End; - } - - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) return false; - return obj is SourceSpan && Equals((SourceSpan) obj); - } - - public override int GetHashCode() - { - unchecked - { - return (Start*397) ^ End; - } - } - - public static bool operator ==(SourceSpan left, SourceSpan right) - { - return left.Equals(right); - } - - public static bool operator !=(SourceSpan left, SourceSpan right) - { - return !left.Equals(right); - } - - public override string ToString() - { - return $"{Start}-{End}"; - } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/Markdig/Syntax/ThematicBreakBlock.cs b/NppMarkdownPanel/Markdig/Syntax/ThematicBreakBlock.cs deleted file mode 100644 index c683937..0000000 --- a/NppMarkdownPanel/Markdig/Syntax/ThematicBreakBlock.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using Markdig.Parsers; - -namespace Markdig.Syntax -{ - /// - /// Repressents a thematic break (Section 4.1 CommonMark specs). - /// - public class ThematicBreakBlock : LeafBlock - { - /// - /// Initializes a new instance of the class. - /// - /// The parser used to create this block. - public ThematicBreakBlock(BlockParser parser) : base(parser) - { - } - - public char ThematicChar { get; set; } - - public int ThematicCharCount { get; set; } - } -} \ No newline at end of file diff --git a/NppMarkdownPanel/MarkdigMarkdownGenerator.cs b/NppMarkdownPanel/MarkdigMarkdownGenerator.cs index 4e37d1c..a246abc 100644 --- a/NppMarkdownPanel/MarkdigMarkdownGenerator.cs +++ b/NppMarkdownPanel/MarkdigMarkdownGenerator.cs @@ -27,8 +27,8 @@ public MarkdigMarkdownGenerator() public string ConvertToHtml(string markDownText, string filepath) { - var pipeline = new MarkdownPipelineBuilder().UseAdvancedExtensions().Build(); - pipeline.PreciseSourceLocation = true; + var pipeline = new MarkdownPipelineBuilder().UseAdvancedExtensions().UsePreciseSourceLocation().Build(); + // pipeline.UsePreciseSourceLocation(); try { htmlRenderer.BaseUrl = new Uri(filepath); diff --git a/NppMarkdownPanel/NppMarkdownPanel.csproj b/NppMarkdownPanel/NppMarkdownPanel.csproj index 8c00193..bb862a8 100644 --- a/NppMarkdownPanel/NppMarkdownPanel.csproj +++ b/NppMarkdownPanel/NppMarkdownPanel.csproj @@ -1,5 +1,6 @@  + Debug x86 @@ -9,8 +10,10 @@ NppMarkdownPanel MarkdownPanel bin\Debug\ - v4.5 + v4.6.1 + + true @@ -68,11 +71,136 @@ $(MSBuildProgramFiles32)\Notepad++\notepad++.exe + + ..\packages\Costura.Fody.5.7.0\lib\netstandard1.0\Costura.dll + + + ..\packages\Markdig.0.26.0\lib\net452\Markdig.dll + + + ..\packages\Microsoft.Win32.Primitives.4.3.0\lib\net46\Microsoft.Win32.Primitives.dll + True + True + + + ..\packages\System.AppContext.4.3.0\lib\net463\System.AppContext.dll + True + True + + + ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + + + ..\packages\System.Console.4.3.1\lib\net46\System.Console.dll + + + ..\packages\System.Diagnostics.DiagnosticSource.6.0.0\lib\net461\System.Diagnostics.DiagnosticSource.dll + + + ..\packages\System.Diagnostics.Tracing.4.3.0\lib\net462\System.Diagnostics.Tracing.dll + True + True + + + ..\packages\System.Globalization.Calendars.4.3.0\lib\net46\System.Globalization.Calendars.dll + True + True + + + ..\packages\System.IO.4.3.0\lib\net462\System.IO.dll + True + True + + + ..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll + True + True + + + + ..\packages\System.IO.Compression.ZipFile.4.3.0\lib\net46\System.IO.Compression.ZipFile.dll + True + True + + + ..\packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll + True + True + + + ..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll + True + True + + + ..\packages\System.Linq.4.3.0\lib\net463\System.Linq.dll + True + True + + + ..\packages\System.Linq.Expressions.4.3.0\lib\net463\System.Linq.Expressions.dll + True + True + + + ..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll + + + ..\packages\System.Net.Http.4.3.4\lib\net46\System.Net.Http.dll + + + ..\packages\System.Net.Sockets.4.3.0\lib\net46\System.Net.Sockets.dll + True + True + + + + ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Reflection.4.3.0\lib\net462\System.Reflection.dll + True + True + + + ..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + + + ..\packages\System.Runtime.InteropServices.4.3.0\lib\net463\System.Runtime.InteropServices.dll + True + True + + + ..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll + True + True + + + ..\packages\System.Security.Cryptography.Algorithms.4.3.1\lib\net461\System.Security.Cryptography.Algorithms.dll + + + ..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + True + True + + + ..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + True + True + + + ..\packages\System.Security.Cryptography.X509Certificates.4.3.2\lib\net461\System.Security.Cryptography.X509Certificates.dll + + + + ..\packages\System.Xml.ReaderWriter.4.3.1\lib\net46\System.Xml.ReaderWriter.dll + @@ -94,264 +222,6 @@ SettingsForms.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -398,6 +268,8 @@ + + @@ -422,6 +294,18 @@ + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + +