-- nil or an empty strings means return an empty string, without
- any name or value."
- (setq value (pcase value
- ('now (pelican-timestamp))
- ('slug (pelican-default-slug))
- ('"" nil)
- (_ value)))
- (when (symbolp name)
- (setq name (string-remove-prefix ":" (symbol-name name))))
- (if value
- (cond ((derived-mode-p 'markdown-mode)
- (format "%s: %s\n" (capitalize name) value))
- ((derived-mode-p 'rst-mode)
- (format ":%s: %s\n" (downcase name) value))
- (t (error "Unsupported major mode %S" major-mode)))
- ""))
-
-(defun pelican-rst-title (title)
- "Format a reStructureText version of TITLE."
- (concat title "\n" (make-string (string-width title) ?#) "\n\n"))
-
-(defun pelican-title (title)
- "Format a TITLE for the current document, according to major mode."
- (cond ((derived-mode-p 'markdown-mode)
- (pelican-field "title" title))
- ((derived-mode-p 'rst-mode)
- (pelican-rst-title title))
- (t (error "Unsupported major mode %S" major-mode))))
-
-(defun pelican-header (title &rest fields)
- "Generate a Pelican header for a post with a TITLE and metadata FIELDS."
- (concat (pelican-title title)
- (mapconcat (apply-partially #'apply #'pelican-field)
- (seq-partition fields 2) "")
- "\n"))
-
-(defun pelican-insert-header (title &rest fields)
- "Insert a Pelican header for a post with a TITLE and metadata FIELDS."
- (save-excursion
- (goto-char 0)
- (insert (apply #'pelican-header (cons title fields)))))
-
-(defun pelican-insert-draft-post-header (title tags)