Added filters to fix a kramdown bug

This commit is contained in:
Yann Esposito (Yogsototh) 2010-12-06 13:46:46 +01:00
parent 8c9cc80a85
commit e5d9f75d87
5 changed files with 35 additions and 3 deletions

View file

@ -69,6 +69,7 @@ task :html do
require 'filters/markdown_macros'
require 'filters/markdown_postmacros'
require 'filters/html_template'
require 'filters/fix_postmacros'
require 'filters/mathjax'
require 'filters/links'
@ -85,6 +86,7 @@ task :html do
@prefilters=[]
@prefilters<<=MarkdownMacros.new
@prefilters<<=MarkdownPostMacros.new
@prefilters<<=FixPostMacros.new
@postfilters=[]
html_template=HTMLTemplate.new
@ -201,6 +203,7 @@ task :compile do
require 'kramdown'
require 'filters/markdown_macros'
require 'filters/markdown_postmacros'
require 'filters/fix_postmacros_latex'
class KrambookCompile
require 'config.rb'
@ -247,6 +250,7 @@ task :compile do
@prefilters=[]
@prefilters<<=MarkdownMacros.new
@prefilters<<=MarkdownPostMacros.new
@prefilters<<=FixPostMacros.new
@postfilters=[]

View file

@ -2,9 +2,7 @@ MACRO(markdown) = `markdown` ENDMACRO
MACRO(kramdown) = [`kramdown`](http://kramdown.rubyforge.org) ENDMACRO
MACRO(krambook) = [`krambook`](http://krambook.espozito.com) ENDMACRO
MACRO(beginbox) = {::nomarkdown type="latex"}\medskip\fbox{\colorbox{boxcolor}{\begin{minipage}{.80\linewidth}% {:/nomarkdown} {::nomarkdown type="html"}<div class="encadre"> {:/nomarkdown} ENDMACRO
PYOSTMACRO(beginbox) = LATEX: \medskip\fbox{\colorbox{boxcolor}{\begin{minipage}{.80\linewidth}% HTML: <div class="encadre"> ENDMACRO
POSTMACRO(beginbox) = LATEX: \medskip\fbox{\colorbox{boxcolor}{\begin{minipage}{.80\linewidth}% HTML: <div class="encadre"> ENDMACRO
POSTMACRO(endbox) = LATEX: \end{minipage}}}\medskip HTML: </div> ENDMACRO

15
filters/fix_postmacros.rb Normal file
View file

@ -0,0 +1,15 @@
# Fix a problem with kramdown
#
# - {::nomarkdown}x{:/nomarkdown}
#
# will render badly
# therefore we will transform all
# of these form adding a return
class FixPostMacros
def run (content)
content.gsub(/(\s*[-+*]) (\{::nomarkdown(.|\n)*?\{:\/nomarkdown\})/m) do |m|
%{#{$1} <span>#{$2}</span>}
end
end
end

View file

@ -0,0 +1,15 @@
# Fix a problem with kramdown
#
# - {::nomarkdown}x{:/nomarkdown}
#
# will render badly
# therefore we will transform all
# of these form adding a return
class FixPostMacros
def run (content)
content.gsub(/(\s*[-+*]) (\{::nomarkdown)/m) do |m|
%{#{$1} {::comment/}#{$2}}
end
end
end

Binary file not shown.