Fix definition lists with internal links in terms (closes #1032).
This fix puts braces around a term that contains an internal link, to avoid problems with square brackets.
This commit is contained in:
parent
d84624f775
commit
e63aafd620
2 changed files with 13 additions and 1 deletions
|
@ -513,8 +513,15 @@ listItemToLaTeX lst = blockListToLaTeX lst >>= return . (text "\\item" $$) .
|
|||
defListItemToLaTeX :: ([Inline], [[Block]]) -> State WriterState Doc
|
||||
defListItemToLaTeX (term, defs) = do
|
||||
term' <- inlineListToLaTeX term
|
||||
-- put braces around term if it contains an internal link,
|
||||
-- since otherwise we get bad bracket interactions: \item[\hyperref[..]
|
||||
let isInternalLink (Link _ ('#':_,_)) = True
|
||||
isInternalLink _ = False
|
||||
let term'' = if any isInternalLink term
|
||||
then braces term'
|
||||
else term'
|
||||
def' <- liftM vsep $ mapM blockListToLaTeX defs
|
||||
return $ "\\item" <> brackets term' $$ def'
|
||||
return $ "\\item" <> brackets term'' $$ def'
|
||||
|
||||
-- | Craft the section header, inserting the secton reference, if supplied.
|
||||
sectionHeader :: Bool -- True for unnumbered
|
||||
|
|
|
@ -39,6 +39,11 @@ tests = [ testGroup "code blocks"
|
|||
, test latexListing "no identifier" $ codeBlock "hi" =?>
|
||||
("\\begin{lstlisting}\nhi\n\\end{lstlisting}" :: String)
|
||||
]
|
||||
, testGroup "definition lists"
|
||||
[ "with internal link" =: definitionList [(link "#go" "" (str "testing"),
|
||||
[plain (text "hi there")])] =?>
|
||||
"\\begin{description}\n\\itemsep1pt\\parskip0pt\\parsep0pt\n\\item[{\\hyperref[go]{testing}}]\nhi there\n\\end{description}"
|
||||
]
|
||||
, testGroup "math"
|
||||
[ "escape |" =: para (math "\\sigma|_{\\{x\\}}") =?>
|
||||
"$\\sigma|_{\\{x\\}}$"
|
||||
|
|
Loading…
Reference in a new issue