diff options
author | Norbert Preining <norbert@preining.info> | 2021-11-13 03:01:22 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2021-11-13 03:01:22 +0000 |
commit | a4ccc84b5ea15905a51f24c56989a29267cfd949 (patch) | |
tree | dc685ede693ac3961a116e6ff8ec6ec2969afea2 /support/latexindent/LatexIndent/GetYamlSettings.pm | |
parent | 3a8398961f2de022af86ec0fcf33eb093b8dce41 (diff) |
CTAN sync 202111130301
Diffstat (limited to 'support/latexindent/LatexIndent/GetYamlSettings.pm')
-rw-r--r-- | support/latexindent/LatexIndent/GetYamlSettings.pm | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/support/latexindent/LatexIndent/GetYamlSettings.pm b/support/latexindent/LatexIndent/GetYamlSettings.pm index 168c5d97bb..41a24db387 100644 --- a/support/latexindent/LatexIndent/GetYamlSettings.pm +++ b/support/latexindent/LatexIndent/GetYamlSettings.pm @@ -510,10 +510,7 @@ sub yaml_read_settings{ # split at : (@keysValues) = split(/(?<!(?:\\|\[)):(?!\])/,$splitAtQuote[0]); - # tabs need special attention - if ($splitAtQuote[1] =~ m/\\t/){ - $splitAtQuote[1] = '"'.$splitAtQuote[1].'"'; - } + $splitAtQuote[1] = '"'.$splitAtQuote[1].'"'; push(@keysValues,$splitAtQuote[1]); } else { @@ -528,15 +525,29 @@ sub yaml_read_settings{ # semi-colon, so we replace it with just a semi-colon $value =~ s/\\:/:/; - # horizontal space needs special treatment - if($value =~ m/^(?:"|')(\h*)(?:"|')$/){ - # pure horizontal space + # strings need special treatment + if($value =~ m/^"(.*)"$/){ + # double-quoted string + # translate: '\t', '\n', '\"', '\\' + my $raw_value = $value; + $value = $1; + # only translate string starts with an odd number of escape characters '\' + $value =~ s/(?<!\\)((\\\\)*)\\t/$1\t/g; + $value =~ s/(?<!\\)((\\\\)*)\\n/$1\n/g; + $value =~ s/(?<!\\)((\\\\)*)\\"/$1"/g; + # translate '\\' in double-quoted strings, but not in single-quoted strings + $value =~ s/\\\\/\\/g; + $logger->info("double-quoted string found in -y switch: $raw_value, substitute to $value"); + } elsif($value =~ m/^'(.*)'$/){ + # single-quoted string + my $raw_value = $value; $value = $1; - } elsif($value =~ m/^(?:"|')((?:\\t)*)(?:"|')$/){ - # tabs - $value =~ s/^(?:"|')//; - $value =~ s/(?:"|')$//; - $value =~ s/\\t/\t/g; + # special treatment for tabs and newlines + # translate: '\t', '\n' + # only translate string starts with an odd number of escape characters '\' + $value =~ s/(?<!\\)((\\\\)*)\\t/$1\t/g; + $value =~ s/(?<!\\)((\\\\)*)\\n/$1\n/g; + $logger->info("single-quoted string found in -y switch: $raw_value, substitute to $value"); } if(scalar(@keysValues) == 2){ |