Git Product home page Git Product logo

pixiv-novel-parser's Introduction

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 = require('pixiv-novel-parser').Parser;
Parser.parse('[chapter: pixiv[[rb:小説 > しょうせつ]]]');

Web Browser

Download the ZIP Package, or use bower:

$ bower install pixiv-novel-parser --save

And include it from HTML:

<script src="dist/pixiv-novel-parser.min.js"></script>
<script>
  var Parser = PixivNovelParser.Parser;
  Parser.parse('[chapter:pixiv[[rb:小説>しょうせつ]]]');
</script>

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.log(Parser.parse('[chapter:見出し]本文[newpage]'));

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 = new Parser();
parser.parse('[chapter:見出し]本文[newpage]');
console.log(parser.tree);
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 <[email protected]>
 */

pixiv-novel-parser's People

Contributors

alphasp avatar hakatashi avatar ne-sachirou avatar zonuexe avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.