-
Notifications
You must be signed in to change notification settings - Fork 2
Fix html truncation #38
base: GSRS_DEV
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to think about the refPname() changes a bit
@@ -88,27 +95,22 @@ public String toStd(String str){ | |||
*/ | |||
@Override | |||
public String truncate(String str, int maxBytes){ | |||
byte[] b = (str + " ").getBytes(); | |||
if(maxBytes >= b.length){ | |||
if(maxBytes >= str.length()){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this will work. The previous code converts to bytes because some encodings take more than 1 byte (up to 4) for some characters. str.length
is the number of characters which may be 1/4 the number of bytes in the worst case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm using str.length() here because of str.charAt(i-1) in for loop.
}else{ | ||
lastComplete = false; | ||
} | ||
if (i > 0 && badLastChars.contains(str.charAt(i-1))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be slower than the old way and looks like the old way was trying to count close tags? I assume this means we don't need that anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check of close tags done by Tidy.
This PR will fix truncate function in HTMLStringConverter class.The refPname property of SubstanceReference class will be truncated before storing in DB. The refPname property will be stored in RAW format which can be converted in Standard or HTML format (o.e getFormattedName for Alternative definitions). The getStandardName function added to Substance class an used for creation of _name JSON properties. The getName function of Substance class will return Display Name in RAW format. The Standard Name will be used as Page Title for Substance details page.