Skip to content

Commit c3b7cac

Browse files
committed
feat(isc): handle multi-line quoted description values
1 parent ca00e1b commit c3b7cac

1 file changed

Lines changed: 22 additions & 5 deletions

File tree

exe/codemod-imp-to-isc

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,31 @@ module Interscript
211211
@out << "\n#{indent}description {"
212212
convert_indented_block_until_dedent(indent)
213213
@out << "\n#{indent}}"
214+
elsif @scanner.scan(/(?:\A|\n)([ \t]+)description[ \t]*:[ \t]*\n[ \t]+"/)
215+
# `description:` with multi-line QUOTED value: starts with `"` on
216+
# next line, ends with `"` somewhere later. Capture as brace block.
217+
indent = @scanner[1]
218+
@out << "\n#{indent}description { "
219+
# We've already consumed the opening `"`. Read until closing `"`.
220+
until @scanner.eos?
221+
if @scanner.scan(/[^"\n]+/)
222+
@out << @scanner.matched
223+
elsif @scanner.scan(/"/)
224+
@out << @scanner.matched
225+
break
226+
elsif @scanner.scan(/\n[ \t]+/)
227+
@out << " "
228+
elsif @scanner.scan(/\n/)
229+
@out << " "
230+
else
231+
break
232+
end
233+
end
234+
@out << " }"
214235
elsif @scanner.scan(/(?:\A|\n)([ \t]+)description[ \t]*:[ \t]*\n[ \t]+/)
215-
# `description:` with value on subsequent indented line(s).
216-
# Capture as brace block with raw text. Continues until dedent
217-
# back to indent level or close brace.
236+
# `description:` with unquoted value on subsequent indented line(s).
218237
indent = @scanner[1]
219238
@out << "\n#{indent}description { "
220-
# Read until dedent or close brace
221239
until @scanner.eos?
222240
if @scanner.check(/\n(?:[ \t]*\n)*([ \t]{0,#{indent.length}}\S)/) ||
223241
@scanner.check(/\n(?:[ \t]*\n)*[ \t]{0,#{indent.length}}\}/)
@@ -228,7 +246,6 @@ module Interscript
228246
elsif @scanner.scan(/\n[ \t]+/)
229247
@out << " "
230248
elsif @scanner.scan(/\n[ \t]*\n/)
231-
# Blank line — preserve as space
232249
@out << " "
233250
elsif @scanner.scan(/\n/)
234251
@out << " "

0 commit comments

Comments
 (0)