// -------------------------------- // Definition Lists // -------------------------------- using System; using NUnit.Framework; namespace Markdig.Tests.Specs.DefinitionLists { [TestFixture] public class TestExtensionsDefinitionLists { // # Extensions // // This section describes the different extensions supported: // // ## Definition lists // // A custom container is similar to a fenced code block, but it is using the character `:` to declare a block (with at least 3 characters), and instead of generating a `
...
` it will generate a `
...
` block. [Test] public void ExtensionsDefinitionLists_Example001() { // Example 1 // Section: Extensions / Definition lists // // The following Markdown: // // Term 1 // : This is a definition item // With a paragraph // > This is a block quote // // - This is a list // - with an item2 // // ```java // Test // // // ``` // // And a last line // : This ia another definition item // // Term2 // Term3 *with some inline* // : This is another definition for term2 // // Should be rendered as: //
//
Term 1
//

This is a definition item // With a paragraph

//
//

This is a block quote

//
// //
Test
            //     
            //     
            //     
//

And a last line

//
//
This ia another definition item
//
Term2
//
Term3 with some inline
//
This is another definition for term2
//
TestParser.TestSpec("\nTerm 1\n: This is a definition item\n With a paragraph\n > This is a block quote\n\n - This is a list\n - with an item2\n\n ```java\n Test\n\n\n ```\n\n And a last line\n: This ia another definition item\n\nTerm2\nTerm3 *with some inline*\n: This is another definition for term2", "
\n
Term 1
\n

This is a definition item\nWith a paragraph

\n
\n

This is a block quote

\n
\n\n
Test\n\n\n
\n

And a last line

\n
\n
This ia another definition item
\n
Term2
\n
Term3 with some inline
\n
This is another definition for term2
\n
", "definitionlists+attributes|advanced", context: "Example 1\nSection Extensions / Definition lists\n"); } // A definition term can be followed at most by one blank line. Lazy continuations are supported for definitions: [Test] public void ExtensionsDefinitionLists_Example002() { // Example 2 // Section: Extensions / Definition lists // // The following Markdown: // Term 1 // // : Definition // with lazy continuation. // // Second paragraph of the definition. // // Should be rendered as: //
//
Term 1
//

Definition // with lazy continuation.

//

Second paragraph of the definition.

//
//
TestParser.TestSpec("Term 1\n\n: Definition\nwith lazy continuation.\n\n Second paragraph of the definition.", "
\n
Term 1
\n

Definition\nwith lazy continuation.

\n

Second paragraph of the definition.

\n
\n
", "definitionlists+attributes|advanced", context: "Example 2\nSection Extensions / Definition lists\n"); } // The definition must be indented to 4 characters including the `:`. [Test] public void ExtensionsDefinitionLists_Example003() { // Example 3 // Section: Extensions / Definition lists // // The following Markdown: // Term 1 // : Invalid with less than 3 characters // // Should be rendered as: //

Term 1 // : Invalid with less than 3 characters

TestParser.TestSpec("Term 1\n: 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"); } // The `:` can be indented up to 3 spaces: [Test] public void ExtensionsDefinitionLists_Example004() { // Example 4 // Section: Extensions / Definition lists // // The following Markdown: // Term 1 // : Valid even if `:` starts at most 3 spaces // // Should be rendered as: //
//
Term 1
//
Valid even if : starts at most 3 spaces
//
TestParser.TestSpec("Term 1\n : Valid even if `:` starts at most 3 spaces", "
\n
Term 1
\n
Valid even if : starts at most 3 spaces
\n
", "definitionlists+attributes|advanced", context: "Example 4\nSection Extensions / Definition lists\n"); } // But more than 3 spaces before `:` will trigger an indented code block: [Test] public void ExtensionsDefinitionLists_Example005() { // Example 5 // Section: Extensions / Definition lists // // The following Markdown: // Term 1 // // : Not valid // // Should be rendered as: //

Term 1

//
: 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"); } // Definition lists can be nested inside list items [Test] public void ExtensionsDefinitionLists_Example006() { // Example 6 // Section: Extensions / Definition lists // // The following Markdown: // 1. First // // 2. Second // // Term 1 // : Definition // // Term 2 // : Second Definition // // Should be rendered as: //
    //
  1. First

  2. //
  3. Second

    //
    //
    Term 1
    //
    Definition
    //
    Term 2
    //
    Second Definition
    //
  4. //
TestParser.TestSpec("1. First\n \n2. Second\n \n Term 1\n : Definition\n \n Term 2\n : Second Definition", "
    \n
  1. First

  2. \n
  3. Second

    \n
    \n
    Term 1
    \n
    Definition
    \n
    Term 2
    \n
    Second Definition
    \n
  4. \n
", "definitionlists+attributes|advanced", context: "Example 6\nSection Extensions / Definition lists\n"); } } }