Hey Org-mode enthusiasts,

Find attached a patch adding export of manual links for markdown.

I wanted to get links to man pages to work nicely for my blog using ox-hugo, an org exporter based on markdown, built by well-known org enthusiast Kaushal Modi.


Org snippet to demonstrate export to markdown feature:

--8<---------------cut here---------------start------------->8---
I sure love [[man:emacs][GNU Emacs]].
--8<---------------cut here---------------end--------------->8---

org-md-export-to-markdown before (link description missing, booh):

--8<---------------cut here---------------start------------->8---
I sure love http://man.he.net/?topic=emacs&section=all.
--8<---------------cut here---------------end--------------->8---

Export to markdown after (pretty, valid markdown, yey):

--8<---------------cut here---------------start------------->8---
I sure love [GNU Emacs](http://man.he.net/?topic=emacs&section=all).
--8<---------------cut here---------------end--------------->8---

This is my first contribution (I welcome feedback regarding patch formatting etc). No FSF papers due to contrib/. Happy I can finally contribute /something/ back, and scratching that itch feels nice.

Have a fantastic day.

--
Jb

>From c7c2fe978a134347a0b6c30667015c687803eb12 Mon Sep 17 00:00:00 2001
From: Jb DOYON <j...@jiby.tech>
Date: Sun, 14 Jun 2020 21:19:20 +0100
Subject: [PATCH] contrib/ol-man.el: Add markdown support to org-man export

---
 contrib/lisp/ol-man.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/contrib/lisp/ol-man.el b/contrib/lisp/ol-man.el
index 580556a..5cb7e01 100644
--- a/contrib/lisp/ol-man.el
+++ b/contrib/lisp/ol-man.el
@@ -68,6 +68,7 @@ PATH should be a topic that can be thrown at the man command."
      ((eq format 'latex) (format "\\href{%s}{%s}" path desc))
      ((eq format 'texinfo) (format "@uref{%s,%s}" path desc))
      ((eq format 'ascii) (format "%s (%s)" desc path))
+     ((eq format 'md) (format "[%s](%s)" desc path))
      (t path))))
 
 (provide 'ol-man)
-- 
2.20.1

Reply via email to