From c2eafb565c8874f92789505c715d78d177d51b90 Mon Sep 17 00:00:00 2001 From: Romain Deltour Date: Fri, 25 May 2018 18:35:09 +0200 Subject: [PATCH] fix: revert to the official xmldom-alpha depdency Using a github dependency requires the usage: git [--version] [--help] [-C ] [-c name=value] [--exec-path[=]] [--html-path] [--man-path] [--info-path] [-p | --paginate | --no-pager] [--no-replace-objects] [--bare] [--git-dir=] [--work-tree=] [--namespace=] [] These are common Git commands used in various situations: start a working area (see also: git help tutorial) clone Clone a repository into a new directory init Create an empty Git repository or reinitialize an existing one work on the current change (see also: git help everyday) add Add file contents to the index mv Move or rename a file, a directory, or a symlink reset Reset current HEAD to the specified state rm Remove files from the working tree and from the index examine the history and state (see also: git help revisions) bisect Use binary search to find the commit that introduced a bug grep Print lines matching a pattern log Show commit logs show Show various types of objects status Show the working tree status grow, mark and tweak your common history branch List, create, or delete branches checkout Switch branches or restore working tree files commit Record changes to the repository diff Show changes between commits, commit and working tree, etc merge Join two or more development histories together rebase Reapply commits on top of another base tip tag Create, list, delete or verify a tag object signed with GPG collaborate (see also: git help workflows) fetch Download objects and refs from another repository pull Fetch from and integrate with another repository or a local branch push Update remote refs along with associated objects 'git help -a' and 'git help -g' list available subcommands and some concept guides. See 'git help ' or 'git help ' to read about a specific subcommand or concept. command to be available at install time. We therefore rever to the xmldom-alpha version in the npm repository, and add a mimetype hack for xmldom to detect the content as XHTML --- packages/epub-utils/package.json | 2 +- packages/epub-utils/src/epub-parse.js | 6 ++++-- yarn.lock | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/epub-utils/package.json b/packages/epub-utils/package.json index 4cf40685..79156eec 100644 --- a/packages/epub-utils/package.json +++ b/packages/epub-utils/package.json @@ -21,7 +21,7 @@ "fs-extra": "^6.0.1", "tmp": "^0.0.33", "winston": "^2.4.0", - "xmldom-alpha": "https://github.com/fchasen/xmldom.git#a38f7ddb536ab74e9fb549477ba9f9b7ea2d0beb", + "xmldom-alpha": "^0.1.28", "xpath": "^0.0.24" }, "publishConfig": { diff --git a/packages/epub-utils/src/epub-parse.js b/packages/epub-utils/src/epub-parse.js index 6686ac23..bbd2b9ee 100644 --- a/packages/epub-utils/src/epub-parse.js +++ b/packages/epub-utils/src/epub-parse.js @@ -40,7 +40,8 @@ function EpubParser() { function parseNavDoc(fullpath, epubDir) { const content = fs.readFileSync(fullpath).toString(); - const doc = new DOMParser({errorHandler}).parseFromString(content, 'application/xhtml+xml'); + //FIXME hack to workaround xmldom-alpha regex test + const doc = new DOMParser({errorHandler}).parseFromString(content, 'application/xhtml'); // Remove all links const aElems = doc.getElementsByTagNameNS('http://www.w3.org/1999/xhtml', 'a'); @@ -175,7 +176,8 @@ EpubParser.prototype.parseData = function(packageDocPath, epubDir) { EpubParser.prototype.parseContentDocTitle = function(filepath) { const content = fs.readFileSync(filepath).toString(); - const doc = new DOMParser({errorHandler}).parseFromString(content, 'application/xhtml+xml'); + //FIXME hack to workaround xmldom-alpha regex test + const doc = new DOMParser({errorHandler}).parseFromString(content, 'application/xhtml'); const select = xpath.useNamespaces({html: "http://www.w3.org/1999/xhtml", epub: "http://www.idpf.org/2007/ops"}); const title = select('//html:title/text()', doc); if (title.length > 0) { diff --git a/yarn.lock b/yarn.lock index c5d87923..5f6a9732 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6080,9 +6080,9 @@ xmlbuilder@~9.0.1: version "9.0.7" resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-9.0.7.tgz#132ee63d2ec5565c557e20f4c22df9aca686b10d" -"xmldom-alpha@https://github.com/fchasen/xmldom.git#a38f7ddb536ab74e9fb549477ba9f9b7ea2d0beb": +xmldom-alpha@^0.1.28: version "0.1.28" - resolved "https://github.com/fchasen/xmldom.git#a38f7ddb536ab74e9fb549477ba9f9b7ea2d0beb" + resolved "https://registry.yarnpkg.com/xmldom-alpha/-/xmldom-alpha-0.1.28.tgz#4e8451d8df4d7bb303baae0bde783062f9d3d600" xpath@^0.0.24: version "0.0.24"