From: Jay Kamat <jaygkamat@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] Add TITLE export to ox-md
Date: Wed, 23 Aug 2017 23:32:55 -0400 [thread overview]
Message-ID: <87fuchzllk.fsf@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1241 bytes --]
Hi!
Currently, the markdown org exporter does not export titles. For example, the
following org file:
#+TITLE: My Title
#+SUBTITLE: My Subtitle
#+OPTIONS: toc:nil
exports to an empty file. This patch adds title support to ox-md. Currently it
exports them as markdown headers. For example, the above org file will export
to:
# My Title
## My Subtitle
Of course, the title can be suppressed by adding #+OPTIONS: title:nil.
The style used for the title export can be configured using the already existing
org-md-headline-style variable.
The markdown editor should support TITLE, but I'm not sure if this is the
'correct' way to support it. It seems like the simplest way for now. If people
want it, I could add a new option to add different title export formats.
There is an existing bug report and discussion at this issue tracker:
https://github.com/larstvei/ox-gfm/issues/21.
From that issue, YAML front-matter is an option for title export, but I would
like to stay away from that (at least by default) since that dosen't seem to be
a feature in default markdown.
Feedback, suggestions, and feature requests are very much appreciated!
-Jay
PS: Apologies if any part of this email is broken, I'm attempting to switch to gnus.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ox-md.el-Add-TITLE-export-to-markdown-export.patch --]
[-- Type: text/x-diff, Size: 1545 bytes --]
From fe45823c8b6da4ecae3347de4859127add03e253 Mon Sep 17 00:00:00 2001
From: Jay Kamat <jaygkamat@gmail.com>
Date: Sun, 20 Aug 2017 19:01:29 -0400
Subject: [PATCH] ox-md.el: Add TITLE export to markdown export
* lisp/ox-md.el (org-md-template): Add title export to md template.
Title will be exported as level 1 and 2 headers, as determined by
org-md-headline-style
See https://github.com/larstvei/ox-gfm/issues/21 for an external bug report
---
lisp/ox-md.el | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/lisp/ox-md.el b/lisp/ox-md.el
index ac94ba648..a552063e8 100644
--- a/lisp/ox-md.el
+++ b/lisp/ox-md.el
@@ -649,14 +649,26 @@ holding export options."
;; Footnotes section.
(org-md--footnote-section info)))
-(defun org-md-template (contents _info)
+(defun org-md-template (contents info)
"Return complete document string after Markdown conversion.
CONTENTS is the transcoded contents string. INFO is a plist used
as a communication channel."
- contents)
+ (concat
+ ;; Generate title and subtitle, if possible
+ (let ((title (and (plist-get info :with-title)
+ (plist-get info :title)))
+ (subtitle (plist-get info :subtitle))
+ (style (plist-get info :md-headline-style)))
+ (when title
+ (concat
+ (org-md--headline-title style
+ 1 (org-export-data title info))
+ (when subtitle
+ (org-md--headline-title style
+ 2 (org-export-data subtitle info))))))
+ contents))
-\f
;;; Interactive function
;;;###autoload
--
2.11.0
next reply other threads:[~2017-08-24 3:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-24 3:32 Jay Kamat [this message]
2017-08-24 9:30 ` [PATCH] Add TITLE export to ox-md Nicolas Goaziou
2017-08-24 10:28 ` Kaushal Modi
2017-08-24 14:41 ` Jay Kamat
2017-08-26 8:11 ` Nicolas Goaziou
2017-08-28 2:43 ` Jay Kamat
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87fuchzllk.fsf@gmail.com \
--to=jaygkamat@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).