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

Revert escaping dollar symbol #193

Merged
merged 3 commits into from
Jun 12, 2024
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 = "PlutoStaticHTML"
uuid = "359b1769-a58e-495b-9770-312e911026ad"
authors = ["Rik Huijzer <github@huijzer.xyz>"]
version = "6.0.24"
version = "6.0.25"

[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
Expand Down
32 changes: 13 additions & 19 deletions docs/src/notebooks/example.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ For example, $x = 3\pi$ and
```math
y = \frac{a \cdot b}{c^2}
```

For using the dollar symbol normally, escape it with a backslash just like in Pluto:
```markdown
The prices were \$5 and \$10.
```
The prices were \$5 and \$10.
"""

# ╔═╡ 3207c229-6a6b-4219-9960-f08ebdff245a
Expand Down Expand Up @@ -74,7 +68,7 @@ DataFrames = "~1.6.1"
PLUTO_MANIFEST_TOML_CONTENTS = """
# This file is machine-generated - editing it directly is not advised

julia_version = "1.10.3"
julia_version = "1.10.4"
manifest_format = "2.0"
project_hash = "c0130941acb94849fd135523260f350f5e51bac6"

Expand Down Expand Up @@ -127,9 +121,9 @@ version = "1.1.1"

[[deps.ArrayInterface]]
deps = ["Adapt", "LinearAlgebra", "SparseArrays", "SuiteSparse"]
git-tree-sha1 = "133a240faec6e074e07c31ee75619c90544179cf"
git-tree-sha1 = "ed2ec3c9b483842ae59cd273834e5b46206d6dda"
uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
version = "7.10.0"
version = "7.11.0"

[deps.ArrayInterface.extensions]
ArrayInterfaceBandedMatricesExt = "BandedMatrices"
Expand Down Expand Up @@ -417,9 +411,9 @@ uuid = "2e619515-83b5-522b-bb60-26c02a35a201"
version = "2.6.2+0"

[[deps.Extents]]
git-tree-sha1 = "2140cd04483da90b2da7f99b2add0750504fc39c"
git-tree-sha1 = "94997910aca72897524d2237c41eb852153b0f65"
uuid = "411431e0-e8b7-467b-b5e0-f676ba4f2910"
version = "0.1.2"
version = "0.1.3"

[[deps.FFMPEG_jll]]
deps = ["Artifacts", "Bzip2_jll", "FreeType2_jll", "FriBidi_jll", "JLLWrappers", "LAME_jll", "Libdl", "Ogg_jll", "OpenSSL_jll", "Opus_jll", "PCRE2_jll", "Zlib_jll", "libaom_jll", "libass_jll", "libfdk_aac_jll", "libvorbis_jll", "x264_jll", "x265_jll"]
Expand Down Expand Up @@ -672,9 +666,9 @@ version = "0.15.1"

[[deps.IntervalArithmetic]]
deps = ["CRlibm_jll", "MacroTools", "RoundingEmulator"]
git-tree-sha1 = "90709228dc114e599a2b62b7d23482a4f50938ee"
git-tree-sha1 = "433b0bb201cd76cb087b017e49244f10394ebe9c"
uuid = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253"
version = "0.22.13"
version = "0.22.14"
weakdeps = ["DiffRules", "ForwardDiff", "RecipesBase"]

[deps.IntervalArithmetic.extensions]
Expand Down Expand Up @@ -1024,9 +1018,9 @@ version = "0.8.1+2"

[[deps.OpenSSL_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "3da7367955dcc5c54c1ba4d402ccdc09a1a3e046"
git-tree-sha1 = "a028ee3cb5641cccc4c24e90c36b0a4f7707bdf5"
uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95"
version = "3.0.13+1"
version = "3.0.14+0"

[[deps.OpenSpecFun_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"]
Expand Down Expand Up @@ -1421,19 +1415,19 @@ version = "0.1.1"

[[deps.StaticArrays]]
deps = ["LinearAlgebra", "PrecompileTools", "Random", "StaticArraysCore"]
git-tree-sha1 = "9ae599cd7529cfce7fea36cf00a62cfc56f0f37c"
git-tree-sha1 = "6e00379a24597be4ae1ee6b2d882e15392040132"
uuid = "90137ffa-7385-5640-81b9-e52037218182"
version = "1.9.4"
version = "1.9.5"
weakdeps = ["ChainRulesCore", "Statistics"]

[deps.StaticArrays.extensions]
StaticArraysChainRulesCoreExt = "ChainRulesCore"
StaticArraysStatisticsExt = "Statistics"

[[deps.StaticArraysCore]]
git-tree-sha1 = "36b3d696ce6366023a0ea192b4cd442268995a0d"
git-tree-sha1 = "192954ef1208c7019899fbf8049e717f92959682"
uuid = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
version = "1.4.2"
version = "1.4.3"

[[deps.Statistics]]
deps = ["LinearAlgebra", "SparseArrays"]
Expand Down
14 changes: 0 additions & 14 deletions src/html.jl
Original file line number Diff line number Diff line change
Expand Up @@ -136,22 +136,8 @@ function _output2html(cell::Cell, ::MIME"text/plain", oopts)
output_block(body; oopts.output_pre_class, var)
end

function _patch_dollar_symbols(body::String)::String
lines = split(body, '\n')
# Pluto wraps inline LaTeX in a tex class, so if we see a dollar symbol in a plain text output,
# we should escape it since it is not a LaTeX expression.
for i in 1:length(lines)
line = lines[i]
if !(contains(line, "<pre>") || contains(line, "<code>") || contains(line, "class=\"tex\""))
lines[i] = replace(line, "&#36;" => raw"\$")
end
end
return join(lines, '\n')
end

function _output2html(cell::Cell, ::MIME"text/html", oopts)
body = string(cell.output.body)::String
body = _patch_dollar_symbols(body)::String

if contains(body, """<script type="text/javascript" id="plutouiterminal">""")
return _patch_with_terminal(body)
Expand Down
22 changes: 0 additions & 22 deletions test/html.jl
Original file line number Diff line number Diff line change
Expand Up @@ -243,25 +243,3 @@ end
])
html, _ = notebook2html_helper(nb; use_distributed=false)
end

@testset "patch_dollar_symbols" begin
nb = Notebook([
Cell(raw"""
md\"\"\"
# Foo

```markdown
The prices are \$4 and \$5.
```
The prices are \$10 and \$20.

But this is math $x$.
\"\"\"
""")
])
html, _ = notebook2html_helper(nb; use_distributed=false)
# Verify that inline math is converted to `<span class="tex">` by Pluto.
@test contains(html, raw"But this is math <span class=\"tex\">$x$</span>.")
@test contains(html, raw"The prices are \$4 and \$5")
@test contains(html, raw"The prices are \$10 and \$20")
end