aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2021-09-04 10:02:38 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2021-09-04 11:06:01 -0700
commitb185560a8ec1fd8a0b578de4d94ea72a3d3e2943 (patch)
tree05369222ab5d2732901482483bdda7ad88029a97 /src/Text/Pandoc/Readers
parentaaef51707c1b7612232d1d97276862ec473bb686 (diff)
downloadpandoc-b185560a8ec1fd8a0b578de4d94ea72a3d3e2943.tar.gz
RTF reader: better handling of `\*` and bookmarks.
We now ensure that groups starting with `\*` never cause text to be added to the document. In addition, bookmarks now create a span between the start and end of the bookmark, rather than an empty span.
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r--src/Text/Pandoc/Readers/RTF.hs16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/Text/Pandoc/Readers/RTF.hs b/src/Text/Pandoc/Readers/RTF.hs
index 26a132758..4eeab1312 100644
--- a/src/Text/Pandoc/Readers/RTF.hs
+++ b/src/Text/Pandoc/Readers/RTF.hs
@@ -395,15 +395,15 @@ isUnderline _ = False
processTok :: PandocMonad m => Blocks -> Tok -> RTFParser m Blocks
processTok bs (Tok pos tok') = do
setPosition pos
- -- ignore \* at beginning of group:
- let tok'' = case tok' of
- Grouped (Tok _ (ControlSymbol '*') : toks) -> Grouped toks
- _ -> tok'
- case tok'' of
+ case tok' of
HexVal{} -> return ()
UnformattedText{} -> return ()
_ -> updateState $ \s -> s{ sEatChars = 0 }
- case tok'' of
+ case tok' of
+ Grouped (Tok _ (ControlSymbol '*') : toks) ->
+ bs <$ (do oldTextContent <- sTextContent <$> getState
+ processTok mempty (Tok pos (Grouped toks))
+ updateState $ \st -> st{ sTextContent = oldTextContent })
Grouped (Tok _ (ControlWord "fonttbl" _) : toks) -> inGroup $ do
updateState $ \s -> s{ sFontTable = processFontTable toks }
pure bs
@@ -440,10 +440,10 @@ processTok bs (Tok pos tok') = do
-- TODO ideally we'd put the span around bkmkstart/end, but this
-- is good for now:
modifyGroup (\g -> g{ gAnchor = Just $ T.strip t })
- addText ""
+ pure bs
+ Grouped (Tok _ (ControlWord "bkmkend" _) : _) -> do
modifyGroup (\g -> g{ gAnchor = Nothing })
pure bs
- Grouped (Tok _ (ControlWord "bkmkend" _) : _) -> pure bs -- TODO
Grouped (Tok _ (ControlWord f _) : _) | isHeaderFooter f -> pure bs
Grouped (Tok _ (ControlWord "footnote" _) : toks) -> do
noteBs <- inGroup $ processDestinationToks toks