From 0cba0b60b42fa62bb3ad7c9b3e03bd1c1cb41ae2 Mon Sep 17 00:00:00 2001 From: Thibaut Lienart Date: Sat, 19 Aug 2023 11:33:18 +0200 Subject: [PATCH] adding explicit classes for repl mode (#1050) * adding explicit classes for repl mode * forcing code blocks in help mode to be language julia * patch release with explicit repl classes --- Project.toml | 2 +- src/eval/codeblock.jl | 3 ++- src/utils/html.jl | 3 ++- test/eval/repl.jl | 16 ++++++++-------- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Project.toml b/Project.toml index 270b7d74e..0c7b16f56 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Franklin" uuid = "713c75ef-9fc9-4b05-94a9-213340da978e" authors = ["Thibaut Lienart "] -version = "0.10.90" +version = "0.10.91" [deps] Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" diff --git a/src/eval/codeblock.jl b/src/eval/codeblock.jl index 66c07541c..560a3af0d 100644 --- a/src/eval/codeblock.jl +++ b/src/eval/codeblock.jl @@ -212,7 +212,8 @@ function resolve_code_block( code => replace(Markdown.html(r), r"\" => "", "" => "", - "language-jldoctest" => "language-julia-repl" + "language-jldoctest" => "language-julia-repl", + "
" => "
"
                 )
             )
 
diff --git a/src/utils/html.jl b/src/utils/html.jl
index 42aeef975..13f1dfc80 100644
--- a/src/utils/html.jl
+++ b/src/utils/html.jl
@@ -116,7 +116,8 @@ html_code_inline(c::AS) = "$c"
 function html_repl_code(chunks::Vector{Pair{String,String}}, s::Symbol)::String
     isempty(chunks) && return ""
     io = IOBuffer()
-    print(io, "
")
+    class = "julia-repl" * ifelse(s == :repl, "", "-$s")
+    print(io, "
")
     prefix = s == :repl ? "julia> " :
              s == :help ? "help?> " :
              s == :pkg ? "" : # the project name is recuperated in resolve_block
diff --git a/test/eval/repl.jl b/test/eval/repl.jl
index dea8d2bbc..042cdbc4c 100644
--- a/test/eval/repl.jl
+++ b/test/eval/repl.jl
@@ -11,7 +11,7 @@
     """ |> fd2html
 
     @test isapproxstr(s, """
-        
julia> x = 5
+        
julia> x = 5
         5
 
         julia> y = 7 + x
@@ -20,7 +20,7 @@
         

some explanation

-

+        

         julia> z = y * 2
         24
 
@@ -34,7 +34,7 @@
     ```
     """ |> fd2html
     @test isapproxstr(s, """
-        
julia> println("hello")
+        
julia> println("hello")
         hello
         
         julia> x = 5
@@ -49,7 +49,7 @@
     ```
     """ |> fd2html
     @test isapproxstr(s, """
-        
julia> x = 5;
+        
julia> x = 5;
 
         
""" @@ -64,10 +64,10 @@ end """ |> fd2html @test occursin(""" -
help?> im
+        
help?> im
         
-
im
+
im

The imaginary unit.

""", s) end @@ -79,7 +79,7 @@ end ``` """ |> fd2html @test isapproxstr(s, """ -
shell> echo "foo"
+        
shell> echo "foo"
         "foo"
         
""") @@ -91,7 +91,7 @@ end ``` """ |> fd2html @test isapproxstr(s, """ -
shell> echo abc
+        
shell> echo abc
         abc
         
         shell> echo "abc"