Project

General

Profile

Actions

Defect #20758

closed

Ampersand+keyword in code highlighting

Added by Sergey Utkin over 8 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Text formatting
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

I came to incorrect behavior of code highlighting in wiki-like pages if keyword begins with an ampersand.

I create a new scanner for coderay for language, which contains a directive for example "&AtServer".
And then parse the string with scan_tokens procedure:

def scan_tokens encoder, options

  state = :initial

  until eos?

    case state 

    when :initial

      if match = scan(%r! & [[:alpha:]]+ !mx)
        encoder.text_token match, :directive

      else
        encoder.text_token getch, :error
      end
    else
      raise_inspect 'Unknown state', encoder

    end

  end

  if state == :string
    encoder.end_group :string
  end

  encoder
end

And then the strange behavior starts. Testing my scanner gives correct result (&AtServer is hightlighted as :directive) but in Redmine wiki the keyword

<pre><code class="my_lang">
&AtServer
</code>


is not highlighted. However if I type ';'
<pre><code class="my_lang">
&AtServer;
</code>


the directive becomes highlighted.


Files

ampersand_error.tar.gz (668 Bytes) ampersand_error.tar.gz example with error (scanner, test suite, test example) Sergey Utkin, 2015-09-16 09:00
2015-09-16_10-16-55.png (1.72 KB) 2015-09-16_10-16-55.png Sergey Utkin, 2015-09-16 09:18

Related issues

Related to Redmine - Defect #29681: "x%x%" is rendered as "&" in Textile formatterNew

Actions
Related to Redmine - Feature #24681: Syntax highlighter: replace CodeRay with RougeClosedJean-Philippe Lang

Actions
Actions

Also available in: Atom PDF