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
diff -r 35f3bfd4f51d -r 21f5edab1fbf src/goodjava/xml/XmlElement.java
--- 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("&amp;");
@@ -98,6 +97,9 @@
 			case '"':
 				buf.append("&quot;");
 				break;
+			case '\'':
+				buf.append("&apos;");
+				break;
 			default:
 				buf.append(c);
 			}
diff -r 35f3bfd4f51d -r 21f5edab1fbf src/luan/modules/HtmlLuan.java
--- 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("&amp;");
diff -r 35f3bfd4f51d -r 21f5edab1fbf src/luan/modules/Parsers.luan
--- 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