mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-03 12:42:41 +00:00
Replace SmartyPants plugin with custom
This commit is contained in:
21
package-lock.json
generated
21
package-lock.json
generated
@@ -32,7 +32,6 @@
|
|||||||
"marked": "5.0.4",
|
"marked": "5.0.4",
|
||||||
"marked-extended-tables": "^1.0.6",
|
"marked-extended-tables": "^1.0.6",
|
||||||
"marked-gfm-heading-id": "^3.0.3",
|
"marked-gfm-heading-id": "^3.0.3",
|
||||||
"marked-smartypants": "^1.0.2",
|
|
||||||
"markedLegacy": "npm:marked@^0.3.19",
|
"markedLegacy": "npm:marked@^0.3.19",
|
||||||
"moment": "^2.29.4",
|
"moment": "^2.29.4",
|
||||||
"mongoose": "^7.2.2",
|
"mongoose": "^7.2.2",
|
||||||
@@ -9684,17 +9683,6 @@
|
|||||||
"marked": "^4 || ^5"
|
"marked": "^4 || ^5"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/marked-smartypants": {
|
|
||||||
"version": "1.0.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/marked-smartypants/-/marked-smartypants-1.0.2.tgz",
|
|
||||||
"integrity": "sha512-hpbM9waiBSIHpqdoU5AAeuYozeObBwUet3xkCFrFBA+1329byRVxLDwYmelMCS3ss+sEVJhDgrunIy+ubiqFwQ==",
|
|
||||||
"dependencies": {
|
|
||||||
"smartypants": "^0.1.6"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"marked": "^4 || ^5"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/markedLegacy": {
|
"node_modules/markedLegacy": {
|
||||||
"name": "marked",
|
"name": "marked",
|
||||||
"version": "0.3.19",
|
"version": "0.3.19",
|
||||||
@@ -15333,15 +15321,6 @@
|
|||||||
"npm": ">= 3.0.0"
|
"npm": ">= 3.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/smartypants": {
|
|
||||||
"version": "0.1.6",
|
|
||||||
"resolved": "https://registry.npmjs.org/smartypants/-/smartypants-0.1.6.tgz",
|
|
||||||
"integrity": "sha512-zGXh+Q6Y3OPTLM5x2HxAIkEAj4ZcePftmIOdIYozv2T+m03Sp5R4YppczKuo6IdnSMc99U+Wgvy8Mil0eeep7g==",
|
|
||||||
"bin": {
|
|
||||||
"smartypants": "bin/smartypants.js",
|
|
||||||
"smartypantsu": "bin/smartypantsu.js"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/snapdragon": {
|
"node_modules/snapdragon": {
|
||||||
"version": "0.8.2",
|
"version": "0.8.2",
|
||||||
"resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz",
|
"resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz",
|
||||||
|
|||||||
@@ -100,7 +100,6 @@
|
|||||||
"marked": "5.0.4",
|
"marked": "5.0.4",
|
||||||
"marked-extended-tables": "^1.0.6",
|
"marked-extended-tables": "^1.0.6",
|
||||||
"marked-gfm-heading-id": "^3.0.3",
|
"marked-gfm-heading-id": "^3.0.3",
|
||||||
"marked-smartypants": "^1.0.2",
|
|
||||||
"markedLegacy": "npm:marked@^0.3.19",
|
"markedLegacy": "npm:marked@^0.3.19",
|
||||||
"moment": "^2.29.4",
|
"moment": "^2.29.4",
|
||||||
"mongoose": "^7.2.2",
|
"mongoose": "^7.2.2",
|
||||||
|
|||||||
@@ -2,8 +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 {gfmHeadingId: MarkedGFMHeadingId} = require('marked-gfm-heading-id');
|
const { gfmHeadingId: MarkedGFMHeadingId } = require('marked-gfm-heading-id');
|
||||||
const {markedSmartypants: MarkedSmartyPants} = require('marked-smartypants');
|
|
||||||
const renderer = new Marked.Renderer();
|
const renderer = new Marked.Renderer();
|
||||||
|
|
||||||
//Processes the markdown within an HTML block if it's just a class-wrapper
|
//Processes the markdown within an HTML block if it's just a class-wrapper
|
||||||
@@ -238,10 +237,49 @@ 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, smartypants: true, mangle: false, smartypants: false });
|
Marked.use({ renderer: renderer, mangle: false });
|
||||||
Marked.use(MarkedExtendedTables(), MarkedGFMHeadingId(), MarkedSmartyPants());
|
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