@curiositystream/legal-docs
Advanced tools
Comparing version 1.0.3 to 1.1.0
{ | ||
"name": "@curiositystream/legal-docs", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"main": "script.js", | ||
@@ -14,2 +14,4 @@ "files": [ | ||
"dependencies": { | ||
"cheerio": "^1.0.0-rc.2", | ||
"lodash": "^4.17.10", | ||
"mammoth": "^1.4.6", | ||
@@ -16,0 +18,0 @@ "mkdirp": "^0.5.1", |
@@ -5,2 +5,4 @@ const fs = require("fs"); | ||
const mammoth = require("mammoth"); | ||
const cheerio = require("cheerio"); | ||
const _ = require("lodash"); | ||
const TurndownService = require("turndown"); | ||
@@ -37,4 +39,21 @@ const turndownService = new TurndownService(); | ||
fs.writeFileSync(outputPath.html, html); | ||
const $ = cheerio.load(html); | ||
// add anchor ids to section headers so we can link to each section | ||
$("strong").each((i, elem) => { | ||
const $el = $(elem); | ||
const text = $el.text(); | ||
const headerRegex = /^[A-Z]\. /i; | ||
const isHeader = headerRegex.test(text); | ||
if (isHeader) { | ||
const title = text.replace(headerRegex, ""); | ||
const id = _.kebabCase(title); | ||
$el.attr("id", id); | ||
} | ||
}); | ||
fs.writeFileSync(outputPath.html, $.html()); | ||
return html; | ||
@@ -41,0 +60,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
90224
49
5
+ Addedcheerio@^1.0.0-rc.2
+ Addedlodash@^4.17.10
+ Addedboolbase@1.0.0(transitive)
+ Addedcheerio@1.0.0(transitive)
+ Addedcheerio-select@2.1.0(transitive)
+ Addedcss-select@5.1.0(transitive)
+ Addedcss-what@6.1.0(transitive)
+ Addeddom-serializer@2.0.0(transitive)
+ Addeddomelementtype@2.3.0(transitive)
+ Addeddomhandler@5.0.3(transitive)
+ Addeddomutils@3.2.2(transitive)
+ Addedencoding-sniffer@0.2.0(transitive)
+ Addedentities@4.5.0(transitive)
+ Addedhtmlparser2@9.1.0(transitive)
+ Addediconv-lite@0.6.3(transitive)
+ Addednth-check@2.1.1(transitive)
+ Addedparse5@7.2.1(transitive)
+ Addedparse5-htmlparser2-tree-adapter@7.1.0(transitive)
+ Addedparse5-parser-stream@7.1.2(transitive)
+ Addedundici@6.21.1(transitive)
+ Addedwhatwg-encoding@3.1.1(transitive)
+ Addedwhatwg-mimetype@4.0.0(transitive)