From af849537819885694cc4487056721480ab21067d Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 21 Jan 2013 09:50:39 -0800 Subject: Markdown reader: Fixed bug with headerless grid tables. The 1.10 code assumed that each table header cell contains exactly one block. That failed for headerless tables (0) and also for tables with multiple blocks in a header cell. The code is fixed and tests provided. Thanks to Andrew Lee for pointing out the bug. --- tests/markdown-reader-more.native | 53 ++++++++++++++++++++++++++++++++++++++- tests/markdown-reader-more.txt | 39 ++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/markdown-reader-more.native b/tests/markdown-reader-more.native index e76b12918..382aa056c 100644 --- a/tests/markdown-reader-more.native +++ b/tests/markdown-reader-more.native @@ -67,4 +67,55 @@ ,Header 2 ("foobar",["baz"],[("key","val")]) [Str "Explicit",Space,Str "header",Space,Str "attributes"] ,Header 2 ("line-blocks",[],[]) [Str "Line",Space,Str "blocks"] ,Para [Str "But",Space,Str "can",Space,Str "a",Space,Str "bee",Space,Str "be",Space,Str "said",Space,Str "to",Space,Str "be",LineBreak,Str "\160\160\160\160or",Space,Str "not",Space,Str "to",Space,Str "be",Space,Str "an",Space,Str "entire",Space,Str "bee,",LineBreak,Str "\160\160\160\160\160\160\160\160when",Space,Str "half",Space,Str "the",Space,Str "bee",Space,Str "is",Space,Str "not",Space,Str "a",Space,Str "bee,",LineBreak,Str "\160\160\160\160\160\160\160\160\160\160\160\160due",Space,Str "to",Space,Str "some",Space,Str "ancient",Space,Str "injury?"] -,Para [Str "Continuation",Space,Str "line",LineBreak,Str "\160\160and",Space,Str "another"]] +,Para [Str "Continuation",Space,Str "line",LineBreak,Str "\160\160and",Space,Str "another"] +,Header 2 ("grid-tables",[],[]) [Str "Grid",Space,Str "Tables"] +,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.2638888888888889,0.16666666666666666,0.18055555555555555] + [[Plain [Str "col",Space,Str "1"]] + ,[Plain [Str "col",Space,Str "2"]] + ,[Plain [Str "col",Space,Str "3"]]] + [[[Para [Str "r1",Space,Str "a",Space,Str "r1",Space,Str "bis"]] + ,[Para [Str "b",Space,Str "b",Space,Str "2"]] + ,[Para [Str "c",Space,Str "c",Space,Str "2"]]] + ,[[Para [Str "r2",Space,Str "d"]] + ,[Para [Str "e"]] + ,[Para [Str "f"]]]] +,Para [Str "Headless"] +,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.2638888888888889,0.16666666666666666,0.18055555555555555] + [[] + ,[] + ,[]] + [[[Para [Str "r1",Space,Str "a",Space,Str "r1",Space,Str "bis"]] + ,[Para [Str "b",Space,Str "b",Space,Str "2"]] + ,[Para [Str "c",Space,Str "c",Space,Str "2"]]] + ,[[Para [Str "r2",Space,Str "d"]] + ,[Para [Str "e"]] + ,[Para [Str "f"]]]] +,Para [Str "Spaces",Space,Str "at",Space,Str "ends",Space,Str "of",Space,Str "lines"] +,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.2638888888888889,0.16666666666666666,0.18055555555555555] + [[] + ,[] + ,[]] + [[[Para [Str "r1",Space,Str "a",Space,Str "r1",Space,Str "bis"]] + ,[Para [Str "b",Space,Str "b",Space,Str "2"]] + ,[Para [Str "c",Space,Str "c",Space,Str "2"]]] + ,[[Para [Str "r2",Space,Str "d"]] + ,[Para [Str "e"]] + ,[Para [Str "f"]]]] +,Para [Str "Multiple",Space,Str "blocks",Space,Str "in",Space,Str "a",Space,Str "cell"] +,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.2638888888888889,0.16666666666666666,0.18055555555555555] + [[] + ,[] + ,[]] + [[[Header 1 ("col-1",[],[]) [Str "col",Space,Str "1"] + ,Para [Str "col",Space,Str "1"]] + ,[Header 1 ("col-2",[],[]) [Str "col",Space,Str "2"] + ,Para [Str "col",Space,Str "2"]] + ,[Header 1 ("col-3",[],[]) [Str "col",Space,Str "3"] + ,Para [Str "col",Space,Str "3"]]] + ,[[Para [Str "r1",Space,Str "a"] + ,Para [Str "r1",Space,Str "bis"]] + ,[BulletList + [[Plain [Str "b"]] + ,[Plain [Str "b",Space,Str "2"]] + ,[Plain [Str "b",Space,Str "2"]]]] + ,[Para [Str "c",Space,Str "c",Space,Str "2",Space,Str "c",Space,Str "2"]]]]] diff --git a/tests/markdown-reader-more.txt b/tests/markdown-reader-more.txt index b8ff74f26..b76b6d985 100644 --- a/tests/markdown-reader-more.txt +++ b/tests/markdown-reader-more.txt @@ -162,3 +162,42 @@ But this is not a link to [My other header], since the reference is defined. | and another +## Grid Tables + ++------------------+-----------+------------+ +| col 1 | col 2 | col 3 | ++==================+===========+============+ +| r1 a | b | c | +| r1 bis | b 2 | c 2 | ++------------------+-----------+------------+ +| r2 d | e | f | ++------------------+-----------+------------+ + +Headless + ++------------------+-----------+------------+ +| r1 a | b | c | +| r1 bis | b 2 | c 2 | ++------------------+-----------+------------+ +| r2 d | e | f | ++------------------+-----------+------------+ + +Spaces at ends of lines + ++------------------+-----------+------------+ +| r1 a | b | c | +| r1 bis | b 2 | c 2 | ++------------------+-----------+------------+ +| r2 d | e | f | ++------------------+-----------+------------+ + +Multiple blocks in a cell + ++------------------+-----------+------------+ +| # col 1 | # col 2 | # col 3 | +| col 1 | col 2 | col 3 | ++------------------+-----------+------------+ +| r1 a | - b | c | +| | - b 2 | c 2 | +| r1 bis | - b 2 | c 2 | ++------------------+-----------+------------+ -- cgit v1.2.3