Skip to content

Commit

Permalink
only process text outside of code blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Helveg committed Sep 27, 2024
1 parent cf66adf commit 01bbb8d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,11 @@ Your markdown files should start like this.

> [!IMPORTANT]
>
> Your root `README.md` front matter should contain a `permalink` attribute:
> Your root `README.md` front matter should contain the following `permalink` attribute:
> ```yaml
> permalink: /index.html
> ```
Link to nested [README](./lib/README.md)
## License
This project is licensed under the MIT License. See the [LICENSE.txt](LICENSE.txt) file
Expand Down
7 changes: 0 additions & 7 deletions lib/README.md

This file was deleted.

10 changes: 10 additions & 0 deletions lib/jekyll-gfm-admonitions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ def self.admonition_pages
end

def convert_admonitions(doc)
code_blocks = []
doc.content.gsub!(/```.*?```/m) do |match|
code_blocks << match
"```{{CODE_BLOCK_#{code_blocks.length - 1}}}```"
end

doc.content.gsub!(/>\s*\[!(IMPORTANT|NOTE|WARNING|TIP|CAUTION)\]\s*\n((?:>.*\n?)*)/) do
type = ::Regexp.last_match(1).downcase
title = type.capitalize
Expand All @@ -78,6 +84,10 @@ def convert_admonitions(doc)
<p>#{@markdown.convert(text)}</p>
</div>\n\n"
end

doc.content.gsub!(/```\{\{CODE_BLOCK_(\d+)}}```/) do
"```#{code_blocks[$1.to_i]}```"
end
end
end

Expand Down

0 comments on commit 01bbb8d

Please sign in to comment.