File tree Expand file tree Collapse file tree 2 files changed +35
-2
lines changed Expand file tree Collapse file tree 2 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -128,10 +128,16 @@ blockToMediaWiki b@(RawBlock f str)
128128
129129blockToMediaWiki HorizontalRule = return " \n -----\n "
130130
131- blockToMediaWiki (Header level _ inlines) = do
131+ blockToMediaWiki (Header level (ident,_,_) inlines) = do
132+ opts <- gets stOptions
133+ let autoId = uniqueIdent (writerExtensions opts) inlines mempty
132134 contents <- inlineListToMediaWiki inlines
133135 let eqs = T. replicate level " ="
134- return $ eqs <> " " <> contents <> " " <> eqs <> " \n "
136+ return $
137+ (if T. null ident || autoId == ident
138+ then " "
139+ else " <span id=\" " <> ident <> " \" ></span>\n " )
140+ <> eqs <> " " <> contents <> " " <> eqs <> " \n "
135141
136142blockToMediaWiki (CodeBlock (_,classes,keyvals) str) = do
137143 let at = Set. fromList classes `Set.intersection` highlightingLangs
Original file line number Diff line number Diff line change 1+ ```
2+ % pandoc -f rst -t mediawiki
3+ .. _refsubpage1:
4+
5+ heading
6+ -------
7+
8+ ref to top of this section: `refsubpage1`_.
9+ ^D
10+ <span id="refsubpage1"></span>
11+ = heading =
12+
13+ ref to top of this section: [[#refsubpage1|refsubpage1]].
14+ ```
15+ ```
16+ % pandoc -f markdown -t mediawiki
17+ # Heading {#foo}
18+ ^D
19+ <span id="foo"></span>
20+ = Heading =
21+ ```
22+ ```
23+ % pandoc -f markdown -t mediawiki
24+ # Heading {#heading}
25+ ^D
26+ = Heading =
27+ ```
You can’t perform that action at this time.
0 commit comments