2016-02-10 00:54:08 +09:00
|
|
|
namespace Textamina.Markdig
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Repressents a indented code block.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <remarks>
|
|
|
|
|
/// Related to CommonMark spec: 4.4 Indented code blocks
|
|
|
|
|
/// </remarks>
|
|
|
|
|
public class CodeBlock : BlockLeaf
|
|
|
|
|
{
|
|
|
|
|
public static readonly BlockMatcher DefaultMatcher = new MatcherInternal();
|
|
|
|
|
|
|
|
|
|
public CodeBlock(Block parent) : base(DefaultMatcher, parent)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class MatcherInternal : BlockMatcher
|
|
|
|
|
{
|
|
|
|
|
public override MatchLineState Match(ref StringLiner liner, MatchLineState matchLineState, ref object matchContext)
|
|
|
|
|
{
|
|
|
|
|
// 4.4 Indented code blocks
|
|
|
|
|
var c = liner.Current;
|
2016-02-10 01:34:37 +09:00
|
|
|
if (liner.Column == 4 && Charset.IsSpace(c) && !liner.IsBlankLine())
|
2016-02-10 00:54:08 +09:00
|
|
|
{
|
|
|
|
|
liner.NextChar();
|
|
|
|
|
return MatchLineState.Continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return matchLineState == MatchLineState.Continue
|
|
|
|
|
? MatchLineState.Break
|
|
|
|
|
: MatchLineState.Discard;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Block New(Block parent)
|
|
|
|
|
{
|
|
|
|
|
return new Heading(parent);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|