diff --git a/_notes/your-first-note.md b/_notes/your-first-note.md index 616d53c..0eb3794 100644 --- a/_notes/your-first-note.md +++ b/_notes/your-first-note.md @@ -73,6 +73,8 @@ And of course, images look great: +You can also ==highlight some content== by wrapping it with `==`. + ### Code syntax highlighting You can add code blocks with full syntax color highlighting by wrapping code snippet in triple backticks and specifying the type of the code (`js`, `rb`, `sh`, etc.): diff --git a/_plugins/markdown-highlighter.rb b/_plugins/markdown-highlighter.rb new file mode 100644 index 0000000..6630d00 --- /dev/null +++ b/_plugins/markdown-highlighter.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +# Turns ==something== in Markdown to something in output HTML + +Jekyll::Hooks.register [:notes], :post_convert do |doc| + replace(doc) +end + +Jekyll::Hooks.register [:pages], :post_convert do |doc| + # jekyll considers anything at the root as a page, + # we only want to consider actual pages + next unless doc.path.start_with?('_pages/') + replace(doc) +end + +def replace(doc) + doc.content.gsub!(/==+(\w(.*?)?[^ .=]?)==+/, "\\1") +end