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

Failed to serve Literate.jl scripte with ERROR: MethodError: no method matching isless #798

Open newptcai opened 3 years ago

newptcai commented 3 years ago

I am trying to run a quite simple Literate.jl script.

# #A test

3+3

Here's my markdown file

@def tags = ["mathematics", "blog", "programming", "Julia"]
@def showall = true

\literate{/_literate/test.jl}

But I get the following error

julia> serve()
 Activating environment at `~/code/julia/franklin-website/ThrowAwayAllThings/Project.toml`
→ Initial full pass...
ERROR: MethodError: no method matching isless(::String, ::Dates.Date)
Closest candidates are:
  isless(::Missing, ::Any) at missing.jl:87
  isless(::AbstractString, ::AbstractString) at strings/basic.jl:335
  isless(::T, ::T) where T<:Dates.TimeType at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Dates/src/types.jl:418
  ...
Stacktrace:
 [1] lt(::Base.Order.ForwardOrdering, ::String, ::Dates.Date) at ./ordering.jl:57
 [2] lt(::Base.Order.ReverseOrdering{Base.Order.ForwardOrdering}, ::Dates.Date, ::String) at ./ordering.jl:58
 [3] lt(::Base.Order.By{Franklin.var"#sorter#175",Base.Order.ReverseOrdering{Base.Order.ForwardOrdering}}, ::String, ::String) at ./ordering.jl:59
 [4] sort!(::Array{String,1}, ::Int64, ::Int64, ::Base.Sort.InsertionSortAlg, ::Base.Order.By{Franklin.var"#sorter#175",Base.Order.ReverseOrdering{Base.Order.ForwardOrdering}}) at ./sort.jl:498
 [5] sort!(::Array{String,1}, ::Int64, ::Int64, ::Base.Sort.MergeSortAlg, ::Base.Order.By{Franklin.var"#sorter#175",Base.Order.ReverseOrdering{Base.Order.ForwardOrdering}}, ::Array{String,1}) at ./sort.jl:583
 [6] sort! at ./sort.jl:582 [inlined]
 [7] sort! at ./sort.jl:673 [inlined]
 [8] #sort!#7 at ./sort.jl:733 [inlined]
 [9] hfun_taglist() at /home/xing/.julia/packages/Franklin/X69Nd/src/converter/html/functions.jl:223
 [10] top-level scope at none:1
 [11] eval at ./boot.jl:347 [inlined]
 [12] eval at /home/xing/.julia/packages/Franklin/X69Nd/src/Franklin.jl:1 [inlined]
 [13] convert_html_fblock(::Franklin.HFun) at /home/xing/.julia/packages/Franklin/X69Nd/src/converter/html/functions.jl:18
 [14] process_html_qblocks(::String, ::Array{Franklin.AbstractBlock,1}, ::Int64, ::Int64) at /home/xing/.julia/packages/Franklin/X69Nd/src/converter/html/html.jl:121
 [15] process_html_qblocks(::String, ::Array{Franklin.AbstractBlock,1}) at /home/xing/.julia/packages/Franklin/X69Nd/src/converter/html/html.jl:101
 [16] convert_html(::String) at /home/xing/.julia/packages/Franklin/X69Nd/src/converter/html/html.jl:22
 [17] write_tag_page(::String) at /home/xing/.julia/packages/Franklin/X69Nd/src/converter/markdown/tags.jl:96
 [18] generate_tag_pages(::Set{String}) at /home/xing/.julia/packages/Franklin/X69Nd/src/converter/markdown/tags.jl:47
 [19] generate_tag_pages at /home/xing/.julia/packages/Franklin/X69Nd/src/converter/markdown/tags.jl:15 [inlined]
 [20] fd_fullpass(::NamedTuple{(:other, :infra, :md, :html, :literate),NTuple{5,Dict{Pair{String,String},Float64}}}) at /home/xing/.julia/packages/Franklin/X69Nd/src/manager/franklin.jl:270
 [21] 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"#231#234", log::Bool, host::String, show_warnings::Bool, launch::Bool) at /home/xing/.julia/packages/Franklin/X69Nd/src/manager/franklin.jl:118
 [22] serve() at /home/xing/.julia/packages/Franklin/X69Nd/src/manager/franklin.jl:66
 [23] top-level scope at REPL[2]:1

I am using Julia 1.5.4 with the following version of Franklin

Status `~/code/julia/franklin-website/ThrowAwayAllThings/Project.toml`
  [713c75ef] Franklin v0.10.28
  [2bd173c7] NodeJS v1.1.1
tlienart commented 3 years ago

hmm thanks for the report, can you comment out the @def tags line and try again to confirm that it works without tags? I'll investigate why the tags specifically make the literate page fail.

newptcai commented 3 years ago

Yes, it is the problem of tag. Removing it and everything works.

BTW, is there anyway to hide the code and only keep outputs?

tlienart commented 3 years ago

yes put #hideall in the code blocks you want to hide

So in the case of a literate file you'll need to add this multiple times:

# #A test

#hideall
r = 3+3
print(r)

# some text here

#hideall
r = 5 * 4
print(r)

# some more text

https://franklinjl.org/code/#hiding_lines

tlienart commented 3 years ago

PS: I guess we could provide a page-wide "hide everything", I just hadn't had the need for it yet but this could be done if you don't like the multiple "hide all" from my previous comment

newptcai commented 3 years ago

A "hide all" would be indeed useful. I just want to show some pictures in a blog post, not the code.