We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
class Foo; end
class ;Foo end
Rubyリファレンスマニュアルのサンプルコードで、class Foo; end が class ;Foo end と表示されています。
具体例: Module#private_constant
ソースを確認したところ、 class Foo; end (相当)で書かれていました。
irb 上の次のコードで再現することが確認できました。
irb> require 'bitclust' irb> BitClust::SyntaxHighlighter.new('class A; end').highlight => "<span class=\"k\">class</span> ;<span class=\"nn\"></span><span class=\"o\"></span><span class=\"nc\">A</span> <span class=\"k\">end</span>"
この状態は on_const と ; が on_default で処理されることが関係しているようです。
on_const
;
on_default
bitclust/lib/bitclust/syntax_highlighter.rb
Lines 178 to 191 in fd203d1
クラス名(and/or モジュール名; 以下、同様)をトリガーとする on_const ではトークンが data ではなく @name_buffer に保存されます。 ですが、次の ; をトリガーとする on_default ではトークンが data に保存されます。 この時点で data にはクラス名の前に ; が保存された状態となっています。
data
@name_buffer
基本的に ; は改行と同様に扱えば良いと考えています。 つまり on_nl と同等の on_semicolon を設ければ良さそうです。
on_nl
on_semicolon
Lines 256 to 276 in fd203d1
フォーク リポジトリにて上述の対処案で修正されることを確認しています:
b853df0...ysjj:rurema-bitclust:da05f15
The text was updated successfully, but these errors were encountered:
No branches or pull requests
概要
Rubyリファレンスマニュアルのサンプルコードで、
class Foo; end
がclass ;Foo end
と表示されています。具体例: Module#private_constant
ソースを確認したところ、
class Foo; end
(相当)で書かれていました。再現確認
irb 上の次のコードで再現することが確認できました。
原因分析
この状態は
on_const
と;
がon_default
で処理されることが関係しているようです。bitclust/lib/bitclust/syntax_highlighter.rb
Lines 178 to 191 in fd203d1
クラス名(and/or モジュール名; 以下、同様)をトリガーとする
on_const
ではトークンがdata
ではなく@name_buffer
に保存されます。ですが、次の
;
をトリガーとするon_default
ではトークンがdata
に保存されます。この時点で
data
にはクラス名の前に;
が保存された状態となっています。対処案
基本的に
;
は改行と同様に扱えば良いと考えています。つまり
on_nl
と同等のon_semicolon
を設ければ良さそうです。bitclust/lib/bitclust/syntax_highlighter.rb
Lines 256 to 276 in fd203d1
対処コード
フォーク リポジトリにて上述の対処案で修正されることを確認しています:
b853df0...ysjj:rurema-bitclust:da05f15
The text was updated successfully, but these errors were encountered: