loading...

Markdown to Pages format conversion

cookrdan profile image Dan ・1 min read

I write a lot of things in Markdown and use Pandoc for a number of things. I haven't been able to find a way to convert markdown to pages format. At times I need to send a document in either docx or pages. It's easier in pages.

Pandoc of course is essential:

pandoc -o document.docx document.md 

It'd be great if I could get .docx to .pages conversion working in the command line somehow. So I fiddled. For too long.

Apple Script is able to accomplish this - and here is the basic thing of it:

set old_doc to POSIX file "/Users/username/path/to/docx/file.docx" as string

set new_doc to POSIX file "/Users/username/path/to/pages/file.pages" as string

tell application "Pages"
    set thisDoc to open old_doc
    save thisDoc in file new_doc
    close thisDoc
end tell

Note: if you don't tell Pages to activate then this process will probably remain hidden behind other open windows - it's also quite fast

I have yet to finish this little project. I plan to script it out more using osascript so that I will just be able to type mdtopages document.md in my terminal and end up with document.pages.

Posted on by:

cookrdan profile

Dan

@cookrdan

I’m a coding guy

Discussion

markdown guide
 

Are you aware of the textutil command ? For some reason it does not support pages but it can convert to and from "txt, rtf, rtfd, html, doc, docx, odt, wordml, or webarchive".