mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-04 16:52:38 +00:00
Merge pull request #2896 from naturalcrit/extractMarkedSmartypantsIntoPackage
extract smartypants into package
This commit is contained in:
35199
package-lock.json
generated
35199
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -100,6 +100,7 @@
|
|||||||
"marked": "5.1.0",
|
"marked": "5.1.0",
|
||||||
"marked-extended-tables": "^1.0.6",
|
"marked-extended-tables": "^1.0.6",
|
||||||
"marked-gfm-heading-id": "^3.0.4",
|
"marked-gfm-heading-id": "^3.0.4",
|
||||||
|
"marked-smartypants-lite": "^1.0.0",
|
||||||
"markedLegacy": "npm:marked@^0.3.19",
|
"markedLegacy": "npm:marked@^0.3.19",
|
||||||
"moment": "^2.29.4",
|
"moment": "^2.29.4",
|
||||||
"mongoose": "^7.3.0",
|
"mongoose": "^7.3.0",
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const Marked = require('marked');
|
const Marked = require('marked');
|
||||||
const MarkedExtendedTables = require('marked-extended-tables');
|
const MarkedExtendedTables = require('marked-extended-tables');
|
||||||
|
const { markedSmartypantsLite: MarkedSmartypantsLite } = require('marked-smartypants-lite');
|
||||||
const { gfmHeadingId: MarkedGFMHeadingId } = require('marked-gfm-heading-id');
|
const { gfmHeadingId: MarkedGFMHeadingId } = require('marked-gfm-heading-id');
|
||||||
const renderer = new Marked.Renderer();
|
const renderer = new Marked.Renderer();
|
||||||
|
|
||||||
@@ -237,49 +238,10 @@ const definitionLists = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const MarkedSmartyPantsLite = ()=>{
|
|
||||||
return {
|
|
||||||
tokenizer : {
|
|
||||||
inlineText(src) {
|
|
||||||
// don't escape inlineText
|
|
||||||
const cap = this.rules.inline.text.exec(src);
|
|
||||||
|
|
||||||
/* istanbul ignore next */
|
|
||||||
if(!cap) {
|
|
||||||
// should never happen
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const text = cap[0]
|
|
||||||
// em-dashes
|
|
||||||
.replace(/---/g, '\u2014')
|
|
||||||
// en-dashes
|
|
||||||
.replace(/--/g, '\u2013')
|
|
||||||
// opening singles
|
|
||||||
.replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018')
|
|
||||||
// closing singles & apostrophes
|
|
||||||
.replace(/'/g, '\u2019')
|
|
||||||
// opening doubles
|
|
||||||
.replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201c')
|
|
||||||
// closing doubles
|
|
||||||
.replace(/"/g, '\u201d')
|
|
||||||
// ellipses
|
|
||||||
.replace(/\.{3}/g, '\u2026');
|
|
||||||
|
|
||||||
return {
|
|
||||||
type : 'text',
|
|
||||||
raw : cap[0],
|
|
||||||
text : text
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
Marked.use({ extensions: [mustacheSpans, mustacheDivs, mustacheInjectInline, definitionLists] });
|
Marked.use({ extensions: [mustacheSpans, mustacheDivs, mustacheInjectInline, definitionLists] });
|
||||||
Marked.use(mustacheInjectBlock);
|
Marked.use(mustacheInjectBlock);
|
||||||
Marked.use({ renderer: renderer, mangle: false });
|
Marked.use({ renderer: renderer, mangle: false });
|
||||||
Marked.use(MarkedExtendedTables(), MarkedGFMHeadingId(), MarkedSmartyPantsLite());
|
Marked.use(MarkedExtendedTables(), MarkedGFMHeadingId(), MarkedSmartypantsLite());
|
||||||
|
|
||||||
//Fix local links in the Preview iFrame to link inside the frame
|
//Fix local links in the Preview iFrame to link inside the frame
|
||||||
renderer.link = function (href, title, text) {
|
renderer.link = function (href, title, text) {
|
||||||
|
|||||||
Reference in New Issue
Block a user