From c193623105161dfb42dfb4da84b3670dfcee3eb9 Mon Sep 17 00:00:00 2001 From: Nathan Musoke Date: Tue, 16 Apr 2024 18:01:21 -0400 Subject: [PATCH] Remove @extref from non-Documenter output Recent versions of Documenter use `@extref` link to documentation of external packages. Remove these in the same way and under the same conditions as `@ref` and `@id` tags. --- CHANGELOG.md | 9 +++++++++ docs/src/documenter.md | 8 ++++---- src/Literate.jl | 4 +++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a10657..6d58f2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Added + - Literate will now remove Documenter-style `@extref` links under the same + circumstances as `@ref` and `@id`. Recent versions of Documenter use + `@extref` to links to the documentation of external packages. See + https://github.com/JuliaDocs/Documenter.jl/issues/2366 for details of + the Documenter implementation. + ## [v2.17.0] - 2024-04-14 ### Added - Literate can now output [Quarto](https://quarto.org/) notebooks (markdown documents with diff --git a/docs/src/documenter.md b/docs/src/documenter.md index 72057b9..5598423 100644 --- a/docs/src/documenter.md +++ b/docs/src/documenter.md @@ -31,8 +31,8 @@ if we set `documenter = true`: ```` ### [`Literate.notebook`](@ref): -- Documenter style `@ref`s and `@id` will be removed. This means that you can use - `@ref` and `@id` in the source file without them leaking to the notebook. +- Documenter style `@ref`s, `@extref`s and `@id` will be removed. This means that you can use + `@ref`, `@extref` and `@id` in the source file without them leaking to the notebook. - Documenter style markdown math ```` ```math @@ -57,5 +57,5 @@ if we set `documenter = true`: ``` ### [`Literate.script`](@ref): -- Documenter style `@ref`s and `@id` will be removed. This means that you can use - `@ref` and `@id` in the source file without them leaking to the script. +- Documenter style `@ref`s, `@extref`s and `@id` will be removed. This means that you can use + `@ref`, `@extref` and `@id` in the source file without them leaking to the script. diff --git a/src/Literate.jl b/src/Literate.jl index 55a064f..046bd87 100644 --- a/src/Literate.jl +++ b/src/Literate.jl @@ -217,9 +217,11 @@ function replace_default(content, sym; # Run some Documenter specific things if !isdocumenter(config) - ## - remove documenter style `@ref`s and `@id`s + ## - remove documenter style `@ref`s, `@extref`s and `@id`s push!(repls, r"\[([^]]+?)\]\(@ref\)"s => s"\1") # [foo](@ref) => foo push!(repls, r"\[([^]]+?)\]\(@ref .*?\)"s => s"\1") # [foo](@ref bar) => foo + push!(repls, r"\[([^]]+?)\]\(@extref\)"s => s"\1") # [foo](@extref) => foo + push!(repls, r"\[([^]]+?)\]\(@extref .*?\)"s => s"\1") # [foo](@extref bar) => foo push!(repls, r"\[([^]]+?)\]\(@id .*?\)"s => s"\1") # [foo](@id bar) => foo end