Skip to content

Instantly share code, notes, and snippets.

@BorisAnthony
Created July 29, 2020 09:30
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 BorisAnthony/d6b8e0291d06bb9d1a5b1bc79d560c99 to your computer and use it in GitHub Desktop.
Save BorisAnthony/d6b8e0291d06bb9d1a5b1bc79d560c99 to your computer and use it in GitHub Desktop.
A little Jekyll plugin to parse ==text== into <mark>text</mark>. With thanks to @ashmaroli on https://talk.jekyllrb.com/t/plugin-help-markdown-in-string-processed-by-plugin-not-being-rendered/4771/2
Jekyll::Hooks.register :documents, :pre_render do |doc|
# We want to catch all pages, posts, docs in collections
doc.content = doc.content.gsub(
/\=\=(.*)\=\=/i,
'<mark markdown="span">\1</mark>'
)
# setting the markdown="span" flag tells Kramdown to parse what's between the tags,
# otherwise it is ignored.
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment