Project

General

Profile

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

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

    
24
puts test