Personal tools

Literate programming/Bird conversion via sed

From HaskellWiki

< Literate programming(Difference between revisions)
Jump to: navigation, search
(Breaking out from main page of literate programming)
 
(fix missing slashes and provide some html)
Line 1: Line 1:
 
<pre>
 
<pre>
 
# bird2code.sed
 
# bird2code.sed
^> !p
+
/^>/ !p
^> {
+
/^>/ {
 
i\
 
i\
 
\\begin{code}
 
\\begin{code}
Line 20: Line 20:
 
}
 
}
 
</pre>
 
</pre>
  +
  +
should be run as:
  +
  +
sed -nf bird2code.sed < code.lhs > code.tex
  +
 
[[Category:Development tools]]
 
[[Category:Development tools]]

Revision as of 12:38, 28 March 2008

# bird2code.sed
/^>/ !p
/^>/ {
  i\
\\begin{code}

  :loop
  N
  /\n>[^\n]*$/{
    b loop
  }
  s/^> //
  s/\(\n\)> /\1/g
  s/\n$//
  a\
\\end{code}\

  p
}

should be run as:

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