mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-02 10:42:44 +00:00
Force lists to be "loose" style (wrap text in <p> tags)
This commit is contained in:
@@ -381,7 +381,12 @@ const forcedParagraphBreaks = {
|
|||||||
tokenizer(src, tokens) {
|
tokenizer(src, tokens) {
|
||||||
const regex = /^(:+)(?:\n|$)/ym;
|
const regex = /^(:+)(?:\n|$)/ym;
|
||||||
const match = regex.exec(src);
|
const match = regex.exec(src);
|
||||||
|
|
||||||
if(match?.length) {
|
if(match?.length) {
|
||||||
|
const lastToken = tokens[tokens.length - 1];
|
||||||
|
if(lastToken?.type == 'text')
|
||||||
|
lastToken.type = 'paragraph';
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type : 'hardBreaks', // Should match "name" above
|
type : 'hardBreaks', // Should match "name" above
|
||||||
raw : match[0], // Text to consume from the source
|
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 = {
|
const nonbreakingSpaces = {
|
||||||
name : 'nonbreakingSpaces',
|
name : 'nonbreakingSpaces',
|
||||||
level : 'inline',
|
level : 'inline',
|
||||||
@@ -774,6 +787,7 @@ Marked.use(MarkedVariables());
|
|||||||
Marked.use({ extensions : [justifiedParagraphs, definitionListsMultiLine, definitionListsSingleLine, forcedParagraphBreaks,
|
Marked.use({ extensions : [justifiedParagraphs, definitionListsMultiLine, definitionListsSingleLine, forcedParagraphBreaks,
|
||||||
nonbreakingSpaces, mustacheSpans, mustacheDivs, mustacheInjectInline] });
|
nonbreakingSpaces, mustacheSpans, mustacheDivs, mustacheInjectInline] });
|
||||||
Marked.use(mustacheInjectBlock);
|
Marked.use(mustacheInjectBlock);
|
||||||
|
Marked.use(patchHardBreaks);
|
||||||
Marked.use(MarkedSubSuperText());
|
Marked.use(MarkedSubSuperText());
|
||||||
Marked.use({ renderer: renderer, tokenizer: tokenizer, mangle: false });
|
Marked.use({ renderer: renderer, tokenizer: tokenizer, mangle: false });
|
||||||
Marked.use(MarkedExtendedTables({interruptPatterns : tableTerminators}), MarkedGFMHeadingId({ globalSlugs: true }),
|
Marked.use(MarkedExtendedTables({interruptPatterns : tableTerminators}), MarkedGFMHeadingId({ globalSlugs: true }),
|
||||||
|
|||||||
@@ -57,12 +57,13 @@
|
|||||||
ul {
|
ul {
|
||||||
padding-left : 1.4em;
|
padding-left : 1.4em;
|
||||||
margin-bottom : 0.8em;
|
margin-bottom : 0.8em;
|
||||||
line-height : 1.25em;
|
|
||||||
}
|
}
|
||||||
ol {
|
ol {
|
||||||
padding-left : 1.4em;
|
padding-left : 1.4em;
|
||||||
margin-bottom : 0.8em;
|
margin-bottom : 0.8em;
|
||||||
line-height : 1.25em;
|
}
|
||||||
|
.page li p {
|
||||||
|
line-height : 1.25em;
|
||||||
}
|
}
|
||||||
//Indents after p or lists
|
//Indents after p or lists
|
||||||
p + p, ul + p, ol + p { text-indent : 1em; }
|
p + p, ul + p, ol + p { text-indent : 1em; }
|
||||||
@@ -137,6 +138,9 @@
|
|||||||
line-height : 0.951em; //Font is misaligned. Shift up slightly
|
line-height : 0.951em; //Font is misaligned. Shift up slightly
|
||||||
& + * { margin-top : 0.2cm; }
|
& + * { margin-top : 0.2cm; }
|
||||||
}
|
}
|
||||||
|
br + h3, br + h4 {
|
||||||
|
margin-top : 0;
|
||||||
|
}
|
||||||
// *****************************
|
// *****************************
|
||||||
// * TABLE
|
// * TABLE
|
||||||
// *****************************/
|
// *****************************/
|
||||||
|
|||||||
Reference in New Issue
Block a user