mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-23 18:55:49 +03:00
markdown: Enable tables, fenced code, and strikethrough (closes #294)
This commit is contained in:
parent
94ff7dc6fb
commit
234783548f
4 changed files with 10 additions and 11 deletions
|
@ -92,7 +92,7 @@ func TestMarkdown(t *testing.T) {
|
|||
expectedBody := `<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Markdown test</title>
|
||||
<title>Markdown test 1</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Header</h1>
|
||||
|
@ -102,11 +102,10 @@ Welcome to A Caddy website!
|
|||
|
||||
<p>Body</p>
|
||||
|
||||
<p><code>go
|
||||
func getTrue() bool {
|
||||
<pre><code class="language-go">func getTrue() bool {
|
||||
return true
|
||||
}
|
||||
</code></p>
|
||||
</code></pre>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
@ -129,7 +128,7 @@ func getTrue() bool {
|
|||
expectedBody = `<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Markdown test</title>
|
||||
<title>Markdown test 2</title>
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" href="/resources/css/log.css">
|
||||
<link rel="stylesheet" href="/resources/css/default.css">
|
||||
|
@ -143,11 +142,10 @@ func getTrue() bool {
|
|||
|
||||
<p>Body</p>
|
||||
|
||||
<p><code>go
|
||||
func getTrue() bool {
|
||||
<pre><code class="language-go">func getTrue() bool {
|
||||
return true
|
||||
}
|
||||
</code></p>
|
||||
</code></pre>
|
||||
|
||||
</body>
|
||||
</html>`
|
||||
|
|
|
@ -65,7 +65,8 @@ func (md Markdown) Process(c *Config, requestPath string, b []byte, ctx middlewa
|
|||
}
|
||||
|
||||
// process markdown
|
||||
markdown = blackfriday.Markdown(markdown, c.Renderer, 0)
|
||||
extns := blackfriday.EXTENSION_TABLES | blackfriday.EXTENSION_FENCED_CODE | blackfriday.EXTENSION_STRIKETHROUGH
|
||||
markdown = blackfriday.Markdown(markdown, c.Renderer, extns)
|
||||
|
||||
// set it as body for template
|
||||
metadata.Variables["body"] = string(markdown)
|
||||
|
|
2
middleware/markdown/testdata/blog/test.md
vendored
2
middleware/markdown/testdata/blog/test.md
vendored
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
title: Markdown test
|
||||
title: Markdown test 1
|
||||
sitename: A Caddy website
|
||||
---
|
||||
|
||||
|
|
2
middleware/markdown/testdata/log/test.md
vendored
2
middleware/markdown/testdata/log/test.md
vendored
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
title: Markdown test
|
||||
title: Markdown test 2
|
||||
sitename: A Caddy website
|
||||
---
|
||||
|
||||
|
|
Loading…
Reference in a new issue