mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-24 20:42:43 +00:00
Merge branch 'master' into marked-justifiedParagraphs
This commit is contained in:
@@ -44,13 +44,19 @@ const fetchThemeBundle = async (obj, renderer, theme)=>{
|
||||
.catch((err)=>{
|
||||
obj.setState({ error: err });
|
||||
});
|
||||
if(!res) return;
|
||||
|
||||
if(!res) {
|
||||
obj.setState((prevState)=>({
|
||||
...prevState,
|
||||
themeBundle : {}
|
||||
}));
|
||||
return;
|
||||
}
|
||||
const themeBundle = res.body;
|
||||
themeBundle.joinedStyles = themeBundle.styles.map((style)=>`<style>${style}</style>`).join('\n\n');
|
||||
obj.setState((prevState)=>({
|
||||
...prevState,
|
||||
themeBundle : themeBundle
|
||||
themeBundle : themeBundle,
|
||||
error : null
|
||||
}));
|
||||
};
|
||||
|
||||
|
||||
@@ -7,7 +7,8 @@ import MarkedExtendedTables from 'marked-extended-tables';
|
||||
import { markedSmartypantsLite as MarkedSmartypantsLite } from 'marked-smartypants-lite';
|
||||
import { gfmHeadingId as MarkedGFMHeadingId, resetHeadings as MarkedGFMResetHeadingIDs } from 'marked-gfm-heading-id';
|
||||
import { markedEmoji as MarkedEmojis } from 'marked-emoji';
|
||||
import MarkedJustifiedParagraphs from 'marked-justified-paragraphs';
|
||||
import MarkedAlignedParagraphs from 'marked-alignment-paragraphs';
|
||||
import MarkedSubSuperText from 'marked-subsuper-text';
|
||||
|
||||
//Icon fonts included so they can appear in emoji autosuggest dropdown
|
||||
import diceFont from '../../themes/fonts/iconFonts/diceFont.js';
|
||||
@@ -334,35 +335,6 @@ const mustacheInjectBlock = {
|
||||
}
|
||||
};
|
||||
|
||||
const superSubScripts = {
|
||||
name : 'superSubScript',
|
||||
level : 'inline',
|
||||
start(src) { return src.match(/\^/m)?.index; }, // Hint to Marked.js to stop and check for a match
|
||||
tokenizer(src, tokens) {
|
||||
const superRegex = /^\^(?!\s)(?=([^\n\^]*[^\s\^]))\1\^/m;
|
||||
const subRegex = /^\^\^(?!\s)(?=([^\n\^]*[^\s\^]))\1\^\^/m;
|
||||
let isSuper = false;
|
||||
let match = subRegex.exec(src);
|
||||
if(!match){
|
||||
match = superRegex.exec(src);
|
||||
if(match)
|
||||
isSuper = true;
|
||||
}
|
||||
if(match?.length) {
|
||||
return {
|
||||
type : 'superSubScript', // Should match "name" above
|
||||
raw : match[0], // Text to consume from the source
|
||||
tag : isSuper ? 'sup' : 'sub',
|
||||
tokens : this.lexer.inlineTokens(match[1])
|
||||
};
|
||||
}
|
||||
},
|
||||
renderer(token) {
|
||||
return `<${token.tag}>${this.parser.parseInline(token.tokens)}</${token.tag}>`;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const forcedParagraphBreaks = {
|
||||
name : 'hardBreaks',
|
||||
level : 'block',
|
||||
@@ -380,7 +352,7 @@ const forcedParagraphBreaks = {
|
||||
}
|
||||
},
|
||||
renderer(token) {
|
||||
return `<div class='blank'></div>`.repeat(token.length).concat('\n');
|
||||
return `<br>\n`.repeat(token.length);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -761,11 +733,12 @@ const tableTerminators = [
|
||||
|
||||
Marked.use(MarkedVariables());
|
||||
Marked.use({ extensions : [definitionListsMultiLine, definitionListsSingleLine, forcedParagraphBreaks,
|
||||
nonbreakingSpaces, superSubScripts, mustacheSpans, mustacheDivs, mustacheInjectInline] });
|
||||
Marked.use(MarkedJustifiedParagraphs());
|
||||
nonbreakingSpaces, mustacheSpans, mustacheDivs, mustacheInjectInline] });
|
||||
Marked.use(mustacheInjectBlock);
|
||||
Marked.use(MarkedAlignedParagraphs());
|
||||
Marked.use(MarkedSubSuperText());
|
||||
Marked.use({ renderer: renderer, tokenizer: tokenizer, mangle: false });
|
||||
Marked.use(MarkedExtendedTables(tableTerminators), MarkedGFMHeadingId({ globalSlugs: true }),
|
||||
Marked.use(MarkedExtendedTables({interruptPatterns : tableTerminators}), MarkedGFMHeadingId({ globalSlugs: true }),
|
||||
MarkedSmartypantsLite(), MarkedEmojis(MarkedEmojiOptions));
|
||||
|
||||
function cleanUrl(href) {
|
||||
|
||||
Reference in New Issue
Block a user