This is my org file:
#+TITLE: Post title
#+DESCRIPTION:
#+AUTHOR: MyName
#+DATE: <2022-11-10 Thu>
#+TAGS: tag1 tag2
#+OPTIONS: toc:nil
*Section 1
Content
I would like to export it to markdown (C-c C-e m m
) and have the following content:
---
author:
- MyName
date: 2022-11-10 Thu
tags: 'tag1 tag2'
title: 'Post title'
---
# Section 1
Content
So the problem comes down to appending some text before the text exported with org-mode exporter by default.
I tried two following approaches. Unfortunately none of them works right.
When I add at the beginning of the file:
#+begin_export markdown --- author: - {{{author}}} date: {{{date}}} tags: ????? title: 'How to tailor the output of org-mode exporter to our needs' --- #+end_export
the macros are not evaluated. What is more, I don't know how to refer to the #+TAGS field.
When I try with:
# #+MACRO: newline src_emacs-lisp[:results raw]{"\n"} # #+MACRO: mdheader --- {{{newline}}} author: -{{{author}}} --- {{{mdheader}}}
the macros are evaluated, however I cannot escape minus signs in macro definition and I obtain:
— author: -MyName —
in the markdown output file. Besides, in this approach there also exist a problem with accessing tag names.
How can those snippets be corrected to get desired result? Or is there any better way of handling this problem?