Skip to content

Commit

Permalink
fix: allow no blank line after front matter
Browse files Browse the repository at this point in the history
  • Loading branch information
gyk authored and tiensonqin committed Jan 13, 2021
1 parent 61af162 commit cc1759b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main/frontend/db/model.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,15 @@
(string/join "\n"))

:markdown
(str (subs content 0 (string/last-index-of content "---\n\n"))
"---\n\n")
(let [[m leading-spaces first-dashes] (re-find #"(\s*)(---\n)" content)]
(if m
(let [begin (count leading-spaces)
begin-inner (+ begin (count first-dashes))
second-dashes "\n---\n"
end-inner (string/index-of content second-dashes begin-inner)
end (if end-inner (+ end-inner (count second-dashes)) begin)]
(subs content begin end))
""))

content))))

Expand Down

0 comments on commit cc1759b

Please sign in to comment.