ktoml icon indicating copy to clipboard operation
ktoml copied to clipboard

Multiline literal strings

Open orchestr7 opened this issue 4 years ago • 3 comments
trafficstars

Multi-line literal strings are surrounded by three single quotes on each side and allow newlines. Like literal strings, there is no escaping whatsoever. A newline immediately following the opening delimiter will be trimmed. All other content between the delimiters is interpreted as-is without modification.

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

orchestr7 avatar Jun 08 '21 15:06 orchestr7

@akuleshov7 can I try to take a stab at this ? Don't know if you've started looking at it yet (and don't know if I can do it quickly) but I'd like to try

bishiboosh avatar Mar 25 '22 12:03 bishiboosh

(I have a WIP right now, as soon as work clears up a little bit I'll try to go back to it)

bishiboosh avatar May 11 '22 07:05 bishiboosh

Got it, removed myself

orchestr7 avatar May 11 '22 12:05 orchestr7

Hi there! I see that there are no updates. I almost completed this issue, MR will be soon.

BOOMeranGG avatar Jan 02 '23 12:01 BOOMeranGG

Hi there! I see that there are no updates. I almost completed this issue, MR will be soon.

the only thing I have is this test :D

class MultilineStrings {
    @Test
    fun positiveSimpleParsing() {
        val string = """
            [[fruits]]
            a = '''
                b = 4
            '''
        """.trimIndent()

        val parsedToml = tomlParser.parseString(string)
        parsedToml.prettyPrint()
        assertEquals(
            """
                | - TomlFile (rootNode)
        """.trimMargin(),
            parsedToml.prettyStr()
        )
    }
}

Could you please also add such parsing test and not only decoding/encoding test

orchestr7 avatar Jan 02 '23 14:01 orchestr7

@BOOMeranGG may be take it into the nearest release? I plan it in 1-2 weeks

orchestr7 avatar Jan 02 '23 14:01 orchestr7

Ok. One question: why was #8 closed? Do we need to support multiline literal and basic strings?

BOOMeranGG avatar Jan 02 '23 14:01 BOOMeranGG