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
6ce83aad
Commit
6ce83aad
authored
May 09, 2015
by
Abiola Ibrahim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
markdown: Refactor fixes
parent
978aef2a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
9 deletions
+13
-9
middleware/markdown/metadata.go
middleware/markdown/metadata.go
+11
-7
middleware/markdown/process.go
middleware/markdown/process.go
+2
-2
No files found.
middleware/markdown/metadata.go
View file @
6ce83aad
...
@@ -162,14 +162,18 @@ func extractMetadata(b []byte) (metadata Metadata, markdown []byte, err error) {
...
@@ -162,14 +162,18 @@ func extractMetadata(b []byte) (metadata Metadata, markdown []byte, err error) {
var
parser
MetadataParser
var
parser
MetadataParser
// Read first line
// Read first line
if
scanner
.
Scan
()
{
if
!
scanner
.
Scan
()
{
line
:=
scanner
.
Bytes
()
// if no line is read,
parser
=
findParser
(
line
)
// if no parser found,
// assume metadata not present
// assume metadata not present
if
parser
==
nil
{
return
metadata
,
b
,
nil
return
metadata
,
b
,
nil
}
}
line
:=
scanner
.
Bytes
()
parser
=
findParser
(
line
)
// if no parser found,
// assume metadata not present
if
parser
==
nil
{
return
metadata
,
b
,
nil
}
}
// buffer for metadata contents
// buffer for metadata contents
...
...
middleware/markdown/process.go
View file @
6ce83aad
...
@@ -137,7 +137,7 @@ func defaultTemplate(c Config, metadata Metadata, requestPath string) []byte {
...
@@ -137,7 +137,7 @@ func defaultTemplate(c Config, metadata Metadata, requestPath string) []byte {
title
:=
metadata
.
Title
title
:=
metadata
.
Title
if
title
==
""
{
if
title
==
""
{
title
=
filepath
.
Base
(
requestPath
)
title
=
filepath
.
Base
(
requestPath
)
if
body
,
_
:=
metadata
.
Variables
[
"
body
"
]
.
([]
byte
);
len
(
body
)
>
128
{
if
body
,
_
:=
metadata
.
Variables
[
"
markdown
"
]
.
([]
byte
);
len
(
body
)
>
128
{
title
=
string
(
body
[
:
128
])
title
=
string
(
body
[
:
128
])
}
else
if
len
(
body
)
>
0
{
}
else
if
len
(
body
)
>
0
{
title
=
string
(
body
)
title
=
string
(
body
)
...
@@ -162,7 +162,7 @@ const (
...
@@ -162,7 +162,7 @@ const (
{{js}}
{{js}}
</head>
</head>
<body>
<body>
{{.
body
}}
{{.
markdown
}}
</body>
</body>
</html>`
</html>`
cssTemplate
=
`<link rel="stylesheet" href="{{url}}">`
cssTemplate
=
`<link rel="stylesheet" href="{{url}}">`
...
...
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