Explorar o código

Update/add discount library tests

mingodad %!s(int64=9) %!d(string=hai) anos
pai
achega
9f60de29a7

+ 1 - 1
discount/Plan9/markdown.2

@@ -122,7 +122,7 @@ tags from the output.
 Suppress Smartypants-style replacement of quotes, dashes, or ellipses.
 .TP
 .B MKD_STRICT
-Disable superscript and relaxed emphasis processing if configured; otherwise a no-op.
+Disable superscript and relaxed emphasis processing.
 .TP
 .B MKD_TAGTEXT
 Process as inside an

+ 1 - 3
discount/Plan9/markdown.6

@@ -520,9 +520,7 @@ cell in the column.
 A colon at both ends of a column's header dashes indicates center alignment.
 .TP
 Relaxed Emphasis
-If configured with
-.BR --relaxed-emphasis ,
-the rules for emphasis are changed so that a single
+The rules for emphasis are changed so that a single
 .B _
 will not count as an emphasis character in the middle of a word.
 This is useful for documenting some code where

+ 1 - 1
discount/Plan9/mkfile

@@ -2,7 +2,7 @@ BIN=/$objtype/bin
 CC='cc -D_BSD_EXTENSION -D_C99_SNPRINTF_EXTENSION'
 
 markdown:
-	ape/psh -c 'cd .. && make'
+	ape/psh -c 'cd .. && $CC mktags.c -o mktags && ./mktags > blocktags && make'
 
 none:V: markdown
 

+ 5 - 0
discount/tests/backslash.t

@@ -12,5 +12,10 @@ try -fautolink 'autolink url with trailing \' \
     'http://a.com/\' \
     '<p><a href="http://a.com/\">http://a.com/\</a></p>'
 
+
+try 'backslashes before <text' '\<code>' '<p>\<code></p>'
+try 'backslashes before <{EOF}' '\<' '<p>&lt;</p>'
+try 'backslashes before <[space]' '\< j' '<p>&lt; j</p>'
+
 summary $0
 exit $rc

+ 108 - 8
discount/tests/code.t

@@ -31,16 +31,54 @@ try 'backslashes in code(1)' '    printf "%s: \n", $1;' \
 try 'backslashes in code(2)' '`printf "%s: \n", $1;`' \
 '<p><code>printf "%s: \n", $1;</code></p>'
 
-if ./markdown -V | grep FENCED-CODE >/dev/null; then
+try 'fenced code disabled backtick' \
+'```
 
-try 'fenced code block' \
+unrecognized code!
+```' \
+'<p>```</p>
+
+<p>unrecognized code!
+```</p>'
+
+# no <pre/> proves it’s the inline variant of `code` delimitation
+try 'fenced code disabled backtick as inline code' \
+'```
+inline code?
+```' \
+'<p><code>
+inline code?
+</code></p>'
+
+try 'fenced code disabled tilde' \
+'~~~
+
+unrecognized code!
+~~~' \
+'<p>~~~</p>
+
+<p>unrecognized code!
+~~~</p>'
+
+try -ffencedcode 'fenced code block with blank lines' \
 '~~~
 code!
+
+still code!
 ~~~' \
     '<pre><code>code!
+
+still code!
 </code></pre>'
 
-try 'fenced code block in list' \
+try  -ffencedcode 'fenced code block' \
+'~~~
+code!
+~~~' \
+    '<pre><code>code!
+</code></pre>'
+
+try  -ffencedcode 'fenced code block in list' \
 '1. ~~~
 code block
 ~~~' \
@@ -49,20 +87,20 @@ code block
 </code></pre></li>
 </ol>'
 
-try 'fenced code block in blockquote' \
+try  -ffencedcode 'fenced code block in blockquote' \
 '>~~~
 code
 ~~~' \
 '<blockquote><pre><code>code
 </code></pre></blockquote>'
 
-try 'unterminated fenced code block' \
+try  -ffencedcode 'unterminated fenced code block' \
 '~~~
 code' \
 '<p>~~~
 code</p>'
 
-try 'fenced code block with tildes' \
+try  -ffencedcode 'fenced code block with tildes' \
 '~~~~~
 ~~~
 code with tildes
@@ -73,7 +111,7 @@ code with tildes
 ~~~
 </code></pre>'
 
-try 'paragraph with trailing fenced block' \
+try  -ffencedcode 'paragraph with trailing fenced block' \
 'text text text
 text text text
 ~~~
@@ -85,7 +123,69 @@ text text text
 code code code?
 ~~~</p>'
 
-fi
+try  -ffencedcode 'fenced code blocks with backtick delimiters' \
+'```
+code
+```' \
+'<pre><code>code
+</code></pre>'
+
+try  -ffencedcode 'fenced code block with mismatched delimters' \
+'```
+code
+~~~' \
+'<p>```
+code
+~~~</p>'
+
+try  -ffencedcode 'fenced code block with lang attribute' \
+'```lang
+code
+```' \
+'<pre><code class="lang">code
+</code></pre>'
+
+try  -ffencedcode 'fenced code block with lang-name attribute' \
+'```lang-name
+code
+```' \
+'<pre><code class="lang-name">code
+</code></pre>'
+
+try  -ffencedcode 'fenced code block with lang_name attribute' \
+'```lang_name
+code
+```' \
+'<pre><code class="lang_name">code
+</code></pre>'
+
+try  -ffencedcode 'fenced code block with lang attribute and space' \
+'``` lang
+code
+```' \
+'<pre><code class="lang">code
+</code></pre>'
+
+try  -ffencedcode 'fenced code block with lang attribute and multiple spaces' \
+'```       lang
+code
+```' \
+'<pre><code class="lang">code
+</code></pre>'
+
+try  -ffencedcode 'fenced code block with lang-name attribute and space' \
+'``` lang-name
+code
+```' \
+'<pre><code class="lang-name">code
+</code></pre>'
+
+try  -ffencedcode 'fenced code block with lang_name attribute and space' \
+'``` lang_name
+code
+```' \
+'<pre><code class="lang_name">code
+</code></pre>'
 
 summary $0
 exit $rc

+ 25 - 0
discount/tests/defects.t

@@ -0,0 +1,25 @@
+. tests/functions.sh
+
+title "reported defects"
+
+rc=0
+MARKDOWN_FLAGS=
+
+try 'masses of non-block html' \
+'<span>foo</span><br>
+<br>
+<span>bar</span><br>' \
+'<p><span>foo</span><br>
+<br>
+<span>bar</span><br></p>'
+
+try -fautolink -G 'autolink + github-flavoured markdown' \
+'http://foo
+bar' \
+'<p><a href="http://foo">http://foo</a><br/>
+bar</p>'
+
+try 'unterminated <p> block' '<p></>*' '<p><p></>*</p>'
+
+summary $0
+exit $rc

+ 28 - 18
discount/tests/dl.t

@@ -2,10 +2,6 @@
 
 title "definition lists"
 
-eval `./markdown -V | tr ' ' '\n' | grep '^DL='`
-
-DL=${DL:-BOTH}
-
 rc=0
 MARKDOWN_FLAGS=
 
@@ -22,11 +18,11 @@ RSLT='<dl>
 <dd>eh?</dd>
 </dl>'
 
-if [ "$DL" = "DISCOUNT" -o "$DL" = "BOTH" ]; then
-    try -fdefinitionlist '=tag= generates definition lists' "$SRC" "$RSLT"
+# discount style
+try -fdefinitionlist '=tag= generates definition lists' "$SRC" "$RSLT"
 
-	try 'one item with two =tags=' \
-	    '=this=
+try 'one item with two =tags=' \
+    '=this=
 =is=
     A test, eh?' \
 	    '<dl>
@@ -35,16 +31,14 @@ if [ "$DL" = "DISCOUNT" -o "$DL" = "BOTH" ]; then
 <dd>A test, eh?</dd>
 </dl>'
 
-
-	try -fnodefinitionlist '=tag= does nothing' "$SRC" \
-	    '<p>=this=
+# extra style
+try -fnodefinitionlist,dlextra '=tag= does nothing' "$SRC" \
+    '<p>=this=
     is an ugly
 =test=
     eh?</p>'
-fi
 
-if [ "$DL" = "EXTRA" -o "$DL" = "BOTH" ]; then
-    try 'markdown extra-style definition lists' \
+try -fdlextra 'markdown extra-style definition lists' \
 'foo
 : bar' \
 '<dl>
@@ -52,7 +46,7 @@ if [ "$DL" = "EXTRA" -o "$DL" = "BOTH" ]; then
 <dd>bar</dd>
 </dl>'
 
-    try '... with two <dt>s in a row' \
+try -fdlextra '... with two <dt>s in a row' \
 'foo
 bar
 : baz' \
@@ -62,7 +56,7 @@ bar
 <dd>baz</dd>
 </dl>'
 
-    try '... with two <dd>s in a row' \
+try -fdlextra '... with two <dd>s in a row' \
 'foo
 : bar
 : baz' \
@@ -72,7 +66,7 @@ bar
 <dd>baz</dd>
 </dl>'
 
-    try '... with blanks between list items' \
+try -fdlextra '... with blanks between list items' \
 'foo
 : bar
 
@@ -85,7 +79,23 @@ zip
 <dd>zap</dd>
 </dl>'
 
-fi
+# Hmm, redundancy...
+SRC='foo
+: bar
+
+=this=
+    is ugly'
+RSLT='<p>foo
+: bar</p>
+
+<p>=this=
+    is ugly</p>'
+try -fnodldiscount '... with definitionlists enabled but all styles disabled' \
+"$SRC" \
+"$RSLT"
+try -fnodefinitionlist,dldiscount,dlextra '... with definitionlists disabled but all styles enabled' \
+    "$SRC" \
+    "$RSLT"
 
 summary $0
 exit $rc

+ 85 - 0
discount/tests/extrafootnotes.t

@@ -31,5 +31,90 @@ try -ffootnote -Cfoot 'footnotes (-ffootnote -Cfoot)' "$FOOTIE" \
 try -fnofootnote 'footnotes (-fnofootnote)' "$FOOTIE" \
 '<p>I haz a footnote<a href="yes?">^1</a></p>'
 
+
+TSRC='Alpha[^AlphaF].
+
+Column 1                         | Column 2
+---------------------------------|--------------------------
+Beta[^BetaF]                     | cell
+
+[^AlphaF]: Alpha Footnote
+
+[^BetaF]: Beta Footnote'
+
+TOUT='<p>Alpha<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup>.</p>
+
+<table>
+<thead>
+<tr>
+<th>Column 1                         </th>
+<th> Column 2</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td>Beta<sup id="fnref:2"><a href="#fn:2" rel="footnote">2</a></sup>                     </td>
+<td> cell</td>
+</tr>
+</tbody>
+</table>
+
+<div class="footnotes">
+<hr/>
+<ol>
+<li id="fn:1">
+<p>Alpha Footnote<a href="#fnref:1" rev="footnote">&#8617;</a></p></li>
+<li id="fn:2">
+<p>Beta Footnote<a href="#fnref:2" rev="footnote">&#8617;</a></p></li>
+</ol>
+</div>'
+
+try -ffootnote 'footnotes inside table elements' "$TSRC" "$TOUT"
+
+
+TSRC='[Test test[^test]](class:test)
+
+<span class="test">
+Test2[^testtwo]
+</span>
+
+Test3[^testthree]
+
+<span class="test">
+Test4[^testfour]
+</span>
+
+[^test]: Test footnote
+[^testtwo]: Test2 footnote
+[^testthree]: Test3 footnote
+[^testfour]: Test4 footnote'
+
+TOUT='<p><span class="test">Test test<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup></span></p>
+
+<p><span class="test">
+Test2<sup id="fnref:2"><a href="#fn:2" rel="footnote">2</a></sup>
+</span></p>
+
+<p>Test3<sup id="fnref:3"><a href="#fn:3" rel="footnote">3</a></sup></p>
+
+<p><span class="test">
+Test4<sup id="fnref:4"><a href="#fn:4" rel="footnote">4</a></sup>
+</span></p>
+<div class="footnotes">
+<hr/>
+<ol>
+<li id="fn:1">
+<p>Test footnote<a href="#fnref:1" rev="footnote">&#8617;</a></p></li>
+<li id="fn:2">
+<p>Test2 footnote<a href="#fnref:2" rev="footnote">&#8617;</a></p></li>
+<li id="fn:3">
+<p>Test3 footnote<a href="#fnref:3" rev="footnote">&#8617;</a></p></li>
+<li id="fn:4">
+<p>Test4 footnote<a href="#fnref:4" rev="footnote">&#8617;</a></p></li>
+</ol>
+</div>'
+
+try -ffootnote 'footnotes inside spans' "$TSRC" "$TOUT"
+
 summary $0
 exit $rc

+ 23 - 0
discount/tests/githubtags.t

@@ -0,0 +1,23 @@
+. tests/functions.sh
+
+title "github tags"
+
+rc=0
+MARKDOWN_FLAGS=
+
+SRC='<element-name>content</element-name>'
+
+try 'github tags disabled by default' \
+"$SRC" \
+'<p>&lt;element-name>content&lt;/element-name></p>'
+
+try -fgithubtags 'github tags' \
+"$SRC" \
+'<p><element-name>content</element-name></p>'
+
+try 'normal tags pass through' \
+'<a>sdf</a>' \
+'<p><a>sdf</a></p>'
+
+summary $0
+exit $rc

+ 0 - 55
discount/tests/html.t

@@ -23,23 +23,6 @@ text' \
 
 <p>text</p>'
 
-try 'self-closing block tags (br)' \
-    '<br>
-
-text' \
-    '<br>
-
-
-<p>text</p>'
-
-try 'html comments' \
-    '<!--
-**hi**
--->' \
-    '<!--
-**hi**
--->'
-    
 try 'no smartypants inside tags (#1)' \
     '<img src="linky">' \
     '<p><img src="linky"></p>'
@@ -91,50 +74,12 @@ so is this</div>'
 try 'unfinished tags' '<foo bar' '<p>&lt;foo bar</p>'
 
 
-try 'comment with trailing text' '<!-- this is -->a test' \
-'<!-- this is -->
-
-
-<p>a test</p>'
-
 try 'block with trailing text' '<p>this is</p>a test' \
 '<p>this is</p>
 
 
 <p>a test</p>'
 
-
-COMMENTS='<!-- 1. -->line 1
-
-<!-- 2. -->line 2'
-
-try 'two comments' "$COMMENTS" \
-'<!-- 1. -->
-
-
-<p>line 1</p>
-
-<!-- 2. -->
-
-
-<p>line 2</p>'
-
-COMMENTS='<!-- 1. -->line 1
-<!-- 2. -->line 2'
-
-try 'two adjacent comments' "$COMMENTS" \
-'<!-- 1. -->
-
-
-<p>line 1</p>
-
-<!-- 2. -->
-
-
-<p>line 2</p>'
-
-try 'comment, no white space' '<!--foo-->' '<!--foo-->'
-
 try 'unclosed block' '<p>here we go!' '<p><p>here we go!</p>'
 
 summary $0

+ 49 - 0
discount/tests/html_comment.t

@@ -0,0 +1,49 @@
+. tests/functions.sh
+
+title "html comments"
+
+rc=0
+MARKDOWN_FLAGS=
+
+try 'html comments' \
+    '<!--
+**hi**
+-->' \
+    '<!--
+**hi**
+-->'
+    
+try 'comment with trailing text' '<!-- this is -->a test' \
+'<p><!-- this is -->a test</p>'
+
+COMMENTS='<!-- 1. -->line 1
+
+<!-- 2. -->line 2'
+
+try 'two comments' "$COMMENTS" \
+'<p><!-- 1. -->line 1</p>
+
+<p><!-- 2. -->line 2</p>'
+
+COMMENTS='<!-- 1. -->line 1
+<!-- 2. -->line 2'
+
+try 'two adjacent comments' "$COMMENTS" \
+'<p><!-- 1. -->line 1
+<!-- 2. -->line 2</p>'
+
+try 'comment, no white space' '<!--foo-->' '<!--foo-->'
+
+try 'comment, indented end with trailing text' \
+'<!--
+    -->00000' \
+'<p><!--
+    -->00000</p>'
+
+try 'comment with leading text' 'Text text text<!--
+    -->' \
+'<p>Text text text<!--
+    --></p>'
+
+summary $0
+exit $rc

+ 30 - 0
discount/tests/latex.t

@@ -0,0 +1,30 @@
+. tests/functions.sh
+
+# don't run these tests unless --with-latex
+./markdown -V | grep LATEX >/dev/null || exit 0
+
+title "embedded latex"
+
+rc=0
+MARKDOWN_FLAGS=
+
+try 'latex w/ \( .. \)' '\(\tex\)' '<p>\(\tex\)</p>'
+try 'latex w/ \( .. \) and link inside' '\([(1+2)*3-4](1-2)\)' '<p>\([(1+2)*3-4](1-2)\)</p>'
+try 'latex w/ \( .. \) and special characters' 'Equation:\(a<+>b\).' \
+    '<p>Equation:\(a&lt;+&gt;b\).</p>'
+
+try 'latex $ delimiter not supported' '$[a](b)$' '<p>$<a href="b">a</a>$</p>'
+
+try 'latex with $$ .. $$' '$$foo$$' '<p>$$foo$$</p>'
+try 'latex with $$ .. $$ like a link' '$$[(1+2)*3-4](1-2)$$' '<p>$$[(1+2)*3-4](1-2)$$</p>'
+try 'latex with multiple $$ .. $$' '$$[a](b)$$$$[a](b)$$' '<p>$$[a](b)$$$$[a](b)$$</p>'
+try 'latex with $$ .. $$ and a real link' '$$[a](b)$$[a](b)$$' '<p>$$[a](b)$$<a href="b">a</a>$$</p>'
+try 'latex with $$ .. $$ and a real link' '$$[a](b)$$$[a](b)$$' '<p>$$[a](b)$$$<a href="b">a</a>$$</p>'
+try 'latex with $$ .. $$ multi lines' '$$\begin{split}\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\   \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\ \nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\ \nabla \cdot \vec{\mathbf{B}} & = 0 \end{split}$$' '<p>$$\begin{split}\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} &amp; = \frac{4\pi}{c}\vec{\mathbf{j}} \\   \nabla \cdot \vec{\mathbf{E}} &amp; = 4 \pi \rho \\ \nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} &amp; = \vec{\mathbf{0}} \\ \nabla \cdot \vec{\mathbf{B}} &amp; = 0 \end{split}$$</p>'
+
+try 'latex with \[ .. \]' '\[foo\]' '<p>\[foo\]</p>'
+try 'latex with \[ .. \] and link inside' '\[[(1+2)*3-4](1-2)\]' '<p>\[[(1+2)*3-4](1-2)\]</p>'
+try 'latex with \[ .. \] multi lines' '\[\begin{split}\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\   \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\ \nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\ \nabla \cdot \vec{\mathbf{B}} & = 0 \end{split}\]' '<p>\[\begin{split}\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} &amp; = \frac{4\pi}{c}\vec{\mathbf{j}} \\   \nabla \cdot \vec{\mathbf{E}} &amp; = 4 \pi \rho \\ \nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} &amp; = \vec{\mathbf{0}} \\ \nabla \cdot \vec{\mathbf{B}} &amp; = 0 \end{split}\]</p>'
+
+summary $0
+exit $rc

+ 8 - 1
discount/tests/linkylinky.t

@@ -10,7 +10,14 @@ try 'url contains +' '[hehehe](u+rl)' '<p><a href="u+rl">hehehe</a></p>'
 try 'url contains "' '[hehehe](u"rl)' '<p><a href="u%22rl">hehehe</a></p>'
 try 'url contains <' '[hehehe](u<rl)' '<p><a href="u&lt;rl">hehehe</a></p>'
 try 'url contains whitespace' '[ha](r u)' '<p><a href="r%20u">ha</a></p>'
-try 'label contains escaped []s' '[a\[b\]c](d)' '<p><a href="d">a[b]c</a></p>'
+
+# latex collides with this test
+if ./markdown -V | grep LATEX >/dev/null; then
+    RESULT='<p><a href="d">a\[b\]c</a></p>'
+else
+    RESULT='<p><a href="d">a[b]c</a></p>'
+fi
+try 'label contains escaped []s' '[a\[b\]c](d)' "$RESULT"
 
 try '<label> w/o title' '[hello](<sailor>)' '<p><a href="sailor">hello</a></p>'
 try '<label> with title' '[hello](<sailor> "boy")' '<p><a href="sailor" title="boy">hello</a></p>'

+ 44 - 3
discount/tests/list.t

@@ -61,9 +61,9 @@ try 'nested lists (2)' \
 <li><p>A (list)</p>
 
 <ol>
-<li> Sub (list)</li>
-<li> Two (items)</li>
-<li> Here</li>
+<li>Sub (list)</li>
+<li>Two (items)</li>
+<li>Here</li>
 </ol>
 
 
@@ -151,5 +151,46 @@ try 'non-dl followed by dl' \
 <dd>hi!</dd>
 </dl>'
 
+try 'long enumerated list tag' \
+    '10000. This is an item
+
+    and this is another paragraph in the same
+    item.
+
+2. and this is another item.
+' \
+'<ol>
+<li><p>This is an item</p>
+
+<p>and this is another paragraph in the same
+item.</p></li>
+<li><p>and this is another item.</p></li>
+</ol>'
+
+try 'long enumerated list tag' \
+    '10000. This is an item
+
+    and this is another paragraph in the same
+    item.
+
+    200000. A longer number in an embedded list.
+    200001. Another longer and bigger number in an embedded list.
+
+2. and this is another item.
+' \
+'<ol>
+<li><p>This is an item</p>
+
+<p>and this is another paragraph in the same
+item.</p>
+
+<ol>
+<li>A longer number in an embedded list.</li>
+<li>Another longer and bigger number in an embedded list.</li>
+</ol>
+</li>
+<li><p>and this is another item.</p></li>
+</ol>'
+
 summary $0
 exit $rc

+ 144 - 0
discount/tests/muñoz.t

@@ -0,0 +1,144 @@
+. tests/functions.sh
+
+title "data corruption cases from Fernando MuĂąoz"
+
+rc=0
+MARKDOWN_FLAGS=
+
+ try 'id_000002_06' '<p></
+ >0' '<p><p>&lt;/</p>
+
+<blockquote><p>0</p></blockquote>'
+ try 'id_000009_06' '<pre
+ </pr>0' '<p><pre
+ </pr>0</p>'
+ try 'id_000010_06' '<pre></pr>>' '<p><pre></pr>></p>'
+ try 'id_000014_06' '<div></di>-' '<p><div></di>-</p>'
+ try 'id_000015_06' '<div></di>>' '<p><div></di>></p>'
+ try 'id_000018_06' '<div></di>#0' '<p><div></di>#0</p>'
+ try 'id_000029_06' '<div </di>#0' '<p><div </di>#0</p>'
+ try 'id_000031_06' '<div </di>>' '<p><div </di>></p>'
+ try 'id_000032_06' '<div <di </di></di>*' '<p><div <di </di></di>*</p>'
+ try 'id_000038_06' '<p>
+    </>00000' '<p><p>
+    </>00000</p>'
+ try 'id_000039_06' '<dl></d>>' '<p><dl></d>></p>'
+ try 'id_000040_06' '<dl></d
+	>00000' '<p><dl></d
+        >00000</p>'
+ try 'id_000043_06' '<dl
+<</d>>' '<p><dl
+<</d>></p>'
+ try 'id_000048_06' '<dl></d
+    >00000' '<p><dl></d
+    >00000</p>'
+ try 'id_000049_06' '<table></tabl>*' '<p><table></tabl>*</p>'
+ try 'id_000057_06' '<table></tabl>-' '<p><table></tabl>-</p>'
+ try 'id_000062_06' '<table></tabl>+' '<p><table></tabl>+</p>'
+ try 'id_000067_06' '<div </di>-' '<p><div </di>-</p>'
+ try 'id_000072_06' '<ul></u>-' '<p><ul></u>-</p>'
+ try 'id_000074_06' '<ul></u>>' '<p><ul></u>></p>'
+ try 'id_000080_06' '<ul
+ </u>0' '<p><ul
+ </u>0</p>'
+ try 'id_000081_06' '<p></
+    >00000' '<p><p></
+    >00000</p>'
+ try 'id_000083_06' '<ul
+    </u>00000' '<p><ul
+    </u>00000</p>'
+ try 'id_000084_06' '<ul></u>*' '<p><ul></u>*</p>'
+ try 'id_000089_06' '<p></>*' '<p><p></>*</p>'
+ try 'id_000099_06' '<p></>0.' '<p><p></>0.</p>'
+ try 'id_000105_06' '<div></di>+' '<p><div></di>+</p>'
+ try 'id_000108_06' '<p><!--
+    ˙</>00000' '<p><p>&lt;!&ndash;
+    </p>'
+ try 'id_000116_06' '<div></di>0.' '<p><div></di>0.</p>'
+ try 'id_000119_06' '<div></di
+    >00000' '<p><div></di
+    >00000</p>'
+ try 'id_000120_06' '<!-->>' '<p><!-->></p>'
+ try 'id_000128_06' '<p></>#0' '<p><p></>#0</p>'
+ try 'id_000130_06' '<blockquote
+ </blockquot>0' '<p><blockquote
+ </blockquot>0</p>'
+ try 'id_000135_06' '<h2></h>>' '<p><h2></h>></p>'
+ try 'id_000136_06' '<p 
+ </>0' '<p><p
+ </>0</p>'
+ try 'id_000143_06' '<h2></h>0.' '<p><h2></h>0.</p>'
+ try 'id_000148_06' '<p 
+    </>00000' '<p><p
+    </>00000</p>'
+ try 'id_000150_06' '<h2 </h>-' '<p><h2 </h>-</p>'
+ try 'id_000152_06' '<p></
+	>00000' '<p><p></
+        >00000</p>'
+ try 'id_000153_06' '<p/
+ </>0' '<p><p/
+ </>0</p>'
+ try 'id_000158_06' '<div </di>+' '<p><div </di>+</p>'
+ try 'id_000163_06' '<div></di
+	>00000' '<p><div></di
+        >00000</p>'
+ try 'id_000164_06' '<div></di
+ >0' '<p><div>&lt;/di</p>
+
+<blockquote><p>0</p></blockquote>'
+ try 'id_000167_06' '<div </di
+	>00000' '<p><div </di
+        >00000</p>'
+ try 'id_000173_06' '<dl></d
+ >0' '<p><dl>&lt;/d</p>
+
+<blockquote><p>0</p></blockquote>'
+ try 'id_000174_06' '<dl></d>+' '<p><dl></d>+</p>'
+ try 'id_000175_06' '<dl></d>=0=
+    0' '<p><dl></d>=0=
+    0</p>'
+ try 'id_000176_06' '<dl
+ </d>0' '<p><dl
+ </d>0</p>'
+ try 'id_000177_06' '<dl
+    </d>00000' '<p><dl
+    </d>00000</p>'
+ try 'id_000182_06' '<p></>-' '<p><p></>-</p>'
+ try 'id_000189_06' '<ol></o>#0' '<p><ol></o>#0</p>'
+ try 'id_000190_06' '<p/</>*' '<p>&lt;p/</>*</p>'
+ try 'id_000192_06' '<div </di>*' '<p><div </di>*</p>'
+ try 'id_000197_06' '<ul></u
+ >0' '<p><ul>&lt;/u</p>
+
+<blockquote><p>0</p></blockquote>'
+ try 'id_000201_06' '<ul></u>+' '<p><ul></u>+</p>'
+ try 'id_000203_06' '<ul></u
+    >00000' '<p><ul></u
+    >00000</p>'
+ try 'id_000209_06' '<!--
+    -->00000' '<p><!--
+    -->00000</p>'
+ try 'id_000211_06' '<p></>+' '<p><p></>+</p>'
+ try 'id_000219_06' '<!-->*' '<p><!-->*</p>'
+ try 'id_000222_06' '<p/</>-' '<p>&lt;p/</>-</p>'
+ try 'id_000223_06' '<!--
+	-->00000' '<p><!--
+        -->00000</p>'
+ try 'id_000224_06' '<!-->0.' '<p><!-->0.</p>'
+ try 'id_000226_06' '<p>
+ </>0' '<p><p>
+ </>0</p>'
+ try 'id_000228_06' '<div></di>*' '<p><div></di>*</p>'
+ try 'id_000231_06' '<div
+ </di>0' '<p><div
+ </di>0</p>'
+ try 'id_000238_06' '<p></>[]' '<p><p></>[]</p>'
+ try 'id_000240_06' '<h2
+ </h>0' '<p><h2
+ </h>0</p>'
+ try 'id_000243_06' '<p </>>' '<p><p </>></p>'
+ try 'id_000246_06' '<p></>>' '<p><p></>></p>'
+ try 'id_000248_06' '<p </>[]' '<p><p </>[]</p>'
+
+summary $0
+exit $rc 

+ 2 - 0
discount/tests/style.t

@@ -30,5 +30,7 @@ try 'multiple lines unclosed' "$UNCLOSED" "$RESULT"
 
 try -fnohtml 'unclosed with -fnohtml' '<style>foo' '<p>&lt;style>foo</p>'
 
+try -fnostyle 'disabling style blocks' "$ASK" "$ASK"
+
 summary $0
 exit $rc

+ 0 - 5
discount/tests/syntax.text

@@ -38,11 +38,6 @@ can [see the source for it by adding '.text' to the URL][src].
 
 * * *
 
-Header 1            {#header1}
-========
-
-## Header 2 ##      {#header2}
-
 <h2 id="overview">Overview</h2>
 
 <h3 id="philosophy">Philosophy</h3>

+ 26 - 8
discount/tests/tables.t

@@ -89,10 +89,6 @@ hello|
 </tbody>
 </table>'
 
-  a  |  b
-----:|:-----
-hello|sailor
-
 try 'two-column table with alignment' \
     '
   a  |  b
@@ -101,14 +97,14 @@ hello|sailor' \
     '<table>
 <thead>
 <tr>
-<th align="right">a  </th>
-<th align="left">  b</th>
+<th style="text-align:right;">a  </th>
+<th style="text-align:left;">  b</th>
 </tr>
 </thead>
 <tbody>
 <tr>
-<td align="right">hello</td>
-<td align="left">sailor</td>
+<td style="text-align:right;">hello</td>
+<td style="text-align:left;">sailor</td>
 </tr>
 </tbody>
 </table>'
@@ -254,5 +250,27 @@ try "table with flanking |'s" \
 </tbody>
 </table>'
 
+try "table with leading |'s and alignment" \
+'|AA|BB|CC
+|:-|::|-:
+|aa|bb|cc' \
+'<table>
+<thead>
+<tr>
+<th style="text-align:left;">AA</th>
+<th style="text-align:center;">BB</th>
+<th style="text-align:right;">CC</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td style="text-align:left;">aa</td>
+<td style="text-align:center;">bb</td>
+<td style="text-align:right;">cc</td>
+</tr>
+</tbody>
+</table>'
+
+
 summary $0
 exit $rc

+ 48 - 29
discount/tests/toc.t

@@ -4,14 +4,13 @@
 rc=0
 MARKDOWN_FLAGS=
 
-if ./markdown -V | grep ID-ANCHOR >/dev/null; then
-    # old-style; uses id= tag (and collides
-    # with #-style css)
-
-    title "(old) table-of-contents support"
-    
-    try '-T -ftoc' 'table of contents' \
-    '#H1
+# old-style; uses id= tag (and collides
+# with #-style css)
+
+title "(old) table-of-contents support"
+
+try -fidanchor '-T -ftoc' 'table of contents' \
+'#H1
 hi' \
 '<ul>
  <li><a href="#H1">H1</a></li>
@@ -20,30 +19,40 @@ hi' \
 
 <p>hi</p>'
 
-    try '-T -ftoc' 'toc item with link' \
-    '##[H2](H2) here' \
+try -fidanchor -fnourlencodedanchor '-T -ftoc' 'toc item with link' \
+'##[H2](H2) here' \
 '<ul>
- <li><ul>
+ <li>
+ <ul>
   <li><a href="#H2.here">H2 here</a></li>
- </ul></li>
+ </ul>
+ </li>
 </ul>
 <h2 id="H2.here"><a href="H2">H2</a> here</h2>'  
 
-    try '-T -ftoc' 'toc item with non-alpha start' \
-    '#1 header' \
+try -fidanchor -fnourlencodedanchor '-T -ftoc' 'toc item with non-alpha start' \
+'#1 header' \
 '<ul>
  <li><a href="#L1.header">1 header</a></li>
 </ul>
 <h1 id="L1.header">1 header</h1>'
 
-else
-    # new-style; uses a (depreciated) name=
-    # inside a null <a> tag
-    
-    title "(new) table-of-contents support"
-    
-    try '-T -ftoc' 'table of contents' \
-    '#H1
+try -fidanchor -furlencodedanchor '-T -ftoc' 'toc item with non-alpha start (url encoded)' \
+'#1 header' \
+'<ul>
+ <li><a href="#1%20header">1 header</a></li>
+</ul>
+<h1 id="1%20header">1 header</h1>'
+
+summary $0
+
+# new-style; uses a (depreciated) name=
+# inside a null <a> tag
+
+title "(new) table-of-contents support"
+
+try '-T -ftoc' 'table of contents' \
+'#H1
 hi' \
 '<ul>
  <li><a href="#H1">H1</a></li>
@@ -53,24 +62,34 @@ hi' \
 
 <p>hi</p>'
 
-    try '-T -ftoc' 'toc item with link' \
-    '##[H2](H2) here' \
+try '-T -ftoc' 'toc item with link' \
+'##[H2](H2) here' \
 '<ul>
- <li><ul>
+ <li>
+ <ul>
   <li><a href="#H2.here">H2 here</a></li>
- </ul></li>
+ </ul>
+ </li>
 </ul>
 <a name="H2.here"></a>
 <h2><a href="H2">H2</a> here</h2>'  
 
-    try '-T -ftoc' 'toc item with non-alpha start' \
-    '#1 header' \
+try '-T -ftoc' 'toc item with non-alpha start' \
+'#1 header' \
 '<ul>
  <li><a href="#L1.header">1 header</a></li>
 </ul>
 <a name="L1.header"></a>
 <h1>1 header</h1>'
-fi
+
+# Be sure to save toc.t as UTF-8.
+try '-T -ftoc,urlencodedanchor' 'urlencoded multibyte chars' \
+'#It’s an apostrophe' \
+'<ul>
+ <li><a href="#It%e2%80%99s%20an%20apostrophe">It’s an apostrophe</a></li>
+</ul>
+<a name="It%e2%80%99s%20an%20apostrophe"></a>
+<h1>It’s an apostrophe</h1>'
 
 summary $0
 exit $rc