diff options
author | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-11-16 06:20:25 +0000 |
---|---|---|
committer | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-11-16 06:20:25 +0000 |
commit | 780b77c14790f8053f7b2c8239bb4a5d6a22c8d7 (patch) | |
tree | 32d816647771ef3dd779236c51b571aaca8c2f44 /src | |
parent | 13d8a75060b8528ee2a2e2d6cace9ff0590bcff2 (diff) | |
download | pandoc-780b77c14790f8053f7b2c8239bb4a5d6a22c8d7.tar.gz |
ConTeXt writer: Use itemize options, not sym{}, to produce ordered
lists with custom numbering styles.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@1079 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Writers/ConTeXt.hs | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/src/Text/Pandoc/Writers/ConTeXt.hs b/src/Text/Pandoc/Writers/ConTeXt.hs index b8173e6af..612f7360b 100644 --- a/src/Text/Pandoc/Writers/ConTeXt.hs +++ b/src/Text/Pandoc/Writers/ConTeXt.hs @@ -129,20 +129,34 @@ blockToConTeXt opts (RawHtml str) = return empty blockToConTeXt opts (BulletList lst) = do contents <- mapM (listItemToConTeXt opts) lst return $ text "\\startltxitem" $$ vcat contents $$ text "\\stopltxitem" -blockToConTeXt opts (OrderedList attribs lst) = case attribs of - (1, DefaultStyle, DefaultDelim) -> do - contents <- mapM (listItemToConTeXt opts) lst - return $ text "\\startltxenum"$$ vcat contents $$ text "\\stopltxenum" - _ -> do - let markers = take (length lst) $ orderedListMarkers attribs - contents <- zipWithM (orderedListItemToConTeXt opts) markers lst - let markerWidth = maximum $ map length markers - let markerWidth' = if markerWidth < 3 - then "" - else "[width=" ++ - show ((markerWidth + 2) `div` 2) ++ "em]" - return $ text ("\\startitemize" ++ markerWidth') $$ vcat contents $$ - text "\\stopitemize" +blockToConTeXt opts (OrderedList (start, style, delim) lst) = do + contents <- mapM (listItemToConTeXt opts) lst + let start' = if start == 1 then "" else "start=" ++ show start + let delim' = case delim of + DefaultDelim -> "" + Period -> "stopper=." + OneParen -> "stopper=)" + TwoParens -> "left=(,stopper=)" + let width = maximum $ map length $ take (length contents) + (orderedListMarkers (start, style, delim)) + let width' = (toEnum width + 1) / 2 + let width'' = if width' > 1.5 + then "width=" ++ show width' ++ "em" + else "" + let specs2Items = filter (not . null) [start', delim', width''] + let specs2 = if null specs2Items + then "" + else "[" ++ joinWithSep "," specs2Items ++ "]" + let style' = case style of + DefaultStyle -> if null specs2 then "" else "[]" + Decimal -> "[n]" + LowerRoman -> "[r]" + UpperRoman -> "[R]" + LowerAlpha -> "[a]" + UpperAlpha -> "[A]" + let specs = style' ++ specs2 + return $ text ("\\startitemize" ++ specs) $$ vcat contents $$ + text "\\stopitemize\n" blockToConTeXt opts (DefinitionList lst) = mapM (defListItemToConTeXt opts) lst >>= return . (<> char '\n') . vcat blockToConTeXt opts HorizontalRule = return $ text "\\thinrule\n" |