Saturday, June 12, 2010

ConnectedText Markup to RTF

I will be on sabbatical next year, and I have seriously started to write on my new book in ConnectedText, but eventually the different topics will end up in a word processor. Accordingly, I have updated the Rtf conversion script.[1] It now needs no text editor.[2] Instead, it writes the file directly (and then opens the directory). The file name is the current time and date with an rtf extension. I have changed the font to Times New Roman.

clipboard :=
Send ^c
ClipWait
clipboard = %clipboard%

StringReplace, clipboard, clipboard, %A_SPACE%`/`/, %A_SPACE%`{`\i%A_SPACE%, All
StringReplace, clipboard, clipboard, %A_SPACE%`(`/`/, %A_SPACE%`{`\i%A_SPACE%, All
StringReplace, clipboard, clipboard, `"/`/, `"`{`\i%A_SPACE%, All
StringReplace, clipboard, clipboard, `'/`/, `'`{`\i%A_SPACE%, All
StringReplace, clipboard, clipboard, `/`/%A_SPACE%, `}%A_SPACE%, All
StringReplace, clipboard, clipboard, `/`/`n`r, `}`,, All
StringReplace, clipboard, clipboard, `/`/%A_EndChar%, `}`,, All


StringReplace, clipboard, clipboard, %A_SPACE%`*`*, %A_SPACE%`{`\b%A_SPACE%, All
StringReplace, clipboard, clipboard, `*`*%A_SPACE%, `}%A_SPACE%, All
StringReplace, clipboard, clipboard, `*`*%A_EndChar%, `}`,, All
StringReplace, clipboard, clipboard, `n`r, `\par, All
StringReplace, clipboard, clipboard, `[`!, \chftn{\footnote \pard\plain \s246 \fs20 {\up6\chftn} , All
StringReplace, clipboard, clipboard, `!`], `}, All
clipboard = `{`\rtf1`\ansi`{`\fonttbl`\f0`\froman\fprq2`\fcharset0 Times New Roman;`}`\f0`\pard %clipboard%
FileAppend, %clipboard%, C:\Users\xxx\Documents\ConnectedText\Projects\xxx\Files\%A_Now%.rtf
Run, C:\Users\Manfred\Documents\ConnectedText\Projects\xxx\Files


I especially like this script because it transforms ConnectedText footnotes into usable Rtf (or doc) footnotes. It also does bold and italics, but it does not do tables or any other fancy formatting. I just don't need them for basic academic writing in Philosophy. I use ":" for blocked quotes in ConnectedText, and it is easy to search for those in a word processor and replace them with proper formatting

Works perfectly in the MS Works word processor.[3] I run the script compiled from the Scripts Menu. (If anyone wants to use it, they have to replace the "xxx" with whatever fits their file system.

I tried several commercial programs to transform HTML or XML with them. They did not perform as well as this home-made and admittedly homely script.


1. For the older version, see Wiki Markup to Rtf.
2. It never needed a text editor. It just didn't occur to me to take the simpler route.
3. For no apparent reason, Atlantis (the word processor I use) does not put the footnote references into superscript. After I open the file in Works and save it as rtf, doc or docx, it does recognize it properly, however. Seems to have something to do with different rtf-versions.

No comments: