Make floated TOCs in wikis compatible with the Liquid engine
The floated tags (>toc and <toc) are invalid syntax because of the < and > characters. We transform them to toc_left and toc_right instead.
This commit is contained in:
parent
7458bca34b
commit
e2c57fd12d
|
@ -740,7 +740,7 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
TOC_RE = /<p>\{\{([<>]?)toc\}\}<\/p>/i unless const_defined?(:TOC_RE)
|
TOC_RE = /<p>\{%\s*toc(_right|_left)?\s*%\}<\/p>/i unless const_defined?(:TOC_RE)
|
||||||
|
|
||||||
# Renders the TOC with given headings
|
# Renders the TOC with given headings
|
||||||
def replace_toc(text, headings)
|
def replace_toc(text, headings)
|
||||||
|
@ -749,8 +749,8 @@ module ApplicationHelper
|
||||||
''
|
''
|
||||||
else
|
else
|
||||||
div_class = 'toc'
|
div_class = 'toc'
|
||||||
div_class << ' right' if $1 == '>'
|
div_class << ' right' if $1 == '_right'
|
||||||
div_class << ' left' if $1 == '<'
|
div_class << ' left' if $1 == '_left'
|
||||||
out = "<fieldset class='header_collapsible collapsible'><legend onclick='toggleFieldset(this);'></legend><div>"
|
out = "<fieldset class='header_collapsible collapsible'><legend onclick='toggleFieldset(this);'></legend><div>"
|
||||||
out << "<ul class=\"#{div_class}\"><li>"
|
out << "<ul class=\"#{div_class}\"><li>"
|
||||||
root = headings.map(&:first).min
|
root = headings.map(&:first).min
|
||||||
|
|
|
@ -63,5 +63,11 @@ module ChiliProject
|
||||||
Legacy.add('child_pages', :tag)
|
Legacy.add('child_pages', :tag)
|
||||||
Legacy.add('hello_world', :tag)
|
Legacy.add('hello_world', :tag)
|
||||||
Legacy.add('include', :tag)
|
Legacy.add('include', :tag)
|
||||||
|
|
||||||
|
# Transform the old textile TOC tags to syntax suported by liquid
|
||||||
|
Legacy.add('toc', :tag)
|
||||||
|
Legacy.add('>toc', :tag, "toc_right")
|
||||||
|
Legacy.add('<toc', :tag, "toc_left")
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,6 +28,15 @@ module ChiliProject::Liquid
|
||||||
register_tag('include', Include, :html => true)
|
register_tag('include', Include, :html => true)
|
||||||
register_tag('tag_list', TagList, :html => true)
|
register_tag('tag_list', TagList, :html => true)
|
||||||
register_tag('variable_list', VariableList, :html => true)
|
register_tag('variable_list', VariableList, :html => true)
|
||||||
|
|
||||||
|
# Output these tags again as they were typed
|
||||||
|
# These are to be handled later
|
||||||
|
register_tag('toc', Identity, :html => true)
|
||||||
|
register_tag('toc_left', Identity, :html => true)
|
||||||
|
register_tag('toc_right', Identity, :html => true)
|
||||||
|
|
||||||
|
# See ChiliProject::Liquid::Legacy for the definition of legacy tags,
|
||||||
|
# most of which are also defined here
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue