Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@ridi/epub-parser
Advanced tools
Common EPUB2 data parser for Ridibooks services written in ES6
readOptions.spine.serializedAnchor
optionreadOptions.spine.truncate
and readOption.spine.truncateMaxLength
optionsreadOptions.spine.minify
and readOptions.css.minify
optionsreadOptions.removeExternalRefs
optionnpm install @ridi/epub-parser
import { EpubParser } from '@ridi/epub-parser';
// or const { EpubParser } = require('@ridi/epub-parser');
const parser = new EpubParser('./foo/bar.epub' or './unzippedPath');
parser.parse().then((book) => {
parser.readItems(book.spines).then((results) => {
...
});
...
});
Returns Promise<Book>
with:
Or throw exception.
?object
Returns string
or Buffer
in Promise
with:
SpineItem, CssItem, InlineCssItem, NcxItem, SvgItem:
string
Other items:
Buffer
or throw exception.
Item
(see: Item Types)?object
Returns string[]
or Buffer[]
in Promise
with:
SpineItem, CssItem, InlineCssItem, NcxItem, SvgItem:
string[]
Other items:
Buffer[]
or throw exception.
Item[]
(see: Item Types)?object
boolean
If true, validation package specifications in IDPF listed below.
mimetype
file must be first file in archive.mimetype
file should not compressed.mimetype
file should only contain string application/epub+zip
.Default: false
boolean
If true, stop parsing when XML parsing errors occur.
Default: false
boolean
If false, stop parsing when NCX file not exists.
Default: true
?string
If specified, uncompress to that path.
Only if input is EPUB file.
Default: undefined
boolean
If true, overwrite to unzipPath when uncompress.
Default: true
boolean
If true, ignore spineIndex
difference caused by isLinear
property of SpineItem.
// e.g. If left is false, right is true.
[{ spineIndex: 0, isLinear: true, ... }, [{ spineIndex: 0, isLinear: true, ... },
{ spineIndex: 1, isLinear: true, ... }, { spineIndex: 1, isLinear: true, ... },
{ spineIndex: -1, isLinear: false, ... }, { spineIndex: 2, isLinear: false, ... },
{ spineIndex: 2, isLinear: true, ... }] { spineIndex: 3, isLinear: true, ... }]
Default: true
boolean
If true, One namespace is given per CSS file or inline style, and styles used for spine is described.
Otherwise it CssItem.namespace
, SpineItem.styles
is undefined
.
In any list, InlineCssItem is always positioned after CssItem. (Book.styles
, Book.items
, SpineItem.styles
, ...)
Default: false
string
Prepend given string to namespace for identification.
Default: 'ridi_style'
?string
If specified, change base path of paths used by spine and css.
HTML: SpineItem
...
<!-- Before -->
<div>
<img src="../Images/cover.jpg">
</div>
<!-- After -->
<div>
<img src="{basePath}/OEBPS/Images/cover.jpg">
</div>
...
CSS: CssItem, InlineCssItem
/* Before */
@font-face {
font-family: NotoSansRegular;
src: url("../Fonts/NotoSans-Regular.ttf");
}
/* After */
@font-face {
font-family: NotoSansRegular;
src: url("{basePath}/OEBPS/Fonts/NotoSans-Regular.ttf");
}
Default: undefined
boolean
If true, extract body. Otherwise it returns a full string. If specify a function instead of true, use function to transform body.
false:
'<!doctype><html>\n<head>\n</head>\n<body style="background-color: #000000;">\n <p>Extract style</p>\n <img src=\"../Images/api-map.jpg\"/>\n</body>\n</html>'
true:
'<body style="background-color: #000000;">\n <p>Extract style</p>\n <img src=\"../Images/api-map.jpg\"/>\n</body>'
function:
readOptions.spine.extractBody = (innerHTML, attrs) => {
const string = attrs.map((attr) => {
return ` ${attr.key}=\"${attr.value}\"`;
}).join(' ');
return `<article ${string}>${innerHTML}</article>`;
};
'<article style="background-color: #000000;">\n <p>Extract style</p>\n <img src=\"../Images/api-map.jpg\"/>\n</article>'
Default: false
boolean
If true, applies readOptions.css to inline styles and style attributes.
Default: false
string[]
Remove at-rules.
Default: []
string[]
Remove selector that point to specified tags.
Default: []
string[]
Remove selector that point to specified ids.
Default: []
string[]
Remove selector that point to specified classes.
Default: []
[0.1.1 (2018-10-08)]
FAQs
Common EPUB2 data parser for Ridibooks services
The npm package @ridi/epub-parser receives a total of 43 weekly downloads. As such, @ridi/epub-parser popularity was classified as not popular.
We found that @ridi/epub-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 9 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.