The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,484 other followers

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:

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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

 
%d bloggers like this: