Further accessibility and semantic improvements

This commit is contained in:
Bad Manners 2024-08-15 23:50:23 -03:00
parent dafb240517
commit bf82d8bcd6
21 changed files with 82 additions and 480 deletions

View file

@ -8,11 +8,16 @@ import fetchRetryWrapper from "fetch-retry";
function getRTFStyles(rtfSource: string) {
const matches = rtfSource.matchAll(
/\\s(\d+)(?:\\sbasedon\d+)?\\snext\d+((?:\\[a-z0-9]+ ?)+)(?: ([A-Z][a-zA-Z ]*));/g,
/\\s(?<styleNumber>\d+)(?:\\sbasedon\d+)?\\snext\d+(?<partialRTFStyle>(?:\\[a-z0-9]+ ?)+)(?: (?<styleName>[A-Z][a-zA-Z ]*));/g,
);
let hasMatches = false;
const rtfStyles: Record<number | string, string> = {};
for (const [_, styleNumber, partialRTFStyle, styleName] of matches) {
for (const match of matches) {
const { styleNumber, partialRTFStyle, styleName } = match.groups as {
styleNumber: string;
partialRTFStyle: string;
styleName: string;
};
hasMatches = true;
const rtfStyle = `\\s${styleNumber}${partialRTFStyle}`;
rtfStyles[Number.parseInt(styleNumber)] = rtfStyle;