diff options
author | John MacFarlane <jgm@berkeley.edu> | 2018-01-10 12:07:33 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2018-01-10 12:07:33 -0800 |
commit | 49007ded7b7a64cf9c875f23e9c59a966e1284c8 (patch) | |
tree | d36e3ef74387291d1f15d91f18e2296260791261 /src/Text/Pandoc/Readers | |
parent | 13f7c2cf83c74c3dd22f355111d856fbfe7d3378 (diff) | |
download | pandoc-49007ded7b7a64cf9c875f23e9c59a966e1284c8.tar.gz |
RST reader: better handling for headers with an anchor.
Instead of creating a div containing the header, we put
the id directly on the header. This way header promotion
will work properly. Closes #4240.
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r-- | src/Text/Pandoc/Readers/RST.hs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs index 27ce5fa2d..ba5a24f8f 100644 --- a/src/Text/Pandoc/Readers/RST.hs +++ b/src/Text/Pandoc/Readers/RST.hs @@ -1157,9 +1157,19 @@ anchor = try $ do refs <- referenceNames blanklines b <- block - -- put identifier on next block: let addDiv ref = B.divWith (ref, [], []) - return $ foldr addDiv b refs + let emptySpanWithId id' = Span (id',[],[]) [] + -- put identifier on next block: + case B.toList b of + [Header lev (_,classes,kvs) txt] -> + case reverse refs of + [] -> return b + (r:rs) -> return $ B.singleton $ + Header lev (r,classes,kvs) + (txt ++ map emptySpanWithId rs) + -- we avoid generating divs for headers, + -- because it hides them from promoteHeader, see #4240 + _ -> return $ foldr addDiv b refs headerBlock :: PandocMonad m => RSTParser m [Char] headerBlock = do |