Skip to content

Fix list ordering, numbers, and potentially extra newlines within #276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
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
17 changes: 10 additions & 7 deletions src/writer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@
# Code blocks
function render(io::IO, mime::MIME"text/plain", node::Documenter.MarkdownAST.Node, code::MarkdownAST.CodeBlock, page, doc; kwargs...)
if startswith(code.info, "@")
@warn """

Check warning on line 1003 in src/writer.jl

View workflow job for this annotation

GitHub Actions / build

DocumenterVitepress: un-expanded `@doctest` block encountered on page src/manual/code_example.md. The first few lines of code in this node are: ``` julia> 1 + 1 2 ```
DocumenterVitepress: un-expanded `$(code.info)` block encountered on page $(page.source).
The first few lines of code in this node are:
```
Expand Down Expand Up @@ -1086,18 +1086,21 @@
println(io, "\$\$", math.math, "\$\$")
end
# Lists
# TODO: list ordering is broken!
function render(io::IO, mime::MIME"text/plain", node::Documenter.MarkdownAST.Node, list::MarkdownAST.List, page, doc; kwargs...)
# @infiltrate
k = 0
bullet() = list.type === :ordered ? "$(k+=1). " : "- "
bullet(i) = list.type === :ordered ? "$(i+1). " : "- "

Check warning on line 1090 in src/writer.jl

View check run for this annotation

Codecov / codecov/patch

src/writer.jl#L1090

Added line #L1090 was not covered by tests
# `iob` is reset at `take!` and then reused in the next loop
iob = IOBuffer()
for item in node.children
# Loop through all items of the list
for (i, item) in enumerate(node.children)

Check warning on line 1094 in src/writer.jl

View check run for this annotation

Codecov / codecov/patch

src/writer.jl#L1094

Added line #L1094 was not covered by tests
render(iob, mime, item, item.children, page, doc; prenewline = false, kwargs...)
eachline = split(String(take!(iob)), '\n')
eachline[2:end] .= " " .* eachline[2:end]
print(io, bullet())
println.((io,), eachline)
final_string = join(eachline, '\n')
if !endswith(final_string, '\n')
final_string = final_string * "\n"

Check warning on line 1100 in src/writer.jl

View check run for this annotation

Codecov / codecov/patch

src/writer.jl#L1098-L1100

Added lines #L1098 - L1100 were not covered by tests
end
print(io, bullet(i))
print(io, final_string)

Check warning on line 1103 in src/writer.jl

View check run for this annotation

Codecov / codecov/patch

src/writer.jl#L1102-L1103

Added lines #L1102 - L1103 were not covered by tests
end
end
# HTMLInline
Expand Down
Loading