From 79a771d72427a514bcbff674dfd42af87d0e3f0f Mon Sep 17 00:00:00 2001 From: James Meng Date: Wed, 4 Jun 2025 19:30:47 -0700 Subject: [PATCH] Add test for doc tag capturing token before enddoc --- test/unit/tags/doc_tag_unit_test.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/unit/tags/doc_tag_unit_test.rb b/test/unit/tags/doc_tag_unit_test.rb index 1d5db06d..cf17b1d0 100644 --- a/test/unit/tags/doc_tag_unit_test.rb +++ b/test/unit/tags/doc_tag_unit_test.rb @@ -131,6 +131,20 @@ class DocTagUnitTest < Minitest::Test assert_template_result('', template) end + def test_doc_tag_captures_token_before_enddoc + template_source = "{% doc %}{{ incomplete{% enddoc %}" + + doc_tag = nil + ParseTreeVisitor + .for(Template.parse(template_source).root) + .add_callback_for(Liquid::Doc) do |tag| + doc_tag = tag + end + .visit + + assert_equal("{{ incomplete", doc_tag.body) + end + def test_doc_tag_preserves_error_line_numbers template = Liquid::Template.parse(<<~LIQUID.chomp, line_numbers: true) {% doc %}