justinmeiners / srcweave

A literate programming system for any language.
https://www.jmeiners.com/literate-programming/
GNU General Public License v2.0
78 stars 4 forks source link

escape --- in code blocks? #23

Open nikonakoneko opened 1 year ago

nikonakoneko commented 1 year ago

I was trying to produce a lit file from a lit file. But I don't find how to escape the code block inside the code block like the following example

# Recursive literate

Consider the following:

--- /example.lit
the following should generate `test.lua` when processing `example.lit`:
--- /test.lua
--- this is a valid lua comment…
print("Hello, Lua!")
---
---
justinmeiners commented 1 year ago

Thanks for the feedback. I currently don't have an escape, but if you add a space so that the --- isn't exactly at he start of the line, I believe that will work. Does that solve your use case, or should we come up with something better?

atweiden commented 1 year ago

I imagine escaping comments will be something people want. Perhaps the srcweave syntax would be conducive to using Lua style comment escapes:

# Recursive literate

Consider the following:

---[==[ /example.lit
the following should generate `test.lua` when processing `example.lit`:
---[=[ /test.lua
--- this is a valid lua comment…
print("Hello, Lua!")
---]=]
---]==]
nikonakoneko commented 1 year ago

@justinmeiners I guess that adding a space would also "escape" it in the generated lit file. What I'd like here is a lit file that produce another lit file with functional code block that can further generate another source file. I'm not dying for that feature, but I wanted to illustrate a basic exemple of writing literate file using literate file. And I ran in that issue that I can't have codeblocks containing codeblocks of the source to generate.

justinmeiners commented 1 year ago

@soratobukuroneko understood. I will give this some thought.