Defect #20758
closedAmpersand+keyword in code highlighting
0%
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
Related issues
Updated by Sergey Utkin about 9 years ago
- File ampersand_error.tar.gz ampersand_error.tar.gz added
attached an example, which looks like this
in Redmine
Updated by Sergey Utkin about 9 years ago
- File 2015-09-16_10-16-55.png 2015-09-16_10-16-55.png added
Updated by Sergey Utkin about 9 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
Updated by Go MAEDA about 6 years ago
- Related to Defect #29681: "x%x%" is rendered as "&" in Textile formatter added
Updated by Go MAEDA about 6 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.
Updated by Go MAEDA about 6 years ago
- Related to Feature #24681: Syntax highlighter: replace CodeRay with Rouge added