emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* exporting markdown with tables
@ 2017-06-03 13:41 Peter Davis
  2017-06-03 16:31 ` Vicente Vera
  2017-06-04 10:49 ` Joost Kremers
  0 siblings, 2 replies; 7+ messages in thread
From: Peter Davis @ 2017-06-03 13:41 UTC (permalink / raw)
  To: emacs-orgmode


I'd like to be able to move easily between org-mode and the IOS app Editorial, which is mainly based around markdown syntax. I can
easily export markdown from org-mode, but the tables seems to come through as straight HTML, as opposed to markdown's table
syntax. This makes it more difficult to edit the resulting files.

Is there a way to get org to export to markdown using md's table syntax?

(FWIW, I tried using pandoc, but this just removed the table syntax altogether, so an entire table would just run together into a
paragraph of gibberish.)

Thanks,
-pd

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

* Re: exporting markdown with tables
  2017-06-03 13:41 exporting markdown with tables Peter Davis
@ 2017-06-03 16:31 ` Vicente Vera
  2017-06-03 16:46   ` Peter Davis
  2017-06-04 10:49 ` Joost Kremers
  1 sibling, 1 reply; 7+ messages in thread
From: Vicente Vera @ 2017-06-03 16:31 UTC (permalink / raw)
  To: Peter Davis; +Cc: emacs-orgmode

There are several Markdown "forks" which have different sets of features.

AFAIK the markdown exporter in Org is based upon John Gruber's
Markdown, which does not include a syntax for tables. Thus all tables
in Org documents get exported as HTML.

A workaround is to wrap your Org tables as:

#+BEGIN_EXPORT md
| Name   | Years |
| Edward |    44 |
| Sylvia |    45 |
#+END_EXPORT

On export to Markdown the tables will be kept unmodified as Org syntax.

It is important that you know which flavor of Markdown you're
targeting, because not all versions accept tables in Org syntax.
Pandoc's Markdown have a similar syntax for "pipe tables". However,
you may type all tables in any syntax accepted by your Markdown
version and keep them wrapped in #+BEGIN_EXPORT tags.

2017-06-03 13:41 GMT+00:00 Peter Davis <pfd@pfdstudio.com>:
>
> I'd like to be able to move easily between org-mode and the IOS app Editorial, which is mainly based around markdown syntax. I can
> easily export markdown from org-mode, but the tables seems to come through as straight HTML, as opposed to markdown's table
> syntax. This makes it more difficult to edit the resulting files.
>
> Is there a way to get org to export to markdown using md's table syntax?
>
> (FWIW, I tried using pandoc, but this just removed the table syntax altogether, so an entire table would just run together into a
> paragraph of gibberish.)
>
> Thanks,
> -pd
>
>

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

* Re: exporting markdown with tables
  2017-06-03 16:31 ` Vicente Vera
@ 2017-06-03 16:46   ` Peter Davis
  2017-06-04 18:24     ` Vicente Vera
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Davis @ 2017-06-03 16:46 UTC (permalink / raw)
  To: Vicente Vera; +Cc: emacs-orgmode

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

Thanks, Vincente.

I'm specifically aiming at the Markdown syntax supported by the
Editorial app, which does include markup for tables. Unfortunately, it
looks like Editorial's Markdown doesn't use the initial '|', so simply
exporting the org markup won't work without some editing.
Thanks!
-pd

On Sat, Jun 3, 2017, at 12:31 PM, Vicente Vera wrote:
> There are several Markdown "forks" which have different sets of
> features.>
> AFAIK the markdown exporter in Org is based upon John Gruber's
> Markdown, which does not include a syntax for tables. Thus all tables> in Org documents get exported as HTML.
>
> A workaround is to wrap your Org tables as:
>
> #+BEGIN_EXPORT md
> | Name   | Years |
> | Edward |    44 |
> | Sylvia |    45 |
> #+END_EXPORT
>
> On export to Markdown the tables will be kept unmodified as Org
> syntax.>
> It is important that you know which flavor of Markdown you're
> targeting, because not all versions accept tables in Org syntax.
> Pandoc's Markdown have a similar syntax for "pipe tables". However,
> you may type all tables in any syntax accepted by your Markdown
> version and keep them wrapped in #+BEGIN_EXPORT tags.
>
> 2017-06-03 13:41 GMT+00:00 Peter Davis <pfd@pfdstudio.com>:
> >
> > I'd like to be able to move easily between org-mode and the IOS app
> > Editorial, which is mainly based around markdown syntax. I can> > easily export markdown from org-mode, but the tables seems to come
> > through as straight HTML, as opposed to markdown's table> > syntax. This makes it more difficult to edit the resulting files.
> >
> > Is there a way to get org to export to markdown using md's table
> > syntax?> >
> > (FWIW, I tried using pandoc, but this just removed the table syntax
> > altogether, so an entire table would just run together into a> > paragraph of gibberish.)
> >
> > Thanks,
> > -pd
> >
> >


--
  Peter Davis
  www.techcurmudgeon.com


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

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

* Re: exporting markdown with tables
  2017-06-03 13:41 exporting markdown with tables Peter Davis
  2017-06-03 16:31 ` Vicente Vera
@ 2017-06-04 10:49 ` Joost Kremers
  1 sibling, 0 replies; 7+ messages in thread
From: Joost Kremers @ 2017-06-04 10:49 UTC (permalink / raw)
  To: Peter Davis; +Cc: emacs-orgmode


On Sat, Jun 03 2017, Peter Davis wrote:
> (FWIW, I tried using pandoc, but this just removed the table 
> syntax altogether, so an entire table would just run together 
> into a
> paragraph of gibberish.)

You need a somewhat recent version of Pandoc for Org tables to be 
handled correctly (some distros still ship a very outdated 
version; latest is 1.19), and not all features are supported. So 
yeah, it's not necessarily the best option...


-- 
Joost Kremers
Life has its moments

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

* Re: exporting markdown with tables
  2017-06-03 16:46   ` Peter Davis
@ 2017-06-04 18:24     ` Vicente Vera
  2017-06-04 20:38       ` Charles C. Berry
  0 siblings, 1 reply; 7+ messages in thread
From: Vicente Vera @ 2017-06-04 18:24 UTC (permalink / raw)
  To: Peter Davis; +Cc: emacs-orgmode

Cool, you're welcome. It is not the most convenient solution, but
keeping your tables in Editorial Markdown syntax should work:

#+BEGIN_EXPORT md
Cat | Fur   |
--- | ---   |
A   | A lot |
B   | None  |
#+END_EXPORT

2017-06-03 16:46 GMT+00:00 Peter Davis <pfd@pfdstudio.com>:
> Thanks, Vincente.
>
> I'm specifically aiming at the Markdown syntax supported by the Editorial
> app, which does include markup for tables. Unfortunately, it looks like
> Editorial's Markdown doesn't use the initial '|', so simply exporting the
> org markup won't work without some editing.
>
> Thanks!
> -pd
>
> On Sat, Jun 3, 2017, at 12:31 PM, Vicente Vera wrote:
>> There are several Markdown "forks" which have different sets of features.
>>
>> AFAIK the markdown exporter in Org is based upon John Gruber's
>> Markdown, which does not include a syntax for tables. Thus all tables
>> in Org documents get exported as HTML.
>>
>> A workaround is to wrap your Org tables as:
>>
>> #+BEGIN_EXPORT md
>> | Name   | Years |
>> | Edward |    44 |
>> | Sylvia |    45 |
>> #+END_EXPORT
>>
>> On export to Markdown the tables will be kept unmodified as Org syntax.
>>
>> It is important that you know which flavor of Markdown you're
>> targeting, because not all versions accept tables in Org syntax.
>> Pandoc's Markdown have a similar syntax for "pipe tables". However,
>> you may type all tables in any syntax accepted by your Markdown
>> version and keep them wrapped in #+BEGIN_EXPORT tags.
>>
>> 2017-06-03 13:41 GMT+00:00 Peter Davis <pfd@pfdstudio.com>:
>> >
>> > I'd like to be able to move easily between org-mode and the IOS app
>> > Editorial, which is mainly based around markdown syntax. I can
>> > easily export markdown from org-mode, but the tables seems to come
>> > through as straight HTML, as opposed to markdown's table
>> > syntax. This makes it more difficult to edit the resulting files.
>> >
>> > Is there a way to get org to export to markdown using md's table syntax?
>> >
>> > (FWIW, I tried using pandoc, but this just removed the table syntax
>> > altogether, so an entire table would just run together into a
>> > paragraph of gibberish.)
>> >
>> > Thanks,
>> > -pd
>> >
>> >
>
>
> --
>   Peter Davis
>   www.techcurmudgeon.com
>

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

* Re: exporting markdown with tables
  2017-06-04 18:24     ` Vicente Vera
@ 2017-06-04 20:38       ` Charles C. Berry
  2017-06-04 21:57         ` Peter Davis
  0 siblings, 1 reply; 7+ messages in thread
From: Charles C. Berry @ 2017-06-04 20:38 UTC (permalink / raw)
  To: Vicente Vera; +Cc: emacs-orgmode, Peter Davis

On Sun, 4 Jun 2017, Vicente Vera wrote:

> Cool, you're welcome. It is not the most convenient solution, but
> keeping your tables in Editorial Markdown syntax should work:
>
> #+BEGIN_EXPORT md
> Cat | Fur   |
> --- | ---   |
> A   | A lot |
> B   | None  |
> #+END_EXPORT
>

Except that the above is not recognized as a table, so all the nifty tools 
for table editing are lost.

IMO, a better solution is to create a filter for table-row that replaces 
the leading vertical with a space (or nothing) and bind that function to 
`org-export-filter-table-row-functions'. See

 	(info "(org) Advanced configuration")


---

However, those intimidated by filters can keep tables in org src blocks 
and convert them on export using a :post argument to clean the leading 
verticals.  That way the tables can be edited as usual via 
org-edit-src-code:

#+name: strip-leading-vertical
#+BEGIN_SRC emacs-lisp
(replace-regexp-in-string "^|" " " *this*)
#+END_SRC


#+header: :results replace :exports results
#+header: :post strip-leading-vertical() :wrap export md
#+BEGIN_SRC org
   | a | b |
   |---+---|
   | 1 | 2 |
   | 3 | 4 |
#+END_SRC

#+RESULTS:
#+BEGIN_export md
   a | b |
  ---+---|
   1 | 2 |
   3 | 4 |
#+END_export

A call to `(require 'ob-org)' or suitable customization is needed to 
enable the org src block to execute.

HTH,

Chuck

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

* Re: exporting markdown with tables
  2017-06-04 20:38       ` Charles C. Berry
@ 2017-06-04 21:57         ` Peter Davis
  0 siblings, 0 replies; 7+ messages in thread
From: Peter Davis @ 2017-06-04 21:57 UTC (permalink / raw)
  To: emacs-orgmode

Thanks to all for the responses here. They have opened my eyes to new
org features I can use in other ways.

For now, I think my solution to the table export question will be just
to keep everything in org mode and to heck with Editorial and Markdown.

Thanks!

-pd



-- 
  Peter Davis
  www.techcurmudgeon.com

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

end of thread, other threads:[~2017-06-04 21:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-03 13:41 exporting markdown with tables Peter Davis
2017-06-03 16:31 ` Vicente Vera
2017-06-03 16:46   ` Peter Davis
2017-06-04 18:24     ` Vicente Vera
2017-06-04 20:38       ` Charles C. Berry
2017-06-04 21:57         ` Peter Davis
2017-06-04 10:49 ` Joost Kremers

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