ANNOUNCE: Anansi 0.4.2 (literate programming pre-processor)

Anansi is a preprocessor for literate programs, in the model of NoWeb or nuweb. Literate programming allows both computer code and documentation to be generated from a single unified source. Home page: https://john-millikin.com/software/anansi/ Hackage: http://hackage.haskell.org/package/anansi-0.4.2 ----- This release has a couple cool new features, suggested by Dirk Laurie. Markdown loom =============== Markdown, a lightweight markup language similar to ReStructuredText, is used often on web forums. Use [[ :loom anansi.markdown ]] in your documents to enable. User-defined line pragmas ======================== Users can now add, modify, and disable line pragmas in tangled output based on file extension. This makes it much easier to combine code and data in a single source file. By default, line pragmas are enabled for the C, C++, C#, Haskell, Perl, and Go languages. Customizing the pragma format is easy. Use the ${line}, ${path}, and ${quoted-path} substitutions in an :option. This example code will insert comments into tangled Python code: ------------------------------------------- :# Insert comments into any tangled output file with a name ending in ".py" :option anansi.line-pragma-py=# Generated from ${path} line ${line} ------------------------------------------- To disable line pragmas for a particular file type, just set its pragma format to an empty string: ------------------------------------------- :option anansi.line-pragma-pl= -------------------------------------------

On Sun, Dec 11, 2011 at 04:22, John Millikin
Anansi is a preprocessor for literate programs, in the model of NoWeb or nuweb. Literate programming allows both computer code and documentation to be generated from a single unified source.
Home page: https://john-millikin.com/software/anansi/ Hackage: http://hackage.haskell.org/package/anansi-0.4.2
-----
This release has a couple cool new features, suggested by Dirk Laurie.
Markdown loom ===============
Markdown, a lightweight markup language similar to ReStructuredText, is used often on web forums. Use [[ :loom anansi.markdown ]] in your documents to enable.
This announcement made me motivated to finally have a closer look at LP. Thanks for a rather excellent tool :) There were some things that I bumped into though: 1. What to call files? I understand (C)WEB suggests using .w, and that noweb uses .nw, what should I call anansi files? 2. Combining anansi and pandoc works quite well for HTML, but it fails miserably when trying to use the generated LaTeX: > markdown2pdf: ! LaTeX Error: Command \guillemotleft unavailable in encoding OT1. Is there any good way to get around that? 3. Is there any editor support for anansi, syntax highlihgting etc? /M -- Magnus Therning OpenPGP: 0xAB4DFBA4 email: magnus@therning.org jabber: magnus@therning.org twitter: magthe http://therning.org/magnus

On Tue, Dec 13, 2011 at 03:39, Magnus Therning
1. What to call files? I understand (C)WEB suggests using .w, and that noweb uses .nw, what should I call anansi files?
I usually use .anansi, but it doesn't matter. You can use whatever extensions you like, or even none at all.
2. Combining anansi and pandoc works quite well for HTML, but it fails miserably when trying to use the generated LaTeX:
> markdown2pdf: ! LaTeX Error: Command \guillemotleft unavailable in encoding OT1.
Is there any good way to get around that?
The LaTeX loom is designed to output basic markup that can be turned into a PDF with minimum fuss. It probably won't work as-is for more advanced cases, such as when a user wants to use custom templates, or has to inter-operate with pseudo-LaTeX parsers like Pandoc. You could try copying the LaTeX loom into your own code, modifying it to generate the custom output format you want, and then running it as a #!runhaskell script.
3. Is there any editor support for anansi, syntax highlihgting etc?
Not that I know of. Note that Anansi's syntax itself is very minimal, so what you need is an editor that can support formatting a file using multiple syntaxes. I don't know enough about editor modification to figure out which editors support such a feature, or how to enable it.

On Tue, Dec 13, 2011 at 12:36:44PM -0800, John Millikin wrote:
On Tue, Dec 13, 2011 at 03:39, Magnus Therning
wrote: 1. What to call files? I understand (C)WEB suggests using .w, and that noweb uses .nw, what should I call anansi files?
I usually use .anansi, but it doesn't matter. You can use whatever extensions you like, or even none at all.
I'll stick to .anansi as well then, it's rather descriptive :-)
2. Combining anansi and pandoc works quite well for HTML, but it fails miserably when trying to use the generated LaTeX:
> markdown2pdf: ! LaTeX Error: Command \guillemotleft unavailable in encoding OT1.
Is there any good way to get around that?
The LaTeX loom is designed to output basic markup that can be turned into a PDF with minimum fuss. It probably won't work as-is for more advanced cases, such as when a user wants to use custom templates, or has to inter-operate with pseudo-LaTeX parsers like Pandoc.
I was probably unclear, I *really* would like to use the markdown loom and then pass the weave through pandoc to be able to create html/latex from the same source. So I suspect the problem I ran into is more related to pandoc than anansi, but I was hoping that someone among the anansi users had run into and solved it already :-)
You could try copying the LaTeX loom into your own code, modifying it to generate the custom output format you want, and then running it as a #!runhaskell script.
I might try that, but then use the markdown loom as the basis instead. It would be nice to have a specific pandoc loom that makes use of its extensions to markdown, where that makes sense.
3. Is there any editor support for anansi, syntax highlihgting etc?
Not that I know of. Note that Anansi's syntax itself is very minimal, so what you need is an editor that can support formatting a file using multiple syntaxes. I don't know enough about editor modification to figure out which editors support such a feature, or how to enable it.
It's rather easy to do in vim, e.g. by setting the filetype to something line 'markdown.haskell'. I haven't tried putting together three filetypes, but I suspect it just works :-) If I get around to putting together an anansi syntax file for vim I'll make sure to share it. /M -- Magnus Therning OpenPGP: 0xAB4DFBA4 email: magnus@therning.org jabber: magnus@therning.org twitter: magthe http://therning.org/magnus Perl is another example of filling a tiny, short-term need, and then being a real problem in the longer term. -- Alan Kay

On Sun, Dec 18, 2011 at 01:05:06PM +0100, Magnus Therning wrote:
On Tue, Dec 13, 2011 at 12:36:44PM -0800, John Millikin wrote:
On Tue, Dec 13, 2011 at 03:39, Magnus Therning
wrote: 1. What to call files? I understand (C)WEB suggests using .w, and that noweb uses .nw, what should I call anansi files?
I usually use .anansi, but it doesn't matter. You can use whatever extensions you like, or even none at all.
I'll stick to .anansi as well then, it's rather descriptive :-)
2. Combining anansi and pandoc works quite well for HTML, but it fails miserably when trying to use the generated LaTeX:
> markdown2pdf: ! LaTeX Error: Command \guillemotleft unavailable in encoding OT1.
Is there any good way to get around that?
The LaTeX loom is designed to output basic markup that can be turned into a PDF with minimum fuss. It probably won't work as-is for more advanced cases, such as when a user wants to use custom templates, or has to inter-operate with pseudo-LaTeX parsers like Pandoc.
I was probably unclear, I *really* would like to use the markdown loom and then pass the weave through pandoc to be able to create html/latex from the same source. So I suspect the problem I ran into is more related to pandoc than anansi, but I was hoping that someone among the anansi users had run into and solved it already :-)
I just thought I'd mention that I've solved this particular issue now. All that was needed was to make sure that \usepackage{aeguill} was added to the generated LaTeX. Personally I did that by putting the line in a file and then use the -H argument to `markdown2pdf` which pandoc provides. /M -- Magnus Therning OpenPGP: 0xAB4DFBA4 email: magnus@therning.org jabber: magnus@therning.org twitter: magthe http://therning.org/magnus Most software today is very much like an Egyptian pyramid with millions of bricks piled on top of each other, with no structural integrity, but just done by brute force and thousands of slaves. -- Alan Kay
participants (2)
-
John Millikin
-
Magnus Therning