fredrikekre / Literate.jl

Simple package for literate programming in Julia
https://fredrikekre.github.io/Literate.jl
Other
547 stars 64 forks source link

DocumenterFlavor with julia codefences and semi-colons #166

Closed DrChainsaw closed 2 years ago

DrChainsaw commented 3 years ago

Not sure where this issue belongs, but when using DocumenterFlavour with julia codefences (to get uniform styling) and semi-colons to supress output a nothing #hide line which shows up in the generated document:

julia> mktempdir() do path
       testfile = joinpath(path, "testfile.md")
       write(testfile, """
       1+2;
       # ^ this shows up in generated webpage
       """)
       outfile = Literate.markdown(testfile, joinpath(path, "outfile.md"); flavor=Literate.DocumenterFlavor(), codefence="````julia" => "````")
       foreach(println, eachline(outfile))
       end
[ Info: generating markdown page from `...\AppData\Local\Temp\jl_8GbQxO\testfile.md`
[ Info: writing result to `...\AppData\Local\Temp\jl_8GbQxO\outfile.md\testfile.md`
1+2;
nothing #hide

^ this shows up in generated webpage


This page was generated using Literate.jl.

fredrikekre commented 3 years ago

(to get uniform styling)

What do you mean with this?

DrChainsaw commented 3 years ago

What do you mean with this?

I seem to get different syntax highlighting with the default fences (@example?) for DocumenterFlavor compared to normal (common?) markdown with julia fences. Some parts of the docs are not litterate docs and I want syntax highlighting to look the same in all docs.

fredrikekre commented 3 years ago

You are not using Documenter? Documenter should replace @example with julia so that sounds strange.

DrChainsaw commented 3 years ago

You are not using Documenter?

I am using Documenter. Perhaps something is malformed in my files then? I'll have another look at it and will open a separate issue if appropriate.

racinmat commented 2 years ago

Hi, I have the same problem with the nothing #hide, which should not be here. Here is my MWE:

using Pkg
cd(@__DIR__)
pkg"activate ."
using Literate, Documenter

open("script.jl", "w+") do io
    write(io, """
    a = 2 + 2;
    """)
end

Literate.markdown("script.jl", "src", execute=true, credit=false)

makedocs(
    sitename = "Test",
    pages = [
        "Script from Literate" => "script.md",
    ],
)

the generated src/script.md looks like this

```@meta
EditURL = "<unknown>/script.jl"
a = 2 + 2;
nothing #hide


and then the generated html page looks like this:
![image](https://user-images.githubusercontent.com/5525771/143589877-0af257e1-e313-410b-b03b-5e9b1968af66.png)
racinmat commented 2 years ago

I think the problem is that #hide works only in examples, as stated in docs https://juliadocs.github.io/Documenter.jl/stable/man/syntax/#@example-block not in the ```julia block.