From 492e69c6c53596e84ff18d0e7c07dc48809be356 Mon Sep 17 00:00:00 2001 From: Christopher McCulloh Date: Mon, 30 Oct 2023 11:32:45 -0400 Subject: [PATCH 1/2] Updates remarkable plugin --- index.js | 21 +++++++++++++++------ package.json | 2 +- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 0b6cc2c..728d5d6 100644 --- a/index.js +++ b/index.js @@ -2,16 +2,18 @@ var hljs = require('highlight.js'); var utils = require('handlebars-utils'); -var Remarkable = require('remarkable'); +const { Remarkable } = require("remarkable"); +const { linkify } = require("remarkable/linkify"); + var defaults = { html: true, breaks: true, highlight: highlight }; -module.exports = function(config) { - if (typeof config === 'string' || utils.isOptions(config)) { +module.exports = function (config) { + if (typeof config === "string" || utils.isOptions(config)) { return markdown.apply(defaults, arguments); } function markdown(str, locals, options) { - if (typeof str !== 'string') { + if (typeof str !== "string") { options = locals; locals = str; str = true; @@ -26,11 +28,18 @@ module.exports = function(config) { var opts = utils.options(this, locals, options); opts = Object.assign({}, defaults, config, opts); - if (opts.hasOwnProperty('lang')) { + if (opts.hasOwnProperty("lang")) { opts.langPrefix = opts.lang; } - var md = new Remarkable(opts); + const useLinkify = opts.linkify; + delete opts.linkify; + + let md = new Remarkable(opts); + if (useLinkify) { + md.use(linkify); + } + var val = utils.value(str, ctx, options); return md.render(val); } diff --git a/package.json b/package.json index 812bd03..f8df54b 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "dependencies": { "handlebars-utils": "^1.0.2", "highlight.js": "^9.12.0", - "remarkable": "^1.7.1" + "remarkable": "^2.0.1" }, "devDependencies": { "gulp-format-md": "^1.0.0", From db40603b6d86f2493b0c6bdb27af640ff4cf06df Mon Sep 17 00:00:00 2001 From: Christopher McCulloh Date: Wed, 1 Nov 2023 10:33:57 -0400 Subject: [PATCH 2/2] Matches library's formatting preferences --- index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 728d5d6..bc13d19 100644 --- a/index.js +++ b/index.js @@ -2,18 +2,18 @@ var hljs = require('highlight.js'); var utils = require('handlebars-utils'); -const { Remarkable } = require("remarkable"); -const { linkify } = require("remarkable/linkify"); +const { Remarkable } = require('remarkable'); +const { linkify } = require('remarkable/linkify'); var defaults = { html: true, breaks: true, highlight: highlight }; -module.exports = function (config) { - if (typeof config === "string" || utils.isOptions(config)) { +module.exports = function(config) { + if (typeof config === 'string' || utils.isOptions(config)) { return markdown.apply(defaults, arguments); } function markdown(str, locals, options) { - if (typeof str !== "string") { + if (typeof str !== 'string') { options = locals; locals = str; str = true; @@ -28,7 +28,7 @@ module.exports = function (config) { var opts = utils.options(this, locals, options); opts = Object.assign({}, defaults, config, opts); - if (opts.hasOwnProperty("lang")) { + if (opts.hasOwnProperty('lang')) { opts.langPrefix = opts.lang; }