diff --git a/src/Markdig.Tests/Specs/DefinitionListSpecs.generated.cs b/src/Markdig.Tests/Specs/DefinitionListSpecs.generated.cs index b76cf50..2a707fe 100644 --- a/src/Markdig.Tests/Specs/DefinitionListSpecs.generated.cs +++ b/src/Markdig.Tests/Specs/DefinitionListSpecs.generated.cs @@ -101,7 +101,7 @@ namespace Markdig.Tests.Specs.DefinitionLists TestParser.TestSpec("Term 1\n\n: Definition\nwith lazy continuation.\n\n Second paragraph of the definition.", "
Definition\nwith lazy continuation.
\nSecond paragraph of the definition.
\nTerm 1 - // : Invalid with less than 3 characters
+ //Term 1\n: Invalid with less than 3 characters
", "definitionlists+attributes|advanced", context: "Example 3\nSection Extensions / Definition lists\n"); + TestParser.TestSpec("First Term\n: This is the definition of the first term.\n\nSecond Term\n: This is one definition of the second term.\n~ This is another definition of the second term.", "Term 1 + // :Invalid without a space after the colon
+ + TestParser.TestSpec("Term 1\n:Invalid without a space after the colon", "Term 1\n:Invalid without a space after the colon
", "definitionlists+attributes|advanced", context: "Example 4\nSection Extensions / Definition lists\n"); + } + + // The `:` can be indented up to 3 spaces: + [Test] + public void ExtensionsDefinitionLists_Example005() + { + // Example 5 + // Section: Extensions / Definition lists + // + // The following Markdown: + // Term 1 // : Valid even if `:` starts at most 3 spaces // // Should be rendered as: @@ -136,14 +163,14 @@ namespace Markdig.Tests.Specs.DefinitionLists //: starts at most 3 spaces: starts at most 3 spaces: starts at most 3 spaces: Not valid
//
- TestParser.TestSpec("Term 1\n\n : Not valid", "Term 1
\n: Not valid\n", "definitionlists+attributes|advanced", context: "Example 5\nSection Extensions / Definition lists\n");
+ TestParser.TestSpec("Term 1\n\n : Not valid", "Term 1
\n: Not valid\n", "definitionlists+attributes|advanced", context: "Example 6\nSection Extensions / Definition lists\n");
}
// Definition lists can be nested inside list items
[Test]
- public void ExtensionsDefinitionLists_Example006()
+ public void ExtensionsDefinitionLists_Example007()
{
- // Example 6
+ // Example 7
// Section: Extensions / Definition lists
//
// The following Markdown:
@@ -189,7 +216,7 @@ namespace Markdig.Tests.Specs.DefinitionLists
//
//
- TestParser.TestSpec("1. First\n \n2. Second\n \n Term 1\n : Definition\n \n Term 2\n : Second Definition", "First
Second
\nFirst
Second
\nTerm 1 -: Invalid with less than 3 characters
+:Invalid without a space after the colon ```````````````````````````````` The `:` can be indented up to 3 spaces: diff --git a/src/Markdig/Extensions/DefinitionLists/DefinitionListParser.cs b/src/Markdig/Extensions/DefinitionLists/DefinitionListParser.cs index 85eb808..191fbc1 100644 --- a/src/Markdig/Extensions/DefinitionLists/DefinitionListParser.cs +++ b/src/Markdig/Extensions/DefinitionLists/DefinitionListParser.cs @@ -2,6 +2,7 @@ // 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; @@ -35,12 +36,12 @@ public class DefinitionListParser : BlockParser var startPosition = processor.Start; var column = processor.ColumnBeforeIndent; - processor.NextChar(); + var c = processor.NextChar(); processor.ParseIndent(); var delta = processor.Column - column; - // We expect to have a least - if (delta < 4) + // The marker must be followed by at least one space or tab + if (!c.IsSpaceOrTab()) { // Return back to original position processor.GoToColumn(column); @@ -144,12 +145,12 @@ public class DefinitionListParser : BlockParser { var startPosition = processor.Start; var column = processor.ColumnBeforeIndent; - processor.NextChar(); + var c = processor.NextChar(); processor.ParseIndent(); var delta = processor.Column - column; - // We expect to have a least - if (delta < 4) + // The marker must be followed by at least one space or tab + if (!c.IsSpaceOrTab()) { // Remove the blankline before breaking this definition item if (lastBlankLine != null)