Skip to content

Commit

Permalink
global anchors, reflink (#855)
Browse files Browse the repository at this point in the history
* global anchors, reflink

* reverting a few minor changes
  • Loading branch information
tlienart authored Jul 27, 2021
1 parent 83455fe commit 4ba6d90
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Franklin"
uuid = "713c75ef-9fc9-4b05-94a9-213340da978e"
authors = ["Thibaut Lienart <[email protected]>"]
version = "0.10.43"
version = "0.10.44"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand Down
9 changes: 9 additions & 0 deletions src/converter/latex/hyperrefs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,18 @@ lx_citep(lxc::LxCom, _) = form_href(lxc, "BIBR"; class="bibref")

function lx_label(lxc::LxCom, _)
refs = content(lxc.braces[1]) |> strip |> refstring
# note: this overwrites a previous label if there was one already
GLOBAL_VARS["anchors"].first[refs] = url_curpage()
return "<a id=\"$refs\" class=\"anchor\"></a>"
end

@delay function lx_reflink(lxc::LxCom, _)
refs = content(lxc.braces[1]) |> strip |> refstring
anchors = globvar(:anchors)
refs in keys(anchors) || return "#"
return "$(anchors[refs])#$refs"
end

function lx_biblabel(lxc::LxCom, _)::String
name = refstring(stent(lxc.braces[1]))
PAGE_BIBREFS[name] = content(lxc.braces[2])
Expand Down
1 change: 1 addition & 0 deletions src/converter/latex/objects.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const LX_INTERNAL_COMMANDS = [
lxd("label", 1), # \label{id}
lxd("biblabel", 2), # \biblabel{id}{name}
lxd("toc", 0), # \toc
lxd("reflink", 1), # \reflink{id}
# -------------------
# inclusion / outputs (see converter/latex/io.jl)
lxd("input", 2), # \input{what}{rpath}
Expand Down
2 changes: 2 additions & 0 deletions src/converter/markdown/blocks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ function convert_header(β::OCBlock, lxdefs::Vector{LxDef})::String
else
PAGE_HEADERS[rstitle] = (title, 1, parse(Int, hk[2]))
end
# make the header anchor globally available
GLOBAL_VARS["anchors"].first[rstitle] = url_curpage()
# return the title
if globvar(:title_links)::Bool
return html_hk(hk,
Expand Down
2 changes: 2 additions & 0 deletions src/utils/vars.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ const GLOBAL_VARS_DEFAULT = [
"fd_page_tags" => Pair(nothing, (DTAG, Nothing)),
"fd_tag_pages" => Pair(nothing, (DTAGI, Nothing)),
"fd_rss_feed_url" => dpair(""),
# keep track of all anchors {label => page} in case of clash, there's no guarantee
"anchors" => dpair(LittleDict{String,String}()),
# -----------------------------------------------------
# LEGACY
"div_content" => dpair(""), # see build_page
Expand Down

2 comments on commit 4ba6d90

@tlienart
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/41587

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.10.44 -m "<description of version>" 4ba6d9020367468bfb77b5bde9eabb2648ab8a21
git push origin v0.10.44

Please sign in to comment.