Skip to content
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

fix: Replace dollar character by appropriate HTML entity, otherwise i… #43

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ public HtmlProcessor(FileResourceProvider fileResourceProvider, LocalizationSett
}

public String processHtmlForPDF(@NotNull String html, @NotNull ExportParams exportParams, @NotNull List<String> selectedRoleEnumValues) {
html = html.replaceAll("\\$", "&dollar;");

html = removePd4mlTags(html);
html = html.replace("/ria/images/enums/", "/icons/default/enums/");
html = html.replace("<p><br></p>", "<br/>");
Expand Down Expand Up @@ -559,13 +561,13 @@ private String removePd4mlTags(@NotNull String html) {
@SuppressWarnings({"java:S5869", "java:S6019"})
String properTableHeads(@NotNull String html) {
// Searches for all subsequent table rows (<tr>-tags) inside <tbody> which contain <th>-tags
// followed by a row which doesn't contain <th>.
// followed by a row which doesn't contain <th> (or closing </tbody> tag).
// There are 2 groups in this regexp, first one is unnamed, containing <tbody> and <tr>-tags containing <th>-tags,
// second one is named ("header") and contains those <tr>-tags which include <th>-tags. The regexp is ending
// by positive lookahead "(?=<tr)" which doesn't take part in replacement.
// The sense in this regexp is to find <tr>-tags containing <th>-tags and move it from <tbody> into <thead>,
// for table headers to repeat on each page.
Pattern pattern = Pattern.compile("(<tbody>[^<]*(?<header><tr>[^<]*<th[\\s|\\S]*?))(?=<tr)");
Pattern pattern = Pattern.compile("(<tbody>[^<]*(?<header><tr>[^<]*<th[\\s|\\S]*?))(?=(<tr|</tbody))");
Matcher matcher = pattern.matcher(html);

StringBuilder buf = new StringBuilder();
Expand Down
Loading