From e149d4e138fdf42df07ff8400a4748b6f7bde150 Mon Sep 17 00:00:00 2001 From: Václav Zeman Date: Wed, 25 Sep 2013 01:18:39 +0200 Subject: src/Text/Pandoc/Writers/OpenDocument.hs: Fix formatting of strikeout code. --- src/Text/Pandoc/Writers/OpenDocument.hs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs index 3ec5c2073..0f9044601 100644 --- a/src/Text/Pandoc/Writers/OpenDocument.hs +++ b/src/Text/Pandoc/Writers/OpenDocument.hs @@ -192,8 +192,15 @@ writeOpenDocument opts (Pandoc meta blocks) = listStyles = map listStyle (stListStyles s) automaticStyles = inTagsIndented "office:automatic-styles" $ vcat $ reverse $ styles ++ listStyles + fontFaceDecls = inTagsIndented "office:font-face-decls" $ vcat $ + [selfClosingTag "style:font-face" [ + ("style:name", "Courier New") + , ("style:font-family-generic", "modern") + , ("style:font-pitch", "fixed") + , ("svg:font-family", "'Courier New'")]] context = defField "body" body $ defField "automatic-styles" (render' automaticStyles) + $ defField "font-face-decls" (render' fontFaceDecls) $ metadata in if writerStandalone opts then renderTemplate' (writerTemplate opts) context @@ -373,18 +380,18 @@ inlineToOpenDocument o ils | Subscript l <- ils = withTextStyle Sub $ inlinesToOpenDocument o l | SmallCaps l <- ils = withTextStyle SmallC $ inlinesToOpenDocument o l | Quoted t l <- ils = inQuotes t <$> inlinesToOpenDocument o l - | Code _ s <- ils = preformatted s + | Code _ s <- ils = withTextStyle Pre $ inTextStyle $ preformatted s | Math _ s <- ils = inlinesToOpenDocument o (readTeXMath s) | Cite _ l <- ils = inlinesToOpenDocument o l | RawInline f s <- ils = if f == "opendocument" || f == "html" - then preformatted s + then withTextStyle Pre $ inTextStyle $ preformatted s else return empty | Link l (s,t) <- ils = mkLink s t <$> inlinesToOpenDocument o l | Image _ (s,t) <- ils = return $ mkImg s t | Note l <- ils = mkNote l | otherwise = return empty where - preformatted = return . inSpanTags "Teletype" . handleSpaces . escapeStringForXML + preformatted s = handleSpaces $ escapeStringForXML s mkLink s t = inTags False "text:a" [ ("xlink:type" , "simple") , ("xlink:href" , s ) , ("office:name", t ) @@ -524,7 +531,8 @@ paraTableStyles t s (a:xs) [ ("fo:text-align", x) , ("style:justify-single-word", "false")] -data TextStyle = Italic | Bold | Strike | Sub | Sup | SmallC deriving ( Eq,Ord ) +data TextStyle = Italic | Bold | Strike | Sub | Sup | SmallC | Pre + deriving ( Eq,Ord ) textStyleAttr :: TextStyle -> [(String,String)] textStyleAttr s @@ -538,5 +546,8 @@ textStyleAttr s | Sub <- s = [("style:text-position" ,"sub 58%" )] | Sup <- s = [("style:text-position" ,"super 58%" )] | SmallC <- s = [("fo:font-variant" ,"small-caps")] + | Pre <- s = [("style:font-name" ,"Courier New") + ,("style:font-name-asian" ,"Courier New") + ,("style:font-name-complex" ,"Courier New")] | otherwise = [] -- cgit v1.2.3 From d76a6e23720f4acb292d3384ee020dfb072a120c Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 24 Sep 2013 18:41:19 -0700 Subject: OpenDocument writer: don't use font-face-decls variable. --- data/templates | 2 +- src/Text/Pandoc/Writers/OpenDocument.hs | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/data/templates b/data/templates index 1ccb16bb3..0bb5f9ba2 160000 --- a/data/templates +++ b/data/templates @@ -1 +1 @@ -Subproject commit 1ccb16bb33e8022c9511284e6718386efa3a0bbf +Subproject commit 0bb5f9ba204ea242e361c264f019490ead1cf313 diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs index 0f9044601..206be7133 100644 --- a/src/Text/Pandoc/Writers/OpenDocument.hs +++ b/src/Text/Pandoc/Writers/OpenDocument.hs @@ -192,15 +192,8 @@ writeOpenDocument opts (Pandoc meta blocks) = listStyles = map listStyle (stListStyles s) automaticStyles = inTagsIndented "office:automatic-styles" $ vcat $ reverse $ styles ++ listStyles - fontFaceDecls = inTagsIndented "office:font-face-decls" $ vcat $ - [selfClosingTag "style:font-face" [ - ("style:name", "Courier New") - , ("style:font-family-generic", "modern") - , ("style:font-pitch", "fixed") - , ("svg:font-family", "'Courier New'")]] context = defField "body" body $ defField "automatic-styles" (render' automaticStyles) - $ defField "font-face-decls" (render' fontFaceDecls) $ metadata in if writerStandalone opts then renderTemplate' (writerTemplate opts) context -- cgit v1.2.3 From a117a881379ca2863bb9adb39cd83a6c4003be56 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 24 Sep 2013 18:41:46 -0700 Subject: Updated opendocument tests. --- tests/writer.opendocument | 117 +++++++++++++++++++++++++--------------------- 1 file changed, 65 insertions(+), 52 deletions(-) diff --git a/tests/writer.opendocument b/tests/writer.opendocument index 1cee01f76..d5eec1b60 100644 --- a/tests/writer.opendocument +++ b/tests/writer.opendocument @@ -1,5 +1,8 @@ + + + @@ -665,37 +668,47 @@ - - - - - + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - + - - + + - + + + + + + + + + + + @@ -1345,22 +1358,22 @@ Markup So is this word. This is code: ->, -$, -\, -\$, -<html>. -This -is -strikeout. +>, +$, +\, +\$, +<html>. +This +is +strikeout. Superscripts: -abcd -ahello -ahello there. +abcd +ahello +ahello there. Subscripts: -H2O, -H23O, -Hmany of themO. +H2O, +H23O, +Hmany of themO. These should not be superscripts or subscripts, because of the unescaped spaces: a^b c^d, a~b c~d. @@ -1374,7 +1387,7 @@ trees. So is ‘pine.’ ‘He said, “I want to go.”’ Were you alive in the 70’s? Here is some quoted -‘code’ and a +‘code’ and a “quoted link”. Some dashes: one—two — three—four — @@ -1392,16 +1405,16 @@ five. 2 + 2 = 4 - x ∈ y + x ∈ y - α ∧ ω + α ∧ ω 223 - p-Tree + p-Tree Here’s some display math: @@ -1409,18 +1422,18 @@ five. Here’s one that has a line break in it: - α + ω × x2. + α + ω × x2. These shouldn’t be math: To get the famous equation, write - $e = mc^2$. + $e = mc^2$. $22,000 is a - lot of money. So is $34,000. + lot of money. So is $34,000. (It worked if “lot” is emphasized.) @@ -1428,11 +1441,11 @@ five. Escaped - $: $73 - this - should - be - emphasized + $: $73 + this + should + be + emphasized 23$. @@ -1557,7 +1570,7 @@ link in pointy braces. Blockquoted: http://example.com/ Auto-links should not occur here: -<http://example.com/> +<http://example.com/> or here: <http://example.com/> Images @@ -1581,14 +1594,14 @@ indented to show that they belong to the footnote (as with list items).{ <code> }If you want, you can indent every line, but you can also be lazy and just indent the first line of each block. This -should not be a footnote +should not be a footnote reference, because it contains a space.[^my note] Here is an inline note.3This -is easier to type. Inline notes +is easier to type. Inline notes may contain links -and ] verbatim characters, -as well as [bracketed text]. +and ] verbatim characters, as +well as [bracketed text]. Notes can go in quotes.4In quote. -- cgit v1.2.3