|
|
@ -57,6 +57,8 @@ require 'open3' |
|
|
|
module OpenProject::TextFormatting::Formatters |
|
|
|
module OpenProject::TextFormatting::Formatters |
|
|
|
module Markdown |
|
|
|
module Markdown |
|
|
|
class TextileConverter |
|
|
|
class TextileConverter |
|
|
|
|
|
|
|
include ActionView::Helpers::TagHelper |
|
|
|
|
|
|
|
|
|
|
|
TAG_CODE = 'pandoc-unescaped-single-backtick'.freeze |
|
|
|
TAG_CODE = 'pandoc-unescaped-single-backtick'.freeze |
|
|
|
TAG_FENCED_CODE_BLOCK = 'force-pandoc-to-ouput-fenced-code-block'.freeze |
|
|
|
TAG_FENCED_CODE_BLOCK = 'force-pandoc-to-ouput-fenced-code-block'.freeze |
|
|
|
DOCUMENT_BOUNDARY = "TextileConverterDocumentBoundary09339cab-f4f4-4739-85b0-d02ba1f342e6".freeze |
|
|
|
DOCUMENT_BOUNDARY = "TextileConverterDocumentBoundary09339cab-f4f4-4739-85b0-d02ba1f342e6".freeze |
|
|
@ -93,7 +95,7 @@ module OpenProject::TextFormatting::Formatters |
|
|
|
print '.' |
|
|
|
print '.' |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
puts 'done' |
|
|
|
puts ' done' |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
## |
|
|
|
## |
|
|
@ -112,7 +114,7 @@ module OpenProject::TextFormatting::Formatters |
|
|
|
|
|
|
|
|
|
|
|
ActiveRecord::Base.connection.execute(batch_update_statement(klass, attributes, new_values)) |
|
|
|
ActiveRecord::Base.connection.execute(batch_update_statement(klass, attributes, new_values)) |
|
|
|
end |
|
|
|
end |
|
|
|
puts 'done' |
|
|
|
puts ' done' |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
@ -126,7 +128,7 @@ module OpenProject::TextFormatting::Formatters |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
puts 'done' |
|
|
|
puts ' done' |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
# Iterate in batches to avoid plucking too much |
|
|
|
# Iterate in batches to avoid plucking too much |
|
|
@ -322,9 +324,44 @@ module OpenProject::TextFormatting::Formatters |
|
|
|
$1.gsub(/([\n])([^\n]*)/, '\1> \2') |
|
|
|
$1.gsub(/([\n])([^\n]*)/, '\1> \2') |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
convert_macro_syntax(markdown) |
|
|
|
|
|
|
|
|
|
|
|
markdown |
|
|
|
markdown |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Convert old {{macroname(args)}} syntax to <macro class="macroname" data-arguments=""> |
|
|
|
|
|
|
|
def convert_macro_syntax(markdown) |
|
|
|
|
|
|
|
old_macro_regex = / |
|
|
|
|
|
|
|
(!)? # escaping |
|
|
|
|
|
|
|
( |
|
|
|
|
|
|
|
\{\{ # opening tag |
|
|
|
|
|
|
|
([\w\\_]+) # macro name |
|
|
|
|
|
|
|
(\(([^\}]*)\))? # optional arguments |
|
|
|
|
|
|
|
\}\} # closing tag |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
/x |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
markdown.gsub!(old_macro_regex) do |
|
|
|
|
|
|
|
esc = $1 |
|
|
|
|
|
|
|
all = $2 |
|
|
|
|
|
|
|
macro = $3.gsub('\_', '_') |
|
|
|
|
|
|
|
args = $5 || '' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Escaped macros should probably render as before? |
|
|
|
|
|
|
|
return all if esc.present? |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case macro |
|
|
|
|
|
|
|
when 'timeline' |
|
|
|
|
|
|
|
content_tag :macro, I18n.t('macros.legacy_warning.timeline'), class: 'legacy-macro -macro-unavailable' |
|
|
|
|
|
|
|
when 'hello_world' |
|
|
|
|
|
|
|
'' |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
data = args.present? ? { arguments: args } : {} |
|
|
|
|
|
|
|
content_tag :macro, '', class: macro, data: data |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
# OpenProject support @ inside inline code marked with @ (such as "@git@github.com@"), but not pandoc. |
|
|
|
# OpenProject support @ inside inline code marked with @ (such as "@git@github.com@"), but not pandoc. |
|
|
|
# So we inject a placeholder that will be replaced later on with a real backtick. |
|
|
|
# So we inject a placeholder that will be replaced later on with a real backtick. |
|
|
|
def placeholder_for_inline_code_at(textile) |
|
|
|
def placeholder_for_inline_code_at(textile) |
|
|
|