git.iko.soy/typeable/pandoc
on master help sign in
Markdown reader: Fixed bug with headerless grid tables.
af84953John MacFarlane
src/Text/Pandoc/Readers/Markdown.hs+2−2
@@ -1110,7 +1110,7 @@ gridTableHeader headless = try $ do
1110 then replicate (length dashes) ""
1110 then replicate (length dashes) ""
1111 else map (intercalate " ") $ transpose
1111 else map (intercalate " ") $ transpose
1112 $ map (gridTableSplitLine indices) rawContent
1112 $ map (gridTableSplitLine indices) rawContent
1113− heads <- fmap sequence $ mapM (parseFromString block) $
1113+ heads <- fmap sequence $ mapM (parseFromString parseBlocks) $
1114 map trim rawHeads
1114 map trim rawHeads
1115 return (heads, aligns, indices)
1115 return (heads, aligns, indices)
1116
1116
@@ -1127,7 +1127,7 @@ gridTableRow indices = do
1127 colLines <- many1 (gridTableRawLine indices)
1127 colLines <- many1 (gridTableRawLine indices)
1128 let cols = map ((++ "\n") . unlines . removeOneLeadingSpace) $
1128 let cols = map ((++ "\n") . unlines . removeOneLeadingSpace) $
1129 transpose colLines
1129 transpose colLines
1130− fmap compactify' <$> fmap sequence (mapM (parseFromString block) cols)
1130+ fmap compactify' <$> fmap sequence (mapM (parseFromString parseBlocks) cols)
1131
1131
1132removeOneLeadingSpace :: [String] -> [String]
1132removeOneLeadingSpace :: [String] -> [String]
1133removeOneLeadingSpace xs =
1133removeOneLeadingSpace xs =
tests/markdown-reader-more.native+52−1
@@ -67,4 +67,55 @@
67,Header 2 ("foobar",["baz"],[("key","val")]) [Str "Explicit",Space,Str "header",Space,Str "attributes"]
67,Header 2 ("foobar",["baz"],[("key","val")]) [Str "Explicit",Space,Str "header",Space,Str "attributes"]
68,Header 2 ("line-blocks",[],[]) [Str "Line",Space,Str "blocks"]
68,Header 2 ("line-blocks",[],[]) [Str "Line",Space,Str "blocks"]
69,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?"]
69,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?"]
70−,Para [Str "Continuation",Space,Str "line",LineBreak,Str "\160\160and",Space,Str "another"]]
70+,Para [Str "Continuation",Space,Str "line",LineBreak,Str "\160\160and",Space,Str "another"]
71+,Header 2 ("grid-tables",[],[]) [Str "Grid",Space,Str "Tables"]
72+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.2638888888888889,0.16666666666666666,0.18055555555555555]
73+ [[Plain [Str "col",Space,Str "1"]]
74+ ,[Plain [Str "col",Space,Str "2"]]
75+ ,[Plain [Str "col",Space,Str "3"]]]
76+ [[[Para [Str "r1",Space,Str "a",Space,Str "r1",Space,Str "bis"]]
77+ ,[Para [Str "b",Space,Str "b",Space,Str "2"]]
78+ ,[Para [Str "c",Space,Str "c",Space,Str "2"]]]
79+ ,[[Para [Str "r2",Space,Str "d"]]
80+ ,[Para [Str "e"]]
81+ ,[Para [Str "f"]]]]
82+,Para [Str "Headless"]
83+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.2638888888888889,0.16666666666666666,0.18055555555555555]
84+ [[]
85+ ,[]
86+ ,[]]
87+ [[[Para [Str "r1",Space,Str "a",Space,Str "r1",Space,Str "bis"]]
88+ ,[Para [Str "b",Space,Str "b",Space,Str "2"]]
89+ ,[Para [Str "c",Space,Str "c",Space,Str "2"]]]
90+ ,[[Para [Str "r2",Space,Str "d"]]
91+ ,[Para [Str "e"]]
92+ ,[Para [Str "f"]]]]
93+,Para [Str "Spaces",Space,Str "at",Space,Str "ends",Space,Str "of",Space,Str "lines"]
94+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.2638888888888889,0.16666666666666666,0.18055555555555555]
95+ [[]
96+ ,[]
97+ ,[]]
98+ [[[Para [Str "r1",Space,Str "a",Space,Str "r1",Space,Str "bis"]]
99+ ,[Para [Str "b",Space,Str "b",Space,Str "2"]]
100+ ,[Para [Str "c",Space,Str "c",Space,Str "2"]]]
101+ ,[[Para [Str "r2",Space,Str "d"]]
102+ ,[Para [Str "e"]]
103+ ,[Para [Str "f"]]]]
104+,Para [Str "Multiple",Space,Str "blocks",Space,Str "in",Space,Str "a",Space,Str "cell"]
105+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.2638888888888889,0.16666666666666666,0.18055555555555555]
106+ [[]
107+ ,[]
108+ ,[]]
109+ [[[Header 1 ("col-1",[],[]) [Str "col",Space,Str "1"]
110+ ,Para [Str "col",Space,Str "1"]]
111+ ,[Header 1 ("col-2",[],[]) [Str "col",Space,Str "2"]
112+ ,Para [Str "col",Space,Str "2"]]
113+ ,[Header 1 ("col-3",[],[]) [Str "col",Space,Str "3"]
114+ ,Para [Str "col",Space,Str "3"]]]
115+ ,[[Para [Str "r1",Space,Str "a"]
116+ ,Para [Str "r1",Space,Str "bis"]]
117+ ,[BulletList
118+ [[Plain [Str "b"]]
119+ ,[Plain [Str "b",Space,Str "2"]]
120+ ,[Plain [Str "b",Space,Str "2"]]]]
121+ ,[Para [Str "c",Space,Str "c",Space,Str "2",Space,Str "c",Space,Str "2"]]]]]
tests/markdown-reader-more.txt+39
@@ -162,3 +162,42 @@ But this is not a link to [My other header], since the reference is defined.
162| and
162| and
163 another
163 another
164
164
165+## Grid Tables
166+
167++------------------+-----------+------------+
168+| col 1 | col 2 | col 3 |
169++==================+===========+============+
170+| r1 a | b | c |
171+| r1 bis | b 2 | c 2 |
172++------------------+-----------+------------+
173+| r2 d | e | f |
174++------------------+-----------+------------+
175+
176+Headless
177+
178++------------------+-----------+------------+
179+| r1 a | b | c |
180+| r1 bis | b 2 | c 2 |
181++------------------+-----------+------------+
182+| r2 d | e | f |
183++------------------+-----------+------------+
184+
185+Spaces at ends of lines
186+
187++------------------+-----------+------------+
188+| r1 a | b | c |
189+| r1 bis | b 2 | c 2 |
190++------------------+-----------+------------+
191+| r2 d | e | f |
192++------------------+-----------+------------+
193+
194+Multiple blocks in a cell
195+
196++------------------+-----------+------------+
197+| # col 1 | # col 2 | # col 3 |
198+| col 1 | col 2 | col 3 |
199++------------------+-----------+------------+
200+| r1 a | - b | c |
201+| | - b 2 | c 2 |
202+| r1 bis | - b 2 | c 2 |
203++------------------+-----------+------------+