diff options
author | John MacFarlane <jgm@berkeley.edu> | 2018-11-11 13:27:25 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2018-11-11 13:46:23 -0800 |
commit | a36d202e862f3fe0652e4f46cf7713120f50be28 (patch) | |
tree | 57b26749c5aff5e02e379fd5ae9824e513677fd4 /src/Text/Pandoc/Extensions.hs | |
parent | ca17ae52465e0194b97d38b9a065a8186cb23a6d (diff) | |
download | pandoc-a36d202e862f3fe0652e4f46cf7713120f50be28.tar.gz |
Text.Pandoc.Shared: add parameter to uniqueIdent, inlineListToIdentifier.
The parameter is Extensions. This allows these functions to
be sensitive to the settings of `Ext_gfm_auto_identifiers` and
`Ext_ascii_identifiers`.
This allows us to use `uniqueIdent` in the CommonMark reader,
replacing some custom code.
It also means that `gfm_auto_identifiers` can now be used
in all formats.
Semantically, `gfm_auto_identifiers` is now a modifier of
`auto_identifiers`; for identifiers to be set, `auto_identifiers`
must be turned on, and then the type of identifier produced
depends on `gfm_auto_identifiers` and `ascii_identifiers` are set.
Closes #5057.
Diffstat (limited to 'src/Text/Pandoc/Extensions.hs')
-rw-r--r-- | src/Text/Pandoc/Extensions.hs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Extensions.hs b/src/Text/Pandoc/Extensions.hs index 1df21e24f..f2599ed6d 100644 --- a/src/Text/Pandoc/Extensions.hs +++ b/src/Text/Pandoc/Extensions.hs @@ -56,7 +56,7 @@ import Data.Bits (clearBit, setBit, testBit, (.|.)) import Data.Data (Data) import Data.Typeable (Typeable) import GHC.Generics (Generic) -import Text.Pandoc.Shared (safeRead) +import Safe (readMay) import Text.Parsec #ifdef DERIVE_JSON_VIA_TH @@ -96,7 +96,8 @@ data Extension = | Ext_all_symbols_escapable -- ^ Make all non-alphanumerics escapable | Ext_amuse -- ^ Enable Text::Amuse extensions to Emacs Muse markup | Ext_angle_brackets_escapable -- ^ Make < and > escapable - | Ext_ascii_identifiers -- ^ ascii-only identifiers for headers + | Ext_ascii_identifiers -- ^ ascii-only identifiers for headers; + -- presupposes Ext_auto_identifiers | Ext_auto_identifiers -- ^ Automatic identifiers for headers | Ext_autolink_bare_uris -- ^ Make all absolute URIs into links | Ext_backtick_code_blocks -- ^ GitHub style ``` code blocks @@ -123,8 +124,9 @@ data Extension = | Ext_fenced_divs -- ^ Allow fenced div syntax ::: | Ext_footnotes -- ^ Pandoc\/PHP\/MMD style footnotes | Ext_four_space_rule -- ^ Require 4-space indent for list contents - | Ext_gfm_auto_identifiers -- ^ Automatic identifiers for headers, using - -- GitHub's method for generating identifiers + | Ext_gfm_auto_identifiers -- ^ Use GitHub's method for generating + -- header identifiers; presupposes + -- Ext_auto_identifiers | Ext_grid_tables -- ^ Grid tables (pandoc, reST) | Ext_hard_line_breaks -- ^ All newlines become hard line breaks | Ext_header_attributes -- ^ Explicit header attributes {#id .class k=v} @@ -265,6 +267,7 @@ githubMarkdownExtensions = extensionsFromList , Ext_pipe_tables , Ext_raw_html , Ext_fenced_code_blocks + , Ext_auto_identifiers , Ext_gfm_auto_identifiers , Ext_backtick_code_blocks , Ext_autolink_bare_uris @@ -384,7 +387,7 @@ parseFormatSpec = parse formatSpec "" extMod = do polarity <- oneOf "-+" name <- many $ noneOf "-+" - ext <- case safeRead ("Ext_" ++ name) of + ext <- case readMay ("Ext_" ++ name) of Just n -> return n Nothing | name == "lhs" -> return Ext_literate_haskell |