From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jay Kamat Subject: [PATCH] Add TITLE export to ox-md Date: Wed, 23 Aug 2017 23:32:55 -0400 Message-ID: <87fuchzllk.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50732) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkitC-0001Za-QG for emacs-orgmode@gnu.org; Wed, 23 Aug 2017 23:33:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dkit9-0002Kt-Js for emacs-orgmode@gnu.org; Wed, 23 Aug 2017 23:33:02 -0400 Received: from mail-yw0-x22c.google.com ([2607:f8b0:4002:c05::22c]:33466) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dkit9-0002KO-E5 for emacs-orgmode@gnu.org; Wed, 23 Aug 2017 23:32:59 -0400 Received: by mail-yw0-x22c.google.com with SMTP id h127so11587218ywf.0 for ; Wed, 23 Aug 2017 20:32:57 -0700 (PDT) Received: from laythe (lawn-128-61-61-150.lawn.gatech.edu. [128.61.61.150]) by smtp.gmail.com with ESMTPSA id y4sm1192052ywk.59.2017.08.23.20.32.55 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 Aug 2017 20:32:56 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain 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. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-ox-md.el-Add-TITLE-export-to-markdown-export.patch >From fe45823c8b6da4ecae3347de4859127add03e253 Mon Sep 17 00:00:00 2001 From: Jay Kamat 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)) - ;;; Interactive function ;;;###autoload -- 2.11.0 --=-=-=--