# Literate.jl announcement

**URL:** <https://discourse.julialang.org/t/literate-jl-announcement/10651>\
**Category:** Package Announcements\
**Created:** [May 2, 2018, 9:31am UTC](https://discourse.julialang.org/t/literate-jl-announcement/10651 "2018-05-02T09:31:09Z")\
**Posts on this page:** 8\
**Page:** 3

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [May 16, 2018, 11:09am UTC](https://discourse.julialang.org/t/literate-jl-announcement/10651/41 "2018-05-16T11:09:47Z")

</div>

Seems like all of this would be solved if you could execute the code without Documenter.

---

<div class="post-metadata">

**Author:** ![janrpeters](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@janrpeters](https://discourse.julialang.org/u/janrpeters)\
**Post date:** [October 14, 2018, 6:35pm UTC](https://discourse.julialang.org/t/literate-jl-announcement/10651/42 "2018-10-14T18:35:51Z")

</div>

I feel ill-Literate.jl as a Literate beginner but I have been trying to replace my

```julia
function export_code_segments(fname)
    run(`jupyter nbconvert --to script $(fname).ipynb`);

    open(fname*".jl") do file_in
        file_content = read(file_in, String)
        split_contents = split(file_content,"###EXPORT CODE")

        for code_segment in split_contents 
            code_listing = split(code_segment,"FROM HERE ###")
            if (code_listing[1][1:9] == " TO FILE ")
                segment_name = strip(code_listing[1][9:end]);
                segment_content = code_listing[2];
                open(segment_name, "w") do file_out
                    write(file_out, strip(segment_content));
                end
            end
        end
    end
end;

###EXPORT CODE TO FILE example_extraction.jl FROM HERE ### 

a=1;
for t=1:10
    a = a + t;
end

###EXPORT CODE UNTIL HERE ###  

export_code_segments("Export_Code")
open("example_extraction.jl") do file
    println("Listing file <example_extraction.jl>")
    for i in enumerate(eachline(file)) #for ln in eachline(ss)
        println("$(i[1]): $(i[2])")
    end
end

```

I am pretty sure it can be done with Literate better. How?

---

<div class="post-metadata">

**Author:** ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Post date:** [April 2, 2020, 5:50pm UTC](https://discourse.julialang.org/t/literate-jl-announcement/10651/43 "2020-04-02T17:50:48Z")

</div>

I use Literate.jl to transform my julia files to markup and markup-to-pdf to generate a pdf file. The only additional feature I could use is to properly process multi-line comments with #= / =# pairs and have the comments stay within the julia script after translation to Markdown. Otherwise, great!

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [April 2, 2020, 7:17pm UTC](https://discourse.julialang.org/t/literate-jl-announcement/10651/44 "2020-04-02T19:17:39Z")

</div>

> [@erlebach](#):
>
> The only additional feature I could use is to properly process multi-line comments with #= / =# pairs

There is an issue about that: [Multi-line comments · Issue #26 · fredrikekre/Literate.jl · GitHub](https://github.com/fredrikekre/Literate.jl/issues/26) but personally I don’t like or use multiline comments so I am unlikely to implement it myself.

> [@erlebach](#):
>
> have the comments stay within the julia script after translation to Markdown.

This should already work though, but in order to signal that it is indeed comments and not markdown you have to use `##`, see [2. File format · Literate.jl](https://fredrikekre.github.io/Literate.jl/stable/fileformat/#Syntax-1)

---

<div class="post-metadata">

**Author:** ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Post date:** [April 2, 2020, 8:38pm UTC](https://discourse.julialang.org/t/literate-jl-announcement/10651/45 "2020-04-02T20:38:28Z")

</div>

By the way, if you use a single comment, but do not leave a space between the “#” and the comment itself, the comment will be considered as a line in Julia. Under those conditions, ## is not required.

If you use ##comment (no space between the # and the comment), I believe that the markdown will contain two “#” symbols. You might want to check this behavior.

Gordon

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [May 4, 2020, 8:19am UTC](https://discourse.julialang.org/t/literate-jl-announcement/10651/46 "2020-05-04T08:19:20Z")

</div>

Executing markdown output and capturing the result (which @baggepinnen, @piever and @Wenjie among others requested above) is available in Literate version 2.4.0.

---

<div class="post-metadata">

**Author:** ![Xing\_Shi\_Cai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xing_shi_cai/32/14128_2.png) [@Xing\_Shi\_Cai](https://discourse.julialang.org/u/Xing_Shi_Cai)\
**Post date:** [May 4, 2020, 8:47am UTC](https://discourse.julialang.org/t/literate-jl-announcement/10651/47 "2020-05-04T08:47:21Z")

</div>

Got 404 in all example links in the original post.

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [May 4, 2020, 8:59am UTC](https://discourse.julialang.org/t/literate-jl-announcement/10651/48 "2020-05-04T08:59:28Z")

</div>

Looks like I can’t edit such old posts so here are the updated links:  
Docs: [https://fredrikekre.github.io/Literate.jl/](https://fredrikekre.github.io/Literate.jl/)  
JuAFEM example: [source](https://github.com/KristofferC/JuAFEM.jl/blob/master/docs/src/literate/heat_equation.jl), [markdown/html](https://kristofferc.github.io/JuAFEM.jl/dev/examples/heat_equation/), [notebook](https://nbviewer.jupyter.org/github/KristofferC/JuAFEM.jl/blob/gh-pages/dev/examples/heat_equation.ipynb), [script](https://github.com/KristofferC/JuAFEM.jl/blob/gh-pages/dev/examples/heat_equation.jl).

[Previous page](https://discourse.julialang.org/t/literate-jl-announcement/10651.md?page=2)
