From eb8402810e32b625dcaa18569a024d3efef82f2c Mon Sep 17 00:00:00 2001 From: Xevion Date: Sat, 13 May 2023 01:27:17 -0500 Subject: [PATCH] Add inline syntax highlighting Liquid tag plugin --- _plugins/jekyll_inline_highlight.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 _plugins/jekyll_inline_highlight.rb diff --git a/_plugins/jekyll_inline_highlight.rb b/_plugins/jekyll_inline_highlight.rb new file mode 100644 index 0000000..54813f7 --- /dev/null +++ b/_plugins/jekyll_inline_highlight.rb @@ -0,0 +1,27 @@ +# jekyll_inline_highlight +# +# A Liquid tag for inline syntax highlighting in Jekyll +# +# https://github.com/bdesham/inline_highlight +# +# Copyright (c) 2014-2015, Tom Preston-Werner and Benjamin Esham +# See README.md for full copyright information. + +module Jekyll + class InlineHighlightBlock < Tags::HighlightBlock + + def add_code_tag(code) + code_attributes = [ + "class=\"highlight language-#{@lang.to_s.gsub('+', '-')}\"", + "data-lang=\"#{@lang.to_s}\"" + ].join(" ") + "#{code.chomp.strip}" + end + + def render(context) + super.strip + end + end +end + +Liquid::Template.register_tag('ihighlight', Jekyll::InlineHighlightBlock) \ No newline at end of file