1 # Copyright 2002-2007 Interchange Development Group and others
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version. See the LICENSE file for details.
8 # $Id: jsq.coretag,v 1.8 2007-03-30 23:40:54 pajamian Exp $
10 UserTag jsquote Alias jsq
13 UserTag jsq PosNumber 0
14 UserTag jsq Version $Revision: 1.8 $
15 UserTag jsq Routine <<EOR
18 $text =~ s/^[ \t\r]*\n//;
19 my @lines = split /\r?\n/, $text;
22 ( $_ !~ /'/ and s/\r/\\r/g, s/(^|[^\\])\$\{?(\w+)\}?/$1' + $2 + '/g, $_ = qq{'$_'} )
24 ( $_ !~ /"/ and s/\r/\\r/g, s/(^|[^\\])\$\{?(\w+)\}?/$1" + $2 + "/g, $_ = qq{"$_"} )
26 ( s/'/\\'/g, s/\r/\\r/g, s/(^|[^\\])\$\{?(\w+)\}?/$1' + $2 + '/g, $_ = qq{'$_'} );
28 @lines = "''" unless @lines;
29 return join (" +\n", @lines);