Implemented tight lists in context, latex writers.
This commit is contained in:
parent
7909982f9a
commit
1a9193c30d
2 changed files with 27 additions and 13 deletions
|
@ -46,8 +46,8 @@ data WriterState =
|
||||||
, stOptions :: WriterOptions -- writer options
|
, stOptions :: WriterOptions -- writer options
|
||||||
}
|
}
|
||||||
|
|
||||||
orderedListStyles :: [[Char]]
|
orderedListStyles :: [Char]
|
||||||
orderedListStyles = cycle ["[n]","[a]", "[r]", "[g]"]
|
orderedListStyles = cycle "narg"
|
||||||
|
|
||||||
-- | Convert Pandoc to ConTeXt.
|
-- | Convert Pandoc to ConTeXt.
|
||||||
writeConTeXt :: WriterOptions -> Pandoc -> String
|
writeConTeXt :: WriterOptions -> Pandoc -> String
|
||||||
|
@ -148,7 +148,10 @@ blockToConTeXt (RawBlock "context" str) = return $ text str <> blankline
|
||||||
blockToConTeXt (RawBlock _ _ ) = return empty
|
blockToConTeXt (RawBlock _ _ ) = return empty
|
||||||
blockToConTeXt (BulletList lst) = do
|
blockToConTeXt (BulletList lst) = do
|
||||||
contents <- mapM listItemToConTeXt lst
|
contents <- mapM listItemToConTeXt lst
|
||||||
return $ "\\startitemize" $$ vcat contents $$ text "\\stopitemize" <> blankline
|
return $ ("\\startitemize" <> if isTightList lst
|
||||||
|
then brackets "packed"
|
||||||
|
else empty) $$
|
||||||
|
vcat contents $$ text "\\stopitemize" <> blankline
|
||||||
blockToConTeXt (OrderedList (start, style', delim) lst) = do
|
blockToConTeXt (OrderedList (start, style', delim) lst) = do
|
||||||
st <- get
|
st <- get
|
||||||
let level = stOrderedListLevel st
|
let level = stOrderedListLevel st
|
||||||
|
@ -171,14 +174,15 @@ blockToConTeXt (OrderedList (start, style', delim) lst) = do
|
||||||
let specs2 = if null specs2Items
|
let specs2 = if null specs2Items
|
||||||
then ""
|
then ""
|
||||||
else "[" ++ intercalate "," specs2Items ++ "]"
|
else "[" ++ intercalate "," specs2Items ++ "]"
|
||||||
let style'' = case style' of
|
let style'' = '[': (case style' of
|
||||||
DefaultStyle -> orderedListStyles !! level
|
DefaultStyle -> orderedListStyles !! level
|
||||||
Decimal -> "[n]"
|
Decimal -> 'n'
|
||||||
Example -> "[n]"
|
Example -> 'n'
|
||||||
LowerRoman -> "[r]"
|
LowerRoman -> 'r'
|
||||||
UpperRoman -> "[R]"
|
UpperRoman -> 'R'
|
||||||
LowerAlpha -> "[a]"
|
LowerAlpha -> 'a'
|
||||||
UpperAlpha -> "[A]"
|
UpperAlpha -> 'A') :
|
||||||
|
if isTightList lst then ",packed]" else "]"
|
||||||
let specs = style'' ++ specs2
|
let specs = style'' ++ specs2
|
||||||
return $ "\\startitemize" <> text specs $$ vcat contents $$
|
return $ "\\startitemize" <> text specs $$ vcat contents $$
|
||||||
"\\stopitemize" <> blankline
|
"\\stopitemize" <> blankline
|
||||||
|
|
|
@ -351,7 +351,10 @@ blockToLaTeX (BulletList lst) = do
|
||||||
incremental <- gets stIncremental
|
incremental <- gets stIncremental
|
||||||
let inc = if incremental then "[<+->]" else ""
|
let inc = if incremental then "[<+->]" else ""
|
||||||
items <- mapM listItemToLaTeX lst
|
items <- mapM listItemToLaTeX lst
|
||||||
return $ text ("\\begin{itemize}" ++ inc) $$ vcat items $$
|
let spacing = if isTightList lst
|
||||||
|
then text "\\itemsep1pt\\parskip0pt\\parsep0pt"
|
||||||
|
else empty
|
||||||
|
return $ text ("\\begin{itemize}" ++ inc) $$ spacing $$ vcat items $$
|
||||||
"\\end{itemize}"
|
"\\end{itemize}"
|
||||||
blockToLaTeX (OrderedList (start, numstyle, numdelim) lst) = do
|
blockToLaTeX (OrderedList (start, numstyle, numdelim) lst) = do
|
||||||
st <- get
|
st <- get
|
||||||
|
@ -381,16 +384,23 @@ blockToLaTeX (OrderedList (start, numstyle, numdelim) lst) = do
|
||||||
then empty
|
then empty
|
||||||
else "\\setcounter" <> braces enum <>
|
else "\\setcounter" <> braces enum <>
|
||||||
braces (text $ show $ start - 1)
|
braces (text $ show $ start - 1)
|
||||||
|
let spacing = if isTightList lst
|
||||||
|
then text "\\itemsep1pt\\parskip0pt\\parsep0pt"
|
||||||
|
else empty
|
||||||
return $ text ("\\begin{enumerate}" ++ inc)
|
return $ text ("\\begin{enumerate}" ++ inc)
|
||||||
$$ stylecommand
|
$$ stylecommand
|
||||||
$$ resetcounter
|
$$ resetcounter
|
||||||
|
$$ spacing
|
||||||
$$ vcat items
|
$$ vcat items
|
||||||
$$ "\\end{enumerate}"
|
$$ "\\end{enumerate}"
|
||||||
blockToLaTeX (DefinitionList lst) = do
|
blockToLaTeX (DefinitionList lst) = do
|
||||||
incremental <- gets stIncremental
|
incremental <- gets stIncremental
|
||||||
let inc = if incremental then "[<+->]" else ""
|
let inc = if incremental then "[<+->]" else ""
|
||||||
items <- mapM defListItemToLaTeX lst
|
items <- mapM defListItemToLaTeX lst
|
||||||
return $ text ("\\begin{description}" ++ inc) $$ vcat items $$
|
let spacing = if and $ map isTightList (map snd lst)
|
||||||
|
then text "\\itemsep1pt\\parskip0pt\\parsep0pt"
|
||||||
|
else empty
|
||||||
|
return $ text ("\\begin{description}" ++ inc) $$ spacing $$ vcat items $$
|
||||||
"\\end{description}"
|
"\\end{description}"
|
||||||
blockToLaTeX HorizontalRule = return $
|
blockToLaTeX HorizontalRule = return $
|
||||||
"\\begin{center}\\rule{3in}{0.4pt}\\end{center}"
|
"\\begin{center}\\rule{3in}{0.4pt}\\end{center}"
|
||||||
|
|
Loading…
Add table
Reference in a new issue