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
320 320
        # This will go into the next line.
321 321
        shebang_line = false
322 322
        # Reguar expression for start of code
323
        pre_re = /\{\{\{/
323
        pre_re = /(.*)\{\{\{(.*)/
324 324
        # Code hightlighing...
325 325
        shebang_re = /^\#\!([a-z]+)/
326 326
        # Regular expression for end of code
327
        pre_end_re = /\}\}\}/
327
        pre_end_re = /(.*)\}\}\}(.*)/
328
        # RE for both on the same line
329
        pre_re_both = /(.*)\{\{\{(.*)\}\}\}(.*)/
328 330

  
329 331
        # Go through the whole text..extract it line by line
330 332
        text = text.gsub(/^(.*)$/) do |line|
331 333
          m_pre = pre_re.match(line)
332
          if m_pre
333
            line = '<pre>'
334
          m_pre_both = pre_re_both.match(line)
335
          if m_pre_both
336
            line = m_pre_both[1]+'@'+m_pre_both[2]+'@'+m_pre_both[3]
337
          elsif m_pre
338
            line = m_pre[1]+'<pre>'+m_pre[2]
334 339
          else
335 340
            m_sl = shebang_re.match(line)
336 341
            if m_sl
......
339 344
            end
340 345
            m_pre_end = pre_end_re.match(line)
341 346
            if m_pre_end
342
              line = '</pre>'
347
              line = m_pre_end[1]+'</pre>'+m_pre_end[2]
343 348
              if shebang_line
344 349
                line = '</code>' + line
345 350
              end
    (1-1/1)