]> git.plutz.net Git - cgilite/commitdiff
additional checks, minor "bug"fix: no newline befor definition lists (for consistency)
authorPaul Hänsch <paul@plutz.net>
Thu, 29 Aug 2024 10:45:08 +0000 (12:45 +0200)
committerPaul Hänsch <paul@plutz.net>
Thu, 29 Aug 2024 10:45:08 +0000 (12:45 +0200)
markdown.awk
tests-markdown.sh

index cb2a8f64b5e5a5330e5ff6513ab9d1a96ee59428..d54d125d6cf4338f212b515dad2e28484943518a 100755 (executable)
@@ -706,7 +706,7 @@ function _block( block, LOCAL, st, len, text, title, attrib, href, guard, code,
                            "|([ \t]*\n)+( ? ? ?\t|  +)[^\n]+(\n|$))*)+" \
   )) {
     list = substr( block, 1, RLENGTH); block = substr( block, RLENGTH + 1);
-    return "\n<dl>\n" _dlist( list ) "</dl>\n" _block( block );
+    return "<dl>\n" _dlist( list ) "</dl>\n" _block( block );
 
   # Unordered list types
   } else if ( text = _startlist( block, "ul", "-",   "([+*•]|[0-9]+\\.|#\\.|[0-9]+\\)|#\\))") ) {
index f5fc8290a9751ec81dd03a4277d198813d0877ea..0147f095d47c2ae4db4a652aa5745f65e8957f6b 100755 (executable)
@@ -161,4 +161,67 @@ assert '![Testbild *ARD*](Test Bild.jpg){tv ard function-check}' \
 # '<figure data-src="Test Bild.jpg" class="tv ard function-check"><img src="Test Bild.jpg" alt="Testbild *ARD*" class="tv ard function-check"></figure>' \
 # "block image tagged"
 
+# Headings
+assert 'Heading first Order
+============' \
+'<section class="h1" id="1:Heading%20first%20Order"><h1>Heading first Order<a class="anchor" href="#1:Heading%20first%20Order"></a></h1>
+</section>' \
+'Heading h1'
+
+assert 'Heading first Order {.foo #bar}
+============' \
+'<section class="h1 foo bar" id="1:Heading%20first%20Order"><h1 class="foo bar">Heading first Order<a class="anchor" href="#1:Heading%20first%20Order"></a></h1>
+</section>' \
+'Heading h1 + attributes'
+
+assert 'Heading second Order
+------------' \
+'<section class="h2" id="0.1:Heading%20second%20Order"><h2>Heading second Order<a class="anchor" href="#0.1:Heading%20second%20Order"></a></h2>
+</section>' \
+'Heading h2'
+
+assert 'Heading second Order {.foo #bar}
+------------' \
+'<section class="h2 foo bar" id="0.1:Heading%20second%20Order"><h2 class="foo bar">Heading second Order<a class="anchor" href="#0.1:Heading%20second%20Order"></a></h2>
+</section>' \
+'Heading h2 + attributes'
+
+assert '#### Heading four' \
+'<section class="h4" id="0.0.0.1:Heading%20four"><h4>Heading four<a class="anchor" href="#0.0.0.1:Heading%20four"></a></h4>
+</section>' \
+'Heading arbitrary'
+
+assert '### Heading three ######' \
+'<section class="h3" id="0.0.1:Heading%20three"><h3>Heading three<a class="anchor" href="#0.0.1:Heading%20three"></a></h3>
+</section>' \
+'Heading arbitrary'
+
+assert '### Heading three ## {foo bar}' \
+'<section class="h3 foo bar" id="0.0.1:Heading%20three"><h3 class="foo bar">Heading three<a class="anchor" href="#0.0.1:Heading%20three"></a></h3>
+</section>' \
+'Heading arbitrary + attributes'
+
+assert '# Heading \# # {foo bar}' \
+'<section class="h1 foo bar" id="1:Heading%20%5C%23"><h1 class="foo bar">Heading #<a class="anchor" href="#1:Heading%20%5C%23"></a></h1>
+</section>' \
+'Heading arbitrary + attributes'
+
+assert 'Definition
+: term
+with line continuation
+
+: second term
+
+foo
+: bar' \
+'<dl>
+<dt>Definition</dt>
+<dd>term
+with line continuation</dd>
+<dd>second term</dd>
+<dt>foo</dt>
+<dd>bar</dd>
+</dl>' \
+'Definition List'
+
 printf '\nAll test passed!\n'