Project

General

Profile

Defect #8674 ยป migrate_from_trac-pre_fix.patch

patch: fix pre handling in trac importer - Nicolas Kratz, 2011-06-23 22:48

View differences:

lib/tasks/migrate_from_trac_pre.rake 2011-06-23 22:44:18.000000000 +0200
# This will go into the next line.
shebang_line = false
# Reguar expression for start of code
pre_re = /\{\{\{/
pre_re = /(.*)\{\{\{(.*)/
# Code hightlighing...
shebang_re = /^\#\!([a-z]+)/
# Regular expression for end of code
pre_end_re = /\}\}\}/
pre_end_re = /(.*)\}\}\}(.*)/
# RE for both on the same line
pre_re_both = /(.*)\{\{\{(.*)\}\}\}(.*)/
# Go through the whole text..extract it line by line
text = text.gsub(/^(.*)$/) do |line|
m_pre = pre_re.match(line)
if m_pre
line = '<pre>'
m_pre_both = pre_re_both.match(line)
if m_pre_both
line = m_pre_both[1]+'@'+m_pre_both[2]+'@'+m_pre_both[3]
elsif m_pre
line = m_pre[1]+'<pre>'+m_pre[2]
else
m_sl = shebang_re.match(line)
if m_sl
......
end
m_pre_end = pre_end_re.match(line)
if m_pre_end
line = '</pre>'
line = m_pre_end[1]+'</pre>'+m_pre_end[2]
if shebang_line
line = '</code>' + line
end
    (1-1/1)