Skip to content

Commit 8bada43

Browse files
committed
fix(codemod): handle comments after blank lines in metadata
Comments following blank lines (# TODO: ...) were not being preserved. Added handler for indented comments at start of scan position. Result: 276/289 deep equivalent
1 parent fdce0d2 commit 8bada43

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

lib/interscript/isc/codemod.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,12 @@ def convert_metadata_block
215215
elsif @scanner.scan(/\n[ \t]*\n/)
216216
# Blank line — preserve one newline
217217
@out << "\n"
218+
elsif @scanner.scan(/([ \t]+)#[^\n]*/)
219+
# Comment line (after newline was consumed by blank-line handler)
220+
@out << "\n#{@scanner[1]}#"
221+
elsif @scanner.scan(/#[^\n]*\n/)
222+
# Comment at start of line
223+
@out << "#\n"
218224
elsif @scanner.scan(/(?:\A|\n)([ \t]+)description[ \t]*:[ \t]*\|[ \t]*\n/)
219225
# Heredoc form: `description: |` followed by indented body.
220226
indent = @scanner[1]

0 commit comments

Comments
 (0)