So after I posted my tribute to my deceased dad here on Blogger, I wondered if I could use Blogger to post code. After a number of false starts, I have chosen the easiest way for me to do so. Here's a step by step for you.
- Type out your text. Insert markers where your code should go. Markers should be a separate paragraph with easily findable text, like:
[SNIPPET #1 GOES HERE] - Create a new gist for each post. Create a new file in the gist for each snippet.
- Copy the embed link from the gist.
- Switch to "HTML view" in Blogger.
- Locate each snippet marker and remove just the tags around it. I usually start at the marker and work left until I find an end tag. Then I know that the tag to the right of the end tag is the start of my snippet. The tags may be spans and font settings.
- Once you have removed all the tags, replace the snippet marker with the embed link. Add "?file=somefilename" to the embed link to limit to one file in the gist.
- Switch back to "Compose view."
- Preview. You won't see anything in Compose view.
- Voila!
Here is the whole gist:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p><span style="font-family: inherit;">So after I posted my tribute to my deceased dad here on Blogger, I wondered if I could use Blogger to post code. After a number of false starts, I have chosen the easiest way for me to do so. Here's a step by step for you.</span></p><p></p><ul style="text-align: left;"><li><span style="font-family: inherit;">Type out your text. Insert markers where your code should go. Markers should be a separate paragraph with easily findable text, like:<br /><br />[SNIPPET #1 GOES HERE]</span></li><li>Create a new gist for each post. Create a new file in the gist for each snippet.</li><li>Copy the embed link from the gist.</li><li>Switch to "HTML view" in Blogger.<br /></li><li>Locate each snippet marker and remove just the tags around it. I usually start at the marker and work left until I find an end tag. Then I know that the tag to the right of the end tag is the start of my snippet. The tags may be spans and font settings.</li><li>Once you have removed all the tags, replace the snippet marker with the embed link. Add "?file=somefilename" to the embed link to limit to one file in the gist.</li><li>Switch back to "Compose view."<br /></li><li>Preview. You won't see anything in Compose view.</li><li>Voila!</li></ul><div>Sample:</div><div><br /></div><div>Here is the whole gist:</div><script src="https://gist.github.com/matthewpersico/c5ae8f9e178c65bd1f2c43134d031380.js"></script><span><div><br /></div><span></span><div>Here is just one file in the gist:</div><script src="https://gist.github.com/matthewpersico/c5ae8f9e178c65bd1f2c43134d031380.js?file=snippet1.pl"></script><span></span><div><br /><br /><br /></div><span></span></span><br /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my $junk = 42; | |
if ($junk == 42) { | |
print("This is snippet1, indent2"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my $junk = 42; | |
if ($junk == 42) { | |
print("This is snippet2, indent 4"); | |
} |
Here is just one file in the gist:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my $junk = 42; | |
if ($junk == 42) { | |
print("This is snippet1, indent2"); | |
} |
As a reference, the first file in the first snip above (post.html) contains the entire HTML for this post as it was BEFORE I added this line and everything below it.