├── .npmignore ├── README.md ├── package.json ├── .gitignore ├── index.js └── LICENSE /.npmignore: -------------------------------------------------------------------------------- 1 | /.idea 2 | /.settings 3 | /.project 4 | /.gitignore 5 | /node_modules 6 | /test 7 | /.tmp 8 | 9 | .DS_Store 10 | 11 | *.db 12 | *.bak 13 | *.tmp 14 | *.cmd 15 | ~* 16 | 17 | upload.py -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## fis-parser-asciidoctor.js 2 | 3 | http://asciidoctor.org/ 4 | 5 | ### install 6 | 7 | ```bash 8 | npm install -g fis-parser-asciidoctor.js 9 | ``` 10 | 11 | 12 | ### settings 13 | 14 | ```javascript 15 | fis.config.set('project.fileType.text', 'adoc'); 16 | fis.config.set('modules.parser.adoc', 'asciidoctor.js'); 17 | fis.config.set('roadmap.ext.adoc', 'html'); 18 | ``` -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "fis-parser-asciidoctor.js", 3 | "version": "1.0.1", 4 | "description": "fis-parser-asciidoctor.js", 5 | "main": "index.js", 6 | "dependencies": { 7 | "asciidoctor.js": "1.5.0" 8 | }, 9 | "devDependencies": {}, 10 | "scripts": { 11 | "test": "echo \"Error: no test specified\" && exit 1" 12 | }, 13 | "keywords": [ 14 | "fis", 15 | "asciidoctor.js" 16 | ], 17 | "author": "fansekey", 18 | "license": "BSD" 19 | } 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | 16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 17 | .grunt 18 | 19 | # Compiled binary addons (http://nodejs.org/api/addons.html) 20 | build/Release 21 | 22 | # Dependency directory 23 | # Commenting this out is preferred by some people, see 24 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- 25 | node_modules 26 | 27 | # Users Environment Variables 28 | .lock-wscript 29 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * fis.baidu.com 3 | */ 4 | 5 | 6 | function removeFromRequireCache(reg) { 7 | for (var path in require.cache) { 8 | if (reg.test(path)) { 9 | delete(require.cache[path]); 10 | } 11 | } 12 | } 13 | 14 | 15 | module.exports = function (content, file, settings) { 16 | 17 | 18 | removeFromRequireCache(/asciidoctor\.js/); //not do cache, fix a bug of asciidoctor.js 19 | 20 | var asciidoctor = require('asciidoctor.js')(); 21 | 22 | var opal = asciidoctor.Opal 23 | var processor = null; 24 | 25 | if (settings.useExtensions) { 26 | processor = asciidoctor.Asciidoctor(true); 27 | } else { 28 | processor = asciidoctor.Asciidoctor(); 29 | } 30 | 31 | var options = opal.hash2( 32 | settings.mod, 33 | settings.opt); 34 | 35 | var html = processor.$convert(content, options); 36 | return html; 37 | 38 | }; 39 | 40 | module.exports.defaultOptions = { 41 | mod: ['doctype', 'attributes'], 42 | opt: {doctype: 'default', attributes: ['showtitle']}, 43 | useExtensions: true 44 | }; -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, fansekey 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of fis-parser-asciidoctor.js nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | --------------------------------------------------------------------------------