Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions src/html/HTMLWriter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -658,13 +658,11 @@ mutable struct HTMLContext
search_index_js::String
search_navnode::Documenter.NavNode
atexample_warnings::Vector{AtExampleFallbackWarning}
admonition_counters::Dict{String, Int}

HTMLContext(doc, settings = nothing) = new(
doc, settings, [], "", "", "", [], "",
Documenter.NavNode("search", "Search", nothing),
AtExampleFallbackWarning[],
Dict{String, Int}(),
)
end

Expand Down Expand Up @@ -2382,19 +2380,13 @@ function domify(dctx::DCtx, node::Node, a::MarkdownAST.Admonition)

admonition_id = if !isempty(a.title)
base_id = Documenter.slugify(a.title)
counter_key = "title:$(base_id)"
count = get!(dctx.ctx.admonition_counters, counter_key, 0) + 1
dctx.ctx.admonition_counters[counter_key] = count
if count > 1
"$(base_id)-$(count)"
else
base_id
end
node_repr = sprint(io -> show(io, node))
content_hash = bytes2hex(SHA.sha1(node_repr))[1:8]
"$(base_id)-$(content_hash)"
else
counter_key = "category:$(a.category)"
count = get!(dctx.ctx.admonition_counters, counter_key, 0) + 1
dctx.ctx.admonition_counters[counter_key] = count
"$(a.category)-$(count)"
node_repr = sprint(io -> show(io, node))
content_hash = bytes2hex(SHA.sha1(node_repr))[1:8]
"$(a.category)-$(content_hash)"
end
anchor_link = DOM.Tag(:a)[".admonition-anchor", :href => "#$(admonition_id)", :title => "Permalink"]()
inner_div = div[".admonition-body"](domify(dctx, node.children))
Expand Down