@@ -217,11 +217,16 @@ blockToMs :: PandocMonad m
217217 -> Block -- ^ Block element
218218 -> MS m Doc
219219blockToMs _ Null = return empty
220−blockToMs opts (Div _ bs) = do
220+blockToMs opts (Div (ident,_,_) bs) = do
221+ let anchor = if null ident
222+ then empty
223+ else nowrap $
224+ text ".pdfhref M "
225+ <> doubleQuotes (text (toAscii ident))
221226 setFirstPara
222227 res <- blockListToMs opts bs
223228 setFirstPara
224− return res
229+ return $ anchor $$ res
225230blockToMs opts (Plain inlines) =
226231 liftM vcat $ mapM (inlineListToMs' opts) $ splitSentences inlines
227232blockToMs opts (Para [Image attr alt (src,_tit)])
@@ -640,7 +645,10 @@ highlightCode opts attr str =
640645 modify (\st -> st{ stHighlighting = True })
641646 return h
642647
648+-- This is used for PDF anchors.
643649toAscii :: String -> String
644−toAscii = concatMap (\c -> case toAsciiChar c of
645− Nothing -> 'u':show (ord c)
646− Just c' -> [c'])
650+toAscii = concatMap
651+ (\c -> case toAsciiChar c of
652+ Nothing -> '_':'u':show (ord c) ++ "_"
653+ Just '/' -> '_':'u':show (ord c) ++ "_" -- see #4515
654+ Just c' -> [c'])