@ridi/epub-parser
Advanced tools
Comparing version 0.6.10 to 0.6.11
@@ -48,2 +48,4 @@ 'use strict'; | ||
DOCTYPE: '!doctype', | ||
HTML: 'html', | ||
BODY: 'body', | ||
STYLE: 'style', | ||
@@ -156,2 +158,32 @@ A: 'a', | ||
function getSafeBody(ast) { | ||
var BODY = Names.Tags.BODY; | ||
var body = ast.find(function (child) { | ||
return child.tagName === BODY; | ||
}); | ||
if ((0, _parserCore.isExists)(body)) return body; | ||
return { | ||
type: 'element', | ||
tagName: BODY, | ||
attributes: [], | ||
children: _parserCore.isArray ? ast : [ast] | ||
}; | ||
} | ||
function getSafeHtml(ast) { | ||
var HTML = Names.Tags.HTML; | ||
var html = ast.find(function (child) { | ||
return child.tagName === HTML; | ||
}); | ||
if ((0, _parserCore.isExists)(html)) return html; | ||
return { | ||
type: 'element', | ||
tagName: HTML, | ||
attributes: [], | ||
children: [getSafeBody(ast)] | ||
}; | ||
} | ||
function spineLoader(spineItem, string) { | ||
@@ -164,8 +196,4 @@ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
if (stringifyOptions.extractBody) { | ||
var html = ast.find(function (child) { | ||
return child.tagName === 'html'; | ||
}); | ||
var body = html.children.find(function (child) { | ||
return child.tagName === 'body'; | ||
}); | ||
var html = getSafeHtml(ast); | ||
var body = getSafeBody(html.children); | ||
var attrs = body.attributes; | ||
@@ -172,0 +200,0 @@ if ((0, _parserCore.isExists)(spineItem.styles)) { |
{ | ||
"name": "@ridi/epub-parser", | ||
"version": "0.6.10", | ||
"version": "0.6.11", | ||
"description": "Common EPUB2 data parser for Ridibooks services", | ||
@@ -31,3 +31,3 @@ "author": { | ||
"dependencies": { | ||
"@ridi/parser-core": "0.6.10", | ||
"@ridi/parser-core": "0.6.11", | ||
"css-tree": "^1.0.0-alpha.29", | ||
@@ -34,0 +34,0 @@ "fast-xml-parser": "^3.12.17", |
119102
2468
+ Added@ridi/parser-core@0.6.11(transitive)
- Removed@ridi/parser-core@0.6.10(transitive)
Updated@ridi/parser-core@0.6.11