pixiv-novel-parser
pixiv novel parser powered by PEG.js.
Getting Started
node.js
Once you installed node.js, install with:
$ npm install pixiv-novel-parser --save
And require it from your project:
var Parser = Parser;Parser;
Web Browser
Download the ZIP Package, or use bower:
$ bower install pixiv-novel-parser --save
And include it from HTML:
Compatibility
- IE 7+
- Firefox 29+
- Google Chrome 42+
- Opera 21+
- node.js 0.10+
- io.js 3
- PECL V8js 0.1.3
API
JavaScript API
Currently pixiv-novel-parser exports object with only one legal property Parser
. This is JavaScript Class that can be used statically or dynamically.
Static Method
Parser.parse(text)
Parse text into AST (Abstract Syntax Tree).
- text: (
String
) the text to parse - Return: AST Object
console;
Result:
[ { type: 'tag', name: 'chapter', title: [ [Object] ] },
{ type: 'text', val: '本文' },
{ type: 'tag', name: 'newpage' } ]
Dynamic Method / Property
parser.parse(text)
Parse text into AST (Abstract Syntax Tree) and store the result.
- text: (
String
) the text to parse - Return: AST Object
var parser = ;parser;console;
parser.tree
Parsed AST Object
parser.toJSON()
Serialize parsed AST into JSON.
- Return: JSON string that represents AST
AST
No docs here but approximately it's just an array of tokens. See test/test.js.
Contribute
See CONTRIBUTING
Copyright
Mozilla Public License, version 2.0
Copyright 2015 pixiv Inc., All Right Reserved.
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
pixiv-novel-editor
pixiv-novel-editor/src/app/index.js
is licensed under GPLv3.
/** * @license GPLv3 ne_Sachirou <utakata.c4se@gmail.com> */