Bug #4242 » test-file.rb

Load this file in emacs with ruby-mode active to see how the syntax highlighting breaks - amasal (Nguma Abojo), 01/06/2011 09:58 PM

# -*- coding: utf-8 -*-
def test
replacements =
#broken highlighting starts here - REs are interpreted as non-RE Ruby code and the string highlighting breaks, too
[/<p>.*1.+CPUID clears the high 32 bits of.+<\/p>\n/, ''],
[' </p>', '</p>'],
[/<sect>.*<\/sect>/m, '', 'CPUID'],
[/<p>NOTES:<\/p>.+/m, '', ["FADD/FADDP/FIADD", "FMUL/FMULP/FIMUL", "FPATAN"]],
[/<p>NOTES:<\/p>.+?\n<\/p>\n/m, '', ["FDIV/FDIVP/FIDIV", "FDIVR/FDIVRP/FIDIVR", "FPREM", "FPREM1"]],
[/<p>NOTES:<\/p>.+?<p>This instruction/m, '<p>This instruction', ["FSUBR/FSUBRP/FISUBR"]],
[/<p>IA-32 Architecture Compatibility<\/p>.+/m, ''],
[/<p>FXCH.+?<\/p>/m, lambda { |x| x[0].gsub('p>', 'pre>').gsub("\n<", '<') }],
["<p>Figure 3-3. ADDSUBPD—Packed Double-FP Add/Subtract</p>\n", ''],
[" See Figure 3-4.</p>\n<p>Figure 3-4. ADDSUBPS—Packed Single-FP Add/Subtract</p>\n<p>3-50 Vol. 2A ADDSUBPS—Packed Single-FP Add/Subtract</p>", '</p>'],
[/<p>Table \d+-\d+. (.+?)<\/p>\n<table>/, lambda { |x| "<table>\n<caption>#{x[1]}</caption>" }],
["\n\n", "\n"],
#everything from this point on is highlighted as a string
x = 2
'This is a perfectly valid Ruby program, yet ruby-mode fails to highlight the RE parts properly.'

puts test