Skip to content

Commit

Permalink
Merge pull request #1281 from JuliaDocs/backports-0.24.8
Browse files Browse the repository at this point in the history
Backports for 0.24.8
  • Loading branch information
mortenpi authored Apr 13, 2020
2 parents e71b24d + d984088 commit 82ce084
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Documenter.jl changelog

## Version `v0.24.8`

* ![Enhancement][badge-enhancement] Non-standard admonition categories are (again) applied to the admonition `<div>` elements in HTML output (as `is-category-$category`). ([#1279][github-1279], [#1280][github-1280])

## Version `v0.24.7`

* ![Bugfix][badge-bugfix] Remove `only`, a new export from `Base` on Julia 1.4, from the JS search filter. ([#1264][github-1264])
Expand Down Expand Up @@ -529,6 +533,8 @@
[github-1258]: https://github.com/JuliaDocs/Documenter.jl/pull/1258
[github-1264]: https://github.com/JuliaDocs/Documenter.jl/pull/1264
[github-1269]: https://github.com/JuliaDocs/Documenter.jl/pull/1269
[github-1279]: https://github.com/JuliaDocs/Documenter.jl/issues/1279
[github-1280]: https://github.com/JuliaDocs/Documenter.jl/pull/1280

[documenterlatex]: https://github.com/JuliaDocs/DocumenterLaTeX.jl
[documentermarkdown]: https://github.com/JuliaDocs/DocumenterMarkdown.jl
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Documenter"
uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
version = "0.24.7"
version = "0.24.8"

[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Expand Down
34 changes: 27 additions & 7 deletions src/Writers/HTMLWriter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1595,13 +1595,33 @@ end
function mdconvert(a::Markdown.Admonition, parent; kwargs...)
@tags header div
colorclass =
(a.category == "danger") ? "is-danger" :
(a.category == "warning") ? "is-warning" :
(a.category == "note") ? "is-info" :
(a.category == "info") ? "is-info" :
(a.category == "tip") ? "is-success" :
(a.category == "compat") ? "is-compat" : ""
div[".admonition.$(colorclass)"](
(a.category == "danger") ? ".is-danger" :
(a.category == "warning") ? ".is-warning" :
(a.category == "note") ? ".is-info" :
(a.category == "info") ? ".is-info" :
(a.category == "tip") ? ".is-success" :
(a.category == "compat") ? ".is-compat" : begin
# If the admonition category is not one of the standard ones, we tag the
# admonition div element with a `is-category-$(category)` class. However, we
# first carefully sanitize the category name. Strictly speaking, this is not
# necessary when were using the Markdown parser in the Julia standard library,
# since it restricts the category to [a-z]+. But it is possible for the users to
# construct their own Admonition objects with arbitrary category strings and
# pass them onto Documenter.
#
# (1) remove all characters except A-Z, a-z, 0-9 and -
cat_sanitized = replace(a.category, r"[^A-Za-z0-9-]" => "")
# (2) remove any dashes from the beginning and end of the string
cat_sanitized = replace(cat_sanitized, r"^[-]+" => "")
cat_sanitized = replace(cat_sanitized, r"[-]+$" => "")
# (3) reduce any duplicate dashes in the middle to single dashes
cat_sanitized = replace(cat_sanitized, r"[-]+" => "-")
cat_sanitized = lowercase(cat_sanitized)
# (4) if nothing is left (or the category was empty to begin with), we don't
# apply a class
isempty(cat_sanitized) ? "" : ".is-category-$(cat_sanitized)"
end
div[".admonition$(colorclass)"](
header[".admonition-header"](a.title),
div[".admonition-body"](mdconvert(a.content, a; kwargs...))
)
Expand Down
2 changes: 1 addition & 1 deletion src/deployconfig.jl
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ function post_github_status(type::S, deploydocs_repo::S, sha::S, subfolder=nothi
try
Sys.which("curl") === nothing && return
## Extract owner and repository name
m = match(r"^github.com\/(.+?)\/(.+?\.jl)(.git)?$", deploydocs_repo)
m = match(r"^github.com\/(.+?)\/(.+?)(.git)?$", deploydocs_repo)
m === nothing && return
owner = String(m.captures[1])
repo = String(m.captures[2])
Expand Down
6 changes: 6 additions & 0 deletions test/examples/src/man/style.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ In an admonition it looks like this:
* Nulla quis venenatis justo.
* In non _sodales_ eros.

Also, custom admonition classes can be used:

!!! myadmonition "My Admonition Class"

In the HTML output, this admonition has `is-category-myadmonition` applied to it.

But otherwise

* Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Expand Down
5 changes: 3 additions & 2 deletions test/examples/tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ end
@test joinpath(build_dir, "omitted", "index.html") |> isfile
@test joinpath(build_dir, "hidden", "index.html") |> isfile
@test joinpath(build_dir, "lib", "autodocs", "index.html") |> isfile
@test joinpath(build_dir, "man", "style", "index.html") |> isfile

# Test existence of some HTML elements
indexhtml = String(read(joinpath(build_dir, "index.html")))
#@test occursin("", indexhtml)
man_style_html = String(read(joinpath(build_dir, "man", "style", "index.html")))
@test occursin("is-category-myadmonition", man_style_html)

# Assets
@test joinpath(build_dir, "assets", "documenter.js") |> isfile
Expand Down

2 comments on commit 82ce084

@mortenpi
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator register branch=release-0.24

Release notes:

Release with bugfixes and enhancements. The changes are documented in the CHANGELOG.md file.

@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/12841

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.24.8 -m "<description of version>" 82ce0840cafafcc87ea1d6c2bbd62fdd0bf72fc7
git push origin v0.24.8

Please sign in to comment.