Page 1 of 1

Convert to Markdown

Posted: 2022-12-30 23:52:19
by loulesko
Inspired by the To Markdown macro by @tomoyuki-kosaka.

This version is a little lighter weight. It doesn't support converting tables because tables in markdown are ridiculous. I wrote this so I can take what I write in Nisus and post it to my markdown only blog. It coverts the document then copies the result to the clipboard. Simply choose Undo to return the document to its previous state.

Updated to the working version. I missed putting a # in front of a comment line. Thanks to Mark for letting me know.

Convert to Markdown.nwm.zip
(3.35 KiB) Downloaded 225 times

Re: Convert to Markdown

Posted: 2022-12-31 05:12:48
by xiamenese
loulesko wrote: 2022-12-30 23:52:19 Inspired by the To Markdown macro by @tomoyuki-kosaka.

This version is a little lighter weight. It doesn't support converting tables because tables in markdown are ridiculous. I wrote this so I can take what I write in Nisus and post it to my markdown only blog. It coverts the document then copies the result to the clipboard. Simply choose Undo to return the document to its previous state.


Convert to Markdown.nwm.zip
Hi,

I've just tried your macro, as well as the other one by @tomoyuki-kosaka on a file with headings, bold, italics and bullet-points.

The @tomoyuki-kosaka macro worked, so I copied the result and pasted it into a plain text document which I opened in Marked2; it looked fine except that the bullet points were not properly rendered. I was able solve the problem by simply editing the .md file I created and replacing single carriage returns with double.

Your macro threw an error as follows:
Screenshot 2022-12-31 at 12.41.jpg
Screenshot 2022-12-31 at 12.41.jpg (213.83 KiB) Viewed 2327 times
If I "continue" the macro, the text has had the double carriage returns inserted, but only the text without any of the markdown code is placed on the clipboard.

I'm happy to be told I'm doing something wrong.

:)

Mark

P.S. I tried doubling the carriage returns myself in NWP before running the macro. Still getting the same error alert.

Re: Convert to Markdown

Posted: 2022-12-31 10:32:12
by loulesko
Mark, Thanks for letting me know. I forgot a # in front of the comment line. :P It works now. 8)

Lou

Re: Convert to Markdown

Posted: 2023-01-01 07:54:06
by xiamenese
loulesko wrote: 2022-12-31 10:32:12 Mark, Thanks for letting me know. I forgot a # in front of the comment line. :P It works now. 8)

Lou
Hi Lou,

Glad to have helped.

I’ve again tried the two macros on the same document. As I said, for @tomoyuki-kosaka’s macro, I need to substitute double carriage returns for the single carriage returns used in the RTF, together with a couple of other tweaks… very easy, and it doesn’t add paragraph spacing within the bullet lists.

For your macro, having inserted the # before that comment, it runs, but:
  • I still don’t get headings or bold/italics converted, but I think the reason is that in the style-sheet for your macro, the style statements are all defined as 12 pt and bold and italic with the latter defined as Courier Prime—presumably that is what you are using—and my styles have different sizes and either Adobe Garamond Pro or Times New Roman. I think that is the problem because @tomoyuki-kosaka doesn’t have either font or font-size specified in the styles. I haven’t yet tried removing those line from your macro style definitions, but will try.
  • Although your macro replaces single with double carriage returns, it doesn’t do so at the end of the line preceding a bullet list, at least not my bullet lists.
I don’t know if you want to spend the time sorting out these small issues in case anyone else is interested in using it, but, just in case, I attach a nonsense document for you to play with. When I have a moment, I’ll try dealing with them myself, though I’m very far from being macro-savvy.

:)

Mark
nonsense-text.rtf
(23.71 KiB) Downloaded 228 times

Re: Convert to Markdown

Posted: 2023-01-01 09:07:11
by xiamenese
Further to that recent post of mine, I have continued playing with Lou’s macro. I have removed the style definitions which were preventing it from working with my document, so now it is handling headings, bold, italic and bullet points.

What it doesn’t work with is block quotes, and here I don’t understand Lou’s code defining them. So that’s for further exploration. I have also not added numbered lists, or different levels of list in my nonsense.rtf document, so that too is for later.

Oh, and for some unknown reason, for me it doesn’t post anything to the clipboard.

So, if anyone else wants to explore it, here is my modified version of the macro, together with an updated version of nonsense-text.rtf to include a block quote, which the original didn’t have.
nonsense-text.rtf
(26.21 KiB) Downloaded 219 times
Convert to Markdown-MH.nwm
(13.39 KiB) Downloaded 231 times
:)

Mark