Commit 89a5cc5b authored by jplang's avatar jplang

Wiki page collapse block image is not displayed in exported PDF (#30162).

Patch by Jun NAITOH.

git-svn-id: https://svn.redmine.org/redmine/trunk@18307 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 1648299c
......@@ -752,7 +752,7 @@ module ApplicationHelper
@current_section = 0 if options[:edit_section_links]
parse_sections(text, project, obj, attr, only_path, options)
text = parse_non_pre_blocks(text, obj, macros) do |text|
text = parse_non_pre_blocks(text, obj, macros, options) do |text|
[:parse_inline_attachments, :parse_hires_images, :parse_wiki_links, :parse_redmine_links].each do |method_name|
send method_name, text, project, obj, attr, only_path, options
end
......@@ -766,7 +766,7 @@ module ApplicationHelper
text.html_safe
end
def parse_non_pre_blocks(text, obj, macros)
def parse_non_pre_blocks(text, obj, macros, options={})
s = StringScanner.new(text)
tags = []
parsed = +''
......@@ -775,9 +775,9 @@ module ApplicationHelper
text, full_tag, closing, tag = s[1], s[2], s[3], s[4]
if tags.empty?
yield text
inject_macros(text, obj, macros) if macros.any?
inject_macros(text, obj, macros, true, options) if macros.any?
else
inject_macros(text, obj, macros, false) if macros.any?
inject_macros(text, obj, macros, false, options) if macros.any?
end
parsed << text
if tag
......@@ -1221,14 +1221,14 @@ module ApplicationHelper
end
# Executes and replaces macros in text
def inject_macros(text, obj, macros, execute=true)
def inject_macros(text, obj, macros, execute=true, options={})
text.gsub!(MACRO_SUB_RE) do
all, index = $1, $2.to_i
orig = macros.delete(index)
if execute && orig && orig =~ MACROS_RE
esc, all, macro, args, block = $2, $3, $4.downcase, $6.to_s, $7.try(:strip)
if esc.nil?
h(exec_macro(macro, obj, args, block) || all)
h(exec_macro(macro, obj, args, block, options) || all)
else
h(all)
end
......
......@@ -26,10 +26,16 @@ module Redmine
Redmine::WikiFormatting::Macros.available_macros.key?(name.to_sym)
end
def exec_macro(name, obj, args, text)
def exec_macro(name, obj, args, text, options={})
macro_options = Redmine::WikiFormatting::Macros.available_macros[name.to_sym]
return unless macro_options
if options[:inline_attachments] == false
Redmine::WikiFormatting::Macros.inline_attachments = false
else
Redmine::WikiFormatting::Macros.inline_attachments = true
end
method_name = "macro_#{name}"
unless macro_options[:parse_args] == false
args = args.split(',').map(&:strip)
......@@ -59,7 +65,9 @@ module Redmine
end
@@available_macros = {}
@@inline_attachments = true
mattr_accessor :available_macros
mattr_accessor :inline_attachments
class << self
# Plugins can use this method to define new macros:
......@@ -211,7 +219,7 @@ module Redmine
@included_wiki_pages ||= []
raise 'Circular inclusion detected' if @included_wiki_pages.include?(page.id)
@included_wiki_pages << page.id
out = textilizable(page.content, :text, :attachments => page.attachments, :headings => false)
out = textilizable(page.content, :text, :attachments => page.attachments, :headings => false, :inline_attachments => @@inline_attachments)
@included_wiki_pages.pop
out
end
......@@ -227,7 +235,7 @@ module Redmine
out = ''.html_safe
out << link_to_function(show_label, js, :id => "#{html_id}-show", :class => 'collapsible collapsed')
out << link_to_function(hide_label, js, :id => "#{html_id}-hide", :class => 'collapsible', :style => 'display:none;')
out << content_tag('div', textilizable(text, :object => obj, :headings => false), :id => html_id, :class => 'collapsed-text', :style => 'display:none;')
out << content_tag('div', textilizable(text, :object => obj, :headings => false, :inline_attachments => @@inline_attachments), :id => html_id, :class => 'collapsed-text', :style => 'display:none;')
out
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment