summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/latexindent/LatexIndent/DoubleBackSlash.pm
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2017-02-24 22:07:42 +0000
committerKarl Berry <karl@freefriends.org>2017-02-24 22:07:42 +0000
commit990e60c6ed4437e5b632b7c9acf7f2237bbda871 (patch)
tree4dc9ea04f5fa46cc8ac59faa8dd62e4f8bc6835b /Master/texmf-dist/scripts/latexindent/LatexIndent/DoubleBackSlash.pm
parent2e70942b44a972908c3180dd7a3c68be51afc466 (diff)
latexindent (23feb17)
git-svn-id: svn://tug.org/texlive/trunk@43326 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts/latexindent/LatexIndent/DoubleBackSlash.pm')
-rw-r--r--Master/texmf-dist/scripts/latexindent/LatexIndent/DoubleBackSlash.pm45
1 files changed, 45 insertions, 0 deletions
diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/DoubleBackSlash.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/DoubleBackSlash.pm
new file mode 100644
index 00000000000..8b8be3e25ec
--- /dev/null
+++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/DoubleBackSlash.pm
@@ -0,0 +1,45 @@
+package LatexIndent::DoubleBackSlash;
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# See http://www.gnu.org/licenses/.
+#
+# Chris Hughes, 2017
+#
+# For all communication, please visit: https://github.com/cmhughes/latexindent.pl
+use strict;
+use warnings;
+use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active/;
+use LatexIndent::Tokens qw/%tokens/;
+use Exporter qw/import/;
+our @EXPORT_OK = qw/dodge_double_backslash un_dodge_double_backslash/;
+
+# some code can contain, e.g
+# cycle list={blue,mark=none\\},
+# see test-cases/texexchange/29293-christian-feuersanger.tex
+#
+# This is problematic, as the argument regexp won't count the right } because it has a
+# backslash immediately infront of it!
+sub dodge_double_backslash{
+ my $self = shift;
+
+ ${$self}{body} =~ s/(?:\\\\(\{|\}|\]))/$tokens{doubleBackSlash}$1/sg;
+ return;
+}
+
+# this routine replaces the token with the \\\\
+sub un_dodge_double_backslash{
+ my $self = shift;
+
+ ${$self}{body} =~ s/$tokens{doubleBackSlash}/\\\\/sg;
+ return;
+}
+
+1;