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.
| @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.
Share this:
- Share on Mastodon (Opens in new window) Mastodon
- Share on Bluesky (Opens in new window) Bluesky
- Share on Tumblr
- Share on Reddit (Opens in new window) Reddit
- Share on Threads (Opens in new window) Threads
- Tweet
- Share on Telegram (Opens in new window) Telegram
- Share on Nextdoor (Opens in new window) Nextdoor
- Share on WhatsApp (Opens in new window) WhatsApp
- Print (Opens in new window) Print
- 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.






Leave a Comment