Reply to topic  [ 9 posts ] 
Macro for RTF to Markfown 
Author Message

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

I wonder if it I'd possible to create a Macro to convert Nisus RTF to Markdown.
Or do you know of a workflow besides just writing in. Nisus in plaintext using Markdown syntax .
Any thoughts would be appreciated.


2014-07-18 18:44:39
Profile
User avatar

Joined: 2007-02-07 00:58:12
Posts: 876
Location: Japan
It certainly would be possible to write such a macro (and of course you can write in plaintext and insert markdown by hand, or macro, or glossary, etc.). It's mainly a question of setting things up. How detailed a markup are you looking for. One place to start would be this thread viewtopic.php?f=17&t=5494.

_________________
philip


2014-07-18 21:28:13
Profile

Joined: 2014-07-18 18:32:13
Posts: 28
What I would like to do is strip out all the extra stuff I guess it is meta data of an rtf file created in Nisus and convert it it to a a markdown/multi markdown
file with MMD syntax.

Does that make sense or is there another strategy that can be taken?


2014-07-25 15:30:32
Profile
User avatar

Joined: 2007-02-07 00:58:12
Posts: 876
Location: Japan
By MMD you have something specific in mind. (I wasn't aware of this format.)

davidrcalvert wrote:
What I would like to do is strip out all the extra stuff I guess it is meta data of an rtf file created in Nisus …

The "stripping out" simply amounts to saving as plain text, but of course after you convert the information you want to keep from WYSIWYG styles/attributes to markdown code.

Quote:
…and convert it it to a a markdown/multi markdown
file with MMD syntax.

Does that make sense or is there another strategy that can be taken?

So you want to write the document in Nisus with styles, but then convert it to MMD, perhaps to transfer to another device?

MMD seems to be intended for humans, rather than computers. As long as the specification is clear and un-ambiguous this should be possible. For example you can use a find/replace to insert the correct number of "#" for each level of heading, and wrap bold and italic bits in "*". Lists, too, should be simple enough, although multi-level lists, and non-contiguous lists could be troublesome.
Tables would be a big hassle. It would probably be easiest to just convert them to HTML tables (again see that other thread), since MMD presumably can incorporate bits with HTML markup (as opposed to allowing text with the HTML markup displayed. Still a bit hazy on how these two cases are distinguished.)

If these are all the bits that are needed, it shouldn't be too difficult, to write a macro to do that (except for the tables).

_________________
philip


2014-07-25 16:39:53
Profile

Joined: 2014-07-18 18:32:13
Posts: 28
Would you use a Find and Replace to change all the BOLD words to
**BOLD** for example and what would that look like .
Thanks.


2014-07-25 22:41:25
Profile
User avatar

Joined: 2007-02-07 00:58:12
Posts: 876
Location: Japan
davidrcalvert wrote:
Would you use a Find and Replace to change all the BOLD words to
**BOLD** for example and what would that look like .
Thanks.

Code:
Find and Replace '.+', '**\0**', 'Eau-i'

Note: for this to work you need to have bold style applied to the '.+'

This is just the simplest way to do things. Expressions like this one can be constructed in the Find/Replace window and then "Macroized".

_________________
philip


Last edited by phspaelti on 2014-07-26 06:23:54, edited 1 time in total.



2014-07-25 22:47:44
Profile

Joined: 2013-11-04 06:16:07
Posts: 27
There is already a macro for converting table to markdown. Please do a search on this forum. It would be easy to do a conversion from rtf to a markdown text. I think that there are only five "styles" to convert:
1. headings
2. Paragraphs (from a single paragraph to two paragraphs)
3. italics
4. bold
5. lists

For tables see the forum.
Thanks


2014-07-25 22:52:06
Profile
User avatar

Joined: 2007-02-07 00:58:12
Posts: 876
Location: Japan
Emilio_Speciale wrote:
For tables see the forum.

Do you mean this one: http://www.nisus.com/forum/viewtopic.php?f=18&t=5619#p25587

Anyhow for headings and italic/bold here is a simple macro:
Attachment:
Styles_to_Markdown_1.nwm [18.73 KiB]
Downloaded 158 times


But even at this simple stage I foresee problems. If you have text with italic and bold, this macro will give you ***text***, which probably is no good. (I'm hazy on how markdown really works).

As for the returns on paragraphs as Emilio points out they all have to be doubled. Except only the ones on the text paragraphs have to be doubled. The ones on the headings presumably don't (in fact shouldn't, I think). Also if you are combining this with tables and lists you need to make sure to do things in the right order. Or really it would be better to adopt a different approach (single pass, rather than multiple Find/Replace statements). I don't really have the time in the near future to work on this.

_________________
philip


2014-07-25 23:11:45
Profile

Joined: 2014-07-18 18:32:13
Posts: 28
Phillip,
Thank You, This is good information . I am new to using Macros with Nisus and was using MMD in other apps and needed help with getting over a sticking point.
I now have something that I can experiment with.
Thanks again.


2014-07-26 06:07:08
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 9 posts ] 

Who is online

Users browsing this forum: Baidu [Spider] and 2 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:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software