Skip to content

Instantly share code, notes, and snippets.

@hugcis
Created June 16, 2021 14:08
Show Gist options
  • Save hugcis/1f2d2ad4b98b07ee543f10232ba1b025 to your computer and use it in GitHub Desktop.
Save hugcis/1f2d2ad4b98b07ee543f10232ba1b025 to your computer and use it in GitHub Desktop.
Elisp script with functions to export my notes to Hugo-markdown with ox-hugo
;;; publish --- Summary
;;; Commentary:
(require 'find-lisp)
;;; Code:
(defun hugcis/publish-note (file)
"Publish a note in FILE."
(with-current-buffer (find-file-noselect file)
(projectile-mode -1)
(setq org-hugo-section "notes"
org-hugo-base-dir "~/website/personal-website/"
citeproc-org-org-bib-header "* Bibliography\n<ol class=\"biblio-list\">"
citeproc-org-org-bib-footer "</ol>")
(let ((org-id-extra-files (find-lisp-find-files org-roam-directory "\.org$")))
(org-hugo-export-wim-to-md))))
(defun hugcis/delete-current-line ()
"Delete (not kill) the current line."
(save-excursion
(delete-region
(progn (forward-visible-line 0) (point))
(progn (forward-visible-line 1) (point)))))
(defun hugcis/publish-lines (filename)
(with-current-buffer (find-file-noselect filename)
(goto-char (point-max))
(while (> (point) (point-min))
(forward-line -1)
(let ((org-fname (message (thing-at-point 'line t))))
(if org-fname ;; if line is empty
(hugcis/publish-note (replace-regexp-in-string "\n$" "" org-fname))))
(hugcis/delete-current-line))
(save-buffer)))
(provide 'publish)
;;; publish.el ends here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment