Skip to content

Commit ccd9c40

Browse files
authored
Merge pull request #239 from LuxDL/ap/citation_links
2 parents 14a8110 + 19c20f7 commit ccd9c40

File tree

6 files changed

+30
-24
lines changed

6 files changed

+30
-24
lines changed

.github/workflows/Documenter.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ permissions:
2020
pages: write
2121
id-token: write
2222
statuses: write
23-
23+
2424
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
2525
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
2626
concurrency:
@@ -38,9 +38,6 @@ jobs:
3838
uses: julia-actions/setup-julia@v1
3939
- name: Pull Julia cache
4040
uses: julia-actions/cache@v1
41-
- name: Install documentation dependencies
42-
run: julia --project=docs -e 'using Pkg; pkg"dev ."; Pkg.instantiate(); Pkg.precompile(); Pkg.status()'
43-
#- name: Creating new mds from src
4441
- name: Build and deploy docs
4542
uses: julia-actions/julia-docdeploy@v1
4643
env:

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "DocumenterVitepress"
22
uuid = "4710194d-e776-4893-9690-8d956a29c365"
33
authors = ["Lazaro Alonso <[email protected]>", "Anshul Singhvi <[email protected]>"]
4-
version = "0.1.11"
4+
version = "0.1.12"
55

66
[deps]
77
ANSIColoredPrinters = "a4c015fc-c6ff-483c-b24f-f7ea428134e9"

docs/Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
33
DocumenterVitepress = "4710194d-e776-4893-9690-8d956a29c365"
44
DocumenterCitations = "daee34ce-89f3-4625-b898-19384cb65244"
5+
6+
[sources]
7+
DocumenterVitepress = { path = ".." }

docs/src/manual/citations.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ This is the default style (`style=:numeric`) used throughout the other pages of
3737
```@bibliography
3838
Pages = [@__FILE__]
3939
Style = :numeric
40-
Canonical = false
4140
```
4241

4342
## [Author-year style](@id author_year_style)

ext/DocumenterVitepressDocumenterCitationsExt.jl

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,40 @@ module DocumenterVitepressDocumenterCitationsExt
33
using DocumenterCitations, DocumenterVitepress
44

55
import 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
1415
function 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...)
2519
end
2620

2721
function _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
3740
end
3841

3942
# Below is the code intended for LaTeXWriter.

src/writer.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,10 @@ function render(io::IO, mime::MIME"text/plain", node::Documenter.MarkdownAST.Nod
965965
println.((io,), eachline)
966966
end
967967
end
968+
# HTMLInline
969+
function render(io::IO, mime::MIME"text/plain", node::Documenter.MarkdownAST.Node, html::MarkdownAST.HTMLInline, page, doc; kwargs...)
970+
println(io, html.html)
971+
end
968972
# Tables
969973
function render(io::IO, mime::MIME"text/plain", node::Documenter.MarkdownAST.Node, table::MarkdownAST.TableCell, page, doc; kwargs...)
970974
println("Encountered table cell!")

0 commit comments

Comments
 (0)