git.iko.soy/typeable/pandoc
on master help sign in
Add generic `attributes` extension.
b75d8deJohn MacFarlane
MANUAL.txt+31
@@ -4933,6 +4933,37 @@ in pandoc, but may be enabled by adding `+EXTENSION` to the format
4933name, where `EXTENSION` is the name of the extension. Thus, for
4933name, where `EXTENSION` is the name of the extension. Thus, for
4934example, `markdown+hard_line_breaks` is Markdown with hard line breaks.
4934example, `markdown+hard_line_breaks` is Markdown with hard line breaks.
4935
4935
4936+#### Extension: `attributes` ####
4937+
4938+Allows attributes to be attached to any inline or block-level
4939+element. The syntax for the attributes is the same as that
4940+used in [`header_attributes`][Extension: `header_attributes`].
4941+
4942+- Attributes that occur immediately after an inline
4943+ element affect that element. If they follow a space, then they
4944+ belong to the space. (Hence, this option subsumes
4945+ `inline_code_attributes` and `link_attributes`.)
4946+- Attributes that occur immediately before a block
4947+ element, on a line by themselves, affect that
4948+ element.
4949+- Consecutive attribute specifiers may be used,
4950+ either for blocks or for inlines. Their attributes
4951+ will be combined.
4952+- Attributes that occur at the end of the text of
4953+ a Setext or ATX heading (separated by whitespace
4954+ from the text) affect the heading element. (Hence, this
4955+ option subsumes `header_attributes`.)
4956+- Attributes that occur after the opening fence
4957+ in a fenced code block affect the code block element. (Hence,
4958+ this option subsumes `fenced_code_attributes`.)
4959+- Attributes that occur at the end of a reference
4960+ link definition affect links that refer to that
4961+ definition.
4962+
4963+Note that pandoc's AST does not currently allow attributes
4964+to be attached to arbitrary elements. Hence a Span or Div
4965+container will be added if needed.
4966+
4936#### Extension: `old_dashes` ####
4967#### Extension: `old_dashes` ####
4937
4968
4938Selects the pandoc <= 1.8.2.1 behavior for parsing smart dashes:
4969Selects the pandoc <= 1.8.2.1 behavior for parsing smart dashes:
src/Text/Pandoc/Extensions.hs+2−4
@@ -150,6 +150,7 @@ data Extension =
150 | Ext_tex_math_single_backslash -- ^ TeX math btw \(..\) \[..\]
150 | Ext_tex_math_single_backslash -- ^ TeX math btw \(..\) \[..\]
151 | Ext_yaml_metadata_block -- ^ YAML metadata block
151 | Ext_yaml_metadata_block -- ^ YAML metadata block
152 | Ext_gutenberg -- ^ Use Project Gutenberg conventions for plain
152 | Ext_gutenberg -- ^ Use Project Gutenberg conventions for plain
153+ | Ext_attributes -- ^ Generic attribute syntax
153 deriving (Show, Read, Enum, Eq, Ord, Bounded, Data, Typeable, Generic)
154 deriving (Show, Read, Enum, Eq, Ord, Bounded, Data, Typeable, Generic)
154
155
155-- | Extensions to be used with pandoc-flavored markdown.
156-- | Extensions to be used with pandoc-flavored markdown.
@@ -447,11 +448,8 @@ getAllExtensions f = universalExtensions <> getAll f
447 , Ext_fenced_divs
448 , Ext_fenced_divs
448 , Ext_bracketed_spans
449 , Ext_bracketed_spans
449 , Ext_raw_attribute
450 , Ext_raw_attribute
450− , Ext_inline_code_attributes
451− , Ext_fenced_code_attributes
452− , Ext_link_attributes
453− , Ext_header_attributes
454 , Ext_implicit_header_references
451 , Ext_implicit_header_references
452+ , Ext_attributes
455 ]
453 ]
456 getAll "commonmark" = getAll "gfm"
454 getAll "commonmark" = getAll "gfm"
457 getAll "org" = autoIdExtensions <>
455 getAll "org" = autoIdExtensions <>
src/Text/Pandoc/Readers/CommonMark.hs+1−4
@@ -48,10 +48,7 @@ readCommonMark opts s = do
48 [ fencedDivSpec | isEnabled Ext_fenced_divs opts ] ++
48 [ fencedDivSpec | isEnabled Ext_fenced_divs opts ] ++
49 [ bracketedSpanSpec | isEnabled Ext_bracketed_spans opts ] ++
49 [ bracketedSpanSpec | isEnabled Ext_bracketed_spans opts ] ++
50 [ rawAttributeSpec | isEnabled Ext_raw_attribute opts ] ++
50 [ rawAttributeSpec | isEnabled Ext_raw_attribute opts ] ++
51− [ attributesSpec | isEnabled Ext_link_attributes opts ||
51+ [ attributesSpec | isEnabled Ext_attributes opts ] ++
52− isEnabled Ext_inline_code_attributes opts ||
53− isEnabled Ext_fenced_code_attributes opts ||
54− isEnabled Ext_header_attributes opts ] ++
55 [ pipeTableSpec | isEnabled Ext_pipe_tables opts ] ++
52 [ pipeTableSpec | isEnabled Ext_pipe_tables opts ] ++
56 [ autolinkSpec | isEnabled Ext_autolink_bare_uris opts ] ++
53 [ autolinkSpec | isEnabled Ext_autolink_bare_uris opts ] ++
57 [ emojiSpec | isEnabled Ext_emoji opts ] ++
54 [ emojiSpec | isEnabled Ext_emoji opts ] ++