From 2b89aaf04dd2d1bdafa0ee507abefd4f0d6df271 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 14 May 2018 10:37:46 -0700 Subject: Make internal links work in ODT/OpenDocument. This adds proper bookmarks to the headers with non-null IDs. Closes #4358. --- test/writer.opendocument | 97 ++++++++++++++++++++++++++---------------------- 1 file changed, 53 insertions(+), 44 deletions(-) (limited to 'test/writer.opendocument') diff --git a/test/writer.opendocument b/test/writer.opendocument index 081b33971..535130c0a 100644 --- a/test/writer.opendocument +++ b/test/writer.opendocument @@ -803,23 +803,31 @@ This is a set of tests for pandoc. Most of them are adapted from John Gruber’s markdown test suite. -Headers -Level 2 with an +Headers +Level +2 with an embedded -link -Level 3 with -emphasis -Level 4 -Level 5 -Level 1 -Level 2 with -emphasis -Level 3 +link +Level +3 with +emphasis +Level +4 +Level +5 +Level +1 +Level +2 with +emphasis +Level +3 with no blank line -Level 2 +Level +2 with no blank line -Paragraphs +Paragraphs Here’s a regular paragraph. In Markdown 1.0.0 and earlier. Version @@ -830,8 +838,8 @@ criminey. There should be a hard line breakhere. -Block -Quotes +Block +Quotes E-mail style: This is a block quote. It is pretty short. @@ -855,8 +863,8 @@ short. 2 > 1. And a following paragraph. -Code -Blocks +Code +Blocks Code: ---- (should be four hyphens) @@ -870,8 +878,8 @@ Blocks These should not be escaped: \$ \\ \> \[ \{ -Lists -Unordered +Lists +Unordered Asterisks tight: @@ -944,7 +952,7 @@ Blocks Minus 3 -Ordered +Ordered Tight: @@ -1007,7 +1015,7 @@ Blocks Item 3. -Nested +Nested Tab @@ -1068,8 +1076,8 @@ paragraphs: Third -Tabs and -spaces +Tabs +and spaces this is a list item indented with @@ -1089,8 +1097,8 @@ spaces -Fancy list -markers +Fancy +list markers begins with 2 @@ -1157,8 +1165,8 @@ item: M.A. 2007 B. Williams -Definition -Lists +Definition +Lists Tight using spaces: apple red fruit @@ -1225,8 +1233,8 @@ fruit sublist -HTML -Blocks +HTML +Blocks Simple block on one line: foo @@ -1262,8 +1270,8 @@ spaces on the line: <hr /> Hr’s: -Inline -Markup +Inline +Markup This is emphasized, and so is this. @@ -1300,8 +1308,9 @@ Hmany of themO. These should not be superscripts or subscripts, because of the unescaped spaces: a^b c^d, a~b c~d. -Smart quotes, -ellipses, dashes +Smart +quotes, ellipses, +dashes “Hello,” said the spider. “‘Shelob’ is my name.” ‘A’, ‘B’, and ‘C’ are letters. @@ -1319,7 +1328,7 @@ five. 1987–1999. Ellipses…and…and…. -LaTeX +LaTeX @@ -1371,8 +1380,8 @@ five. Here’s a LaTeX table: -Special -Characters +Special +Characters Here is some unicode: @@ -1415,8 +1424,8 @@ it. Plus: + Minus: - -Links -Explicit +Links +Explicit Just a URL. URL @@ -1433,7 +1442,7 @@ and title Email link Empty. -Reference +Reference Foo bar. With @@ -1453,8 +1462,8 @@ by itself should be a link. bar. Foo biz. -With -ampersands +With +ampersands Here’s a link with an ampersand in the URL. @@ -1467,7 +1476,7 @@ link. Here’s an inline link in pointy braces. -Autolinks +Autolinks With an ampersand: http://example.com/?foo=1&bar=2 @@ -1489,7 +1498,7 @@ link in pointy braces. <http://example.com/> or here: <http://example.com/> -Images +Images From “Voyage dans la Lune” by Georges Melies (1902): @@ -1498,7 +1507,7 @@ Georges Melies (1902): icon. -Footnotes +Footnotes Here is a footnote reference,1Here is the footnote. It can go anywhere after the footnote reference. It need not -- cgit v1.2.3 From f82d574d14c9ad71e76b8dfcbadac89ab4d10501 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 2 Oct 2018 10:11:32 -0700 Subject: OpenDocument writer: improve bullet/numbering alignment. This patch eliminates the large gap we used to have between bullet and text, and also ensures that numbers in numbered lists will be right-aligned. Closes #4385. --- src/Text/Pandoc/Writers/OpenDocument.hs | 16 +- test/writer.opendocument | 756 ++++++++++++++++++++++++-------- 2 files changed, 579 insertions(+), 193 deletions(-) (limited to 'test/writer.opendocument') diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs index 6f6f58ae6..cb29e390a 100644 --- a/src/Text/Pandoc/Writers/OpenDocument.hs +++ b/src/Text/Pandoc/Writers/OpenDocument.hs @@ -563,10 +563,18 @@ orderedListLevelStyle (s,n, d) (l,ls) = listLevelStyle :: Int -> Doc listLevelStyle i = - let indent = show (0.4 * fromIntegral (i - 1) :: Double) in - selfClosingTag "style:list-level-properties" - [ ("text:space-before" , indent ++ "in") - , ("text:min-label-width", "0.4in")] + let indent = show (0.5 * fromIntegral i :: Double) in + inTags True "style:list-level-properties" + [ ("text:list-level-position-and-space-mode", + "label-alignment") + , ("fo:text-align", "right") + ] $ + selfClosingTag "style:list-level-label-alignment" + [ ("text:label-followed-by", "listtab") + , ("text:list-tab-stop-position", indent ++ "in") + , ("fo:text-indent", "-0.1in") + , ("fo:margin-left", indent ++ "in") + ] tableStyle :: Int -> [(Char,Double)] -> Doc tableStyle num wcs = diff --git a/test/writer.opendocument b/test/writer.opendocument index 535130c0a..28c38ee1d 100644 --- a/test/writer.opendocument +++ b/test/writer.opendocument @@ -6,629 +6,1007 @@ - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + -- cgit v1.2.3 From ecd4d5b8d8cfda6a2cd8d8fb631e0d7c79bee363 Mon Sep 17 00:00:00 2001 From: Nils Carlson Date: Wed, 3 Oct 2018 21:21:46 +0000 Subject: OpenDocument writer: Implement figure numbering in captions (#4944) Figure captions are now numbered 1, 2, 3, ... The format in the caption is "Figure 1: " and so on. This is necessary in order for libreoffice to generate an Illustration Index (Table of Figures) for included figures. --- src/Text/Pandoc/Writers/OpenDocument.hs | 14 +++++++++++++- test/writer.opendocument | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'test/writer.opendocument') diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs index cb29e390a..cd907bbea 100644 --- a/src/Text/Pandoc/Writers/OpenDocument.hs +++ b/src/Text/Pandoc/Writers/OpenDocument.hs @@ -411,10 +411,22 @@ blockToOpenDocument o bs figure attr caption source title | null caption = withParagraphStyle o "Figure" [Para [Image attr caption (source,title)]] | otherwise = do + id' <- gets stImageId imageDoc <- withParagraphStyle o "FigureWithCaption" [Para [Image attr caption (source,title)]] - captionDoc <- withParagraphStyle o "FigureCaption" [Para caption] + captionDoc <- numberedFigureCaption id' <$> inlinesToOpenDocument o caption return $ imageDoc $$ captionDoc +numberedFigureCaption :: Int -> Doc -> Doc +numberedFigureCaption num caption = + let t = text "Figure " + r = num - 1 + s = inTags False "text:sequence" [ ("text:ref-name", "refIllustration" ++ show r), + ("text:name", "Illustration"), + ("text:formula", "ooow:Illustration+1"), + ("style:num-format", "1") ] $ text $ show num + c = text ": " + in inParagraphTagsWithStyle "FigureCaption" $ hcat [ t, s, c, caption ] + colHeadsToOpenDocument :: PandocMonad m => WriterOptions -> [String] -> [[Block]] -> OD m Doc diff --git a/test/writer.opendocument b/test/writer.opendocument index 28c38ee1d..09a246b52 100644 --- a/test/writer.opendocument +++ b/test/writer.opendocument @@ -1880,7 +1880,7 @@ link in pointy braces. From “Voyage dans la Lune” by Georges Melies (1902): -lalune +Figure 1: lalune Here is a movie icon. -- cgit v1.2.3