(defun preprocess-org (input) (with-temp-buffer (insert-file-contents input) (org-mode) (while (re-search-forward org-heading-regexp nil t) (save-excursion (save-match-data (when-let ((tags (org-get-tags (point)))) (insert "\n#+begin_tags\n") (dolist (tag tags) (insert "- " tag "\n")) (insert "#+end_tags\n"))))) (let ((org-export-with-properties t) (org-export-with-section-numbers nil) (org-export-with-sub-superscripts '{}) (org-export-with-tags nil) (org-export-with-title nil) (org-export-with-toc nil)) (org-md-export-as-markdown)) (princ (buffer-string))))