Skip to content

Instantly share code, notes, and snippets.

@alexdiliberto
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexdiliberto/e3a2a85a32dc7566dd4c to your computer and use it in GitHub Desktop.
Save alexdiliberto/e3a2a85a32dc7566dd4c to your computer and use it in GitHub Desktop.
Converts some custom Jekyll liquid tags into inline code blocks
# Convert the following liquid tags into output wrapped with <code class="inline-code"> ... </code>
# 1. {% i %} var foo="bar"; {% ei %}
# 2. {% inline %} var foo="bar"; {% endinline %}
module Jekyll
class SyntaxHighlightInlineTag < Liquid::Tag
def render(context)
'<code class="inline-code">'
end
end
class SyntaxHighlightInlineEndTag < Liquid::Tag
def render(context)
'</code>'
end
end
end
Liquid::Template.register_tag('inline', Jekyll::SyntaxHighlightInlineTag)
Liquid::Template.register_tag('endinline', Jekyll::SyntaxHighlightInlineEndTag)
Liquid::Template.register_tag('i', Jekyll::SyntaxHighlightInlineTag)
Liquid::Template.register_tag('ei', Jekyll::SyntaxHighlightInlineEndTag)
# ...And here's the CSS
#
# code.inline-code {
# background-color: rgba(222,222,222,.2);
# border-radius: 3px;
# padding: 0 3px;
# outline: solid 1px #d1d1d1;
# }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment