diff --git a/.gitignore b/.gitignore index 4e0bf5b..696db86 100644 --- a/.gitignore +++ b/.gitignore @@ -1,15 +1,184 @@ -build -bin -obj -Release -Debug -*.pdb -*.user +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files *.suo -*.swp -*.swo +*.user +*.sln.docstates + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +build/ +bld/ +[Bb]in/ +[Oo]bj/ + +# Roslyn cache directories +*.ide/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +#NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps *.ncb -*.minime-options -*.zip +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding addin-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# NuGet Packages *.nupkg -/packages/* \ No newline at end of file +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# If using the old MSBuild-Integrated Package Restore, uncomment this: +#!**/packages/repositories.config + +# Windows Azure Build Output +csx/ +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +sql/ +*.Cache +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +node_modules/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ +.vs/config/applicationhost.config diff --git a/Backup/MarkdownDeep.sln b/Backup/MarkdownDeep.sln deleted file mode 100644 index b4d557e..0000000 --- a/Backup/MarkdownDeep.sln +++ /dev/null @@ -1,96 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MarkdownDeep", "MarkdownDeep\MarkdownDeep.csproj", "{1569ED47-C7C9-4261-B6F4-7445BD0F2C95}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MarkdownDeepTests", "MarkdownDeepTests\MarkdownDeepTests.csproj", "{CD1F5BFF-0118-4994-86A2-92658A36CE1B}" - ProjectSection(ProjectDependencies) = postProject - {AE271B39-C3D2-422B-860F-E3BA86AE4C37} = {AE271B39-C3D2-422B-860F-E3BA86AE4C37} - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MarkdownDeepBenchmark", "MarkdownDeepBenchmark\MarkdownDeepBenchmark.csproj", "{655AA41D-B9F5-48C6-99A8-3D04659B2591}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MarkdownDevBed", "MarkdownDevBed\MarkdownDevBed.csproj", "{B8264266-5809-4D05-BB99-312BCBE45B28}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MarkdownDeepGui", "MarkdownDeepGui\MarkdownDeepGui.csproj", "{FBDF1B77-BF84-4B3D-83DE-46271C468690}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MarkdownDeepJS", "MarkdownDeepJS\MarkdownDeepJS.csproj", "{AE271B39-C3D2-422B-860F-E3BA86AE4C37}" - ProjectSection(ProjectDependencies) = postProject - {1569ED47-C7C9-4261-B6F4-7445BD0F2C95} = {1569ED47-C7C9-4261-B6F4-7445BD0F2C95} - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|Mixed Platforms = Debug|Mixed Platforms - Debug|Win32 = Debug|Win32 - Release|Any CPU = Release|Any CPU - Release|Mixed Platforms = Release|Mixed Platforms - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1569ED47-C7C9-4261-B6F4-7445BD0F2C95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1569ED47-C7C9-4261-B6F4-7445BD0F2C95}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1569ED47-C7C9-4261-B6F4-7445BD0F2C95}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {1569ED47-C7C9-4261-B6F4-7445BD0F2C95}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {1569ED47-C7C9-4261-B6F4-7445BD0F2C95}.Debug|Win32.ActiveCfg = Debug|Any CPU - {1569ED47-C7C9-4261-B6F4-7445BD0F2C95}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1569ED47-C7C9-4261-B6F4-7445BD0F2C95}.Release|Any CPU.Build.0 = Release|Any CPU - {1569ED47-C7C9-4261-B6F4-7445BD0F2C95}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {1569ED47-C7C9-4261-B6F4-7445BD0F2C95}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {1569ED47-C7C9-4261-B6F4-7445BD0F2C95}.Release|Win32.ActiveCfg = Release|Any CPU - {CD1F5BFF-0118-4994-86A2-92658A36CE1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CD1F5BFF-0118-4994-86A2-92658A36CE1B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CD1F5BFF-0118-4994-86A2-92658A36CE1B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {CD1F5BFF-0118-4994-86A2-92658A36CE1B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {CD1F5BFF-0118-4994-86A2-92658A36CE1B}.Debug|Win32.ActiveCfg = Debug|Any CPU - {CD1F5BFF-0118-4994-86A2-92658A36CE1B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CD1F5BFF-0118-4994-86A2-92658A36CE1B}.Release|Any CPU.Build.0 = Release|Any CPU - {CD1F5BFF-0118-4994-86A2-92658A36CE1B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {CD1F5BFF-0118-4994-86A2-92658A36CE1B}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {CD1F5BFF-0118-4994-86A2-92658A36CE1B}.Release|Win32.ActiveCfg = Release|Any CPU - {655AA41D-B9F5-48C6-99A8-3D04659B2591}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {655AA41D-B9F5-48C6-99A8-3D04659B2591}.Debug|Any CPU.Build.0 = Debug|Any CPU - {655AA41D-B9F5-48C6-99A8-3D04659B2591}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {655AA41D-B9F5-48C6-99A8-3D04659B2591}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {655AA41D-B9F5-48C6-99A8-3D04659B2591}.Debug|Win32.ActiveCfg = Debug|Any CPU - {655AA41D-B9F5-48C6-99A8-3D04659B2591}.Release|Any CPU.ActiveCfg = Release|Any CPU - {655AA41D-B9F5-48C6-99A8-3D04659B2591}.Release|Any CPU.Build.0 = Release|Any CPU - {655AA41D-B9F5-48C6-99A8-3D04659B2591}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {655AA41D-B9F5-48C6-99A8-3D04659B2591}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {655AA41D-B9F5-48C6-99A8-3D04659B2591}.Release|Win32.ActiveCfg = Release|Any CPU - {B8264266-5809-4D05-BB99-312BCBE45B28}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B8264266-5809-4D05-BB99-312BCBE45B28}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B8264266-5809-4D05-BB99-312BCBE45B28}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {B8264266-5809-4D05-BB99-312BCBE45B28}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {B8264266-5809-4D05-BB99-312BCBE45B28}.Debug|Win32.ActiveCfg = Debug|Any CPU - {B8264266-5809-4D05-BB99-312BCBE45B28}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B8264266-5809-4D05-BB99-312BCBE45B28}.Release|Any CPU.Build.0 = Release|Any CPU - {B8264266-5809-4D05-BB99-312BCBE45B28}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {B8264266-5809-4D05-BB99-312BCBE45B28}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {B8264266-5809-4D05-BB99-312BCBE45B28}.Release|Win32.ActiveCfg = Release|Any CPU - {FBDF1B77-BF84-4B3D-83DE-46271C468690}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FBDF1B77-BF84-4B3D-83DE-46271C468690}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FBDF1B77-BF84-4B3D-83DE-46271C468690}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {FBDF1B77-BF84-4B3D-83DE-46271C468690}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {FBDF1B77-BF84-4B3D-83DE-46271C468690}.Debug|Win32.ActiveCfg = Debug|Any CPU - {FBDF1B77-BF84-4B3D-83DE-46271C468690}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FBDF1B77-BF84-4B3D-83DE-46271C468690}.Release|Any CPU.Build.0 = Release|Any CPU - {FBDF1B77-BF84-4B3D-83DE-46271C468690}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {FBDF1B77-BF84-4B3D-83DE-46271C468690}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {FBDF1B77-BF84-4B3D-83DE-46271C468690}.Release|Win32.ActiveCfg = Release|Any CPU - {AE271B39-C3D2-422B-860F-E3BA86AE4C37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AE271B39-C3D2-422B-860F-E3BA86AE4C37}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AE271B39-C3D2-422B-860F-E3BA86AE4C37}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {AE271B39-C3D2-422B-860F-E3BA86AE4C37}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {AE271B39-C3D2-422B-860F-E3BA86AE4C37}.Debug|Win32.ActiveCfg = Debug|Any CPU - {AE271B39-C3D2-422B-860F-E3BA86AE4C37}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AE271B39-C3D2-422B-860F-E3BA86AE4C37}.Release|Any CPU.Build.0 = Release|Any CPU - {AE271B39-C3D2-422B-860F-E3BA86AE4C37}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {AE271B39-C3D2-422B-860F-E3BA86AE4C37}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {AE271B39-C3D2-422B-860F-E3BA86AE4C37}.Release|Win32.ActiveCfg = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/Backup/MarkdownDeep/Abbreviation.cs b/Backup/MarkdownDeep/Abbreviation.cs deleted file mode 100644 index f2a1f59..0000000 --- a/Backup/MarkdownDeep/Abbreviation.cs +++ /dev/null @@ -1,29 +0,0 @@ -// -// MarkdownDeep - http://www.toptensoftware.com/markdowndeep -// -// The contents of this file are subject to the license terms as -// specified at the web address above. -// -// Software distributed under the License is distributed on an -// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -// implied. See the License for the specific language governing -// rights and limitations under the License. -// -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace MarkdownDeep -{ - class Abbreviation - { - public Abbreviation(string abbr, string title) - { - Abbr = abbr; - Title = title; - } - public string Abbr; - public string Title; - } -} diff --git a/Backup/MarkdownDeep/Block.cs b/Backup/MarkdownDeep/Block.cs deleted file mode 100644 index 1d3e96c..0000000 --- a/Backup/MarkdownDeep/Block.cs +++ /dev/null @@ -1,464 +0,0 @@ -// -// MarkdownDeep - http://www.toptensoftware.com/markdowndeep -// -// The contents of this file are subject to the license terms as -// specified at the web address above. -// -// Software distributed under the License is distributed on an -// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -// implied. See the License for the specific language governing -// rights and limitations under the License. -// -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace MarkdownDeep -{ - // Some block types are only used during block parsing, some - // are only used during rendering and some are used during both - internal enum BlockType - { - Blank, // blank line (parse only) - h1, // headings (render and parse) - h2, - h3, - h4, - h5, - h6, - post_h1, // setext heading lines (parse only) - post_h2, - quote, // block quote (render and parse) - ol_li, // list item in an ordered list (render and parse) - ul_li, // list item in an unordered list (render and parse) - p, // paragraph (or plain line during parse) - indent, // an indented line (parse only) - hr, // horizontal rule (render and parse) - html, // html content (render and parse) - unsafe_html, // unsafe html that should be encoded - span, // an undecorated span of text (used for simple list items - // where content is not wrapped in paragraph tags - codeblock, // a code block (render only) - li, // a list item (render only) - ol, // ordered list (render only) - ul, // unordered list (render only) - HtmlTag, // Data=(HtmlTag), children = content - Composite, // Just a list of child blocks - table_spec, // A table row specifier eg: |---: | ---| `data` = TableSpec reference - dd, // definition (render and parse) `data` = bool true if blank line before - dt, // render only - dl, // render only - footnote, // footnote definition eg: [^id] `data` holds the footnote id - p_footnote, // paragraph with footnote return link append. Return link string is in `data`. - } - - class Block - { - internal Block() - { - - } - - internal Block(BlockType type) - { - blockType = type; - } - - public string Content - { - get - { - switch (blockType) - { - case BlockType.codeblock: - StringBuilder s = new StringBuilder(); - foreach (var line in children) - { - s.Append(line.Content); - s.Append('\n'); - } - return s.ToString(); - } - - - if (buf==null) - return null; - else - return contentStart == -1 ? buf : buf.Substring(contentStart, contentLen); - } - } - - internal void RenderChildren(Markdown m, StringBuilder b) - { - foreach (var block in children) - { - block.Render(m, b); - } - } - - internal void RenderChildrenPlain(Markdown m, StringBuilder b) - { - foreach (var block in children) - { - block.RenderPlain(m, b); - } - } - - internal string ResolveHeaderID(Markdown m) - { - // Already resolved? - if (this.data!=null) - return (string)this.data; - - // Approach 1 - PHP Markdown Extra style header id - int end=contentEnd; - string id = Utils.StripHtmlID(buf, contentStart, ref end); - if (id != null) - { - contentEnd = end; - } - else - { - // Approach 2 - pandoc style header id - id = m.MakeUniqueHeaderID(buf, contentStart, contentLen); - } - - this.data = id; - return id; - } - - internal void Render(Markdown m, StringBuilder b) - { - switch (blockType) - { - case BlockType.Blank: - return; - - case BlockType.p: - m.SpanFormatter.FormatParagraph(b, buf, contentStart, contentLen); - break; - - case BlockType.span: - m.SpanFormatter.Format(b, buf, contentStart, contentLen); - b.Append("\n"); - break; - - case BlockType.h1: - case BlockType.h2: - case BlockType.h3: - case BlockType.h4: - case BlockType.h5: - case BlockType.h6: - if (m.ExtraMode && !m.SafeMode) - { - b.Append("<" + blockType.ToString()); - string id = ResolveHeaderID(m); - if (!String.IsNullOrEmpty(id)) - { - b.Append(" id=\""); - b.Append(id); - b.Append("\">"); - } - else - { - b.Append(">"); - } - } - else - { - b.Append("<" + blockType.ToString() + ">"); - } - m.SpanFormatter.Format(b, buf, contentStart, contentLen); - b.Append("\n"); - break; - - case BlockType.hr: - b.Append("
\n"); - return; - - case BlockType.ol_li: - case BlockType.ul_li: - b.Append("
  • "); - m.SpanFormatter.Format(b, buf, contentStart, contentLen); - b.Append("
  • \n"); - break; - - case BlockType.dd: - b.Append("
    "); - if (children != null) - { - b.Append("\n"); - RenderChildren(m, b); - } - else - m.SpanFormatter.Format(b, buf, contentStart, contentLen); - b.Append("
    \n"); - break; - - case BlockType.dt: - { - if (children == null) - { - foreach (var l in Content.Split('\n')) - { - b.Append("
    "); - m.SpanFormatter.Format(b, l.Trim()); - b.Append("
    \n"); - } - } - else - { - b.Append("
    \n"); - RenderChildren(m, b); - b.Append("
    \n"); - } - break; - } - - case BlockType.dl: - b.Append("
    \n"); - RenderChildren(m, b); - b.Append("
    \n"); - return; - - case BlockType.html: - b.Append(buf, contentStart, contentLen); - return; - - case BlockType.unsafe_html: - m.HtmlEncode(b, buf, contentStart, contentLen); - return; - - case BlockType.codeblock: - b.Append("
    ");
    -					foreach (var line in children)
    -					{
    -						m.HtmlEncodeAndConvertTabsToSpaces(b, line.buf, line.contentStart, line.contentLen);
    -						b.Append("\n");
    -					}
    -					b.Append("
    \n\n"); - return; - - case BlockType.quote: - b.Append("
    \n"); - RenderChildren(m, b); - b.Append("
    \n"); - return; - - case BlockType.li: - b.Append("
  • \n"); - RenderChildren(m, b); - b.Append("
  • \n"); - return; - - case BlockType.ol: - b.Append("
      \n"); - RenderChildren(m, b); - b.Append("
    \n"); - return; - - case BlockType.ul: - b.Append("\n"); - return; - - case BlockType.HtmlTag: - var tag = (HtmlTag)data; - - // Prepare special tags - var name=tag.name.ToLowerInvariant(); - if (name == "a") - { - m.OnPrepareLink(tag); - } - else if (name == "img") - { - m.OnPrepareImage(tag, m.RenderingTitledImage); - } - - tag.RenderOpening(b); - b.Append("\n"); - RenderChildren(m, b); - tag.RenderClosing(b); - b.Append("\n"); - return; - - case BlockType.Composite: - case BlockType.footnote: - RenderChildren(m, b); - return; - - case BlockType.table_spec: - ((TableSpec)data).Render(m, b); - break; - - case BlockType.p_footnote: - b.Append("

    "); - if (contentLen > 0) - { - m.SpanFormatter.Format(b, buf, contentStart, contentLen); - b.Append(" "); - } - b.Append((string)data); - b.Append("

    \n"); - break; - - default: - b.Append("<" + blockType.ToString() + ">"); - m.SpanFormatter.Format(b, buf, contentStart, contentLen); - b.Append("\n"); - break; - } - } - - internal void RenderPlain(Markdown m, StringBuilder b) - { - switch (blockType) - { - case BlockType.Blank: - return; - - case BlockType.p: - case BlockType.span: - m.SpanFormatter.FormatPlain(b, buf, contentStart, contentLen); - b.Append(" "); - break; - - case BlockType.h1: - case BlockType.h2: - case BlockType.h3: - case BlockType.h4: - case BlockType.h5: - case BlockType.h6: - m.SpanFormatter.FormatPlain(b, buf, contentStart, contentLen); - b.Append(" - "); - break; - - - case BlockType.ol_li: - case BlockType.ul_li: - b.Append("* "); - m.SpanFormatter.FormatPlain(b, buf, contentStart, contentLen); - b.Append(" "); - break; - - case BlockType.dd: - if (children != null) - { - b.Append("\n"); - RenderChildrenPlain(m, b); - } - else - m.SpanFormatter.FormatPlain(b, buf, contentStart, contentLen); - break; - - case BlockType.dt: - { - if (children == null) - { - foreach (var l in Content.Split('\n')) - { - var str = l.Trim(); - m.SpanFormatter.FormatPlain(b, str, 0, str.Length); - } - } - else - { - RenderChildrenPlain(m, b); - } - break; - } - - case BlockType.dl: - RenderChildrenPlain(m, b); - return; - - case BlockType.codeblock: - foreach (var line in children) - { - b.Append(line.buf, line.contentStart, line.contentLen); - b.Append(" "); - } - return; - - case BlockType.quote: - case BlockType.li: - case BlockType.ol: - case BlockType.ul: - case BlockType.HtmlTag: - RenderChildrenPlain(m, b); - return; - } - } - - public void RevertToPlain() - { - blockType = BlockType.p; - contentStart = lineStart; - contentLen = lineLen; - } - - public int contentEnd - { - get - { - return contentStart + contentLen; - } - set - { - contentLen = value - contentStart; - } - } - - // Count the leading spaces on a block - // Used by list item evaluation to determine indent levels - // irrespective of indent line type. - public int leadingSpaces - { - get - { - int count = 0; - for (int i = lineStart; i < lineStart + lineLen; i++) - { - if (buf[i] == ' ') - { - count++; - } - else - { - break; - } - } - return count; - } - } - - public override string ToString() - { - string c = Content; - return blockType.ToString() + " - " + (c==null ? "" : c); - } - - public Block CopyFrom(Block other) - { - blockType = other.blockType; - buf = other.buf; - contentStart = other.contentStart; - contentLen = other.contentLen; - lineStart = other.lineStart; - lineLen = other.lineLen; - return this; - } - - internal BlockType blockType; - internal string buf; - internal int contentStart; - internal int contentLen; - internal int lineStart; - internal int lineLen; - internal object data; // content depends on block type - internal List children; - } -} diff --git a/Backup/MarkdownDeep/BlockProcessor.cs b/Backup/MarkdownDeep/BlockProcessor.cs deleted file mode 100644 index 81c3bd1..0000000 --- a/Backup/MarkdownDeep/BlockProcessor.cs +++ /dev/null @@ -1,1508 +0,0 @@ -// -// MarkdownDeep - http://www.toptensoftware.com/markdowndeep -// -// The contents of this file are subject to the license terms as -// specified at the web address above. -// -// Software distributed under the License is distributed on an -// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -// implied. See the License for the specific language governing -// rights and limitations under the License. -// -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace MarkdownDeep -{ - public class BlockProcessor : StringScanner - { - public BlockProcessor(Markdown m, bool MarkdownInHtml) - { - m_markdown = m; - m_bMarkdownInHtml = MarkdownInHtml; - m_parentType = BlockType.Blank; - } - - internal BlockProcessor(Markdown m, bool MarkdownInHtml, BlockType parentType) - { - m_markdown = m; - m_bMarkdownInHtml = MarkdownInHtml; - m_parentType = parentType; - } - - internal List Process(string str) - { - return ScanLines(str); - } - - internal List ScanLines(string str) - { - // Reset string scanner - Reset(str); - return ScanLines(); - } - - internal List ScanLines(string str, int start, int len) - { - Reset(str, start, len); - return ScanLines(); - } - - internal bool StartTable(TableSpec spec, List lines) - { - // Mustn't have more than 1 preceeding line - if (lines.Count > 1) - return false; - - // Rewind, parse the header row then fast forward back to current pos - if (lines.Count == 1) - { - int savepos = position; - position = lines[0].lineStart; - spec.Headers = spec.ParseRow(this); - if (spec.Headers == null) - return false; - position = savepos; - lines.Clear(); - } - - // Parse all rows - while (true) - { - int savepos = position; - - var row=spec.ParseRow(this); - if (row!=null) - { - spec.Rows.Add(row); - continue; - } - - position = savepos; - break; - } - - return true; - } - - internal List ScanLines() - { - // The final set of blocks will be collected here - var blocks = new List(); - - // The current paragraph/list/codeblock etc will be accumulated here - // before being collapsed into a block and store in above `blocks` list - var lines = new List(); - - // Add all blocks - BlockType PrevBlockType = BlockType.unsafe_html; - while (!eof) - { - // Remember if the previous line was blank - bool bPreviousBlank = PrevBlockType == BlockType.Blank; - - // Get the next block - var b = EvaluateLine(); - PrevBlockType = b.blockType; - - // For dd blocks, we need to know if it was preceeded by a blank line - // so store that fact as the block's data. - if (b.blockType == BlockType.dd) - { - b.data = bPreviousBlank; - } - - - // SetExt header? - if (b.blockType == BlockType.post_h1 || b.blockType == BlockType.post_h2) - { - if (lines.Count > 0) - { - // Remove the previous line and collapse the current paragraph - var prevline = lines.Pop(); - CollapseLines(blocks, lines); - - // If previous line was blank, - if (prevline.blockType != BlockType.Blank) - { - // Convert the previous line to a heading and add to block list - prevline.RevertToPlain(); - prevline.blockType = b.blockType == BlockType.post_h1 ? BlockType.h1 : BlockType.h2; - blocks.Add(prevline); - continue; - } - } - - // Couldn't apply setext header to a previous line - - if (b.blockType == BlockType.post_h1) - { - // `===` gets converted to normal paragraph - b.RevertToPlain(); - lines.Add(b); - } - else - { - // `---` gets converted to hr - if (b.contentLen >= 3) - { - b.blockType = BlockType.hr; - blocks.Add(b); - } - else - { - b.RevertToPlain(); - lines.Add(b); - } - } - - continue; - } - - - // Work out the current paragraph type - BlockType currentBlockType = lines.Count > 0 ? lines[0].blockType : BlockType.Blank; - - // Starting a table? - if (b.blockType == BlockType.table_spec) - { - // Get the table spec, save position - TableSpec spec = (TableSpec)b.data; - int savepos = position; - if (!StartTable(spec, lines)) - { - // Not a table, revert the tablespec row to plain, - // fast forward back to where we were up to and continue - // on as if nothing happened - position = savepos; - b.RevertToPlain(); - } - else - { - blocks.Add(b); - continue; - } - } - - // Process this line - switch (b.blockType) - { - case BlockType.Blank: - switch (currentBlockType) - { - case BlockType.Blank: - FreeBlock(b); - break; - - case BlockType.p: - CollapseLines(blocks, lines); - FreeBlock(b); - break; - - case BlockType.quote: - case BlockType.ol_li: - case BlockType.ul_li: - case BlockType.dd: - case BlockType.footnote: - case BlockType.indent: - lines.Add(b); - break; - - default: - System.Diagnostics.Debug.Assert(false); - break; - } - break; - - case BlockType.p: - switch (currentBlockType) - { - case BlockType.Blank: - case BlockType.p: - lines.Add(b); - break; - - case BlockType.quote: - case BlockType.ol_li: - case BlockType.ul_li: - case BlockType.dd: - case BlockType.footnote: - var prevline = lines.Last(); - if (prevline.blockType == BlockType.Blank) - { - CollapseLines(blocks, lines); - lines.Add(b); - } - else - { - lines.Add(b); - } - break; - - case BlockType.indent: - CollapseLines(blocks, lines); - lines.Add(b); - break; - - default: - System.Diagnostics.Debug.Assert(false); - break; - } - break; - - case BlockType.indent: - switch (currentBlockType) - { - case BlockType.Blank: - // Start a code block - lines.Add(b); - break; - - case BlockType.p: - case BlockType.quote: - var prevline = lines.Last(); - if (prevline.blockType == BlockType.Blank) - { - // Start a code block after a paragraph - CollapseLines(blocks, lines); - lines.Add(b); - } - else - { - // indented line in paragraph, just continue it - b.RevertToPlain(); - lines.Add(b); - } - break; - - - case BlockType.ol_li: - case BlockType.ul_li: - case BlockType.dd: - case BlockType.footnote: - case BlockType.indent: - lines.Add(b); - break; - - default: - System.Diagnostics.Debug.Assert(false); - break; - } - break; - - case BlockType.quote: - if (currentBlockType != BlockType.quote) - { - CollapseLines(blocks, lines); - } - lines.Add(b); - break; - - case BlockType.ol_li: - case BlockType.ul_li: - switch (currentBlockType) - { - case BlockType.Blank: - lines.Add(b); - break; - - case BlockType.p: - case BlockType.quote: - var prevline = lines.Last(); - if (prevline.blockType == BlockType.Blank || m_parentType==BlockType.ol_li || m_parentType==BlockType.ul_li || m_parentType==BlockType.dd) - { - // List starting after blank line after paragraph or quote - CollapseLines(blocks, lines); - lines.Add(b); - } - else - { - // List's can't start in middle of a paragraph - b.RevertToPlain(); - lines.Add(b); - } - break; - - case BlockType.ol_li: - case BlockType.ul_li: - case BlockType.dd: - case BlockType.footnote: - if (b.blockType != currentBlockType) - { - CollapseLines(blocks, lines); - } - lines.Add(b); - break; - - case BlockType.indent: - // List after code block - CollapseLines(blocks, lines); - lines.Add(b); - break; - } - break; - - case BlockType.dd: - case BlockType.footnote: - switch (currentBlockType) - { - case BlockType.Blank: - case BlockType.p: - case BlockType.dd: - case BlockType.footnote: - CollapseLines(blocks, lines); - lines.Add(b); - break; - - default: - b.RevertToPlain(); - lines.Add(b); - break; - } - break; - - default: - CollapseLines(blocks, lines); - blocks.Add(b); - break; - } - } - - CollapseLines(blocks, lines); - - if (m_markdown.ExtraMode) - { - BuildDefinitionLists(blocks); - } - - return blocks; - } - - internal Block CreateBlock() - { - return m_markdown.CreateBlock(); - } - - internal void FreeBlock(Block b) - { - m_markdown.FreeBlock(b); - } - - internal void FreeBlocks(List blocks) - { - foreach (var b in blocks) - FreeBlock(b); - blocks.Clear(); - } - - internal string RenderLines(List lines) - { - StringBuilder b = m_markdown.GetStringBuilder(); - foreach (var l in lines) - { - b.Append(l.buf, l.contentStart, l.contentLen); - b.Append('\n'); - } - return b.ToString(); - } - - internal void CollapseLines(List blocks, List lines) - { - // Remove trailing blank lines - while (lines.Count>0 && lines.Last().blockType == BlockType.Blank) - { - FreeBlock(lines.Pop()); - } - - // Quit if empty - if (lines.Count == 0) - { - return; - } - - - // What sort of block? - switch (lines[0].blockType) - { - case BlockType.p: - { - // Collapse all lines into a single paragraph - var para = CreateBlock(); - para.blockType = BlockType.p; - para.buf = lines[0].buf; - para.contentStart = lines[0].contentStart; - para.contentEnd = lines.Last().contentEnd; - blocks.Add(para); - FreeBlocks(lines); - break; - } - - case BlockType.quote: - { - // Create a new quote block - var quote = new Block(BlockType.quote); - quote.children = new BlockProcessor(m_markdown, m_bMarkdownInHtml, BlockType.quote).Process(RenderLines(lines)); - FreeBlocks(lines); - blocks.Add(quote); - break; - } - - case BlockType.ol_li: - case BlockType.ul_li: - blocks.Add(BuildList(lines)); - break; - - case BlockType.dd: - if (blocks.Count > 0) - { - var prev=blocks[blocks.Count-1]; - switch (prev.blockType) - { - case BlockType.p: - prev.blockType = BlockType.dt; - break; - - case BlockType.dd: - break; - - default: - var wrapper = CreateBlock(); - wrapper.blockType = BlockType.dt; - wrapper.children = new List(); - wrapper.children.Add(prev); - blocks.Pop(); - blocks.Add(wrapper); - break; - } - - } - blocks.Add(BuildDefinition(lines)); - break; - - case BlockType.footnote: - m_markdown.AddFootnote(BuildFootnote(lines)); - break; - - case BlockType.indent: - { - var codeblock = new Block(BlockType.codeblock); - codeblock.children = new List(); - codeblock.children.AddRange(lines); - blocks.Add(codeblock); - lines.Clear(); - break; - } - } - } - - - Block EvaluateLine() - { - // Create a block - Block b=CreateBlock(); - - // Store line start - b.lineStart=position; - b.buf=input; - - // Scan the line - b.contentStart = position; - b.contentLen = -1; - b.blockType=EvaluateLine(b); - - // If end of line not returned, do it automatically - if (b.contentLen < 0) - { - // Move to end of line - SkipToEol(); - b.contentLen = position - b.contentStart; - } - - // Setup line length - b.lineLen=position-b.lineStart; - - // Next line - SkipEol(); - - // Create block - return b; - } - - BlockType EvaluateLine(Block b) - { - // Empty line? - if (eol) - return BlockType.Blank; - - // Save start of line position - int line_start= position; - - // ## Heading ## - char ch=current; - if (ch == '#') - { - // Work out heading level - int level = 1; - SkipForward(1); - while (current == '#') - { - level++; - SkipForward(1); - } - - // Limit of 6 - if (level > 6) - level = 6; - - // Skip any whitespace - SkipLinespace(); - - // Save start position - b.contentStart = position; - - // Jump to end - SkipToEol(); - - // In extra mode, check for a trailing HTML ID - if (m_markdown.ExtraMode && !m_markdown.SafeMode) - { - int end=position; - string strID = Utils.StripHtmlID(input, b.contentStart, ref end); - if (strID!=null) - { - b.data = strID; - position = end; - } - } - - // Rewind over trailing hashes - while (position>b.contentStart && CharAtOffset(-1) == '#') - { - SkipForward(-1); - } - - // Rewind over trailing spaces - while (position>b.contentStart && char.IsWhiteSpace(CharAtOffset(-1))) - { - SkipForward(-1); - } - - // Create the heading block - b.contentEnd = position; - - SkipToEol(); - return BlockType.h1 + (level - 1); - } - - // Check for entire line as - or = for setext h1 and h2 - if (ch=='-' || ch=='=') - { - // Skip all matching characters - char chType = ch; - while (current==chType) - { - SkipForward(1); - } - - // Trailing whitespace allowed - SkipLinespace(); - - // If not at eol, must have found something other than setext header - if (eol) - { - return chType == '=' ? BlockType.post_h1 : BlockType.post_h2; - } - - position = line_start; - } - - // MarkdownExtra Table row indicator? - if (m_markdown.ExtraMode) - { - TableSpec spec = TableSpec.Parse(this); - if (spec!=null) - { - b.data = spec; - return BlockType.table_spec; - } - - position = line_start; - } - - // Fenced code blocks? - if (m_markdown.ExtraMode && ch == '~') - { - if (ProcessFencedCodeBlock(b)) - return b.blockType; - - // Rewind - position = line_start; - } - - // Scan the leading whitespace, remembering how many spaces and where the first tab is - int tabPos = -1; - int leadingSpaces = 0; - while (!eol) - { - if (current == ' ') - { - if (tabPos < 0) - leadingSpaces++; - } - else if (current == '\t') - { - if (tabPos < 0) - tabPos = position; - } - else - { - // Something else, get out - break; - } - SkipForward(1); - } - - // Blank line? - if (eol) - { - b.contentEnd = b.contentStart; - return BlockType.Blank; - } - - // 4 leading spaces? - if (leadingSpaces >= 4) - { - b.contentStart = line_start + 4; - return BlockType.indent; - } - - // Tab in the first 4 characters? - if (tabPos >= 0 && tabPos - line_start<4) - { - b.contentStart = tabPos + 1; - return BlockType.indent; - } - - // Treat start of line as after leading whitespace - b.contentStart = position; - - // Get the next character - ch = current; - - // Html block? - if (ch == '<') - { - // Scan html block - if (ScanHtml(b)) - return b.blockType; - - // Rewind - position = b.contentStart; - } - - // Block quotes start with '>' and have one space or one tab following - if (ch == '>') - { - // Block quote followed by space - if (IsLineSpace(CharAtOffset(1))) - { - // Skip it and create quote block - SkipForward(2); - b.contentStart = position; - return BlockType.quote; - } - - SkipForward(1); - b.contentStart = position; - return BlockType.quote; - } - - // Horizontal rule - a line consisting of 3 or more '-', '_' or '*' with optional spaces and nothing else - if (ch == '-' || ch == '_' || ch == '*') - { - int count = 0; - while (!eol) - { - char chType = current; - if (current == ch) - { - count++; - SkipForward(1); - continue; - } - - if (IsLineSpace(current)) - { - SkipForward(1); - continue; - } - - break; - } - - if (eol && count >= 3) - { - return BlockType.hr; - } - - // Rewind - position = b.contentStart; - } - - // Abbreviation definition? - if (m_markdown.ExtraMode && ch == '*' && CharAtOffset(1) == '[') - { - SkipForward(2); - SkipLinespace(); - - Mark(); - while (!eol && current != ']') - { - SkipForward(1); - } - - var abbr = Extract().Trim(); - if (current == ']' && CharAtOffset(1) == ':' && !string.IsNullOrEmpty(abbr)) - { - SkipForward(2); - SkipLinespace(); - - Mark(); - - SkipToEol(); - - var title = Extract(); - - m_markdown.AddAbbreviation(abbr, title); - - return BlockType.Blank; - } - - position = b.contentStart; - } - - // Unordered list - if ((ch == '*' || ch == '+' || ch == '-') && IsLineSpace(CharAtOffset(1))) - { - // Skip it - SkipForward(1); - SkipLinespace(); - b.contentStart = position; - return BlockType.ul_li; - } - - // Definition - if (ch == ':' && m_markdown.ExtraMode && IsLineSpace(CharAtOffset(1))) - { - SkipForward(1); - SkipLinespace(); - b.contentStart = position; - return BlockType.dd; - } - - // Ordered list - if (char.IsDigit(ch)) - { - // Ordered list? A line starting with one or more digits, followed by a '.' and a space or tab - - // Skip all digits - SkipForward(1); - while (char.IsDigit(current)) - SkipForward(1); - - if (SkipChar('.') && SkipLinespace()) - { - b.contentStart = position; - return BlockType.ol_li; - } - - position=b.contentStart; - } - - // Reference link definition? - if (ch == '[') - { - // Footnote definition? - if (m_markdown.ExtraMode && CharAtOffset(1) == '^') - { - var savepos = position; - - SkipForward(2); - - string id; - if (SkipFootnoteID(out id) && SkipChar(']') && SkipChar(':')) - { - SkipLinespace(); - b.contentStart = position; - b.data = id; - return BlockType.footnote; - } - - position = savepos; - } - - // Parse a link definition - LinkDefinition l = LinkDefinition.ParseLinkDefinition(this, m_markdown.ExtraMode); - if (l!=null) - { - m_markdown.AddLinkDefinition(l); - return BlockType.Blank; - } - } - - // Nothing special - return BlockType.p; - } - - internal enum MarkdownInHtmlMode - { - NA, // No markdown attribute on the tag - Block, // markdown=1 or markdown=block - Span, // markdown=1 or markdown=span - Deep, // markdown=deep - recursive block mode - Off, // Markdown="something else" - } - - internal MarkdownInHtmlMode GetMarkdownMode(HtmlTag tag) - { - // Get the markdown attribute - string strMarkdownMode; - if (!m_markdown.ExtraMode || !tag.attributes.TryGetValue("markdown", out strMarkdownMode)) - { - if (m_bMarkdownInHtml) - return MarkdownInHtmlMode.Deep; - else - return MarkdownInHtmlMode.NA; - } - - // Remove it - tag.attributes.Remove("markdown"); - - // Parse mode - if (strMarkdownMode == "1") - return (tag.Flags & HtmlTagFlags.ContentAsSpan)!=0 ? MarkdownInHtmlMode.Span : MarkdownInHtmlMode.Block; - - if (strMarkdownMode == "block") - return MarkdownInHtmlMode.Block; - - if (strMarkdownMode == "deep") - return MarkdownInHtmlMode.Deep; - - if (strMarkdownMode == "span") - return MarkdownInHtmlMode.Span; - - return MarkdownInHtmlMode.Off; - } - - internal bool ProcessMarkdownEnabledHtml(Block b, HtmlTag openingTag, MarkdownInHtmlMode mode) - { - // Current position is just after the opening tag - - // Scan until we find matching closing tag - int inner_pos = position; - int depth = 1; - bool bHasUnsafeContent = false; - while (!eof) - { - // Find next angle bracket - if (!Find('<')) - break; - - // Is it a html tag? - int tagpos = position; - HtmlTag tag = HtmlTag.Parse(this); - if (tag == null) - { - // Nope, skip it - SkipForward(1); - continue; - } - - // In markdown off mode, we need to check for unsafe tags - if (m_markdown.SafeMode && mode == MarkdownInHtmlMode.Off && !bHasUnsafeContent) - { - if (!tag.IsSafe()) - bHasUnsafeContent = true; - } - - // Ignore self closing tags - if (tag.closed) - continue; - - // Same tag? - if (tag.name == openingTag.name) - { - if (tag.closing) - { - depth--; - if (depth == 0) - { - // End of tag? - SkipLinespace(); - SkipEol(); - - b.blockType = BlockType.HtmlTag; - b.data = openingTag; - b.contentEnd = position; - - switch (mode) - { - case MarkdownInHtmlMode.Span: - { - Block span = this.CreateBlock(); - span.buf = input; - span.blockType = BlockType.span; - span.contentStart = inner_pos; - span.contentLen = tagpos - inner_pos; - - b.children = new List(); - b.children.Add(span); - break; - } - - case MarkdownInHtmlMode.Block: - case MarkdownInHtmlMode.Deep: - { - // Scan the internal content - var bp = new BlockProcessor(m_markdown, mode == MarkdownInHtmlMode.Deep); - b.children = bp.ScanLines(input, inner_pos, tagpos - inner_pos); - break; - } - - case MarkdownInHtmlMode.Off: - { - if (bHasUnsafeContent) - { - b.blockType = BlockType.unsafe_html; - b.contentEnd = position; - } - else - { - Block span = this.CreateBlock(); - span.buf = input; - span.blockType = BlockType.html; - span.contentStart = inner_pos; - span.contentLen = tagpos - inner_pos; - - b.children = new List(); - b.children.Add(span); - } - break; - } - } - - - return true; - } - } - else - { - depth++; - } - } - } - - // Missing closing tag(s). - return false; - } - - // Scan from the current position to the end of the html section - internal bool ScanHtml(Block b) - { - // Remember start of html - int posStartPiece = this.position; - - // Parse a HTML tag - HtmlTag openingTag = HtmlTag.Parse(this); - if (openingTag == null) - return false; - - // Closing tag? - if (openingTag.closing) - return false; - - // Safe mode? - bool bHasUnsafeContent = false; - if (m_markdown.SafeMode && !openingTag.IsSafe()) - bHasUnsafeContent = true; - - HtmlTagFlags flags = openingTag.Flags; - - // Is it a block level tag? - if ((flags & HtmlTagFlags.Block) == 0) - return false; - - // Closed tag, hr or comment? - if ((flags & HtmlTagFlags.NoClosing) != 0 || openingTag.closed) - { - SkipLinespace(); - SkipEol(); - - b.contentEnd = position; - b.blockType = bHasUnsafeContent ? BlockType.unsafe_html : BlockType.html; - return true; - } - - // Can it also be an inline tag? - if ((flags & HtmlTagFlags.Inline) != 0) - { - // Yes, opening tag must be on a line by itself - SkipLinespace(); - if (!eol) - return false; - } - - // Work out the markdown mode for this element - if (m_markdown.ExtraMode) - { - MarkdownInHtmlMode MarkdownMode = this.GetMarkdownMode(openingTag); - if (MarkdownMode != MarkdownInHtmlMode.NA) - { - return this.ProcessMarkdownEnabledHtml(b, openingTag, MarkdownMode); - } - } - - List childBlocks = null; - - // Now capture everything up to the closing tag and put it all in a single HTML block - int depth = 1; - - while (!eof) - { - // Find next angle bracket - if (!Find('<')) - break; - - // Save position of current tag - int posStartCurrentTag = position; - - // Is it a html tag? - HtmlTag tag = HtmlTag.Parse(this); - if (tag == null) - { - // Nope, skip it - SkipForward(1); - continue; - } - - // Safe mode checks - if (m_markdown.SafeMode && !tag.IsSafe()) - bHasUnsafeContent = true; - - // Ignore self closing tags - if (tag.closed) - continue; - - // Markdown enabled content? - if (!tag.closing && m_markdown.ExtraMode && !bHasUnsafeContent) - { - MarkdownInHtmlMode MarkdownMode = this.GetMarkdownMode(tag); - if (MarkdownMode != MarkdownInHtmlMode.NA) - { - Block markdownBlock = this.CreateBlock(); - if (this.ProcessMarkdownEnabledHtml(markdownBlock, tag, MarkdownMode)) - { - if (childBlocks==null) - { - childBlocks = new List(); - } - - // Create a block for everything before the markdown tag - if (posStartCurrentTag > posStartPiece) - { - Block htmlBlock = this.CreateBlock(); - htmlBlock.buf = input; - htmlBlock.blockType = BlockType.html; - htmlBlock.contentStart = posStartPiece; - htmlBlock.contentLen = posStartCurrentTag - posStartPiece; - - childBlocks.Add(htmlBlock); - } - - // Add the markdown enabled child block - childBlocks.Add(markdownBlock); - - // Remember start of the next piece - posStartPiece = position; - - continue; - } - else - { - this.FreeBlock(markdownBlock); - } - } - } - - // Same tag? - if (tag.name == openingTag.name) - { - if (tag.closing) - { - depth--; - if (depth == 0) - { - // End of tag? - SkipLinespace(); - SkipEol(); - - // If anything unsafe detected, just encode the whole block - if (bHasUnsafeContent) - { - b.blockType = BlockType.unsafe_html; - b.contentEnd = position; - return true; - } - - // Did we create any child blocks - if (childBlocks != null) - { - // Create a block for the remainder - if (position > posStartPiece) - { - Block htmlBlock = this.CreateBlock(); - htmlBlock.buf = input; - htmlBlock.blockType = BlockType.html; - htmlBlock.contentStart = posStartPiece; - htmlBlock.contentLen = position - posStartPiece; - - childBlocks.Add(htmlBlock); - } - - // Return a composite block - b.blockType = BlockType.Composite; - b.contentEnd = position; - b.children = childBlocks; - return true; - } - - // Straight html block - b.blockType = BlockType.html; - b.contentEnd = position; - return true; - } - } - else - { - depth++; - } - } - } - - // Rewind to just after the tag - return false; - } - - /* - * Spacing - * - * 1-3 spaces - Promote to indented if more spaces than original item - * - */ - - /* - * BuildList - build a single
      or