Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

Fix html truncation #38

Open
wants to merge 5 commits into
base: GSRS_DEV
Choose a base branch
from
Open

Fix html truncation #38

wants to merge 5 commits into from

Conversation

epuzanov
Copy link
Contributor

@epuzanov epuzanov commented Mar 8, 2021

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.

Copy link
Contributor

@dkatzel-ncats dkatzel-ncats left a 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()){
Copy link
Contributor

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.

Copy link
Contributor Author

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))) {
Copy link
Contributor

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

Copy link
Contributor Author

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants