tamasfe / taplo

A TOML toolkit written in Rust
https://taplo.tamasfe.dev
MIT License
1.32k stars 110 forks source link

The wrong format from multi-line basic string #483

Open leolcao opened 10 months ago

leolcao commented 10 months ago

From the https://toml.io/en/v1.0.0#string, I found the sample str7 will make the color style of rest part in toml file become to invalid style.

str4 = """Here are two quotation marks: "". Simple enough."""
# str5 = """Here are three quotation marks: """."""  # INVALID
str5 = """Here are three quotation marks: ""\"."""
str6 = """Here are fifteen quotation marks: ""\"""\"""\"""\"""\"."""

# "This," she said, "is just a pointless statement."
str7 = """"This," she said, "is just a pointless statement.""""

# What you see is what you get.
winpath  = 'C:\Users\nodejs\templates'
winpath2 = '\\ServerX\admin$\system32\'
quoted   = 'Tom "Dubs" Preston-Werner'
regex    = '<\i\c*\s*>'

regex2 = '''I [dw]on't need \d{2} apples'''
lines  = '''
The first newline is
trimmed in raw strings.
   All other whitespace
   is preserved.
'''

result:

image

But, the syntax is right, and I still can use 'copy as json' to get right result.

{
  "str4": "Here are two quotation marks: \"\". Simple enough.",
  "str5": "Here are three quotation marks: \"\"\".",
  "str6": "Here are fifteen quotation marks: \"\"\"\"\"\"\"\"\"\"\"\"\"\"\".",
  "str7": "\"This,\" she said, \"is just a pointless statement.\"",
  "winpath": "C:\\Users\\nodejs\\templates",
  "winpath2": "\\\\ServerX\\admin$\\system32\\",
  "quoted": "Tom \"Dubs\" Preston-Werner",
  "regex": "<\\i\\c*\\s*>",
  "regex2": "I [dw]on't need \\d{2} apples",
  "lines": "The first newline is\ntrimmed in raw strings.\n   All other whitespace\n   is preserved.\n"
}

vscode version: 1.82.2 extension version: v0.19.2

ia0 commented 10 months ago

I don't think Taplo is responsible for syntax highlighting. At least that's not how it works in Emacs. Did you try not using Taplo and see if you have the same issue?

tamasfe commented 10 months ago

I don't think Taplo is responsible for syntax highlighting.

We have to provide a grammar for vscode as it has no built-in syntax highlighting for toml.