From f5b6163cd35fa2b22b3d305315052cfa37ed175f Mon Sep 17 00:00:00 2001 From: Sharon Rosner Date: Mon, 19 Feb 2024 10:23:34 +0100 Subject: [PATCH] Fix compiler on Ruby 3.4 --- lib/papercraft/compiler.rb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/papercraft/compiler.rb b/lib/papercraft/compiler.rb index 0947098..1246267 100644 --- a/lib/papercraft/compiler.rb +++ b/lib/papercraft/compiler.rb @@ -180,7 +180,7 @@ def fcall_inner_text_from_args(args) case first.type when :STR first.children.first - when :LIT + when :LIT, :SYM first.children.first.to_s when :HASH nil @@ -246,7 +246,7 @@ def emit_tag_attribute_key(key) case key.type when :STR emit_literal(key.children.first) - when :LIT + when :LIT, :SYM emit_literal(key.children.first.to_s) when :NIL emit_literal('nil') @@ -258,9 +258,11 @@ def emit_tag_attribute_key(key) def emit_tag_attribute_value(value, key) case value.type when :STR - encoding = (key.type == :LIT) && (key.children.first == :href) ? :uri : :html + type = key.type + is_href_attr = (type == :LIT || type == :SYM) && (key.children.first == :href) + encoding = is_href_attr ? :uri : :html emit_text(value.children.first, encoding: encoding) - when :LIT + when :LIT, :SYM emit_text(value.children.first.to_s) else parse(value) @@ -313,6 +315,11 @@ def parse_lit(node) emit_literal(value.inspect) end + def parse_sym(node) + value = node.children.first + emit_literal(value.inspect) + end + def parse_true(node) emit_expression { emit_literal('true') } end