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 #1

Updated by Sergey Utkin over 8 years ago

attached an example, which looks like this

in Redmine

Actions #3

Updated by Sergey Utkin over 8 years ago

Environment:
  Redmine version                3.1.0.stable
  Ruby version                   2.0.0-p645 (2015-04-13) [i686-linux]
  Rails version                  4.2.3
  Environment                    production
  Database adapter               Mysql2
SCM:
  Subversion                     1.8.13
  Git                            1.9.5
  Filesystem                     
Redmine plugins:
  a_common_libs                  1.1.5
  computed_custom_field          0.0.2
  custom_menu                    1.5.0
  extra_queries                  2.0.0
  global_roles                   2.0.0
  redmine_checklists             3.1.1
  redmine_codebutton             0.1.0
  redmine_dashboard              2.7.0
  redmine_dmsf                   1.5.3
  redmine_email_fetcher          0.3.1
  redmine_my_page                0.1.6
  redmine_tweaks                 0.5.5
  rm_user_mentions               1.0.0
  single_auth                    2.0.0
  under_construction             2.0.0
  unread_issues                  1.5.0
  usability                      1.3.0
Actions #4

Updated by Go MAEDA over 5 years ago

  • Related to Defect #29681: "x%x%" is rendered as "&" in Textile formatter added
Actions #5

Updated by Go MAEDA over 5 years ago

  • Category changed from Third-party libraries to Text formatting
  • Status changed from New to Closed
  • Resolution set to Fixed

The bug that "&" is changed to "x%x%" in the text passed to the syntax highlighter has been fixed in r17532. Please see source:trunk/lib/redmine/wiki_formatting/textile/formatter.rb@17532#L128

Please note that Redmine 4.0 no longer uses CodeRay. See #24681 for details.

Actions #6

Updated by Go MAEDA over 5 years ago

  • Related to Feature #24681: Syntax highlighter: replace CodeRay with Rouge added
Actions

Also available in: Atom PDF