sainsburys-tech / k2zpl

Kotlin DSL for generating ZPL (Zebra Programming Language)
MIT License
2 stars 0 forks source link

Support conversion of `\n` to ZPL newline characters `\\&` #15

Open itsmattking opened 3 weeks ago

itsmattking commented 3 weeks ago

Create an extension function of String perhaps?

jbduncan commented 3 weeks ago

I can see at least two options:

  1. Automatically translate \n into \\& behind the scenes, as part of the build() function perhaps.
    • Pro: This would let us use Kotlin multiline blocks and trimIndent().
    • Cons:
      • It's less explicit what's happening.
      • If \n means something useful to the printer, we'd need a workaround to support it.
  2. Make a function like ZplBuilder.appendLine(), à la https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/append-line.html#appendline.
    • Pro: It's explicit what's happening.
    • Con: We wouldn't be able to use Kotlin multiline blocks.