From 2637e3595afef05cbd67a69b8d79682ebc7a716a Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Tue, 15 Jul 2008 23:25:49 +0000 Subject: Add preliminary support for SmallCaps inline element. (Andrea Rossato) git-svn-id: https://pandoc.googlecode.com/svn/trunk@1327 788f1e2b-df1e-0410-8736-df70ead52e1b --- Text/Pandoc/Definition.hs | 1 + Text/Pandoc/Writers/ConTeXt.hs | 1 + Text/Pandoc/Writers/Docbook.hs | 1 + Text/Pandoc/Writers/HTML.hs | 3 +++ Text/Pandoc/Writers/LaTeX.hs | 1 + Text/Pandoc/Writers/Man.hs | 1 + Text/Pandoc/Writers/Markdown.hs | 1 + Text/Pandoc/Writers/OpenDocument.hs | 22 ++++++++++++---------- Text/Pandoc/Writers/RST.hs | 1 + Text/Pandoc/Writers/RTF.hs | 1 + Text/Pandoc/Writers/Texinfo.hs | 2 ++ 11 files changed, 25 insertions(+), 10 deletions(-) (limited to 'Text') diff --git a/Text/Pandoc/Definition.hs b/Text/Pandoc/Definition.hs index 04deca1ea..e17b1b788 100644 --- a/Text/Pandoc/Definition.hs +++ b/Text/Pandoc/Definition.hs @@ -104,6 +104,7 @@ data Inline | Superscript [Inline] -- ^ Superscripted text (list of inlines) | Subscript [Inline] -- ^ Subscripted text (list of inlines) | Quoted QuoteType [Inline] -- ^ Quoted text (list of inlines) + | SmallCaps [Inline] -- ^ Small caps text (list of inlines) | Code String -- ^ Inline code (literal) | Space -- ^ Inter-word space | EmDash -- ^ Em dash diff --git a/Text/Pandoc/Writers/ConTeXt.hs b/Text/Pandoc/Writers/ConTeXt.hs index f3e8a839a..4f171f2ce 100644 --- a/Text/Pandoc/Writers/ConTeXt.hs +++ b/Text/Pandoc/Writers/ConTeXt.hs @@ -263,6 +263,7 @@ inlineToConTeXt (Quoted SingleQuote lst) = do inlineToConTeXt (Quoted DoubleQuote lst) = do contents <- inlineListToConTeXt lst return $ text "\\quotation{" <> contents <> char '}' +inlineToConTeXt (SmallCaps lst) = inlineListToConTeXt lst inlineToConTeXt Apostrophe = return $ char '\'' inlineToConTeXt EmDash = return $ text "---" inlineToConTeXt EnDash = return $ text "--" diff --git a/Text/Pandoc/Writers/Docbook.hs b/Text/Pandoc/Writers/Docbook.hs index d089116cf..6621c3d1d 100644 --- a/Text/Pandoc/Writers/Docbook.hs +++ b/Text/Pandoc/Writers/Docbook.hs @@ -225,6 +225,7 @@ inlineToDocbook opts (Subscript lst) = inTagsSimple "subscript" $ inlinesToDocbook opts lst inlineToDocbook opts (Quoted _ lst) = inTagsSimple "quote" $ inlinesToDocbook opts lst +inlineToDocbook opts (SmallCaps lst) = inlinesToDocbook opts lst inlineToDocbook _ Apostrophe = char '\'' inlineToDocbook _ Ellipses = text "…" inlineToDocbook _ EmDash = text "—" diff --git a/Text/Pandoc/Writers/HTML.hs b/Text/Pandoc/Writers/HTML.hs index 435d78fad..d0c45bec1 100644 --- a/Text/Pandoc/Writers/HTML.hs +++ b/Text/Pandoc/Writers/HTML.hs @@ -241,6 +241,7 @@ inlineListToIdentifier' (x:xs) = Emph lst -> inlineListToIdentifier' lst Strikeout lst -> inlineListToIdentifier' lst Superscript lst -> inlineListToIdentifier' lst + SmallCaps lst -> inlineListToIdentifier' lst Subscript lst -> inlineListToIdentifier' lst Strong lst -> inlineListToIdentifier' lst Quoted _ lst -> inlineListToIdentifier' lst @@ -426,6 +427,8 @@ inlineToHtml opts inline = (Code str) -> return $ thecode << str (Strikeout lst) -> inlineListToHtml opts lst >>= return . (thespan ! [thestyle "text-decoration: line-through;"]) + (SmallCaps lst) -> inlineListToHtml opts lst >>= + return . (thespan ! [thestyle "font-variant: small-caps;"]) (Superscript lst) -> inlineListToHtml opts lst >>= return . sup (Subscript lst) -> inlineListToHtml opts lst >>= return . sub (Quoted quoteType lst) -> diff --git a/Text/Pandoc/Writers/LaTeX.hs b/Text/Pandoc/Writers/LaTeX.hs index be145922d..9b235c53a 100644 --- a/Text/Pandoc/Writers/LaTeX.hs +++ b/Text/Pandoc/Writers/LaTeX.hs @@ -290,6 +290,7 @@ inlineToLaTeX (Quoted DoubleQuote lst) = do then text "\\," else empty return $ text "``" <> s1 <> contents <> s2 <> text "''" +inlineToLaTeX (SmallCaps lst) = inlineListToLaTeX lst inlineToLaTeX Apostrophe = return $ char '\'' inlineToLaTeX EmDash = return $ text "---" inlineToLaTeX EnDash = return $ text "--" diff --git a/Text/Pandoc/Writers/Man.hs b/Text/Pandoc/Writers/Man.hs index 139953104..4ea28e5f5 100644 --- a/Text/Pandoc/Writers/Man.hs +++ b/Text/Pandoc/Writers/Man.hs @@ -262,6 +262,7 @@ inlineToMan opts (Quoted SingleQuote lst) = do inlineToMan opts (Quoted DoubleQuote lst) = do contents <- inlineListToMan opts lst return $ text "\\[lq]" <> contents <> text "\\[rq]" +inlineToMan opts (SmallCaps lst) = inlineListToMan opts lst inlineToMan _ EmDash = return $ text "\\[em]" inlineToMan _ EnDash = return $ text "\\[en]" inlineToMan _ Apostrophe = return $ char '\'' diff --git a/Text/Pandoc/Writers/Markdown.hs b/Text/Pandoc/Writers/Markdown.hs index 93bb593f6..76b57343d 100644 --- a/Text/Pandoc/Writers/Markdown.hs +++ b/Text/Pandoc/Writers/Markdown.hs @@ -323,6 +323,7 @@ inlineToMarkdown opts (Quoted SingleQuote lst) = do inlineToMarkdown opts (Quoted DoubleQuote lst) = do contents <- inlineListToMarkdown opts lst return $ char '"' <> contents <> char '"' +inlineToMarkdown opts (SmallCaps lst) = inlineListToMarkdown opts lst inlineToMarkdown _ EmDash = return $ text "--" inlineToMarkdown _ EnDash = return $ char '-' inlineToMarkdown _ Apostrophe = return $ char '\'' diff --git a/Text/Pandoc/Writers/OpenDocument.hs b/Text/Pandoc/Writers/OpenDocument.hs index 9c041906c..ecaea2705 100644 --- a/Text/Pandoc/Writers/OpenDocument.hs +++ b/Text/Pandoc/Writers/OpenDocument.hs @@ -369,6 +369,7 @@ inlineToOpenDocument o ils | Strikeout l <- ils = withTextStyle Strike $ inlinesToOpenDocument o l | Superscript l <- ils = withTextStyle Sup $ inlinesToOpenDocument o l | 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 | Math s <- ils = inlinesToOpenDocument o (readTeXMath s) @@ -508,19 +509,20 @@ paraTableStyles t s (a:xs) [ ("fo:text-align", x) , ("style:justify-single-word", "false")] -data TextStyle = Italic | Bold | Strike | Sub | Sup deriving ( Eq ) +data TextStyle = Italic | Bold | Strike | Sub | Sup | SmallC deriving ( Eq ) textStyleAttr :: TextStyle -> [(String,String)] textStyleAttr s - | Italic <- s = [("fo:font-style" ,"italic" ) - ,("style:font-style-asian" ,"italic" ) - ,("style:font-style-complex" ,"italic" )] - | Bold <- s = [("fo:font-weight" ,"bold" ) - ,("style:font-weight-asian" ,"bold" ) - ,("style:font-weight-complex" ,"bold" )] - | Strike <- s = [("style:text-line-through-style", "solid" )] - | Sub <- s = [("style:text-position" ,"sub 58%" )] - | Sup <- s = [("style:text-position" ,"super 58%")] + | Italic <- s = [("fo:font-style" ,"italic" ) + ,("style:font-style-asian" ,"italic" ) + ,("style:font-style-complex" ,"italic" )] + | Bold <- s = [("fo:font-weight" ,"bold" ) + ,("style:font-weight-asian" ,"bold" ) + ,("style:font-weight-complex" ,"bold" )] + | Strike <- s = [("style:text-line-through-style", "solid" )] + | Sub <- s = [("style:text-position" ,"sub 58%" )] + | Sup <- s = [("style:text-position" ,"super 58%" )] + | SmallC <- s = [("fo:font-variant" ,"small-caps")] | otherwise = [] openDocumentNameSpaces :: [(String, String)] diff --git a/Text/Pandoc/Writers/RST.hs b/Text/Pandoc/Writers/RST.hs index 1d95a5613..0c172ad54 100644 --- a/Text/Pandoc/Writers/RST.hs +++ b/Text/Pandoc/Writers/RST.hs @@ -282,6 +282,7 @@ inlineToRST (Quoted SingleQuote lst) = do inlineToRST (Quoted DoubleQuote lst) = do contents <- inlineListToRST lst return $ char '"' <> contents <> char '"' +inlineToRST (SmallCaps lst) = inlineListToRST lst inlineToRST EmDash = return $ text "--" inlineToRST EnDash = return $ char '-' inlineToRST Apostrophe = return $ char '\'' diff --git a/Text/Pandoc/Writers/RTF.hs b/Text/Pandoc/Writers/RTF.hs index fb7c58713..b95b218e9 100644 --- a/Text/Pandoc/Writers/RTF.hs +++ b/Text/Pandoc/Writers/RTF.hs @@ -268,6 +268,7 @@ inlineToRTF (Quoted SingleQuote lst) = "\\u8216'" ++ (inlineListToRTF lst) ++ "\\u8217'" inlineToRTF (Quoted DoubleQuote lst) = "\\u8220\"" ++ (inlineListToRTF lst) ++ "\\u8221\"" +inlineToRTF (SmallCaps lst) = inlineListToRTF lst inlineToRTF Apostrophe = "\\u8217'" inlineToRTF Ellipses = "\\u8230?" inlineToRTF EmDash = "\\u8212-" diff --git a/Text/Pandoc/Writers/Texinfo.hs b/Text/Pandoc/Writers/Texinfo.hs index 84563b966..e08448813 100644 --- a/Text/Pandoc/Writers/Texinfo.hs +++ b/Text/Pandoc/Writers/Texinfo.hs @@ -356,6 +356,7 @@ inlineForNode (Superscript lst) = inlineListForNode lst inlineForNode (Subscript lst) = inlineListForNode lst inlineForNode (Quoted _ lst) = inlineListForNode lst inlineForNode (Code str) = inlineForNode (Str str) +inlineForNode (SmallCaps lst) = inlineListForNode lst inlineForNode Space = return $ char ' ' inlineForNode EmDash = return $ text "---" inlineForNode EnDash = return $ text "--" @@ -425,6 +426,7 @@ inlineToTexinfo (Quoted DoubleQuote lst) = do contents <- inlineListToTexinfo lst return $ text "``" <> contents <> text "''" +inlineToTexinfo (SmallCaps lst) = inlineListToTexinfo lst inlineToTexinfo Apostrophe = return $ char '\'' inlineToTexinfo EmDash = return $ text "---" inlineToTexinfo EnDash = return $ text "--" -- cgit v1.2.3