mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-21 23:15:52 +00:00
Implemented Ext_header_identifiers, Ext_implicit_header_references.
Now by default pandoc will act as if link references have been defined
for all headers. So, you can do this:
# My header
Link to [My header].
Another link to [it][My header].
Closes #691.
This commit is contained in:
@@ -858,7 +858,7 @@ wrapping). Consider, for example:
|
||||
|
||||
### Header identifiers in HTML, LaTeX, and ConTeXt ###
|
||||
|
||||
**Extension**
|
||||
**Extension: `header_identifiers`**
|
||||
|
||||
Each header element in pandoc's HTML and ConTeXt output is given a
|
||||
unique identifier. This identifier is based on the text of the header.
|
||||
@@ -906,6 +906,30 @@ and the identifier will be attached to the enclosing `<div>`
|
||||
sections to be manipulated using javascript or treated differently in
|
||||
CSS.
|
||||
|
||||
**Extension: `implicit_header_references`**
|
||||
|
||||
Pandoc behaves as if reference links have been defined for each header.
|
||||
So, instead of
|
||||
|
||||
[header identifiers](#header-identifiers-in-html)
|
||||
|
||||
you can simply write
|
||||
|
||||
[header identifiers]
|
||||
|
||||
or
|
||||
|
||||
[header identifiers][]
|
||||
|
||||
or
|
||||
|
||||
[the section on header identifiers][header identifiers]
|
||||
|
||||
If there are multiple headers with identical text, the corresponding
|
||||
reference will link to the first one only, and you will need to use explicit
|
||||
links to link to the others, as described above.
|
||||
|
||||
Unlike regular reference links, these references are case-sensitive.
|
||||
|
||||
Block quotations
|
||||
----------------
|
||||
|
||||
@@ -89,6 +89,8 @@ data Extension =
|
||||
| Ext_hard_line_breaks -- ^ All newlines become hard line breaks
|
||||
| Ext_literate_haskell -- ^ Enable literate Haskell conventions
|
||||
| Ext_abbreviations -- ^ PHP markdown extra abbreviation definitions
|
||||
| Ext_header_identifiers -- ^ Automatic identifiers for headers
|
||||
| Ext_implicit_header_references -- ^ Implicit reference links for headers
|
||||
deriving (Show, Read, Enum, Eq, Ord, Bounded)
|
||||
|
||||
pandocExtensions :: Set Extension
|
||||
@@ -125,6 +127,8 @@ pandocExtensions = Set.fromList
|
||||
, Ext_strikeout
|
||||
, Ext_superscript
|
||||
, Ext_subscript
|
||||
, Ext_header_identifiers
|
||||
, Ext_implicit_header_references
|
||||
]
|
||||
|
||||
strictExtensions :: Set Extension
|
||||
|
||||
@@ -721,6 +721,7 @@ data ParserState = ParserState
|
||||
stateAuthors :: [[Inline]], -- ^ Authors of document
|
||||
stateDate :: [Inline], -- ^ Date of document
|
||||
stateHeaderTable :: [HeaderType], -- ^ Ordered list of header types used
|
||||
stateHeaders :: [[Inline]], -- ^ List of headers (used for implicit ref links)
|
||||
stateNextExample :: Int, -- ^ Number of next example
|
||||
stateExamples :: M.Map String Int, -- ^ Map from example labels to numbers
|
||||
stateHasChapters :: Bool, -- ^ True if \chapter encountered
|
||||
@@ -747,6 +748,7 @@ defaultParserState =
|
||||
stateAuthors = [],
|
||||
stateDate = [],
|
||||
stateHeaderTable = [],
|
||||
stateHeaders = [],
|
||||
stateNextExample = 1,
|
||||
stateExamples = M.empty,
|
||||
stateHasChapters = False,
|
||||
|
||||
+163
-143
File diff suppressed because it is too large
Load Diff
@@ -281,7 +281,9 @@ elementToHtml slideLevel opts (Sec level num id' title' elements) = do
|
||||
then filter isSec elements
|
||||
else elements
|
||||
let header'' = if (writerSectionDivs opts ||
|
||||
writerSlideVariant opts == S5Slides || slide)
|
||||
writerSlideVariant opts == S5Slides ||
|
||||
slide ||
|
||||
not (isEnabled Ext_header_identifiers opts))
|
||||
then header'
|
||||
else header' ! prefixedId opts id'
|
||||
let inNl x = mconcat $ nl opts : intersperse (nl opts) x ++ [nl opts]
|
||||
|
||||
Reference in New Issue
Block a user