👓 Posting Source Code | Support — WordPress.com

Read Posting Source Code (WordPress Support)
While WordPress.com doesn’t allow you to use potentially dangerous code on your blog, you can post source code for viewing by using the directions found in this support doc.
I’d wondered before how to better display code on my website. This article has a link to an excellent plugin on WordPress.org for doing it and even better, it also syndicates across to my mirrored site on WordPress.com well.

Published by

Chris Aldrich

I'm a biomedical and electrical engineer with interests in information theory, complexity, evolution, genetics, signal processing, IndieWeb, theoretical mathematics, and big history. I'm also a talent manager-producer-publisher in the entertainment industry with expertise in representation, distribution, finance, production, content delivery, and new media.

One thought on “👓 Posting Source Code | Support — WordPress.com”

  1. Although WordPress fully supports Markdown via the JetPack plugin and Markdown supports code blocks there are occasions where the encoding gets thrown off on posting and has to be edited before making a post live.
    Chris Aldrich linked to a piece on the WordPress.com support pages that details the [code] shortcode which, with a language parameter, preserves formatting and even adds syntax highlighting within posts and pages.
    This is native to WordPress.com but a plugin is available for self-hosted blogs which I may start using.
    Compare the two blocks below:
    function make_post($post){
    $post = [
    'title' => $title,
    'content' => $body,
    'status' => $status,
    'format' => $format,
    ];
    return $post;
    }

    function make_post($post){
    $post = [
    'title' => $title,
    'content' => $body,
    'status' => $status,
    'format' => $format,
    ];
    return $post;
    }

    The first is the standard Markdown rendering (I had to correct the greater than symbols having been converted to >) and the second uses the plugin.
    Pretty cool!
    In Drafts I can create an action that inserts the shortcode after prompting for the language I want and I'll look at creating an Alfred workflow to do the same thing.
    (You’ll need to visit the actual post to see the difference as you won’t get the effect via RSS.)

Mentions

Leave a Reply

Your email address will not be published. Required fields are marked *

To respond to a post on this site using your own website, create your post making sure to include the (target) URL/permalink for my post in your response. Then enter the URL/permalink of your response in the (source) box and click the 'Ping me' button. Your response will appear (possibly after moderation) on my page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Learn More)