From 977562382626dba8ec7e500f4d7cd28d67ac6d1b Mon Sep 17 00:00:00 2001 From: Domizio Demichelis Date: Fri, 8 Mar 2024 16:40:18 +0700 Subject: [PATCH] Fix incomplete same-tag nesting and style rules in pagy_style.ru Formatter --- apps/pagy_styles.ru | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/apps/pagy_styles.ru b/apps/pagy_styles.ru index a768a2532..8668df05a 100644 --- a/apps/pagy_styles.ru +++ b/apps/pagy_styles.ru @@ -154,6 +154,11 @@ class Formatter push.(tag) elsif (match = input.match(PAIRED)) tag_start, name, block, tag_end, rest = match.captures + ## Handle incomplete same-tag nesting + while block.scan(/<#{name}.*?>/).size > block.scan(tag_end).size + more, rest = rest.split(tag_end, 2) + block << tag_end << more + end if name.eql?('a') tag_start.gsub!(/[\s]+/, ' ') tag_start.gsub!(/[\s]>/, '>') @@ -213,58 +218,60 @@ __END__ <%= erb :"#{style}_head" if defined?(style) %>