Skip to content

Commit

Permalink
Update dependencies (#782)
Browse files Browse the repository at this point in the history
* Run npm audit fix

* Updates marked

* Updates spritesmith

* Updates simple git

* Updates cheerio

* Removes blessed

* Bumps mailgun

* Bumps gifsicle

* Bumps pngquant

* Bumps mozjpeg

* Bumps mozjpeg

* Bumps mailgun

* Updates usage of marked

* Fixes org converter

* Fixes markdown and rtf converters

* Updates usage of cheerio

* Fixes ODT

* Fixes encodeXML

* Fixes video embed tests

* Fixes gdoc tests

* Fixes docx converter

* Updates git client

* Updates spritesmith

* Revert "Updates spritesmith"

This reverts commit 6df80ca.
  • Loading branch information
davidmerfield authored Mar 27, 2024
1 parent b1c9ad8 commit 64cf063
Show file tree
Hide file tree
Showing 43 changed files with 9,855 additions and 8,586 deletions.
4 changes: 2 additions & 2 deletions app/blog/render/retrieve/absoluteURLs.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Use it like this:
var cheerio = require("cheerio");
var debug = require("debug")("blot:render:absoluteURLs");

function absoluteURLs(base, $) {
function absoluteURLs (base, $) {
try {
$("[href], [src]").each(function () {
var href = $(this).attr("href");
Expand Down Expand Up @@ -51,7 +51,7 @@ module.exports = function (req, callback) {

text = render(text);

var $ = cheerio.load(text);
var $ = cheerio.load(text, null, false);

text = absoluteURLs(base, $);
text = $.html();
Expand Down
13 changes: 10 additions & 3 deletions app/blog/render/retrieve/encodeXML.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ var cheerio = require("cheerio");

// Removes everything forbidden by XML 1.0 specifications,
// plus the unicode replacement character U+FFFD
function removeXMLInvalidChars(string) {
var regex = /((?:[\0-\x08\x0B\f\x0E-\x1F\uFFFD\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]))/g;
function removeXMLInvalidChars (string) {
var regex =
/((?:[\0-\x08\x0B\f\x0E-\x1F\uFFFD\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]))/g;
return string.replace(regex, "");
}

Expand All @@ -22,7 +23,13 @@ module.exports = function (req, callback) {
text = render(text);

try {
$ = cheerio.load(text);
$ = cheerio.load(
text,
{
decodeEntities: false
},
false
);
$ = absoluteURLs(req.protocol + "://" + req.get("host"), $);
$("script").remove();
xml = $.html();
Expand Down
4 changes: 2 additions & 2 deletions app/blog/render/retrieve/tests/encodeXML.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe("encodeXML", function () {
protocol: "http",
get: function () {
return "example.com";
},
}
};
});

Expand All @@ -34,7 +34,7 @@ describe("encodeXML", function () {

encodeXML(this.request, function (err, lambda) {
result = mustache.render(template, { encodeXML: lambda });
expect(result).toEqual("& foo (便利");
expect(result).toEqual("& foo (便利");
done();
});
});
Expand Down
15 changes: 13 additions & 2 deletions app/build/converters/docx/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,25 @@ function read (blog, path, options, callback) {
}

fs.readFile(outPath, "utf-8", function (err, html) {
var $ = cheerio.load(html, { decodeEntities: false });
// remove everything between '<!--[if lt IE 9]>' and '<![endif]-->' including those comments
html = html.replace(
/<!--\[if lt IE 9\]>[\s\S]*<!\[endif\]-->/g,
""
);

var $ = cheerio.load(html, { decodeEntities: false }, false);

// all p that contain possible metadata are checked until one is encountered that does not
// p that are entirely bold are turned into h tags
// first p that is entirely bold is h1, next are all h2

var metadata = {};

// remove <style>, <meta> and <title>
$("style").remove();
$("meta").remove();
$("title").remove();

$("p").each(function (i) {
if ($(this).children().length) return false;

Expand Down Expand Up @@ -190,7 +201,7 @@ function read (blog, path, options, callback) {
$(this).removeAttr("style");
});

html = $("body").html().trim();
html = $.html().trim();

var metadataString = "<!--";

Expand Down
2 changes: 1 addition & 1 deletion app/build/converters/gdoc/tests/metadata.gdoc.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
date: 12-12-2023
link: foo
-->
<p><span></span></p><h1><span>How about this</span></h1><p><span></span></p><p><span>Metadata </span><em>test. </em><span>Hey </span><strong>you</strong><span>. This is me&hellip;</span></p>
<p><span></span></p><h1><span>How about this</span></h1><p><span></span></p><p><span>Metadata </span><em>test. </em><span>Hey </span><strong>you</strong><span>. This is me</span></p>
8 changes: 4 additions & 4 deletions app/build/converters/markdown-without-pandoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// locally on a machine without pandoc – it's useful
// for developers who want to contribute
const fs = require("fs-extra");
const marked = require("marked");
const { marked } = require("marked");
const extname = require("path").extname;
const localPath = require("helper/localPath");

Expand All @@ -12,15 +12,15 @@ module.exports = {

const text = fs.readFileSync(path, "utf-8");
const stat = fs.statSync(path);
const html = marked(text);
const html = marked.parse(text);

callback(null, html, stat);
},
is: function is(path) {
is: function is (path) {
return (
[".txt", ".text", ".md", ".markdown"].indexOf(
extname(path).toLowerCase()
) > -1
);
},
}
};
2 changes: 1 addition & 1 deletion app/build/converters/markdown/footnotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var cheerio = require("cheerio");
var makeUid = require("helper/makeUid");

module.exports = function (html) {
var $ = cheerio.load(html, { decodeEntities: false });
var $ = cheerio.load(html, { decodeEntities: false }, false);

var changes = false;
var postfix = makeUid(3);
Expand Down
16 changes: 8 additions & 8 deletions app/build/converters/markdown/indentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
// This function will not remove the indents for pre
// formatted text <pre> since pandoc will leave those.
var cheerio = require("cheerio");
var $ = cheerio.load("");
var $ = cheerio.load("", null, false);

function indentation(text) {
function indentation (text) {
// Ensure the text contains the ingredients
// needed for a complete HTML tag! (<,>,/)
if (!/<|>|\//.test(text)) return text;
Expand Down Expand Up @@ -78,7 +78,7 @@ function indentation(text) {

// ensure the only thing that has changed
// is whitespace...
function verify(before, after) {
function verify (before, after) {
before = before.replace(/\s/g, "");
after = after.replace("/s/g", "");

Expand All @@ -87,24 +87,24 @@ function verify(before, after) {
return after;
}

function hasPreTag(line) {
function hasPreTag (line) {
return line.indexOf("```") > -1;
}

function hasClosingTag(line, name) {
function hasClosingTag (line, name) {
return line.indexOf("</" + name + ">") > -1;
}

function firstTag(str) {
function firstTag (str) {
str = str.trim();
return str[0] === "<" && str.indexOf(">") > 0 && $(str)[0].name;
}

function leadingWhitespace(str) {
function leadingWhitespace (str) {
return /^\s/.test(str);
}

function trimLeading(str) {
function trimLeading (str) {
return str.slice(str.indexOf(str.trim()));
}

Expand Down
Loading

0 comments on commit 64cf063

Please sign in to comment.