Convert all pages in document
I have a document that's evolved over the years and now has pages of all different formats (plain text, rich text, markdown). I'd like to make all the pages consistent, but don't want to go page by page selecting Format > Convert Page To…> Rich Text. Enter the wonderful world of scripting and VoodooPad's awesome plugin support. I can write a script to walk through every page of the document, but I can't figure out what method and argument I need on each page to covert the page type. I'm quite willing to believe that I'm overlooking the documentation on this, and I've tried poking around some. I thought I had it when I found setType_ on the page object, but type() just returns "page", so that doesn't seem to be it.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by John on 03 Jan, 2020 03:37 AM
The item conversion code is gnarly and isn't exposed through the scripting interface, so there's currently no way to convert items from one format to another via a script.
2 Posted by Erik Ackerman on 03 Jan, 2020 02:02 PM
That would certainly explain why I had trouble figuring it out. Thanks! How about being able to tell from a script which format a page is in, so I don’t have to manually walk through every page to check?
Support Staff 3 Posted by John on 13 Jan, 2020 06:02 AM
You can call
uti()
on an item to determine its type:You'll get a UTI back (e.g.,
public.utf8-plain-text
) rather than a straightforward type name, but text pages generally only have a handful of types:com.apple.rtfd
net.daringfireball.markdown
public.utf8-plain-text
4 Posted by Erik Ackerman on 13 Jan, 2020 11:43 AM
Perfect! Thank you.
Erik
5 Posted by Kent Sandvik on 02 Feb, 2020 11:02 PM
Before you do this, have a backup of two of your existing Vodoopad document(s) in case they are corrupted after the conversion.