Skip to content

Bring back the JSPs #1018

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions UnicodeJsps/src/main/java/org/unicode/jsp/UnicodeJsp.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,19 @@ public static String getSimpleSet(
String a_out;
a.clear();
try {
if (setA.length() > 4
&& setA.startsWith("[:k")
&& setA.endsWith(":]")
&& setA.contains("=")
&& !setA.substring(2, setA.length() - 2).contains(":]")
&& XPropertyFactory.make()
.getProperty(setA.substring(2, setA.indexOf("=")))
.isMultivalued()) {
throw new Exception(
"POSIX-style queries for multivalued Unihan properties are temporarily disabled. Try \\p{"
+ setA.substring(2, setA.length() - 2)
+ "}");
}
// setA = UnicodeSetUtilities.MyNormalize(setA, Normalizer.NFC);
a.addAll(UnicodeSetUtilities.parseUnicodeSet(setA));
a_out = UnicodeUtilities.getPrettySet(a, abbreviate, escape);
Expand Down
23 changes: 14 additions & 9 deletions UnicodeJsps/src/main/java/org/unicode/jsp/UnicodeUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -1648,6 +1648,7 @@ class PropertyAssignment {
VersionInfo last;
String value;
}
final boolean isMultivalued = getFactory().getProperty(propName).isMultivalued();
List<PropertyAssignment> history = new ArrayList<>();
// TODO(eggrobin): TUP normalization chokes on sufficiently old versions, but this is not
// worth debugging as we want to get rid of it.
Expand Down Expand Up @@ -1732,17 +1733,21 @@ class PropertyAssignment {
out.append(
"<td"
+ defaultClass
+ "><a target='u' "
+ (isNew ? "class='changed' " : "")
+ "href='list-unicodeset.jsp?a=[:"
+ (isCurrent ? "" : "U" + last + ":")
+ propName
+ "="
+ hValue
+ ":]'>"
+ ">"
+ (isMultivalued
? ""
: ("<a target='u' "
+ (isNew ? "class='changed' " : "")
+ "href='list-unicodeset.jsp?a=[:"
+ (isCurrent ? "" : "U" + last + ":")
+ propName
+ "="
+ hValue
+ ":]'>"))
+ versionRange
+ hValue
+ "</a></td>");
+ (isMultivalued ? "" : "</a>")
+ "</td>");
}
}
out.append("</tr>");
Expand Down
42 changes: 0 additions & 42 deletions UnicodeJsps/src/main/java/org/unicode/jsp/XPropertyFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,48 +145,6 @@ public String transform(Integer source) {
},
false)
.setMain("toNFKD", "toNFKD", UnicodeProperty.STRING, "1.1"));

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find these very useful in practice. Is there a compelling reason to remove?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, they are very slow (getSet involves computing the preimage of a function).

But what do you use these for, as opposed to Lowercase_Mapping, Uppercase_Mapping, and Titlecase_Mapping?

Copy link
Member Author

@eggrobin eggrobin Jan 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just checked (on the staging JSPs which do not yet have these changes), and both of the following contain only characters whose mappings changed in 16.0 (because we are lagging on the ICU version used in the right-hand side):

  • [:^Lowercase_Mapping=@toLowercase@:]
  • [:^Uppercase_Mapping=@toUppercase@:]

[:^Titlecase_Mapping=@toTitlecase@:] contains one interesting difference, U+0345, because ICU skips past a leading U+0345 in titlecasing. But I think for all practical purposes, you can just use the mappings.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, makes sense.

add(
new StringTransformProperty(
new StringTransform() {
@Override
public String transform(String source) {
return UCharacter.foldCase(source, true);
}
},
false)
.setMain("toCasefold", "toCF", UnicodeProperty.STRING, "1.1"));
add(
new StringTransformProperty(
new StringTransform() {
@Override
public String transform(String source) {
return UCharacter.toLowerCase(ULocale.ROOT, source);
}
},
false)
.setMain("toLowercase", "toLC", UnicodeProperty.STRING, "1.1"));
add(
new StringTransformProperty(
new StringTransform() {
@Override
public String transform(String source) {
return UCharacter.toUpperCase(ULocale.ROOT, source);
}
},
false)
.setMain("toUppercase", "toUC", UnicodeProperty.STRING, "1.1"));
add(
new StringTransformProperty(
new StringTransform() {
@Override
public String transform(String source) {
return UCharacter.toTitleCase(ULocale.ROOT, source, null);
}
},
false)
.setMain("toTitlecase", "toTC", UnicodeProperty.STRING, "1.1"));

add(
new StringTransformProperty(
new StringTransform() {
Expand Down
3 changes: 2 additions & 1 deletion UnicodeJsps/src/main/webapp/properties.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ th { text-align: left }
UtfParameters utfParameters = new UtfParameters(queryString);

String propForValues = utfParameters.getParameter("a");
UnicodeJsp.showPropsTable(out, propForValues, "properties.jsp");
// TODO(egg): Cache this page.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok for now. I think just a static page with an explicit list of the properties (and if enumerated, the values) without links would be very helpful for the users, and not hard to generate at build time.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. And we should probably grab some information from IndexUnicodeProperties as well, e.g., which files they come from.

But not today.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed

//UnicodeJsp.showPropsTable(out, propForValues, "properties.jsp");
%>
<h2>Key</h2>
<p>The Categories are from <a target='_blank' href='http://www.unicode.org/reports/tr44#Property_Index'>UCD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ public UnicodeProperty setMultivalued(boolean value) {
return this;
}

public boolean isMultivalued() {
return isMultivalued;
}

public UnicodeProperty setDelimiter(String value) {
delimiter = value;
delimiterSplitter = Splitter.on(delimiter);
Expand Down
Loading