#4836: literate markdown not handled correctly by unlit ---------------------------------+------------------------------------------ Reporter: guest | Owner: Type: bug | Status: new Priority: normal | Component: Compiler Version: 7.0.1 | Keywords: Testcase: | Blockedby: Os: Unknown/Multiple | Blocking: Architecture: Unknown/Multiple | Failure: GHC rejects valid program ---------------------------------+------------------------------------------ This simple program in literate haskell, using markdown in the comments gives unlit problems: {{{ ### Ok so lets try this again.
### A page that loads and compiles: > myfact 0 = 1 > myfact n = n * n-1 Lets see if it works! }}} If I run unlit and collect the output I can see where it went wrong: {{{ $ ~/lib/ghc-7.0.1/unlit Main.lhs Main.lpp $ cat Main.lpp ### Ok so lets try this again. ### A page that loads and compiles: myfact 0 = 1 myfact n = n * n-1 }}} When I look through the source code of unlit.c I think the place to check for this would be here: {{{ if ( c == '#' ) { if ( ignore_shebang ) { c1 = egetc(istream); if ( c1 == '!' ) { while (c=egetc(istream), !isLineTerm(c)) ; return SHEBANG; } myputc(c, ostream); c=c1; } if ( leavecpp ) { myputc(c, ostream); while (c=egetc(istream), !isLineTerm(c)) myputc(c,ostream); myputc('\n',ostream); return HASH; } } }}} It seems that cabal has a similar unlit function: http://www.haskell.org/ghc/docs/latest/html/libraries/Cabal-1.10.0.0/src /Distribution-Simple-PreProcess-Unlit.html#unlit I haven't tested it but, I think the cabal version would handle this case correctly (or be easier to fix than a C program from 1990). Would it be possible/wise/feasible to extract the cabal version and make it a permanent replacement for the current unlit.c code? -- Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4836> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler _______________________________________________ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs