[GHC] #4836: literate markdown not handled correctly by unlit

GHC ghc-devs at haskell.org
Sun Jun 8 08:59:52 UTC 2014


#4836: literate markdown not handled correctly by unlit
----------------------------------------------+----------------------------
        Reporter:  guest                      |            Owner:
            Type:  bug                        |           Status:  new
        Priority:  low                        |        Milestone:  7.6.2
       Component:  Compiler                   |          Version:  7.0.1
      Resolution:                             |         Keywords:
Operating System:  Unknown/Multiple           |     Architecture:
 Type of failure:  GHC rejects valid program  |  Unknown/Multiple
       Test Case:                             |       Difficulty:  Unknown
        Blocking:                             |       Blocked By:
                                              |  Related Tickets:  #7120
----------------------------------------------+----------------------------

Comment (by dominic):

 With your patches for markdown and a .md file


 {{{
 ### Ok so lets try this again.

 ### A page that loads and compiles:

 ```
 module Main where

 myfact 0 = 1
 myfact n = n * n-1

 main = putStrLn (show (myfact 5))
 ```

 Lets see if it works!

     [ghci]
     :!which ghc
     myfact 5
 }}}

 this compiles so hurrah!

 But BlogLiteraly does '''not''' a) do syntax highlighting b) evaluate
 "myfact 5"


 {{{
 ~/ghc $ BlogLiteratelyD --ghci TheLitTest.md
 <h3 id="ok-so-lets-try-this-again.">Ok so lets try this again.</h3>
 <h3 id="a-page-that-loads-and-compiles">A page that loads and
 compiles:</h3>
 <pre><code>module Main where

 myfact 0 = 1
 myfact n = n * n-1

 main = putStrLn (show (myfact 5))</code></pre>
 <p>Lets see if it works!</p>
 <pre><code><span style="color: gray;">ghci> </span>:!which ghc
   /usr/local/bin/ghc

 <span style="color: gray;">ghci> </span>myfact 5</code></pre>
 <div class="references">

 </div>
 }}}

 On the other hand with a .lhs file


 {{{
 ### Ok so lets try this again.

 ### A page that loads and compiles:

 module Main where

 > myfact 0 = 1
 > myfact n = n * n-1

 > main = putStrLn (show (myfact 5))

 Lets see if it works!

     [ghci]
     :!which ghc
     myfact 5
 }}}

 This does not compile


 {{{
 ~/ghc $ ./inplace/bin/ghc-stage2 TheLitTest.lhs

 TheLitTest.lhs:1:2: lexical error at character '#'
 }}}

 But BlogLiterately produces code which is syntax highlighted and evaluates
 "myfact 5".


 {{{
 ~/ghc $ BlogLiteratelyD --ghci TheLitTest.lhs
 <h3 id="ok-so-lets-try-this-again.">Ok so lets try this again.</h3>
 <h3 id="a-page-that-loads-and-compiles">A page that loads and
 compiles:</h3>
 <p>module Main where</p>
 <pre class="sourceCode haskell"><code class="sourceCode haskell"><span
 style="">></span> <span style="">myfact</span> <span class="hs-
 num">0</span> <span style="color: red;">=</span> <span class="hs-
 num">1</span>
 <span style="">></span> <span style="">myfact</span> <span
 style="">n</span> <span style="color: red;">=</span> <span
 style="">n</span> <span style="">*</span> <span style="">n</span><span
 style="color: green;">-</span><span class="hs-num">1</span>
 </code></pre>
 <pre class="sourceCode haskell"><code class="sourceCode haskell"><span
 style="">></span> <span style="">main</span> <span style="color:
 red;">=</span> <span style="">putStrLn</span> <span style="color:
 red;">(</span><span style="">show</span> <span style="color:
 red;">(</span><span style="">myfact</span> <span class="hs-
 num">5</span><span style="color: red;">)</span><span style="color:
 red;">)</span>
 </code></pre>
 <p>Lets see if it works!</p>
 <pre><code><span style="color: gray;">ghci> </span>:!which ghc
   /usr/local/bin/ghc

 <span style="color: gray;">ghci> </span>myfact 5
   24
 </code></pre>
 <div class="references">

 </div>
 }}}

 I've discussed this ticket (not BlogLiterately) with Simon Marlow and we
 concluded that we should try changing the order of unlit and cpp. There
 may be literate programs which have e.g. #ifdef in their literate (non-
 code / not in chevrons) block and these will now fail but we concluded
 that this is the correct behaviour (I hope I am not misquoting Simon
 here).

 If this works then I think supporting .md files becomes more
 straightforward and BlogLiterately will work (and I will remove the
 workaround that Brent put in to make it handle # correctly when it calls
 ghci). Does that make sense?

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/4836#comment:16>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list