Git Product home page Git Product logo

tocmd.npm's Introduction

i5ting_toc

npm version

i5ting_toc a node npm wrapper of i5ting_ztree_toc https://github.com/i5ting/i5ting_ztree_toc

Preview

Install

npm install -g i5ting_toc

Usage

➜  tocmd.npm git:(master) ✗ i5ting_toc -h

  Usage: i5ting_toc  a node npm wrapper of i5ting_ztree_toc https://github.com/i5ting/i5ting_ztree_toc 

  Options:

    -h, --help             output usage information
    -V, --version          output the version number
    -f, --file [filename]  default is README.md 
		-o, --open             open in browser
    -v, --verbose          打印详细日志

这个版本的命令比较简单,只有一个-f参数,如果没有填写,默认使用README.md,常见用法

i5ting_toc -f sample.md -o

Api Usages

示例说明

var is_open = true;
var markd_config = {
	debug: false
}
//函数可以返回当前正在执行的项目路径
var pwd = process.cwd()  

var source_file_name = pwd + '/' + source_file
var file_name = source_file_name.split('/').pop();;
var _file_name = file_name.split('.')[0];

var dest_file_path = pwd + '/preview/' + _file_name + '.html';

console.log('pwd=' + pwd);
console.log('source_file_name=' + source_file_name);
console.log('dest_file_path=' + dest_file_path);

require('../index')(pwd, source_file_name, dest_file_path, is_open, markd_config);

参数说明

  • pwd是存放preview的位置
  • source_file 要编译的mardown文件
  • dest_file_path 生成的html完整路径和文件名
  • is_open 是否在编译后使用浏览器中打开html
  • markd_config 编译md的选项(具体见 https://github.com/chjj/marked

Basic

current path

var pwd = process.cwd()

file path

__dirname

use shelljs judge dir is

if (test('-d', preview_path)) { 
	/* do something with dir */ 
	mkdir('-p', preview_path);
};

http://documentup.com/arturadib/shelljs

  • '-b', 'path': true if path is a block device
  • '-c', 'path': true if path is a character device
  • '-d', 'path': true if path is a directory
  • '-e', 'path': true if path exists
  • '-f', 'path': true if path is a regular file
  • '-L', 'path': true if path is a symboilc link
  • '-p', 'path': true if path is a pipe (FIFO)
  • '-S', 'path': true if path is a socket

template for compile use handlebars

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

推荐

版本历史

  • v0.1.0 初始化版本

欢迎fork和反馈

如有建议或意见,请在issue提问或邮件

License

this repo is released under the MIT License.

tocmd.npm's People

Contributors

i5ting 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.