Skip to main content

Pretty code for blogging

Occasionally I use chunks of code in this blog, one lament that I heard (and I agree) is that the formatting often makes it difficult to read or copy the code chunks.
There are multiple solutions out there and I haven’t been using primarily for laziness, however, I managed to build a tiny script for my blog offline editor that snags in the HTML code necessary without having me going to the annoying step of switching from Rich Text to HTML.
I used Google Prettifier that is hosted on GitHub. The setup is super simple and is explained already in this markdown.
The result should be that the following code should not appear as of after a long night with your buddies and plenty of vodka in your bloodstream…
func presentModalMessageComposeViewController(animated: Bool) {
        if MFMessageComposeViewController.canSendText() {
            let messageComposeVC = MFMessageComposeViewController()

            messageComposeVC.messageComposeDelegate = self
            messageComposeVC.body = "<#body#>"
            messageComposeVC.recipients = [<#recipients#>]
            presentViewController(messageComposeVC, animated: animated, completion: nil)

        } else {
            UIAlertView(title: NSLocalizedString("Error", value: "Error", comment: ""), message: NSLocalizedString("Your device doesn't support messaging", value: "Your device doesn't support messaging", comment: ""), delegate: nil, cancelButtonTitle: NSLocalizedString("OK", value: "OK", comment: "")).show()
Originally I was using Tumblr until they start wasting my time with stupid issues that a blogger doesn't need. Here I found the instructions for Blogger.


Popular posts from this blog

Postgres on Synology

Bring Boxee Box back to life

Zen-inification - The art of decluttering