LHS 和 Markdown:代码块
我碰巧真的很喜欢 Markdown (可能是因为 SO)并且我喜欢用 Haskell 编程。我最近发现了 Literate Haskell (LHS),我想同时使用 Markdown 和 LHS。让我给你举一个愚蠢的例子:
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?
这是一个编写为稍后由 Markdown 解析的有文字的 haskell 文件的例子。但是,我希望代码实际出现在 html 代码块中,并且没有 >在他们面前。因此,我不能仅仅将所有代码行缩进四行,因为这会产生您在上面看到的降价。基本上,我希望 html 像这样出现:
<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 >>= print
</code></pre>
<p>Wasn't that cool?</p>
需要注意的是它没有 >符号。我该怎么做呢?
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 >>= print
</code></pre>
<p>Wasn't that cool?</p>
The thing to notice is that it has no > symbols. How would I do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 Pandoc。它有一个 markdown+lhs 模式,用于在文字 Haskell 文件中使用 markdown,如果您不喜欢它生成的 html,可以使用一个 api 来修改文档结构。
安装它
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