deft
deft copied to clipboard
Read jekyll style Front Matter for titles and other metadata
It would be sweet to use deft for writing markdown files for static sites.
The titles and other metadata for these files however are in Front Matter (YAML) rather than on the first line.
---
layout: post
title: Write Your Blog Using Deft!!!
---
Start of the post
...
Seconding this. I couldn't work around this by providing a new deft-parse-title-function
as that function is only passed the first line, and I couldn't get it to work adding advice to deft-parse-title
. This feature would be great!
For anyone from the future, here's what more or less works for me:
(defun my-strip-front-matter (contents)
(replace-regexp-in-string "^---\\(?:\n.*\\)*---.*$" "" contents))
(defun my-deft-parse-title-wrapper (f file contents)
(let ((new-contents (my-strip-front-matter contents)))
(funcall f file new-contents)))
(defun my-deft-parse-summary-wrapper (f contents title)
(let ((new-contents (my-strip-front-matter contents)))
(funcall f new-contents title)))
(advice-add 'deft-parse-title :around 'my-deft-parse-title-wrapper)
(advice-add 'deft-parse-summary :around 'my-deft-parse-summary-wrapper)