Last active
August 29, 2015 14:02
-
-
Save alexdiliberto/e3a2a85a32dc7566dd4c to your computer and use it in GitHub Desktop.
Converts some custom Jekyll liquid tags into inline code blocks
This file contains 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
# 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