mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-27 15:05:38 -04:00
(blog) replace &qout; entities in title with proper "
This commit is contained in:
parent
ee30f0ef1a
commit
af88f5d9bf
@ -4,6 +4,8 @@ import type { Translator } from './translator.ts';
|
||||
let census_groups: Record<string, string> = {};
|
||||
let census_comparisons: Record<string, string> = {};
|
||||
|
||||
const replaceQuoteEntity = (string: string): string => string.replace(/"/g, '"');
|
||||
|
||||
const mainPlusDetails = (dict: Record<string, string>, wide: boolean) => (_: string, keys: string, content: string) => {
|
||||
let selectedDict: Record<string, string> = {};
|
||||
if (keys === undefined) {
|
||||
@ -63,7 +65,7 @@ const generateToC = (content: string, translator: Translator) => (_: string) =>
|
||||
};
|
||||
|
||||
const generateGallery = (_: string, itemsString: string) => {
|
||||
const items: Record<string, string> = JSON.parse(`{${itemsString.replace(/"/g, '"').replace(/,\s*$/, '')}}`);
|
||||
const items: Record<string, string> = JSON.parse(`{${replaceQuoteEntity(itemsString).replace(/,\s*$/, '')}}`);
|
||||
|
||||
const label = (alt: string): string => {
|
||||
if (!alt.startsWith('! ')) {
|
||||
@ -106,11 +108,11 @@ export default async function parseMarkdown(markdown: string, translator: Transl
|
||||
.replace(/{graph=([^}]+)}/g, '<iframe class="graph" src="$1.html" loading="lazy"></iframe>')
|
||||
|
||||
.replace(/<p>{set_census_groups=(.+?)}<\/p>/gms, (_, value) => {
|
||||
census_groups = JSON.parse(value.replace(/"/g, '"'));
|
||||
census_groups = JSON.parse(replaceQuoteEntity(value));
|
||||
return '';
|
||||
})
|
||||
.replace(/<p>{set_census_comparisons=(.+?)}<\/p>/gms, (_, value) => {
|
||||
census_comparisons = JSON.parse(value.replace(/"/g, '"'));
|
||||
census_comparisons = JSON.parse(replaceQuoteEntity(value));
|
||||
return '';
|
||||
})
|
||||
.replace(/<p>{census_groups(:.+?)?}<\/p>(.+?)<p>{\/census_groups}<\/p>/gms, mainPlusDetails(census_groups, false))
|
||||
@ -140,7 +142,7 @@ export default async function parseMarkdown(markdown: string, translator: Transl
|
||||
});
|
||||
|
||||
const titleMatch = content.match('<h1[^>]*>(.+?)</h1>');
|
||||
const title = titleMatch ? titleMatch[1] : null;
|
||||
const title = titleMatch ? replaceQuoteEntity(titleMatch[1]) : null;
|
||||
const imgMatch = content.match('<img src="([^"]+)"[^>]*>');
|
||||
const img = imgMatch ? imgMatch[1] : null;
|
||||
let intro: string[] = [];
|
||||
|
Loading…
x
Reference in New Issue
Block a user