LHS and Markdown: Codeblocks

 ̄綄美尐妖づ 提交于 2019-12-04 17:06:22

问题


I happen to really like Markdown (probably because of SO) and I like programming in Haskell. I have recently discovered Literate Haskell (LHS) and I want to use Markdown and LHS together. Let me give you this dumb example:

Crazy Literate Haskell
======================

This is an example of some literate Haskell Code:

> module Main where

Look at that IO Monad work:

> main = return 2 >>= print

Wasn't that cool?

That is an example of a literate haskell file written to be parsed by Markdown later. However, I want the code to actually appear in html code blocks and without the > before them. Therefore I cannot merely indent all of the code lines by four because that would produce the markdown that you see above. Basically, I want the html to come out like this:

<h1>Crazy Literate Haskell</h1>

<p>This is an example of some literate Haskell Code:</p>

<pre><code>module Main where
</code></pre>

<p>Look at that IO Monad work:</p>

<pre><code>main = return 2 &gt;&gt;= print
</code></pre>

<p>Wasn't that cool?</p>

The thing to notice is that it has no > symbols. How would I do that?


回答1:


Use Pandoc. It has a markdown+lhs mode for using markdown in literal Haskell files, and if you don't like the html it produces, there is an api for modifying the document structure.

Install it with

cabal install pandoc


来源:https://stackoverflow.com/questions/3473389/lhs-and-markdown-codeblocks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!