rouge-ruby / rouge

A pure Ruby code highlighter that is compatible with Pygments
https://rouge.jneen.net/
Other
3.32k stars 731 forks source link

lexer: TOML: Support more integer and floating formats #1831

Closed ToruNiina closed 2 years ago

ToruNiina commented 2 years ago

Name of the lexer TOML

Code sample

# float variants
float_space1 = 3.141_592_653
float_space2 = 123_456.789_012e1_000
just_inf = inf
pos_inf  = +inf
neg_inf  = -inf
just_nan = nan
pos_nan  = +nan
neg_nan  = -nan

# integer variants
dec         = 123456
dec_spacing = 123_456
hex         = 0xdeadBEEF
hex_spacing = 0xdead_BEEF
oct         = 0o755
oct_spacing = 0o755_777
bin         = 0b1100
bin_spacing = 0b0101_1100

# should be an error
float_no_int_part  = .1
float_no_frac_part = 1.

http://rouge.jneen.net/v3.29.0/toml/IyBmbG9hdCB2YXJpYW50cwpmbG9hdF9zcGFjZTEgPSAzLjE0MV81OTJfNjUzCmZsb2F0X3NwYWNlMiA9IDEyM180NTYuNzg5XzAxMmUxXzAwMApqdXN0X2luZiA9IGluZgpwb3NfaW5mICA9ICtpbmYKbmVnX2luZiAgPSAtaW5mCmp1c3RfbmFuID0gbmFuCnBvc19uYW4gID0gK25hbgpuZWdfbmFuICA9IC1uYW4KCiMgaW50ZWdlciB2YXJpYW50cwpkZWMgICAgICAgICA9IDEyMzQ1NgpkZWNfc3BhY2luZyA9IDEyM180NTYKaGV4ICAgICAgICAgPSAweGRlYWRCRUVGCmhleF9zcGFjaW5nID0gMHhkZWFkX0JFRUYKb2N0ICAgICAgICAgPSAwbzc1NQpvY3Rfc3BhY2luZyA9IDBvNzU1Xzc3NwpiaW4gICAgICAgICA9IDBiMTEwMApiaW5fc3BhY2luZyA9IDBiMDEwMV8xMTAwCgojIHNob3VsZCBiZSBhbiBlcnJvcgpmbG9hdF9ub19pbnRfcGFydCAgPSAuMQpmbG9hdF9ub19mcmFjX3BhcnQgPSAxLg

Additional context

Hi, Thank you for developing and maintaining this library! I'm using an application that depends on this library almost everyday.

Today I found that some TOML features listed below are currently not supported.

TOML v1.0.0 supports the following features:

I also found the current TOML lexer allows floating point numbers that lacks integer part xor fractional part. But those are actually invalid. In TOML, floating point value should have both integer and fractional parts.

I'm now writing a pull request that supports the features and fix the bug listed above. Thanks for your time!