Merge pull request #75 from maximevaillancourt/add-highlight-syntax

Highlight content wrapped with ==
This commit is contained in:
Maxime Vaillancourt 2021-08-23 19:42:22 -04:00 committed by GitHub
commit 35ae90f29c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View File

@ -73,6 +73,8 @@ And of course, images look great:
<img src="/assets/image.jpg"/>
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.):

View File

@ -0,0 +1,18 @@
# frozen_string_literal: true
# Turns ==something== in Markdown to <mark>something</mark> 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(.*?)?[^ .=]?)==+/, "<mark>\\1</mark>")
end