@ridi/epub-parser
Advanced tools
Comparing version 0.5.8 to 0.6.0-alpha.2
@@ -123,3 +123,3 @@ 'use strict'; | ||
return (0, _extends3.default)({}, _Parser.parseDefaultOptions, { | ||
// If true, validation package specifications in IDPF listed below. (only using if input is EPUB file.) | ||
// If true, validation package specifications in IDPF listed below. (used only if input is EPUB file.) | ||
// - Zip header should not corrupt. | ||
@@ -137,4 +137,6 @@ // - mimetype file must be first file in archive. | ||
parseStyle: true, | ||
// Prepend given string to namespace for identification. (only using if parseStyle is true.) | ||
styleNamespacePrefix: 'ridi_style' | ||
// Prepend given string to namespace for identification. (only available if parseStyle is true.) | ||
styleNamespacePrefix: 'ridi_style', | ||
// If specified, added inline styles to all spines. (only available if parseStyle is true.) | ||
additionalInlineStyle: undefined | ||
}); | ||
@@ -154,3 +156,4 @@ } | ||
parseStyle: 'Boolean', | ||
styleNamespacePrefix: 'String' | ||
styleNamespacePrefix: 'String', | ||
additionalInlineStyle: 'String|Undefined' | ||
}); | ||
@@ -800,2 +803,3 @@ } | ||
* @see EpubParser.parseDefaultOptions.styleNamespacePrefix | ||
* @see EpubParser.parseDefaultOptions.additionalInlineStyle | ||
*/ | ||
@@ -806,3 +810,3 @@ | ||
var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(rawItem, entry, options) { | ||
var styles, inlineStyles, find, filter, document, html, head; | ||
var styles, inlineStyles, find, filter, document, html, head, lastIdx, userStyle, namespace, href; | ||
return _regenerator2.default.wrap(function _callee6$(_context7) { | ||
@@ -880,2 +884,4 @@ while (1) { | ||
// ^~~ | ||
lastIdx = void 0; | ||
filter(head.children, 'tagName', 'style').forEach(function (style, idx) { | ||
@@ -900,8 +906,26 @@ var firstNode = style.children[0]; | ||
inlineStyles.push(inlineStyleItem); | ||
lastIdx = idx; | ||
} | ||
}); | ||
userStyle = options.additionalInlineStyle; | ||
if (userStyle) { | ||
namespace = '' + options.styleNamespacePrefix + ((0, _parserCore.isExists)(lastIdx) ? lastIdx + 1 : 0); | ||
href = rawItem.href + '_' + namespace; | ||
inlineStyles.push({ | ||
id: rawItem.id + '_' + namespace, | ||
href: href, | ||
mediaType: 'text/css', | ||
size: userStyle.length, | ||
itemType: _InlineCssItem2.default, | ||
namespace: namespace, | ||
style: userStyle | ||
}); | ||
} | ||
return _context7.abrupt('return', { styles: styles, inlineStyles: inlineStyles }); | ||
case 20: | ||
case 23: | ||
case 'end': | ||
@@ -908,0 +932,0 @@ return _context7.stop(); |
@@ -69,6 +69,2 @@ 'use strict'; | ||
var _Version = require('./Version'); | ||
var _Version2 = _interopRequireDefault(_Version); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -186,3 +182,3 @@ | ||
this.rights = rawBook.rights; | ||
this.version = new _Version2.default(rawBook.version); | ||
this.version = new _parserCore.Version(rawBook.version); | ||
this.metas = (rawBook.metas || []).map(function (rawObj) { | ||
@@ -189,0 +185,0 @@ return new _Meta2.default(rawObj); |
@@ -25,2 +25,3 @@ 'use strict'; | ||
this.options = undefined; | ||
this.entries = undefined; | ||
this.opfPath = undefined; | ||
@@ -27,0 +28,0 @@ this.basePath = undefined; |
{ | ||
"name": "@ridi/epub-parser", | ||
"version": "0.5.8", | ||
"version": "0.6.0-alpha.2", | ||
"description": "Common EPUB2 data parser for Ridibooks services", | ||
@@ -31,5 +31,5 @@ "author": { | ||
"dependencies": { | ||
"@ridi/parser-core": "^0.5.8", | ||
"@ridi/parser-core": "^0.6.0-alpha.2", | ||
"css-tree": "^1.0.0-alpha.29", | ||
"fast-xml-parser": "^3.11.2", | ||
"fast-xml-parser": "^3.12.17", | ||
"fs-extra": "^8.0.0", | ||
@@ -36,0 +36,0 @@ "he": "^1.1.1", |
@@ -436,3 +436,3 @@ # @ridi/epub-parser | ||
### [Version](./src/model/Version.js) | ||
### [Version](../parser-core/src/Version.js) | ||
@@ -442,3 +442,2 @@ - major: *number* | ||
- patch: *number* | ||
- isValid: *boolean* (**Only 2.x.x is valid because current epub-parser only supports EPUB2.**) | ||
- toString(): *string* | ||
@@ -456,2 +455,3 @@ | ||
* [styleNamespacePrefix](#styleNamespacePrefix) | ||
* [additionalInlineStyle](#additionalInlineStyle) | ||
@@ -465,3 +465,4 @@ --- | ||
If true, validation package specifications in [IDPF listed](http://www.idpf.org/doc_library/epub/OCF_2.0.1_draft.doc) below. | ||
> only using if input is EPUB file. | ||
> used only if input is EPUB file. | ||
- Zip header should not corrupt. | ||
@@ -528,6 +529,17 @@ - `mimetype` file must be first file in archive. | ||
Prepend given string to namespace for identification. | ||
> only using if parseStyle is true. | ||
> only available if parseStyle is true. | ||
**Default:** `'ridi_style'` | ||
--- | ||
<a id="additionalInlineStyle"></a> | ||
### additionalInlineStyle: *`?string`* | ||
If specified, added inline styles to all spines. | ||
> only available if parseStyle is true. | ||
**Default:** `undefined` | ||
<a id="readOptions"></a> | ||
@@ -713,2 +725,2 @@ | ||
[MIT](https://github.com/ridi/content-parser/blob/master/LICENSE) | ||
[MIT](https://github.com/ridi/content-parser/packages/epub-parser/LICENSE) |
117269
721
2410
+ Added@ridi/parser-core@0.6.15(transitive)
+ Addedat-least-node@1.0.0(transitive)
+ Addedcrypto-js@4.2.0(transitive)
+ Addedfs-extra@9.1.0(transitive)
+ Addedjsonfile@6.1.0(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedstream-chopper@3.0.1(transitive)
+ Addedstring-natural-compare@3.0.1(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addeduniversalify@2.0.1(transitive)
- Removed@ridi/parser-core@0.5.8(transitive)
- Removedaes-js@3.1.2(transitive)
- Removedstring-natural-compare@2.0.3(transitive)
Updatedfast-xml-parser@^3.12.17