Reply to topic  [ 8 posts ] 
RTF to Markdown 
Author Message

Joined: 2009-02-17 17:44:12
Posts: 37
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


2014-01-27 18:00:18
Profile
User avatar

Joined: 2007-02-07 00:58:12
Posts: 876
Location: Japan
Generally this is a macro that's fairly easy to write. Use the find window (with macroize) to create expressions like this:
Code:
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.
viewtopic.php?f=17&t=5494&p=24912#p24912

_________________
philip


2014-01-27 20:58:19
Profile

Joined: 2009-02-17 17:44:12
Posts: 37
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


2014-01-28 15:56:24
Profile
User avatar

Joined: 2007-02-07 00:58:12
Posts: 876
Location: Japan
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.
Attachment:
Convert Tables to Markup.nwm [17.29 KiB]
Downloaded 158 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.

_________________
philip


2014-01-28 17:29:55
Profile

Joined: 2009-02-17 17:44:12
Posts: 37
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


2014-02-07 17:05:29
Profile

Joined: 2013-11-04 06:16:07
Posts: 27
Any news on this macro? I am very interested!
Thanks


2014-07-24 10:17:39
Profile

Joined: 2014-07-18 18:32:13
Posts: 28
Kosaka,

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


2014-07-25 15:38:57
Profile

Joined: 2009-02-17 17:44:12
Posts: 37
Sorry. It's still a plan.
I'd like to do, but have not done yet.


2014-07-25 22:36:40
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 8 posts ] 

Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software