Published 2020-10-03.
Last modified 2023-05-18.
Time to read: 1 minutes.
jekyll_plugins
collection, categorized under Jekyll.
jekyll_run
is a Jekyll tag plugin that executes a program and returns the output from STDOUT
.
This plugin was designed to be embedded within a {% pre %}{% endpre %}
tags.
That is why the output includes the command that was executed,
and contains unselectable <span>
tags,
Installation
Add the following highlighted line to your Jekyll project's Gemfile
,
within the jekyll_plugins
group:
group :jekyll_plugins do gem 'jekyll_run' end
And then execute:
$ bundle
Usage Example
{% run echo "asdf" %}
The generated HTML is:
<span class='unselectable'>$ </span>#{@command}\n<span class='unselectable'>#{output}</span>
Which renders as the following, when enclosed within {% pre %}{% endpre %}
:
$ echo "asdf" asdf
CSS
The following CSS must be used in order for the plugin to work:
.unselectable { color: #7922f9; -moz-user-select: none; -khtml-user-select: none; user-select: none; }