generated from digitalservicebund/java-application-template
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit: - Updates the converter version to the most recent version. This version imports line breaks in titles as `<br/>` tags - Displays line breaks in the norm title in the frontend - Displays line breaks as white space in section titles in the table of contents RISDEV-2581 RISDEV-2546 RISDEV-2545
- Loading branch information
1 parent
d1ed3ee
commit 0064890
Showing
10 changed files
with
534 additions
and
21 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* -------------------------------------------------- * | ||
* Shared * | ||
* -------------------------------------------------- */ | ||
|
||
type SanitizeRule = { | ||
pattern: RegExp | string | ||
replacement: string | null | ||
} | ||
|
||
/** Cleans up an input string according to a list of rules. */ | ||
function sanitize(input: string, rules: SanitizeRule[]): string { | ||
let output = input | ||
|
||
rules.forEach((rule) => { | ||
output = output.replace(rule.pattern, rule.replacement ?? "") | ||
}) | ||
|
||
return output | ||
} | ||
|
||
/** Removes tags that indicate "Kuppelwörter" */ | ||
const kwReplacement: SanitizeRule = { | ||
pattern: /<(kw|KW)\/>/g, | ||
replacement: null, | ||
} | ||
|
||
/** Removes FNR tags */ | ||
const fnrReplacement: SanitizeRule = { | ||
pattern: /<FnR ID="[^"]*"\/>/g, | ||
replacement: null, | ||
} | ||
|
||
/* -------------------------------------------------- * | ||
* Specific sanitizers * | ||
* -------------------------------------------------- */ | ||
|
||
export function sanitizeTableOfContentEntry(input: string): string { | ||
return sanitize(input, [ | ||
kwReplacement, | ||
fnrReplacement, | ||
{ pattern: /\s*<(br|BR)\/>\s*/g, replacement: " " }, | ||
]) | ||
} | ||
|
||
export function sanitizeNormTitle(input: string): string { | ||
return sanitize(input, [ | ||
kwReplacement, | ||
fnrReplacement, | ||
{ pattern: /\s*<(br|BR)\/>\s*/g, replacement: "\n" }, | ||
]) | ||
} |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.