all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tim Cross <theophilusx@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: Exporting .org to .md for Sourcehut (sr.ht); ox-md not following Markdown spec?
Date: Thu, 03 Dec 2020 06:44:42 +1100	[thread overview]
Message-ID: <874kl4j8lx.fsf@gmail.com> (raw)
In-Reply-To: <9aa624fff553d9d140a6d89aab12e21b@isnotmyreal.name>


TRS-80 <lists.trs-80@isnotmyreal.name> writes:

> Hallo,
>
> I became quite interested in what Drew Devault was doing with his
> Sourcehut project, so I decided to join.  I was really enjoying
> everything except for the fact that .org files are not supported insofar
> as automatic rendering into nice looking HTML in the same way that
> Markdown files are for the README at the root of the project.  And the
> official word is that only Markdown is to be supported.[0]
>
> So I start digging into this, my first try was to use
> org-md-export-to-markdown function to generate the supported Markdown.
> However, doing it that way broke all inter-page links (to headings,
> footnotes, etc.).
>
> Some further digging revealed that the ox-md exporter (which itself is
> derived from the HTML exporter(?) makes extensive use of the id
> attribute in links.  And Sourcehut's HTML sanitizer only allows href and
> title attributes (not id).[1]
>
> For example, here are the sort of links that the ox-md exporter create:
>
> ToC:
>
> ```
> 1.  [rofi-in-elisp](#orgdbf2274)
> ```
>
> Body:
>
> ```
> <a id="orgdbf2274"></a>
>
> # rofi-in-elisp
> ```
>
> Above was copied straight from Eli Schwartz reply to me in my post to
> Sourcehut mailing list about this[0] (although I had already noticed the
> same thing as well).
>
> I tend to agree with him that this is not following the Markdown spec,
> where links should instead become simply:
>
> ToC:
>
> ```
> 1.  [rofi-in-elisp](#rofi-in-elisp)
> ```
>
> And if so, then the Right Thing to do would be to fix that in the ox-md
> exporter?
>
> However OTOH, I can't help but venture a guess that there must have been
> some reason to do it that way in the first place.
>
> So before I invest any more time going down this path, I thought I would
> take a step back and seek some advice whether this is actually the
> correct path or not?
>
> Cheers,
> TRS-80
>
> [0]
> https://lists.sr.ht/~sircmpwn/sr.ht-discuss/%3Cfe7aa296-9c90-463d-b4e6-50eeb7e57428%40localhost%3E
> [1] https://man.sr.ht/markdown/#post-processing

I could be completely wrong here, but I suspect this is a combination of
the evolving markdown spec (or more specifically, no one standard spec)
and the age of the org mode markdown exporter. This probably highlights
the advantages of a standardised spec.

One of the challenges with markdown is that there has never been one
universally accepted spec. While the situation has consolidated somewhat
since markdown first became popular, there is still some variation in
implementations and some of the decisions made when the org mode
exporter was first implemented may not be as correct/accepted now.

It might be worth looking in the archive. I seem to recall other
discussions along these lines some months back. My flawed memory seems
to recall that it was probably time for org's markdown exporter to be
updated to fit with the more 'common' markdown standard, but I don't
recall which that was or whether anyone decided to take that
responsibility on.

Org already has two markdown flavors - 'generic' markdown and github
flavoured markdown. Org's current markdown is based on
http://daringfireball.net/projects/markdown, which probably varies
enough from the one used by sourcehut to cause the problems you are
seeing.

Unfortunately, this fails to provide a clear path to fix your problem. I
guess the 'sane' thing to do would be to look at how the two different
specs differ and then decide if that difference can be managed by
providing additional customisation options to the existing markdown
exporter or whether the differences are sufficient to warrant another
completely different markdown exporter along similar lines to the github
flavoured markdown (probably also worth checking the differences between
sourceht and github as well in case it is closer to what sorcehut
expects).

--
Tim Cross


  parent reply	other threads:[~2020-12-02 19:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-02 18:52 Exporting .org to .md for Sourcehut (sr.ht); ox-md not following Markdown spec? TRS-80
2020-12-02 19:12 ` Jean Louis
2020-12-02 19:56   ` TRS-80
2020-12-02 21:32     ` TRS-80
2020-12-02 19:44 ` Tim Cross [this message]
2020-12-02 20:44   ` TRS-80
2020-12-02 21:59     ` Tim Cross
2020-12-02 23:17       ` TRS-80
2020-12-02 23:36         ` Tim Cross
2020-12-02 19:45 ` Diego Zamboni
2020-12-02 20:25   ` TRS-80
2020-12-11 15:53 ` TRS-80

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874kl4j8lx.fsf@gmail.com \
    --to=theophilusx@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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.