Skip to content

Commit

Permalink
adding explicit classes for repl mode (#1050)
Browse files Browse the repository at this point in the history
* adding explicit classes for repl mode

* forcing code blocks in help mode to be language julia

* patch release with explicit repl classes
  • Loading branch information
tlienart authored Aug 19, 2023
1 parent 7cdbba6 commit 0cba0b6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
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.90"
version = "0.10.91"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand Down
3 changes: 2 additions & 1 deletion src/eval/codeblock.jl
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ function resolve_code_block(
code => replace(Markdown.html(r),
r"\<a href=\"@ref(.*?)\"\>" => "",
"</code></a>" => "</code>",
"language-jldoctest" => "language-julia-repl"
"language-jldoctest" => "language-julia-repl",
"<pre><code>" => "<pre><code class=\"language-julia\">"
)
)

Expand Down
3 changes: 2 additions & 1 deletion src/utils/html.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ html_code_inline(c::AS) = "<code>$c</code>"
function html_repl_code(chunks::Vector{Pair{String,String}}, s::Symbol)::String
isempty(chunks) && return ""
io = IOBuffer()
print(io, "<pre><code class=\"language-julia-repl\">")
class = "julia-repl" * ifelse(s == :repl, "", "-$s")
print(io, "<pre><code class=\"language-julia-repl $class\">")
prefix = s == :repl ? "julia> " :
s == :help ? "help?> " :
s == :pkg ? "" : # the project name is recuperated in resolve_block
Expand Down
16 changes: 8 additions & 8 deletions test/eval/repl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
""" |> fd2html

@test isapproxstr(s, """
<pre><code class="language-julia-repl">julia> x &#61; 5
<pre><code class="language-julia-repl julia-repl">julia> x &#61; 5
5
julia> y &#61; 7 &#43; x
Expand All @@ -20,7 +20,7 @@
</code></pre>
<p>some explanation</p>
<pre><code class="language-julia-repl">
<pre><code class="language-julia-repl julia-repl">
julia> z &#61; y * 2
24
Expand All @@ -34,7 +34,7 @@
```
""" |> fd2html
@test isapproxstr(s, """
<pre><code class="language-julia-repl">julia> println&#40;&quot;hello&quot;&#41;
<pre><code class="language-julia-repl julia-repl">julia> println&#40;&quot;hello&quot;&#41;
hello
julia> x &#61; 5
Expand All @@ -49,7 +49,7 @@
```
""" |> fd2html
@test isapproxstr(s, """
<pre><code class="language-julia-repl">julia> x &#61; 5;
<pre><code class="language-julia-repl julia-repl">julia> x &#61; 5;
</code></pre>
"""
Expand All @@ -64,10 +64,10 @@ end
""" |> fd2html

@test occursin("""
<pre><code class="language-julia-repl">help?> im
<pre><code class="language-julia-repl julia-repl-help">help?> im
</code></pre>
<div class="julia-help">
<pre><code>im</code></pre>
<pre><code class="language-julia">im</code></pre>
<p>The imaginary unit.</p>
""", s)
end
Expand All @@ -79,7 +79,7 @@ end
```
""" |> fd2html
@test isapproxstr(s, """
<pre><code class="language-julia-repl">shell> echo &quot;foo&quot;
<pre><code class="language-julia-repl julia-repl-shell">shell> echo &quot;foo&quot;
"foo"
</code></pre>
""")
Expand All @@ -91,7 +91,7 @@ end
```
""" |> fd2html
@test isapproxstr(s, """
<pre><code class="language-julia-repl">shell> echo abc
<pre><code class="language-julia-repl julia-repl-shell">shell> echo abc
abc
shell> echo &quot;abc&quot;
Expand Down

2 comments on commit 0cba0b6

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

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.91 -m "<description of version>" 0cba0b60b42fa62bb3ad7c9b3e03bd1c1cb41ae2
git push origin v0.10.91

Please sign in to comment.