From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kaushal Modi Subject: Re: [PATCH] Add TITLE export to ox-md Date: Thu, 24 Aug 2017 10:28:34 +0000 Message-ID: References: <87fuchzllk.fsf@gmail.com> <87a82p1fey.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="94eb2c0b07f016b68705577d4be3" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57973) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkpNY-00050F-Mw for emacs-orgmode@gnu.org; Thu, 24 Aug 2017 06:28:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dkpNW-000275-RO for emacs-orgmode@gnu.org; Thu, 24 Aug 2017 06:28:48 -0400 Received: from mail-yw0-x233.google.com ([2607:f8b0:4002:c05::233]:34565) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dkpNW-00026x-K2 for emacs-orgmode@gnu.org; Thu, 24 Aug 2017 06:28:46 -0400 Received: by mail-yw0-x233.google.com with SMTP id z3so1076037ywz.1 for ; Thu, 24 Aug 2017 03:28:46 -0700 (PDT) In-Reply-To: <87a82p1fey.fsf@nicolasgoaziou.fr> 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: Nicolas Goaziou , Jay Kamat Cc: emacs-org list --94eb2c0b07f016b68705577d4be3 Content-Type: text/plain; charset="UTF-8" On Thu, Aug 24, 2017, 5:31 AM Nicolas Goaziou wrote: > > I'm not so sure about it. Vanilla Markdown does not support title. > Neither does "ox-md.el" > Correct, vanilla Markdown does not support title. The file name is the title. For example, the file names of the Wiki pages on GitHub are rendered as titles (that is again not using 100% vanilla Markdown, but that's a good example specific to this question about titles). Is there any consensus about how title are handled in _vanilla_ syntax? > > > -(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)) > > But then you would need to shift all headlines 1 or 2 levels down. > `setext' style becomes unusable because there is no room left for other > headlines. I will soon submit ox-hugo for review for submission to Org. That is an enhanced Makrdown exporter backend, that also handles the post front matter generation for the Hugo static site generator. In there, I have added an option for the user to set an offset for the headings in a post. By default an Org heading with 1 star becomes level-1 heading in Markdown. For ox-hugo, I have set the default to an offset of 1. So the 1-star Org headings will now become level-2 headings in Markdown. Here's a little snippet that implements that: (let ((level-mark (make-string (+ loffset level) ?#))) (concat "\n" level-mark " " todo title " " anchor "\n\n")) (Full code: https://github.com/kaushalmodi/ox-hugo/blob/master/ox-hugo.el) While that doesn't translate title and subtitle to level 1 and level 2 Markdown headings, it at least helps keep the font sizes of title and level-1 Markdown headings different. I would suggest making the title/subtitle to Markdown headings optional at best. Because most HTML renderers will render the file name as title. So will end up with duplicate titles: the one rendered from file name and another from the level-1 Markdown heading based on the above quoted org-md-template snippet. @Jay Would this offset option help in ox-md? Maybe we eventually end up with 3 options (something like below): - org-md-title-as-h1 - org-md-subtitle-as-h2 - org-md-heading-offset WDYT? (Side question: Would it be preferred to create a scratch branch on Org for reviewing ox-hugo? Or would the GitHub repo mentioned above be fine?) -- Kaushal Modi --94eb2c0b07f016b68705577d4be3 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Thu, Aug 24, 2017, 5:31 AM N= icolas Goaziou <mail@nicolasgo= aziou.fr> wrote:

I'm not so sure about it. Vanilla Markdown does not support title.
Neither does "ox-md.el"

Correct, vanilla Markdown does not support title. The file name is the tit= le.=C2=A0

For example, the file names of the Wiki = pages on GitHub are rendered as titles (that is again not using 100% vanill= a Markdown, but that's a good example specific to this question about t= itles).

Is there any consensus about how title are handled in _vanilla_ = syntax?

> -(defun org-md-template (contents _info)
> +(defun org-md-template (contents info)
>=C2=A0 =C2=A0 "Return complete document string after Markdown conv= ersion.
>=C2=A0 CONTENTS is the transcoded contents string.=C2=A0 INFO is a plis= t used
>=C2=A0 as a communication channel."
> -=C2=A0 contents)
> +=C2=A0 (concat
> +=C2=A0 =C2=A0 ;; Generate title and subtitle, if possible
> +=C2=A0 =C2=A0 (let ((title (and (plist-get info :with-title)
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (plist-get in= fo :title)))
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 (subtitle (plist-get info :subtitle))
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 (style (plist-get info :md-headline-style= )))
> +=C2=A0 =C2=A0 =C2=A0 (when title
> +=C2=A0 =C2=A0 =C2=A0(concat
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0(org-md--headline-title style
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A01 (org-export-data title info))
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0(when subtitle
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(org-md--headline-title style
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A02 (org-export-data subtitle = info))))))
> +=C2=A0 =C2=A0 contents))

But then you would need to shift all headlines 1 or 2 levels down.
`setext' style becomes unusable because there is no room left for other=
headlines.

I will soon submit ox-hugo= for review for submission to Org. That is an enhanced Makrdown exporter ba= ckend, that also handles the post front matter generation for the Hugo stat= ic site generator.

In there, I have added an optio= n for the user to set an offset for the headings in a post. By default an O= rg heading with 1 star becomes level-1 heading in Markdown. For ox-hugo, I = have set the default to an offset of 1. So the 1-star Org headings will now= become level-2 headings in Markdown.=C2=A0

Here&#= 39;s a little snippet that implements that:

(l= et ((level-mark (make-string (+ loffset level) ?#)))
=C2=A0 (concat &quo= t;\n" level-mark " " todo title " " anchor "\= n\n"))

While that doesn&= #39;t translate title and subtitle to level 1 and level 2 Markdown headings= , it at least helps keep the font sizes of title and level-1 Markdown headi= ngs different.=C2=A0

I would suggest making the ti= tle/subtitle to Markdown headings optional at best. Because most HTML rende= rers will render the file name as title.

So will e= nd up with duplicate titles: the one rendered from file name and another fr= om the level-1 Markdown heading based on the above quoted org-md-template s= nippet.

@Jay Would this offset option help in ox-m= d?=C2=A0

Maybe we eventually end up with 3 options= (something like below):

- org-md-title-as-h1
- org-md-subtitle-as-h2
- org-md-heading-offset
<= br>
WDYT?

(Side question: Would it be pr= eferred to create a scratch branch on Org for reviewing ox-hugo? Or would t= he GitHub repo mentioned above be fine?)
--

Kaushal Modi

--94eb2c0b07f016b68705577d4be3--