lib/octopress-escape-code.rb in octopress-escape-code-2.0.3 vs lib/octopress-escape-code.rb in octopress-escape-code-2.0.4
- old
+ new
@@ -85,10 +85,20 @@
"#{c1}#{c2.gsub(/{% (end)?raw %}/, '')}\n#{c4}"
end
end
+ # Escape codeblock tag contents
+ content = content.gsub /^({%\s*codeblock.+?%})(.+?){%\s*endcodeblock\s*%}/m do
+ "#{$1}{% raw %}#{$2.gsub /{% (end)?raw %}/, ''}{% endraw %}{% endcodeblock %}"
+ end
+
+ # Escape highlight tag contents
+ content = content.gsub /^({%\s*highlight.+?%})(.+?){%\s*endhighlight\s*%}/m do
+ "#{$1}{% raw %}#{$2.gsub(/{% (end)?raw %}/, '')}{% endraw %}{% endhighlight %}"
+ end
+
# Escape codefenced codeblocks
content = content.gsub /^(`{3}.+?`{3})/m do
# Replace any raw/endraw tags inside of codefence block
# as some of the regex above may have escaped contents
@@ -96,19 +106,9 @@
#
code = $1.gsub(/{% raw %}/, '').gsub(/{% endraw %}/, '')
# Wrap codefence content in raw tags
"{% raw %}\n#{code}\n{% endraw %}"
- end
-
- # Escape codeblock tag contents
- content = content.gsub /^({%\s*codeblock.+?%})(.+?){%\s*endcodeblock\s*%}/m do
- "#{$1}{% raw %}#{$2.gsub /{% (end)?raw %}/, ''}{% endraw %}{% endcodeblock %}"
- end
-
- # Escape highlight tag contents
- content = content.gsub /^({%\s*highlight.+?%})(.+?){%\s*endhighlight\s*%}/m do
- "#{$1}{% raw %}#{$2.gsub(/{% (end)?raw %}/, '')}{% endraw %}{% endhighlight %}"
end
content
end
end