Mercurial Hosting > luan
changeset 1469:21f5edab1fbf
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 14 Apr 2020 13:15:18 -0600 |
parents | 35f3bfd4f51d |
children | 580ee513a4b7 |
files | src/goodjava/xml/XmlElement.java src/luan/modules/HtmlLuan.java src/luan/modules/Parsers.luan |
diffstat | 3 files changed, 9 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/goodjava/xml/XmlElement.java Tue Apr 14 08:44:33 2020 -0600 +++ b/src/goodjava/xml/XmlElement.java Tue Apr 14 13:15:18 2020 -0600 @@ -80,11 +80,10 @@ } } - private static String encode(String s) { + public static String encode(String s) { final char[] a = s.toCharArray(); StringBuilder buf = new StringBuilder(); - for( int i=0; i<a.length; i++ ) { - char c = a[i]; + for( char c : a ) { switch(c) { case '&': buf.append("&"); @@ -98,6 +97,9 @@ case '"': buf.append("""); break; + case '\'': + buf.append("'"); + break; default: buf.append(c); }
--- a/src/luan/modules/HtmlLuan.java Tue Apr 14 08:44:33 2020 -0600 +++ b/src/luan/modules/HtmlLuan.java Tue Apr 14 13:15:18 2020 -0600 @@ -17,10 +17,9 @@ public static String encode(String s) throws LuanException { Utils.checkNotNull(s); - char[] a = s.toCharArray(); + final char[] a = s.toCharArray(); StringBuilder buf = new StringBuilder(); - for( int i=0; i<a.length; i++ ) { - char c = a[i]; + for( char c : a ) { switch(c) { case '&': buf.append("&");
--- a/src/luan/modules/Parsers.luan Tue Apr 14 08:44:33 2020 -0600 +++ b/src/luan/modules/Parsers.luan Tue Apr 14 13:15:18 2020 -0600 @@ -3,6 +3,7 @@ local Csv = require "java:luan.modules.parsers.Csv" local Theme = require "java:luan.modules.parsers.Theme" local Xml = require "java:luan.modules.parsers.Xml" +local XmlElement = require "java:goodjava.xml.XmlElement" local BasicLuan = require "java:luan.modules.BasicLuan" @@ -13,6 +14,7 @@ Parsers.csv_to_list = Csv.toList Parsers.json_string = BasicLuan.json_string Parsers.theme_to_luan = Theme.toLuan +Parsers.xml_encode = XmlElement.encode Parsers.xml_parse = Xml.parse Parsers.xml_string = Xml.toString