summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorAlexander Krotov <ilabdsf@gmail.com>2017-05-04 12:36:52 +0300
committerJohn MacFarlane <jgm@berkeley.edu>2017-05-04 11:36:52 +0200
commit430e6be1f41358bed21b2edf02bcdb41dbee88cc (patch)
tree996da142d8f2957243a8d6958a0c8d1e29f9daf5 /src/Text/Pandoc
parent57cba3f1d5aa682df4ca8aafc3bc1d2ed4ead911 (diff)
Muse writer: omit automatic header identifiers (#3633)
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Writers/Muse.hs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/Muse.hs b/src/Text/Pandoc/Writers/Muse.hs
index 8f6493975..8b083e2c6 100644
--- a/src/Text/Pandoc/Writers/Muse.hs
+++ b/src/Text/Pandoc/Writers/Muse.hs
@@ -53,6 +53,7 @@ import Text.Pandoc.Shared
import Text.Pandoc.Templates (renderTemplate')
import Text.Pandoc.Writers.Math
import Text.Pandoc.Writers.Shared
+import qualified Data.Set as Set
type Notes = [[Block]]
data WriterState =
@@ -60,6 +61,7 @@ data WriterState =
, stOptions :: WriterOptions
, stTopLevel :: Bool
, stInsideBlock :: Bool
+ , stIds :: Set.Set String
}
-- | Convert Pandoc to Muse.
@@ -72,6 +74,7 @@ writeMuse opts document =
, stOptions = opts
, stTopLevel = True
, stInsideBlock = False
+ , stIds = Set.empty
}
in evalStateT (pandocToMuse document) st
@@ -184,8 +187,14 @@ blockToMuse (DefinitionList items) = do
let ind = offset label''
return $ hang ind label'' contents
blockToMuse (Header level (ident,_,_) inlines) = do
+ opts <- gets stOptions
contents <- inlineListToMuse inlines
- let attr' = if null ident
+
+ ids <- gets stIds
+ let autoId = uniqueIdent inlines ids
+ modify $ \st -> st{ stIds = Set.insert autoId ids }
+
+ let attr' = if null ident || (isEnabled Ext_auto_identifiers opts && ident == autoId)
then empty
else "#" <> text ident <> cr
let header' = text $ replicate level '*'