git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: Retain the Div around tables with attributes.

We'll need this to store table attributes until all writers are adjusted to react to attributes on the Table element.

commit9b7282bb0f27546354b777d2174c26fb88c8e110 authorJohn MacFarlane <jgm@berkeley.edu> dateTue 23 Jun 2020, 11:12 (6 years ago) parent3b25511
3 files changed+34−33
changelog.md−7 src/Text/Pandoc/Readers/LaTeX.hs+8−1 test/command/6137.md+26−25
changelog.md−7
@@ -89,13 +89,6 @@
8989 for the part after the initial capital. Ensure that both
9090 arguments are parsed, so that in Markdown both
9191 are treated as raw LateX. (Closes #6258.)
92− + Don't put surrounding Div around Table.
93− This reverts a change in the last release; the Div is
94− no longer needed, because we can now put the id right in
95− the Table's attributes. However, writers may still need
96− to be modified to do something with the id in a Table
97− (e.g. create an anchor), so in the short term we may lose
98− the ability to link to tables in some writers.
9992
10093 * Org reader (Albert Krewinkel):
10194
src/Text/Pandoc/Readers/LaTeX.hs+8−1
@@ -2433,9 +2433,16 @@ addTableCaption = walkM go
24332433 ((_,classes,kvs), Just ident) ->
24342434 (ident,classes,kvs)
24352435 _ -> attr
2436− return $ Table attr' capt spec th tb tf
2436+ return $ addAttrDiv attr' $ Table nullAttr capt spec th tb tf
24372437 go x = return x
24382438
2439+-- TODO: For now we add a Div to contain table attributes, since
2440+-- most writers don't do anything yet with attributes on Table.
2441+-- This can be removed when that changes.
2442+addAttrDiv :: Attr -> Block -> Block
2443+addAttrDiv ("",[],[]) b = b
2444+addAttrDiv attr b = Div attr [b]
2445+
24392446block :: PandocMonad m => LP m Blocks
24402447block = do
24412448 res <- (mempty <$ spaces1)
test/command/6137.md+26−25
@@ -16,31 +16,32 @@ This reference to Figure \ref{fig:label} works fine.
1616\end{figure}
1717^D
1818[Para [Str "This",Space,Str "reference",Space,Str "to",Space,Str "Table",Space,Link ("",[],[("reference-type","ref"),("reference","tbl:label")]) [Str "1"] ("#tbl:label",""),Space,Str "doesn\8217t",Space,Str "work."]
19−,Table ("tbl:label",[],[]) (Caption Nothing
20− [Plain [Str "This",Space,Str "caption",Space,Str "has",Space,Str "no",Space,Str "number."]])
21− [(AlignLeft,ColWidthDefault)
22− ,(AlignCenter,ColWidthDefault)
23− ,(AlignRight,ColWidthDefault)]
24− (TableHead ("",[],[])
25− [])
26− [(TableBody ("",[],[]) (RowHeadColumns 0)
27− []
28− [Row ("",[],[])
29− [Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
30− [Plain [Str "\8212\8212\8211"]]
31− ,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
32− [Plain [Str "\8212\8212\8211"]]
33− ,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
34− [Plain [Str "\8212\8212\8211"]]]
35− ,Row ("",[],[])
36− [Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
37− [Plain [Str "\8212\8212\8211"]]
38− ,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
39− [Plain [Str "\8212\8212\8211"]]
40− ,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
41− [Plain [Str "\8212\8212\8211"]]]])]
42− (TableFoot ("",[],[])
43− [])
19+,Div ("tbl:label",[],[])
20+ [Table ("",[],[]) (Caption Nothing
21+ [Plain [Str "This",Space,Str "caption",Space,Str "has",Space,Str "no",Space,Str "number."]])
22+ [(AlignLeft,ColWidthDefault)
23+ ,(AlignCenter,ColWidthDefault)
24+ ,(AlignRight,ColWidthDefault)]
25+ (TableHead ("",[],[])
26+ [])
27+ [(TableBody ("",[],[]) (RowHeadColumns 0)
28+ []
29+ [Row ("",[],[])
30+ [Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
31+ [Plain [Str "\8212\8212\8211"]]
32+ ,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
33+ [Plain [Str "\8212\8212\8211"]]
34+ ,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
35+ [Plain [Str "\8212\8212\8211"]]]
36+ ,Row ("",[],[])
37+ [Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
38+ [Plain [Str "\8212\8212\8211"]]
39+ ,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
40+ [Plain [Str "\8212\8212\8211"]]
41+ ,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
42+ [Plain [Str "\8212\8212\8211"]]]])]
43+ (TableFoot ("",[],[])
44+ [])]
4445,Para [Str "This",Space,Str "reference",Space,Str "to",Space,Str "Figure",Space,Link ("",[],[("reference-type","ref"),("reference","fig:label")]) [Str "1"] ("#fig:label",""),Space,Str "works",Space,Str "fine."]
4546,Para [Image ("fig:label",[],[("width","\\textwidth")]) [Str "A",Space,Str "numbered",Space,Str "caption,",Space,Str "if",Space,Str "I",Space,Str "use",Space,Str "pandoc-crossref."] ("example.png","fig:")]]
4647```