Skip to content

Commit 142bbee

Browse files
authored
Remove at-extref from non-Documenter output (#245)
1 parent 65e8796 commit 142bbee

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased]
9+
10+
### Added
11+
- Literate will now remove Documenter-style `@extref` links under the same
12+
circumstances as `@ref` and `@id`. Recent versions of Documenter use
13+
`@extref` to links to the documentation of external packages. See
14+
https://github.com/JuliaDocs/Documenter.jl/issues/2366 for details of
15+
the Documenter implementation. ([#245])
16+
817
## [v2.17.0] - 2024-04-14
918
### Added
1019
- Literate can now output [Quarto](https://quarto.org/) notebooks (markdown documents with
@@ -303,6 +312,7 @@ https://discourse.julialang.org/t/ann-literate-jl/10651 for release announcement
303312
[#229]: https://github.com/fredrikekre/Literate.jl/issues/229
304313
[#230]: https://github.com/fredrikekre/Literate.jl/issues/230
305314
[#233]: https://github.com/fredrikekre/Literate.jl/issues/233
315+
[#245]: https://github.com/fredrikekre/Literate.jl/issues/245
306316
[0872a96]: https://github.com/fredrikekre/Literate.jl/commit/0872a96
307317
[0f9e836]: https://github.com/fredrikekre/Literate.jl/commit/0f9e836
308318
[1d02868]: https://github.com/fredrikekre/Literate.jl/commit/1d02868

docs/src/documenter.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ if we set `documenter = true`:
3131
````
3232

3333
### [`Literate.notebook`](@ref):
34-
- Documenter style `@ref`s and `@id` will be removed. This means that you can use
35-
`@ref` and `@id` in the source file without them leaking to the notebook.
34+
- Documenter style `@ref`s, `@extref`s and `@id` will be removed. This means that you can use
35+
`@ref`, `@extref` and `@id` in the source file without them leaking to the notebook.
3636
- Documenter style markdown math
3737
````
3838
```math
@@ -57,5 +57,5 @@ if we set `documenter = true`:
5757
```
5858

5959
### [`Literate.script`](@ref):
60-
- Documenter style `@ref`s and `@id` will be removed. This means that you can use
61-
`@ref` and `@id` in the source file without them leaking to the script.
60+
- Documenter style `@ref`s, `@extref`s and `@id` will be removed. This means that you can use
61+
`@ref`, `@extref` and `@id` in the source file without them leaking to the script.

src/Literate.jl

+3-1
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,11 @@ function replace_default(content, sym;
217217

218218
# Run some Documenter specific things
219219
if !isdocumenter(config)
220-
## - remove documenter style `@ref`s and `@id`s
220+
## - remove documenter style `@ref`s, `@extref`s and `@id`s
221221
push!(repls, r"\[([^]]+?)\]\(@ref\)"s => s"\1") # [foo](@ref) => foo
222222
push!(repls, r"\[([^]]+?)\]\(@ref .*?\)"s => s"\1") # [foo](@ref bar) => foo
223+
push!(repls, r"\[([^]]+?)\]\(@extref\)"s => s"\1") # [foo](@extref) => foo
224+
push!(repls, r"\[([^]]+?)\]\(@extref .*?\)"s => s"\1") # [foo](@extref bar) => foo
223225
push!(repls, r"\[([^]]+?)\]\(@id .*?\)"s => s"\1") # [foo](@id bar) => foo
224226
end
225227

test/runtests.jl

+5-1
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ end # testset parser
220220
content = """
221221
# # [Example](@id example-id)
222222
# [foo](@ref), [bar](@ref bbaarr)
223+
# [baz](@extref), [bax](@extref bbaaxx)
223224
x = 1
224225
#md # Only markdown
225226
# Only markdown #md
@@ -580,6 +581,7 @@ end end
580581
581582
# [Example](@id example-id)
582583
[foo](@ref), [bar](@ref bbaarr)
584+
[baz](@extref), [bax](@extref bbaaxx)
583585
584586
````@example inputfile
585587
x = 1
@@ -1027,7 +1029,8 @@ end end
10271029
"""
10281030
"source": [
10291031
"# Example\\n",
1030-
"foo, bar"
1032+
"foo, bar\\n",
1033+
"baz, bax"
10311034
]
10321035
""",
10331036

@@ -1263,6 +1266,7 @@ end end
12631266
notebook = read(joinpath(outdir, "inputfile.ipynb"), String)
12641267
@test !occursin("# [Example](@id example-id", notebook)
12651268
@test !occursin("[foo](@ref), [bar](@ref bbaarr)", notebook)
1269+
@test !occursin("[baz](@ref), [bax](@ref bbaaxx)", notebook)
12661270

12671271
# name
12681272
Literate.notebook(inputfile, outdir, name = "foobar", execute = false)

0 commit comments

Comments
 (0)