Skip to content
  • Jonathan Dowland's avatar
    utils/unlit: adjust parser to match Report spec · e817c871
    Jonathan Dowland authored and Marge Bot's avatar Marge Bot committed
    The Haskell 2010 Report says that, for Latex-style Literate format,
    "Program code begins on the first line following a line that begins
    \begin{code}". (This is unchanged from the 98 Report)
    
    However the unlit.c implementation only matches a line that contains
    "\begin{code}" and nothing else. One consequence of this is that one
    cannot suffix Latex options to the code environment. I.e., this does
    not work:
    
    \begin{code}[label=foo,caption=Foo Code]
    
    Adjust the matcher to conform to the specification from the Report.
    
    The Haskell Wiki currently recommends suffixing a '%' to \begin{code}
    in order to deliberately hide a code block from Haskell. This is bad
    advice, as it's relying on an implementation quirk rather than specified
    behaviour. None-the-less, some people have tried to use it, c.f.
    <https://mail.haskell.org/pipermail/haskell-cafe/2009-September/066780.html>
    
    An alternative solution is to define a separate, equivalent Latex
    environment to "code", that is functionally identical in Latex but
    ignored by unlit. This should not be a burden: users are required to
    manually define the code environment anyway, as it is not provided
    by the Latex verbatim or lstlistings packages usually used for
    presenting code in documents.
    
    Fixes #3549.
    e817c871