Personal tools

Literate programming/Bird conversion via sed

From HaskellWiki

< Literate programming(Difference between revisions)
Jump to: navigation, search
(fix missing slashes and provide some html)
(Problems with no newline after last line of code)

Latest revision as of 10:10, 7 November 2013

# bird2code.sed
/^>/ !p
/^>/ {

    b loop
  s/^> //
  s/\(\n\)> /\1/g


should be run as:

sed -nf bird2code.sed < code.lhs > code.tex

Note that the above sed script does not handle all input well. For example, if the last line of an input file is a line of bird-style code and there is no newline before end-of-file, than the last "/end{code}" is omitted. You are advised to consider using the alternative awk script.