Just like when we can use SyntaxHighlighter2 plugin to show sourcecodes with syntax highlight in popular programming languages while blogging on Wordpress MU.

I'm wondering if we can set syntax highlight for a certain block of texts on iWork 09 Pages.

For example, say I have ruby, rails, jQuery, javascript, html source codes, on my writing on Pages, then I want to set them using syntax highlight for each different language/framework without blocking each character then set its colour one by one. How ?


Pages does not actually allow for code syntax highlighting, so you will have to use a bit of a work around to do it.

Luckily, Pages supports keeping the formatting of pasted text. Using this feature, you can just paste your code into a pastebin that supports syntax highlighting, then copy and paste the code into your Pages document.

Here are a couple of pastebins that will work (each with pros and cons)

  1. Slexy: Slexy supports the most number of languages for syntax highlighting, but when you copy-and-paste your code, it copies the line numbers as well. You may or may not be after this.
  2. dpaste: Dpaste supports only 14 different 'languages', all pretty new web-orienated, so If you are after C++ highlighting, go with one of the others. However, it does not copy across the line numbers.
  3. Pastie: Pastie supports the same languages (more or less) as dpaste, but also includes more 'traditional' languages, such as C and C++. It also features 16 different themes for syntax highlighting. It does not copy across the line numbers.

Using the same code sample, I made this little preview of the three pastebins pasted into Pages 09

| improve this answer | |
  • Would it be possible to automate this with services, or via Applescript? – Mikey P Jun 17 '13 at 23:03

I found this discussion, it's very much the same problem he got just like mine, so I contacted the guy, he said that he was never able to find a solution, so that he learnt and use a text script language TeX (he actually learned LaTeX), he said that it has the power to do such things easily.

So far, I guess while waiting (and praying) for Apple iWork Pages people to implement this feature (or any addon) for technical book writer, I'll use Pages with common courier font for codes and get serious to learn LaTeX (I've never been serious to learn it), hopefully it can solve my problem. I'll find out whether or not LaTeX can also "attach" my last-updated source codes in a directory so that I won't copy paste one by one if I update my source code file.

| improve this answer | |
  • 1
    Re: "attaching" source code files: In LaTeX, you can have a source code listing reference a source code file, so whenever you update that source code file (and recompile your LaTeX document), the changes will be seen by LaTex. You can read more about it here: texblog.wordpress.com/2008/04/02/… – mipadi Oct 9 '09 at 2:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.