tlienart / Franklin.jl

(yet another) static site generator. Simple, customisable, fast, maths with KaTeX, code evaluation, optional pre-rendering, in Julia.
https://franklinjl.org
MIT License
951 stars 113 forks source link

Backslash in single backticks throws error #996

Open maleadt opened 1 year ago

maleadt commented 1 year ago

The following markdown confuses Franklin:

`\`
caused by: I found the opening token 'CODE_SINGLE' but not the corresponding closing token.
Context:

`\` (near line 10)
                            ^---

Stacktrace:
  [1] find_ocblocks(tokens::Vector{Franklin.Token}, ocproto::Franklin.OCProto; inmath::Bool)
    @ Franklin ~/Julia/depot/packages/Franklin/tWDGK/src/parser/ocblocks.jl:39
  [2] find_all_ocblocks(tokens::Vector{Franklin.Token}, ocplist::Vector{Franklin.OCProto}; inmath::Bool)
    @ Franklin ~/Julia/depot/packages/Franklin/tWDGK/src/parser/ocblocks.jl:95
  [3] find_all_ocblocks
    @ ~/Julia/depot/packages/Franklin/tWDGK/src/parser/ocblocks.jl:91 [inlined]
  [4] convert_md(mds::String, pre_lxdefs::Vector{Franklin.LxDef}; isrecursive::Bool, isinternal::Bool, isconfig::Bool, has_mddefs::Bool, pagevar::Bool, nostripp::Bool)
    @ Franklin ~/Julia/depot/packages/Franklin/tWDGK/src/converter/markdown/md.jl:80
  [5] convert_md (repeats 2 times)
    @ ~/Julia/depot/packages/Franklin/tWDGK/src/converter/markdown/md.jl:23 [inlined]
  [6] convert_and_write(root::String, file::String, head::String, pgfoot::String, foot::String, output_path::String)
    @ Franklin ~/Julia/depot/packages/Franklin/tWDGK/src/manager/write_page.jl:175
  [7] process_file_err(case::Symbol, fpair::Pair{String, String}, head::String, pgfoot::String, foot::String, t::Float64)
    @ Franklin ~/Julia/depot/packages/Franklin/tWDGK/src/manager/file_utils.jl:153
  [8] process_file(::Symbol, ::Pair{String, String}, ::String, ::Vararg{Any})
    @ Franklin ~/Julia/depot/packages/Franklin/tWDGK/src/manager/file_utils.jl:104
  [9] fd_loop(cycle_counter::Int64, #unused#::LiveServer.SimpleWatcher, watched_files::NamedTuple{(:other, :infra, :md, :html, :literate), NTuple{5, Dict{Pair{String, String}, Float64}}})
    @ Franklin ~/Julia/depot/packages/Franklin/tWDGK/src/manager/franklin.jl:403
 [10] #241
    @ ~/Julia/depot/packages/Franklin/tWDGK/src/manager/franklin.jl:134 [inlined]
 [11] serve(fw::LiveServer.SimpleWatcher; host::String, port::Int64, dir::String, verbose::Bool, coreloopfun::Franklin.var"#241#244"{NamedTuple{(:other, :infra, :md, :html, :literate), NTuple{5, Dict{Pair{String, String}, Float64}}}}, preprocess_request::typeof(identity), inject_browser_reload_script::Bool, launch_browser::Bool, allow_cors::Bool)
    @ LiveServer ~/Julia/depot/packages/LiveServer/ofHCn/src/server.jl:326
 [12] serve(; clear::Bool, verb::Bool, port::Int64, single::Bool, prerender::Bool, nomess::Bool, is_final_pass::Bool, no_fail_prerender::Bool, eval_all::Bool, silent::Bool, cleanup::Bool, on_write::Franklin.var"#242#245", log::Bool, host::String, show_warnings::Bool, fail_on_warning::Bool, launch::Bool, no_set_paths::Bool, join_to_prepath::String)
    @ Franklin ~/Julia/depot/packages/Franklin/tWDGK/src/manager/franklin.jl:138
 [13] serve()
    @ Franklin ~/Julia/depot/packages/Franklin/tWDGK/src/manager/franklin.jl:49
 [14] top-level scope
    @ REPL[2]:1

Even though \ is legal (as shown here).

This is on 0.10.59, because of https://github.com/tlienart/Franklin.jl/issues/995.

Workaround: add a space (presumably this breaks the \ escaping the backtick):

`\ `
tlienart commented 1 year ago

Yes there was a choice between making \` work or `\` ; your workaround is the expected way to solve the issue :)