Skip to content
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

adding explicit classes for repl mode #1050

Merged
merged 3 commits into from
Aug 19, 2023
Merged
Show file tree
Hide file tree
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
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 <tlienart@me.com>"]
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