Page 1 of 1

RTF to Markdown

Posted: 2014-01-27 18:00:18
by tomoyuki-kosaka
I'd like to convert RTF to Markdown format because when I write in NWP to move to blog converter (e.g., jekyll gem of Ruby).
Does someone know the most efficient way to do this?
Yes, I know the markdown not cover all of RTF functions.
I'm considering to make a macro for this purpose.

Kosaka

Re: RTF to Markdown

Posted: 2014-01-27 20:58:19
by phspaelti
Generally this is a macro that's fairly easy to write. Use the find window (with macroize) to create expressions like this:

Code: Select all

Find and Replace '.+', '<h1>\0</h1>', 'Eau'
Note that this is an attributed find, so you should apply the relevant style ("Heading 1" in this case) to the find expression.

Having said that, it can get a bit tricky depending on how complicated things get in your markup, and how 'good' of a result you want. Lou Lesko has written a pretty good basic macro for this purpose. You might be able to use that, at least as a starting point.
http://www.nisus.com/forum/viewtopic.ph ... 912#p24912

Re: RTF to Markdown

Posted: 2014-01-28 15:56:24
by tomoyuki-kosaka
Thanks Fillip.
I forgot to see the post about "Convert to HTML Macro for Writers".
I'll try to modify the script to adjust to Markdown format.

I have one more question.
I'm considering about converting table object in RTF to Markdown.
Other objects can be converted just "Find and Replace" as you mentioned.
But table needs some consideration.
Do you know the good example script for to use my purpose?

Kosaka

Re: RTF to Markdown

Posted: 2014-01-28 17:29:55
by phspaelti
Hi Kosaka,
yes, tables. This is where things get a bit trickier.
Here a basic macro that will turn tables into markup in a simple fashion.
Convert Tables to Markup.nwm
(17.29 KiB) Downloaded 688 times
Note: This macro does not seem to undo completely. Make sure to run this on a copy of your file.

Converting tables has some extra issues.
First: table headers
The macro above just converts all cells to <td>. Table headers could be handled either by using a style (e.g. "Table Header Cell") or simply by making the first row and column into header cells in all cases.

Second: in-cell formatting
Currently the macro just eliminates paragraphs in table cells using line breaks <br/>. But actually rtf would allow differently formatted paragraphs within a table. If that is desired, a more complex macro will be required. Similar issues come up for tabs within table cells, lists, etc. (Markup would even allow nested tables, but since (Nisus) rtf doesn't allow that, that is one problem less to worry about.)
Note that if you try the macro with formatting applied to different cells the formatting will be spread around, and partly lost. So one might need to first mark-up styles (or other info) in the table before using a macro like this. So for a more complete rtf-to-markup conversion macro I think I would get away from the simple Find/Replace approach and use a more structured approach using macro language object commands.

Re: RTF to Markdown

Posted: 2014-02-07 17:05:29
by tomoyuki-kosaka
Thank you Fillip.
I'm sorry for late my response.
I confirmed the macro can convert a table object to markup format.
I'll try to make markdown conversion macro based on these macros, if I can make a time.
Anyway, thanks again you always giving us the useful information about Nisus macro's.

Best,

Kosaka

Re: RTF to Markdown

Posted: 2014-07-24 10:17:39
by Emilio_Speciale
Any news on this macro? I am very interested!
Thanks

Re: RTF to Markdown

Posted: 2014-07-25 15:38:57
by davidrcalvert
Kosaka,

I would like to see if you came up with the RTF to MMD MACRO yet. It would be a great contribution.

Re: RTF to Markdown

Posted: 2014-07-25 22:36:40
by tomoyuki-kosaka
Sorry. It's still a plan.
I'd like to do, but have not done yet.