Embedding a Gist in WordPress is easy (via: Support — WordPress.com)
Posted by jpluimers on 2014/12/08
Boy, I wish I had found out about this a long time ago.
Embedding source code in WordPress web sites has always been a pain, as the Jekyll & Hyde faces of the WordPress Visual & Text keep fighting about the content.
A few artefacts I stumbled upon on a regular base:
- supurious insertions of html br tags.
- xml disappearing (same for html).
- reformatting of the text
Not so any more: just put your code in a public gist, then put the Gist url in the code without making it an actual link.
The only drawback: for backing up (own your own content!) you now need to backup both your WordPress site as well as all your gists. For a restore if something goes wrong with Gist, you need to reinstate all the Gist links in your blogs.
Example: I embedded https://gist.github.com/jpluimers/6248572 as plain text below.
This file contains hidden or 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
| @echo off | |
| if #%1#==## goto :help | |
| setlocal | |
| call :main %* | |
| endlocal | |
| goto :eof | |
| :help | |
| echo Syntax: %0 Project-Root-Path [Empty.ddp] | |
| echo This will delete all empty DDP files, with the default second paramameter being "%~dp0Empty.ddp" | |
| goto :eof | |
| :main | |
| set emptyDDP=%2 | |
| if #%2#==## set emptyDDP=%~dp0Empty.ddp | |
| echo emptyDDP=%emptyDDP% | |
| set root=%1 | |
| ::echo root=%root% | |
| ::Does string have a trailing slash? if so remove it | |
| if %root:~-1%==\ SET root=%root:~0,-1% | |
| ::echo root=%root% | |
| for /R %root% %%f in (*.ddp) do call :compare "%%f" | |
| goto :eof | |
| :compare | |
| ::echo %1 | |
| :: do not compare the predefined empty one itself, otherwise it gets deleted | |
| if /I %1=="%emptyDDP%" goto :eof | |
| ::echo before %ERRORLEVEL% | |
| FC %1 "%emptyDDP%" > nul | |
| ::echo after %ERRORLEVEL% | |
| if ERRORLEVEL 1 goto :keep | |
| if ERRORLEVEL 0 goto :delete | |
| echo ### Wrong ERRORLEVEL | |
| goto :eof | |
| :keep | |
| echo keep %1 | |
| goto :eof | |
| :delete | |
| del %1 | |
| goto :eof | |
| :eof |
–jeroen
via: Gist — Support — WordPress.com.
Rate this:
Share this:
- Click to share on Mastodon (Opens in new window) Mastodon
- Click to share on Bluesky (Opens in new window) Bluesky
- Share on Tumblr
- Click to share on Reddit (Opens in new window) Reddit
- Click to share on Threads (Opens in new window) Threads
- Tweet
- Click to share on Telegram (Opens in new window) Telegram
- Click to share on Nextdoor (Opens in new window) Nextdoor
- Click to share on WhatsApp (Opens in new window) WhatsApp
- Click to print (Opens in new window) Print
- Click to email a link to a friend (Opens in new window) Email
Related
This entry was posted on 2014/12/08 at 06:00 and is filed under Power User, SocialMedia, WordPress. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
This site uses Akismet to reduce spam. Learn how your comment data is processed.






Leave a comment