@@ -3,37 +3,40 @@ module DocumenterVitepressDocumenterCitationsExt
33using DocumenterCitations, DocumenterVitepress
44
55import DocumenterVitepress as DV
6- using Documenter: MarkdownAST
6+ using Documenter: Documenter, MarkdownAST
7+ using . MarkdownAST: @ast
78
8- # TODO :
9+ # TODO :
910# - List style (rendered vs unrendered)
1011# - Loose vs tight lists
1112# - handle :dl properly, we cannot use Markdown for this, since it cannot be represented
1213# using pure Markdown. We need to insert HTML directly.
1314# At the moment, we treat :dl as :ol
1415function DV. render (io:: IO , mime:: MIME"text/plain" , node:: DV.MarkdownAST.Node , bibliography:: DocumenterCitations.BibliographyNode , page, doc; kwargs... )
15-
16- println (io)
17- println (io, " ***" )
18- println (io, " # Bibliography" )
19- println (io)
20-
2116 # Turn the list into a proper MarkdownAST.node
2217 bibnode = _bibliography_to_list (bibliography)
23-
2418 return DV. render (io, mime, bibnode, bibnode. element, page, doc; kwargs... )
2519end
2620
2721function _bibliography_to_list (bib:: DocumenterCitations.BibliographyNode )
28- # Construct a MarkdownAST.Node containing this list
29- list = MarkdownAST. List (bib. list_style in [:ol , :dl ] ? :ordered : :bullet , false )
30- node = MarkdownAST. Node (list)
31- for item in bib. items
32- newitem = MarkdownAST. Node (MarkdownAST. Item ())
33- push! (newitem. children, item. reference)
34- push! (node. children, newitem)
35- end
36- node
22+ # Construct a MarkdownAST.Node containing this list
23+ list = MarkdownAST. List (bib. list_style in [:ol , :dl ] ? :ordered : :bullet , false )
24+ node = MarkdownAST. Node (list)
25+ for item in bib. items
26+ newitem = MarkdownAST. Node (MarkdownAST. Item ())
27+ reference = item. reference
28+ if item. anchor_key != = nothing
29+ pushfirst! (
30+ reference. children,
31+ @ast MarkdownAST. HTMLInline (
32+ join ([" <a id='" , item. anchor_key, " '></a>" ])
33+ )
34+ )
35+ end
36+ push! (newitem. children, reference)
37+ push! (node. children, newitem)
38+ end
39+ node
3740end
3841
3942# Below is the code intended for LaTeXWriter.
0 commit comments