mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-13 10:52:46 +00:00
extract smartypants into package
This commit is contained in:
9
package-lock.json
generated
9
package-lock.json
generated
@@ -32,6 +32,7 @@
|
||||
"marked": "5.1.0",
|
||||
"marked-extended-tables": "^1.0.6",
|
||||
"marked-gfm-heading-id": "^3.0.4",
|
||||
"marked-smartypants-lite": "^1.0.0",
|
||||
"markedLegacy": "npm:marked@^0.3.19",
|
||||
"moment": "^2.29.4",
|
||||
"mongoose": "^7.3.0",
|
||||
@@ -9677,6 +9678,14 @@
|
||||
"marked": "^4 || ^5"
|
||||
}
|
||||
},
|
||||
"node_modules/marked-smartypants-lite": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/marked-smartypants-lite/-/marked-smartypants-lite-1.0.0.tgz",
|
||||
"integrity": "sha512-+EGU6lP4VVoQBJp1OMoM3wDG0m/n9z2pek9hA9NtOG1EDrW0DCQc6T4KzdEzaVAghc2XMyEBDqlUsN/3/QvD9g==",
|
||||
"peerDependencies": {
|
||||
"marked": "^4 || ^5"
|
||||
}
|
||||
},
|
||||
"node_modules/markedLegacy": {
|
||||
"name": "marked",
|
||||
"version": "0.3.19",
|
||||
|
||||
@@ -100,6 +100,7 @@
|
||||
"marked": "5.1.0",
|
||||
"marked-extended-tables": "^1.0.6",
|
||||
"marked-gfm-heading-id": "^3.0.4",
|
||||
"marked-smartypants-lite": "^1.0.0",
|
||||
"markedLegacy": "npm:marked@^0.3.19",
|
||||
"moment": "^2.29.4",
|
||||
"mongoose": "^7.3.0",
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
const _ = require('lodash');
|
||||
const Marked = require('marked');
|
||||
const MarkedExtendedTables = require('marked-extended-tables');
|
||||
const { markedSmartypantsLite: MarkedSmartypantsLite } = require('marked-smartypants-lite');
|
||||
const { gfmHeadingId: MarkedGFMHeadingId } = require('marked-gfm-heading-id');
|
||||
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(mustacheInjectBlock);
|
||||
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
|
||||
renderer.link = function (href, title, text) {
|
||||
|
||||
Reference in New Issue
Block a user