Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Łukasz Nowak
caddy
Commits
23478354
Commit
23478354
authored
Oct 29, 2015
by
Matthew Holt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
markdown: Enable tables, fenced code, and strikethrough (closes #294)
parent
94ff7dc6
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
11 deletions
+10
-11
middleware/markdown/markdown_test.go
middleware/markdown/markdown_test.go
+6
-8
middleware/markdown/process.go
middleware/markdown/process.go
+2
-1
middleware/markdown/testdata/blog/test.md
middleware/markdown/testdata/blog/test.md
+1
-1
middleware/markdown/testdata/log/test.md
middleware/markdown/testdata/log/test.md
+1
-1
No files found.
middleware/markdown/markdown_test.go
View file @
23478354
...
@@ -92,7 +92,7 @@ func TestMarkdown(t *testing.T) {
...
@@ -92,7 +92,7 @@ func TestMarkdown(t *testing.T) {
expectedBody
:=
`<!DOCTYPE html>
expectedBody
:=
`<!DOCTYPE html>
<html>
<html>
<head>
<head>
<title>Markdown test</title>
<title>Markdown test
1
</title>
</head>
</head>
<body>
<body>
<h1>Header</h1>
<h1>Header</h1>
...
@@ -102,11 +102,10 @@ Welcome to A Caddy website!
...
@@ -102,11 +102,10 @@ Welcome to A Caddy website!
<p>Body</p>
<p>Body</p>
<p><code>go
<pre><code class="language-go">func getTrue() bool {
func getTrue() bool {
return true
return true
}
}
</code></p>
</code></p
re
>
</body>
</body>
</html>
</html>
...
@@ -129,7 +128,7 @@ func getTrue() bool {
...
@@ -129,7 +128,7 @@ func getTrue() bool {
expectedBody
=
`<!DOCTYPE html>
expectedBody
=
`<!DOCTYPE html>
<html>
<html>
<head>
<head>
<title>Markdown test</title>
<title>Markdown test
2
</title>
<meta charset="utf-8">
<meta charset="utf-8">
<link rel="stylesheet" href="/resources/css/log.css">
<link rel="stylesheet" href="/resources/css/log.css">
<link rel="stylesheet" href="/resources/css/default.css">
<link rel="stylesheet" href="/resources/css/default.css">
...
@@ -143,11 +142,10 @@ func getTrue() bool {
...
@@ -143,11 +142,10 @@ func getTrue() bool {
<p>Body</p>
<p>Body</p>
<p><code>go
<pre><code class="language-go">func getTrue() bool {
func getTrue() bool {
return true
return true
}
}
</code></p>
</code></p
re
>
</body>
</body>
</html>`
</html>`
...
...
middleware/markdown/process.go
View file @
23478354
...
@@ -65,7 +65,8 @@ func (md Markdown) Process(c *Config, requestPath string, b []byte, ctx middlewa
...
@@ -65,7 +65,8 @@ func (md Markdown) Process(c *Config, requestPath string, b []byte, ctx middlewa
}
}
// process markdown
// 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
// set it as body for template
metadata
.
Variables
[
"body"
]
=
string
(
markdown
)
metadata
.
Variables
[
"body"
]
=
string
(
markdown
)
...
...
middleware/markdown/testdata/blog/test.md
View file @
23478354
---
---
title
:
Markdown test
title
:
Markdown test
1
sitename
:
A Caddy website
sitename
:
A Caddy website
---
---
...
...
middleware/markdown/testdata/log/test.md
View file @
23478354
---
---
title
:
Markdown test
title
:
Markdown test
2
sitename
:
A Caddy website
sitename
:
A Caddy website
---
---
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment