发现 deft 在处理类似下面格式的 Markdown 文档时候并不能正确的显示标题,显示成横线了
1
2
3
4
5
6
7
8
9
10
11
|
---
title: "Fix Title In Hugo Markdown"
date: 2021-09-25T13:09:00+08:00
lastmod: 2021-09-25T13:09:00+08:00
draft: false
tags: ["Emacs", "Deft", "Productive"]
categories: ["Emacs"]
author: "FanJun Kong"
---
|
参考了这里 我改了加Blog前缀,这样更方便查看和编辑
1
2
3
4
5
6
7
8
9
10
11
12
13
|
(defun my-strip-front-matter (contents)
(replace-regexp-in-string "^---\\(?:\n.*\\)*title:" "Blog " 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)
|