Skip to content

Commit 2f64ca7

Browse files
committed
fix(codemod): handle inline comments in heredoc note markers
YAML heredoc notes like "- | # note[1]" were not matching the regex. Updated to strip optional comments after the | marker. Result: 262/289 deep equivalent
1 parent 4d6973a commit 2f64ca7

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lib/interscript/isc/codemod.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,8 @@ def convert_notes_list_until_dedent(indent)
385385
# Blank line(s) — preserve one newline. Do NOT consume the
386386
# indent of the next item.
387387
@out << "\n"
388-
elsif @scanner.scan(/\n([ \t]+)-[ \t]*\|[ \t]*\n/)
389-
# `|` heredoc form
388+
elsif @scanner.scan(/\n([ \t]+)-[ \t]*\|(?:[ \t]*#[^\n]*)?\n/)
389+
# `|` heredoc form (with optional inline comment after |)
390390
note_indent = @scanner[1]
391391
@out << "\n#{note_indent}note \""
392392
read_heredoc_into_string(note_indent)
@@ -395,7 +395,7 @@ def convert_notes_list_until_dedent(indent)
395395
# Single-line item start (possibly with continuation lines).
396396
note_indent = @scanner[1]
397397
emit_note_with_continuation(note_indent)
398-
elsif @scanner.scan(/([ \t]+)-[ \t]*\|[ \t]*\n/)
398+
elsif @scanner.scan(/([ \t]+)-[ \t]*\|(?:[ \t]*#[^\n]*)?\n/)
399399
# First item right after `notes:` consumed; scanner at `<indent>- |\n`.
400400
emit_heredoc_note(@scanner[1])
401401
elsif @scanner.scan(/([ \t]+)-[ \t]+/)

0 commit comments

Comments
 (0)