aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorAlexander Krotov <ilabdsf@gmail.com>2018-02-13 23:12:28 +0300
committerAlexander Krotov <ilabdsf@gmail.com>2018-02-13 23:19:34 +0300
commit6dcb9744237be713f4ef94017a6b68fc0cfddb73 (patch)
tree8e77bc1f7b90289d6e634dc9299cf2b7c56e76e4 /src/Text
parent39f0eebf38163f57f9dbfe7760717a667dc2b316 (diff)
downloadpandoc-6dcb9744237be713f4ef94017a6b68fc0cfddb73.tar.gz
AsciiDoc writer: do not output implicit heading IDs
Convert to asciidoc-auto_identifiers for old behaviour. Fixes #4363
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Writers/AsciiDoc.hs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/AsciiDoc.hs b/src/Text/Pandoc/Writers/AsciiDoc.hs
index b8f647b66..f91fa8fa0 100644
--- a/src/Text/Pandoc/Writers/AsciiDoc.hs
+++ b/src/Text/Pandoc/Writers/AsciiDoc.hs
@@ -43,6 +43,7 @@ import Data.Char (isPunctuation, isSpace)
import Data.List (intercalate, intersperse, stripPrefix)
import qualified Data.Map as M
import Data.Maybe (fromMaybe, isJust)
+import qualified Data.Set as Set
import Data.Text (Text)
import qualified Data.Text as T
import Text.Pandoc.Class (PandocMonad, report)
@@ -60,6 +61,7 @@ data WriterState = WriterState { defListMarker :: String
, orderedListLevel :: Int
, bulletListLevel :: Int
, intraword :: Bool
+ , autoIds :: Set.Set String
}
-- | Convert Pandoc to AsciiDoc.
@@ -70,6 +72,7 @@ writeAsciiDoc opts document =
, orderedListLevel = 1
, bulletListLevel = 1
, intraword = False
+ , autoIds = Set.empty
}
type ADW = StateT WriterState
@@ -164,7 +167,11 @@ blockToAsciiDoc opts (Header level (ident,_,_) inlines) = do
let len = offset contents
-- ident seem to be empty most of the time and asciidoc will generate them automatically
-- so lets make them not show up when null
- let identifier = if null ident then empty else "[[" <> text ident <> "]]"
+ ids <- gets autoIds
+ let autoId = uniqueIdent inlines ids
+ modify $ \st -> st{ autoIds = Set.insert autoId ids }
+ let identifier = if null ident || (isEnabled Ext_auto_identifiers opts && ident == autoId)
+ then empty else "[[" <> text ident <> "]]"
let setext = writerSetextHeaders opts
return
(if setext