lib/i18n/tasks/scanners/erb_ast_processor.rb in i18n-tasks-1.0.4 vs lib/i18n/tasks/scanners/erb_ast_processor.rb in i18n-tasks-1.0.5
- old
+ new
@@ -68,12 +68,19 @@
node.children[0]&.type == :indicator && node.children[0].children[0] == "#" &&
node.children[1].nil? &&
node.children[2]&.type == :code &&
node.children[3].nil?
code_node = node.children[2]
+
+ # Prepend # to each line to make it a valid Ruby comment.
+ code = code_node.children[0].split("\n").map do |line|
+ next line if line =~ /^\s*#/
+ "##{line}"
+ end.join("\n")
+
node.updated(
nil,
- [nil, nil, code_node.updated(nil, ["##{code_node.children[0]}"]), nil]
+ [nil, nil, code_node.updated(nil, [code]), nil]
)
end
def node?(node)
node.is_a?(::Parser::AST::Node)