emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* ox-md export title block
@ 2015-10-23 17:37 Matt Price
  2015-10-23 20:38 ` Rasmus
  2015-10-23 20:39 ` Nicolas Goaziou
  0 siblings, 2 replies; 6+ messages in thread
From: Matt Price @ 2015-10-23 17:37 UTC (permalink / raw)
  To: Org Mode


[-- Attachment #1.1: Type: text/plain, Size: 434 bytes --]

I don't know that much about markdown, and I know there are many different
flavours.  pandoc can make use of title, author, and date info in a
markdown file -- from what i cna tell, it expects a "title block atthe head
of a file (http://pandoc.org/README.html#extension-pandoc_title_block)

% author
% title
% date

I have a simple, inadequate patch to ox-md-template that inserts this info.
It's a start maybe for a better patch?

m

[-- Attachment #1.2: Type: text/html, Size: 630 bytes --]

[-- Attachment #2: 0001-ox-md-export-title-block.patch --]
[-- Type: text/x-patch, Size: 1065 bytes --]

diff --git a/lisp/ox-md.el b/lisp/ox-md.el
index e4291e5..321539a 100644
--- a/lisp/ox-md.el
+++ b/lisp/ox-md.el
@@ -468,12 +468,26 @@ holding export options."
   ;; footnotes with at least a blank line.
   (org-trim (org-html-inner-template (concat "\n" contents "\n") info)))
 
+;;;; template
 (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
+   ;;(message (concat info))
+   (and (plist-get info :with-author)
+	(let ((author (org-export-data (plist-get info :author) info)))
+	  (and (org-string-nw-p author)
+	       (concat  "\% " author "\n"))))
+   (and (plist-get info :with-title)
+	(concat "\% " (org-export-data (plist-get info :title) info) "\n"))
+   (and (plist-get info :with-date)
+	(let ((date (org-export-data (org-export-get-date info) info)))
+	  (and (org-string-nw-p date)
+	       (concat "\% " date "\n"))))
+   
+   contents)
+  )
 
 \f
 ;;; Interactive function

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: ox-md export title block
  2015-10-23 17:37 ox-md export title block Matt Price
@ 2015-10-23 20:38 ` Rasmus
  2015-10-23 21:22   ` Nick Dokos
  2015-10-23 20:39 ` Nicolas Goaziou
  1 sibling, 1 reply; 6+ messages in thread
From: Rasmus @ 2015-10-23 20:38 UTC (permalink / raw)
  To: emacs-orgmode

Hi Matt,

Thanks for your patch.

Matt Price <moptop99@gmail.com> writes:

> I don't know that much about markdown, and I know there are many different
> flavours.  pandoc can make use of title, author, and date info in a
> markdown file -- from what i cna tell, it expects a "title block atthe head
> of a file (http://pandoc.org/README.html#extension-pandoc_title_block)
>
> % author
> % title
> % date
>
> I have a simple, inadequate patch to ox-md-template that inserts this info.
> It's a start maybe for a better patch?

I don't think it's inadequate, but I also don't know if this should be
part of ox-md in it’s present form.

The original md specification doesn’t seem to support this syntax:

         https://daringfireball.net/projects/markdown/syntax

(I searched for % and author).

Would it be recognized by say Github or Stack Exchange?  On Github
"^% Rasmus\n"  is printed as just that, so I guess not.

Perhaps it would be better to define a new backend, ox-md-pandoc.el, or
add a "#+MARKDOWN_FLAVOR" keyword to condition such insertions on.

Cheers,
Rasmus

-- 
What will be next?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: ox-md export title block
  2015-10-23 17:37 ox-md export title block Matt Price
  2015-10-23 20:38 ` Rasmus
@ 2015-10-23 20:39 ` Nicolas Goaziou
  1 sibling, 0 replies; 6+ messages in thread
From: Nicolas Goaziou @ 2015-10-23 20:39 UTC (permalink / raw)
  To: Matt Price; +Cc: Org Mode

Hello,

Matt Price <moptop99@gmail.com> writes:

> I don't know that much about markdown, and I know there are many different
> flavours.  pandoc can make use of title, author, and date info in a
> markdown file -- from what i cna tell, it expects a "title block atthe head
> of a file (http://pandoc.org/README.html#extension-pandoc_title_block)
>
> % author
> % title
> % date
>
> I have a simple, inadequate patch to ox-md-template that inserts this info.
> It's a start maybe for a better patch?

Thank you for the patch.

However, "ox-md.el" is for Vanilla Markdown, where such constructs do
not exist. So it cannot be applied there.

ISTR there are a few others export back-ends in contrib/ that may use
this. You may also create ox-md-pandoc.el if it doesn't exist already.

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: ox-md export title block
  2015-10-23 20:38 ` Rasmus
@ 2015-10-23 21:22   ` Nick Dokos
  2015-10-24  0:41     ` Matt Price
  0 siblings, 1 reply; 6+ messages in thread
From: Nick Dokos @ 2015-10-23 21:22 UTC (permalink / raw)
  To: emacs-orgmode

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> However, "ox-md.el" is for Vanilla Markdown, where such constructs do
> not exist. So it cannot be applied there.

> ISTR there are a few others export back-ends in contrib/ that may use
> this. You may also create ox-md-pandoc.el if it doesn't exist already.

Rasmus <rasmus@gmx.us> writes:

> I don't think it's inadequate, but I also don't know if this should be
> part of ox-md in it’s present form.
>
> The original md specification doesn’t seem to support this syntax:
>
>          https://daringfireball.net/projects/markdown/syntax
>
> (I searched for % and author).
>
> Would it be recognized by say Github or Stack Exchange?  On Github
> "^% Rasmus\n"  is printed as just that, so I guess not.
>
> Perhaps it would be better to define a new backend, ox-md-pandoc.el, or
> add a "#+MARKDOWN_FLAVOR" keyword to condition such insertions on.
>

Great minds always meet ;-)

--
Nick

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: ox-md export title block
  2015-10-23 21:22   ` Nick Dokos
@ 2015-10-24  0:41     ` Matt Price
  2015-10-24 11:49       ` Rasmus
  0 siblings, 1 reply; 6+ messages in thread
From: Matt Price @ 2015-10-24  0:41 UTC (permalink / raw)
  Cc: Org Mode

[-- Attachment #1: Type: text/plain, Size: 1515 bytes --]

On Fri, Oct 23, 2015 at 5:22 PM, Nick Dokos <ndokos@gmail.com> wrote:

> Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
>
> > However, "ox-md.el" is for Vanilla Markdown, where such constructs do
> > not exist. So it cannot be applied there.
>
> > ISTR there are a few others export back-ends in contrib/ that may use
> > this. You may also create ox-md-pandoc.el if it doesn't exist already.
>
> Rasmus <rasmus@gmx.us> writes:
>
> > I don't think it's inadequate, but I also don't know if this should be
> > part of ox-md in it’s present form.
> >
> > The original md specification doesn’t seem to support this syntax:
> >
> >          https://daringfireball.net/projects/markdown/syntax
> >
> > (I searched for % and author).
> >
> > Would it be recognized by say Github or Stack Exchange?  On Github
> > "^% Rasmus\n"  is printed as just that, so I guess not.
> >
> > Perhaps it would be better to define a new backend, ox-md-pandoc.el, or
> > add a "#+MARKDOWN_FLAVOR" keyword to condition such insertions on.
> >
>
> Great minds always meet ;-)
>
> --
> Nick
>
>
> OK, I've written a totally primitive ox-md-pandoc.e.  For now it's up on
github, because it's veyr clumsy and doesn't support enough of the pandoc
syntax.  I put it here:

https://github.com/titaniumbones/org-md-pandoc

I would love it if other people would help me improve it. I put a few ideas
in the README.  Happy to add to contrib if/when people think it's good
enough to be of general use.

[-- Attachment #2: Type: text/html, Size: 2363 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: ox-md export title block
  2015-10-24  0:41     ` Matt Price
@ 2015-10-24 11:49       ` Rasmus
  0 siblings, 0 replies; 6+ messages in thread
From: Rasmus @ 2015-10-24 11:49 UTC (permalink / raw)
  To: emacs-orgmode

Matt Price <moptop99@gmail.com> writes:

> OK, I've written a totally primitive ox-md-pandoc.e.  For now it's up on
> github, because it's veyr clumsy and doesn't support enough of the pandoc
> syntax.  I put it here:
>
> https://github.com/titaniumbones/org-md-pandoc
>
> I would love it if other people would help me improve it. I put a few ideas
> in the README.  Happy to add to contrib if/when people think it's good
> enough to be of general use.

If you want to eventually add it to Org, you should pay attention to
copyright assignment, or it may forever live in contrib, much like
ox-koma-letter.el (which is, I must say, extremely inconvenient, at least
for me).  If you care about this issue, perhaps you’ll want to check how
company-mode organizes itself on teh githubs.

Rasmus

-- 
Hvor meget poesi tror De kommer ud af et glas isvand?

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-10-24 11:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-23 17:37 ox-md export title block Matt Price
2015-10-23 20:38 ` Rasmus
2015-10-23 21:22   ` Nick Dokos
2015-10-24  0:41     ` Matt Price
2015-10-24 11:49       ` Rasmus
2015-10-23 20:39 ` Nicolas Goaziou

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).