This repository was archived by the owner on Jun 12, 2026. It is now read-only.
Fix html truncation#38
Open
epuzanov wants to merge 5 commits into
Open
Conversation
added 2 commits
April 13, 2021 11:37
dkatzel-ncats
left a comment
Contributor
There was a problem hiding this comment.
I need to think about the refPname() changes a bit
| public String truncate(String str, int maxBytes){ | ||
| byte[] b = (str + " ").getBytes(); | ||
| if(maxBytes >= b.length){ | ||
| if(maxBytes >= str.length()){ |
Contributor
There was a problem hiding this comment.
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.
Contributor
Author
There was a problem hiding this comment.
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))) { |
Contributor
There was a problem hiding this comment.
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
Contributor
Author
There was a problem hiding this comment.
check of close tags done by Tidy.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.