Skip to content

Commit 5b060cd

Browse files
committed
feat(isc): handle notes: "" empty quoted, multi-line list values
1 parent af1de61 commit 5b060cd

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

exe/codemod-imp-to-isc

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,10 @@ module Interscript
257257
# `notes: []` — empty notes list
258258
indent = @scanner[1]
259259
@out << "\n#{indent}notes { }"
260+
elsif @scanner.scan(/(?:\A|\n)([ \t]+)notes[ \t]*:[ \t]*""/)
261+
# `notes: ""` — empty quoted notes value
262+
indent = @scanner[1]
263+
@out << "\n#{indent}notes { }"
260264
elsif @scanner.scan(/(?:\A|\n)([ \t]+)notes[ \t]*:[ \t]*"[ \t]*\n/)
261265
# `notes: "X"` — single quoted-string note value
262266
indent = @scanner[1]
@@ -279,7 +283,21 @@ module Interscript
279283
@out << "\n#{indent}notes {"
280284
convert_notes_list_until_dedent(indent)
281285
@out << "\n#{indent}}"
282-
elsif @scanner.scan(/(?:\A|\n)([ \t]+)([A-Za-z_][\w]*)[ \t]*:[ \t]*/)
286+
elsif @scanner.scan(/(?:\A|\n)([ \t]+)([A-Za-z_][\w]*)[ \t]*:[ \t]*\n([ \t]+)-[ \t]*/)
287+
# Multi-line list value: `field:\n - item1\n - item2`
288+
indent = @scanner[1]
289+
field = @scanner[2]
290+
first_item_indent = @scanner[3]
291+
@out << "\n#{indent}#{field} "
292+
# Read the first item value
293+
text = @scanner.scan(/[^\n]+/).to_s
294+
@out << text
295+
# Read subsequent `- item` lines at the same or deeper indent
296+
while @scanner.check(/\n[ \t]{#{first_item_indent.length},}-[ \t]/)
297+
@scanner.scan(/\n[ \t]+-[ \t]+/)
298+
text = @scanner.scan(/[^\n]+/).to_s
299+
@out << " " + text
300+
end
283301
# key: value -> key value, only when the key is at the start of a
284302
# (indented) line. Use [ \t] instead of \s to avoid eating newlines
285303
# (which would merge `key:\n next:` into `key next:`).

0 commit comments

Comments
 (0)