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
nexedi
caddy
Commits
8394d72f
Commit
8394d72f
authored
May 13, 2015
by
Abiola Ibrahim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for Issue 72: Markdown: 500 for YAML metadata
parent
018fd217
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
5 deletions
+18
-5
middleware/markdown/metadata.go
middleware/markdown/metadata.go
+13
-0
middleware/markdown/metadata_test.go
middleware/markdown/metadata_test.go
+5
-5
No files found.
middleware/markdown/metadata.go
View file @
8394d72f
...
...
@@ -154,6 +154,19 @@ func (y *YAMLMetadataParser) Parse(b []byte) ([]byte, error) {
if
err
:=
yaml
.
Unmarshal
(
b
,
&
m
);
err
!=
nil
{
return
markdown
,
err
}
// convert variables (if present) to map[string]interface{}
// to match expected type
if
vars
,
ok
:=
m
[
"variables"
]
.
(
map
[
interface
{}]
interface
{});
ok
{
vars1
:=
make
(
map
[
string
]
interface
{})
for
k
,
v
:=
range
vars
{
if
key
,
ok
:=
k
.
(
string
);
ok
{
vars1
[
key
]
=
v
}
}
m
[
"variables"
]
=
vars1
}
y
.
metadata
.
load
(
m
)
return
markdown
,
nil
}
...
...
middleware/markdown/metadata_test.go
View file @
8394d72f
...
...
@@ -35,13 +35,13 @@ var YAML = [4]string{`
title : A title
template : default
variables :
-
name : value
name : value
`
,
`---
title : A title
template : default
variables :
-
name : value
name : value
---
Page content
`
,
...
...
@@ -49,7 +49,7 @@ Page content
title : A title
template : default
variables :
-
name : value
name : value
`
,
`title : A title template : default variables : name : value`
,
}
...
...
@@ -112,7 +112,7 @@ func TestParsers(t *testing.T) {
return
false
}
}
return
true
return
len
(
m
.
Variables
)
==
1
}
data
:=
[]
struct
{
...
...
@@ -135,7 +135,7 @@ func TestParsers(t *testing.T) {
md
,
err
:=
v
.
parser
.
Parse
([]
byte
(
v
.
testData
[
1
]))
check
(
t
,
err
)
if
!
compare
(
v
.
parser
.
Metadata
())
{
t
.
Fatalf
(
"Expected %v, found %v for %v"
,
expected
,
v
.
parser
.
Metadata
()
.
Variables
,
v
.
name
)
t
.
Fatalf
(
"Expected %v, found %v for %v"
,
expected
,
v
.
parser
.
Metadata
(),
v
.
name
)
}
if
"Page content"
!=
strings
.
TrimSpace
(
string
(
md
))
{
t
.
Fatalf
(
"Expected %v, found %v for %v"
,
"Page content"
,
string
(
md
),
v
.
name
)
...
...
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