0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-26 22:43:07 +00:00

Compare commits

..

1 Commits

Author SHA1 Message Date
Trevor Buckner
cb987930f2 Force lists to be "loose" style (wrap text in <p> tags) 2025-03-25 17:34:17 -04:00
4 changed files with 49 additions and 16 deletions

32
package-lock.json generated
View File

@@ -23,6 +23,7 @@
"cors": "^2.8.5",
"create-react-class": "^15.7.0",
"dedent-tabs": "^0.10.3",
"dompurify": "^3.2.4",
"expr-eval": "^2.0.2",
"express": "^4.21.2",
"express-async-handler": "^1.2.0",
@@ -35,14 +36,14 @@
"lodash": "^4.17.21",
"marked": "14.0.0",
"marked-emoji": "^2.0.0",
"marked-extended-tables": "^2.0.1",
"marked-extended-tables": "^2.0.0",
"marked-gfm-heading-id": "^4.0.1",
"marked-smartypants-lite": "^1.0.3",
"marked-subsuper-text": "^1.0.3",
"markedLegacy": "npm:marked@^0.3.19",
"moment": "^2.30.1",
"mongoose": "^8.12.1",
"nanoid": "5.1.3",
"nanoid": "5.1.2",
"nconf": "^0.12.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
@@ -2952,6 +2953,12 @@
"dev": true,
"license": "MIT"
},
"node_modules/@types/trusted-types": {
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz",
"integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==",
"optional": true
},
"node_modules/@types/webidl-conversions": {
"version": "7.0.3",
"resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-7.0.3.tgz",
@@ -5359,6 +5366,15 @@
"npm": ">=1.2"
}
},
"node_modules/dompurify": {
"version": "3.2.4",
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.2.4.tgz",
"integrity": "sha512-ysFSFEDVduQpyhzAob/kkuJjf5zWkZD8/A9ywSp1byueyuCfHamrCBa14/Oc2iiB0e51B+NpxSl5gmzn+Ms/mg==",
"license": "(MPL-2.0 OR Apache-2.0)",
"optionalDependencies": {
"@types/trusted-types": "^2.0.7"
}
},
"node_modules/dunder-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
@@ -9858,9 +9874,9 @@
}
},
"node_modules/marked-extended-tables": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/marked-extended-tables/-/marked-extended-tables-2.0.1.tgz",
"integrity": "sha512-DV4Si978ZdaFbycIxzG4TdaNMtC0J8QfIKj1UOCejgJHwVjVJse8DNdJriWDeo/n74DWVYpRC6S56AdgWDPrPA==",
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/marked-extended-tables/-/marked-extended-tables-2.0.0.tgz",
"integrity": "sha512-MWmxvFLkJYQ5K46MFieOP1uueMgfIpDPMkYLLgIyTl20HyvLIW4J37BAtIGfR8fDp2uE4Kyyev4s3dhoT2FQOA==",
"license": "MIT",
"peerDependencies": {
"marked": ">=3 <16"
@@ -10406,9 +10422,9 @@
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
},
"node_modules/nanoid": {
"version": "5.1.3",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-5.1.3.tgz",
"integrity": "sha512-zAbEOEr7u2CbxwoMRlz/pNSpRP0FdAU4pRaYunCdEezWohXFs+a0Xw7RfkKaezMsmSM1vttcLthJtwRnVtOfHQ==",
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-5.1.2.tgz",
"integrity": "sha512-b+CiXQCNMUGe0Ri64S9SXFcP9hogjAJ2Rd6GdVxhPLRm7mhGaM7VgOvCAJ1ZshfHbqVDI3uqTI5C8/GaKuLI7g==",
"funding": [
{
"type": "github",

View File

@@ -97,6 +97,7 @@
"cors": "^2.8.5",
"create-react-class": "^15.7.0",
"dedent-tabs": "^0.10.3",
"dompurify": "^3.2.4",
"expr-eval": "^2.0.2",
"express": "^4.21.2",
"express-async-handler": "^1.2.0",
@@ -109,14 +110,14 @@
"lodash": "^4.17.21",
"marked": "14.0.0",
"marked-emoji": "^2.0.0",
"marked-extended-tables": "^2.0.1",
"marked-extended-tables": "^2.0.0",
"marked-gfm-heading-id": "^4.0.1",
"marked-smartypants-lite": "^1.0.3",
"marked-subsuper-text": "^1.0.3",
"markedLegacy": "npm:marked@^0.3.19",
"moment": "^2.30.1",
"mongoose": "^8.12.1",
"nanoid": "5.1.3",
"nanoid": "5.1.2",
"nconf": "^0.12.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",

View File

@@ -381,7 +381,12 @@ const forcedParagraphBreaks = {
tokenizer(src, tokens) {
const regex = /^(:+)(?:\n|$)/ym;
const match = regex.exec(src);
if(match?.length) {
const lastToken = tokens[tokens.length - 1];
if(lastToken?.type == 'text')
lastToken.type = 'paragraph';
return {
type : 'hardBreaks', // Should match "name" above
raw : match[0], // Text to consume from the source
@@ -395,6 +400,14 @@ const forcedParagraphBreaks = {
}
};
const patchHardBreaks = {
walkTokens(token) {
if(token.type == 'list' || token.type == 'list_item') {
token.loose = true;
}
}
}
const nonbreakingSpaces = {
name : 'nonbreakingSpaces',
level : 'inline',
@@ -774,6 +787,7 @@ Marked.use(MarkedVariables());
Marked.use({ extensions : [justifiedParagraphs, definitionListsMultiLine, definitionListsSingleLine, forcedParagraphBreaks,
nonbreakingSpaces, mustacheSpans, mustacheDivs, mustacheInjectInline] });
Marked.use(mustacheInjectBlock);
Marked.use(patchHardBreaks);
Marked.use(MarkedSubSuperText());
Marked.use({ renderer: renderer, tokenizer: tokenizer, mangle: false });
Marked.use(MarkedExtendedTables({interruptPatterns : tableTerminators}), MarkedGFMHeadingId({ globalSlugs: true }),

View File

@@ -57,12 +57,13 @@
ul {
padding-left : 1.4em;
margin-bottom : 0.8em;
line-height : 1.25em;
}
ol {
padding-left : 1.4em;
margin-bottom : 0.8em;
line-height : 1.25em;
}
.page li p {
line-height : 1.25em;
}
//Indents after p or lists
p + p, ul + p, ol + p { text-indent : 1em; }
@@ -137,6 +138,9 @@
line-height : 0.951em; //Font is misaligned. Shift up slightly
& + * { margin-top : 0.2cm; }
}
br + h3, br + h4 {
margin-top : 0;
}
// *****************************
// * TABLE
// *****************************/
@@ -545,9 +549,8 @@
columns : 1;
text-align : center;
&::after { display : none; }
.frontCover { position : absolute; }
h1 {
margin-top : 1.55cm;
margin-top : 1.2cm;
margin-bottom : 0;
font-family : 'NodestoCapsCondensed';
font-size : 2.245cm;
@@ -633,9 +636,8 @@
columns : 1;
text-align : center;
&::after { display : none; }
.insideCover { position : absolute; }
h1 {
margin-top : 1.55cm;
margin-top : 1.2cm;
margin-bottom : 0;
font-family : 'NodestoCapsCondensed';
font-size : 2.1cm;