From eccdc9d08e094f7fdbcdbd6147be90dc0641690f Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Tue, 3 Aug 2021 16:47:30 -0700 Subject: [PATCH] Markdown.pl: improve readability of a few regexs Instead of using internal "\" escapes to match "/", just replace the surrounding "/"..."/" delimiters with "m{"..."}" instead. Also remove unnecessary surrounding brackets from single character character classes. These changes make it easier to understand the patterns. This is a cosmetic change only, no functional differences. Signed-off-by: Kyle J. McKay --- Markdown.pl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Markdown.pl b/Markdown.pl index 4fa727d..f466be1 100755 --- a/Markdown.pl +++ b/Markdown.pl @@ -3756,7 +3756,7 @@ sub _Sanitize { $tag =~ tr/\t\n\f\r //d; # remove whitespace return (lc($tag),2,$autocloseflag); } - if ($tag =~ /^<([^\s<\/>]+)\s+/gs) { + if ($tag =~ m{^<([^\s]+)\s+}gs) { my $tt = lc($1); my $autocloseflag = undef; $autocloseflag = 1, $tt="p" if $tt eq "\20"; @@ -3764,7 +3764,7 @@ sub _Sanitize { my $ok = $tagatt{$tt}; ref($ok) eq "HASH" or $ok = {}; my $atc = 0; - while ($tag =~ /\G\s*([^\s\042\047<\/>=]+)((?>=)|\s*)/gcs) { + while ($tag =~ m{\G\s*([^\s\042\047=]+)((?>=)|\s*)}gcs) { my ($a,$s) = ($1, $2); if ($s eq "" && substr($tag, pos($tag), 1) =~ /^[\042\047]/) { # pretend the "=" sign wasn't overlooked @@ -3782,7 +3782,7 @@ sub _Sanitize { ++$atc; next; } - if ($tag =~ /\G([\042\047])((?:(?!\1)(?![<>])(?![\/][>]).)*)/gcs) { + if ($tag =~ m{\G([\042\047])((?:(?!\1)(?![<>])(?!/>).)*)}gcs) { # what to do what to do what to do # trim trailing \s+ and magically add the missing quote my ($q, $v) = ($1, $2);