git.iko.soy/typeable/pandoc
on master help sign in
Docx reader: Move pandoc inline styling inside custom-style span

Previously Emph, Strong, etc were outside the custom-style span. This moves them inside in order to make it easier to write filters that act on the formatting in these contents. Tests and MANUAL example are changed to match.

commit8b7df2d915fb4cedb99e60188b0899de9b8b7024 authorJesse Rosenthal <jrosenthal@jhu.edu> dateThu 22 Feb 2018, 13:39 (9 years ago) parent87e0728
3 files changed+10−10
MANUAL.txt+2−2 src/Text/Pandoc/Readers/Docx.hs+7−7 test/docx/custom-style-with-styles.native+1−1
MANUAL.txt+2−2
@@ -4538,8 +4538,8 @@ And with the extension:
45384538 :::
45394539
45404540 ::: {custom-style="BodyText"}
4541− This is text with an *[emphasized]{custom-style="Emphatic"}* text style.
4542− And this is text with a **[strengthened]{custom-style="Strengthened"}**
4541+ This is text with an [*emphasized*]{custom-style="Emphatic"} text style.
4542+ And this is text with a [**strengthened**]{custom-style="Strengthened"}
45434543 text style.
45444544 :::
45454545
src/Text/Pandoc/Readers/Docx.hs+7−7
@@ -301,37 +301,37 @@ runStyleToTransform rPr
301301 extraInfo <- extraRunStyleInfo rPr
302302 transform <- local (\e -> e{docxCustomStyleAlready = True}) $
303303 runStyleToTransform rPr {isItalic = Nothing}
304− return $ emph . extraInfo . transform
304+ return $ extraInfo . emph . transform
305305 | Just True <- isBold rPr = do
306306 extraInfo <- extraRunStyleInfo rPr
307307 transform <- local (\e -> e{docxCustomStyleAlready = True}) $
308308 runStyleToTransform rPr {isBold = Nothing}
309− return $ strong . extraInfo . transform
309+ return $ extraInfo . strong . transform
310310 | Just True <- isSmallCaps rPr = do
311311 extraInfo <- extraRunStyleInfo rPr
312312 transform <- local (\e -> e{docxCustomStyleAlready = True}) $
313313 runStyleToTransform rPr {isSmallCaps = Nothing}
314− return $ smallcaps . extraInfo .transform
314+ return $ extraInfo . smallcaps . transform
315315 | Just True <- isStrike rPr = do
316316 extraInfo <- extraRunStyleInfo rPr
317317 transform <- local (\e -> e{docxCustomStyleAlready = True}) $
318318 runStyleToTransform rPr {isStrike = Nothing}
319− return $ strikeout . extraInfo . transform
319+ return $ extraInfo . strikeout . transform
320320 | Just SupScrpt <- rVertAlign rPr = do
321321 extraInfo <- extraRunStyleInfo rPr
322322 transform <- local (\e -> e{docxCustomStyleAlready = True}) $
323323 runStyleToTransform rPr {rVertAlign = Nothing}
324− return $ superscript . extraInfo . transform
324+ return $ extraInfo . superscript . transform
325325 | Just SubScrpt <- rVertAlign rPr = do
326326 extraInfo <- extraRunStyleInfo rPr
327327 transform <- local (\e -> e{docxCustomStyleAlready = True}) $
328328 runStyleToTransform rPr {rVertAlign = Nothing}
329− return $ subscript . extraInfo . transform
329+ return $ extraInfo . subscript . transform
330330 | Just "single" <- rUnderline rPr = do
331331 extraInfo <- extraRunStyleInfo rPr
332332 transform <- local (\e -> e{docxCustomStyleAlready = True}) $
333333 runStyleToTransform rPr {rUnderline = Nothing}
334− return $ underlineSpan . extraInfo . transform
334+ return $ extraInfo . underlineSpan . transform
335335 | otherwise = extraRunStyleInfo rPr
336336
337337runToInlines :: PandocMonad m => Run -> DocxContext m Inlines
test/docx/custom-style-with-styles.native+1−1
@@ -1,7 +1,7 @@
11[Div ("",[],[("custom-style","FirstParagraph")])
22 [Para [Str "This",Space,Str "is",Space,Str "some",Space,Str "text."]]
33,Div ("",[],[("custom-style","BodyText")])
4− [Para [Str "This",Space,Str "is",Space,Str "text",Space,Str "with",Space,Str "an",Space,Emph [Span ("",[],[("custom-style","Emphatic")]) [Str "emphasized"]],Space,Str "text",Space,Str "style.",Space,Str "And",Space,Str "this",Space,Str "is",Space,Str "text",Space,Str "with",Space,Str "a",Space,Strong [Span ("",[],[("custom-style","Strengthened")]) [Str "strengthened"]],Space,Str "text",Space,Str "style."]]
4+ [Para [Str "This",Space,Str "is",Space,Str "text",Space,Str "with",Space,Str "an",Space,Span ("",[],[("custom-style","Emphatic")]) [Emph [Str "emphasized"]],Space,Str "text",Space,Str "style.",Space,Str "And",Space,Str "this",Space,Str "is",Space,Str "text",Space,Str "with",Space,Str "a",Space,Span ("",[],[("custom-style","Strengthened")]) [Strong [Str "strengthened"]],Space,Str "text",Space,Str "style."]]
55,Div ("",[],[("custom-style","MyBlockStyle")])
66 [BlockQuote
77 [Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "styled",Space,Str "paragraph",Space,Str "that",Space,Str "inherits",Space,Str "from",Space,Str "Block",Space,Str "Text."]]]]