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
RTF to Markdown
Re: RTF to Markdown
Generally this is a macro that's fairly easy to write. Use the find window (with macroize) to create expressions like this:
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
Code: Select all
Find and Replace '.+', '<h1>\0</h1>', 'Eau'
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
philip
-
- Posts: 41
- Joined: 2009-02-17 17:44:12
Re: RTF to Markdown
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
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
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. 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.
yes, tables. This is where things get a bit trickier.
Here a basic macro that will turn tables into markup in a simple fashion. 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
-
- Posts: 41
- Joined: 2009-02-17 17:44:12
Re: RTF to Markdown
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
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
-
- Posts: 27
- Joined: 2013-11-04 06:16:07
Re: RTF to Markdown
Any news on this macro? I am very interested!
Thanks
Thanks
-
- Posts: 28
- Joined: 2014-07-18 18:32:13
Re: RTF to Markdown
Kosaka,
I would like to see if you came up with the RTF to MMD MACRO yet. It would be a great contribution.
I would like to see if you came up with the RTF to MMD MACRO yet. It would be a great contribution.
-
- Posts: 41
- Joined: 2009-02-17 17:44:12
Re: RTF to Markdown
Sorry. It's still a plan.
I'd like to do, but have not done yet.
I'd like to do, but have not done yet.