-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 33e6812
Showing
38 changed files
with
1,780 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"env": { | ||
"node": true, | ||
"browser": true | ||
}, | ||
"rules": { | ||
"quotes": [2, "single"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.DS_Store | ||
*.log | ||
bower_components/ | ||
build/ | ||
components/ | ||
coverage/ | ||
node_modules/ | ||
build.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
{ | ||
"plugins": [ | ||
"jscs-jsdoc" | ||
], | ||
"jsDoc": { | ||
"checkAnnotations": "jsdoc3", | ||
"checkParamNames": true, | ||
"requireParamTypes": true, | ||
"checkRedundantParams": true, | ||
"checkReturnTypes": true, | ||
"checkRedundantReturns": true, | ||
"requireReturnTypes": true, | ||
"checkTypes": "strictNativeCase", | ||
"checkRedundantAccess": true, | ||
"enforceExistence": true, | ||
"requireHyphenBeforeDescription": true | ||
}, | ||
"requireCurlyBraces": [ | ||
"if", | ||
"else", | ||
"for", | ||
"while", | ||
"do", | ||
"try", | ||
"catch" | ||
], | ||
"requireSpaceAfterKeywords": [ | ||
"if", | ||
"else", | ||
"for", | ||
"while", | ||
"do", | ||
"switch", | ||
"return", | ||
"try", | ||
"catch" | ||
], | ||
"requireSpaceBeforeBlockStatements": true, | ||
"requireParenthesesAroundIIFE": true, | ||
"requireSpacesInConditionalExpression": true, | ||
"requireSpacesInAnonymousFunctionExpression": { | ||
"beforeOpeningRoundBrace": true, | ||
"beforeOpeningCurlyBrace": true | ||
}, | ||
"requireSpacesInNamedFunctionExpression": { | ||
"beforeOpeningRoundBrace": true, | ||
"beforeOpeningCurlyBrace": true | ||
}, | ||
"requireSpacesInFunctionExpression": { | ||
"beforeOpeningCurlyBrace": true | ||
}, | ||
"requireBlocksOnNewline": true, | ||
"disallowPaddingNewlinesInBlocks": true, | ||
"disallowEmptyBlocks": true, | ||
"disallowSpacesInsideObjectBrackets": true, | ||
"disallowSpacesInsideArrayBrackets": true, | ||
"disallowSpacesInsideParentheses": true, | ||
"requireSpacesInsideObjectBrackets": "all", | ||
"disallowDanglingUnderscores": true, | ||
"disallowSpaceAfterObjectKeys": true, | ||
"requireCommaBeforeLineBreak": true, | ||
"requireOperatorBeforeLineBreak": [ | ||
"?", | ||
"+", | ||
"-", | ||
"/", | ||
"*", | ||
"=", | ||
"==", | ||
"===", | ||
"!=", | ||
"!==", | ||
">", | ||
">=", | ||
"<", | ||
"<=" | ||
], | ||
"requireSpaceBeforeBinaryOperators": [ | ||
"+", | ||
"-", | ||
"/", | ||
"*", | ||
"=", | ||
"==", | ||
"===", | ||
"!=", | ||
"!==" | ||
], | ||
"requireSpaceAfterBinaryOperators": [ | ||
"+", | ||
"-", | ||
"/", | ||
"*", | ||
"=", | ||
"==", | ||
"===", | ||
"!=", | ||
"!==" | ||
], | ||
"disallowSpaceAfterPrefixUnaryOperators": [ | ||
"++", | ||
"--", | ||
"+", | ||
"-", | ||
"~", | ||
"!" | ||
], | ||
"disallowSpaceBeforePostfixUnaryOperators": [ | ||
"++", | ||
"--" | ||
], | ||
"disallowImplicitTypeConversion": [ | ||
"numeric", | ||
"boolean", | ||
"binary", | ||
"string" | ||
], | ||
"requireCamelCaseOrUpperCaseIdentifiers": true, | ||
"disallowKeywords": [ | ||
"with" | ||
], | ||
"disallowMultipleLineStrings": true, | ||
"disallowMultipleLineBreaks": true, | ||
"validateLineBreaks": "LF", | ||
"validateQuoteMarks": "'", | ||
"disallowMixedSpacesAndTabs": true, | ||
"disallowTrailingWhitespace": true, | ||
"disallowTrailingComma": true, | ||
"disallowKeywordsOnNewLine": [ | ||
"else" | ||
], | ||
"requireLineFeedAtFileEnd": true, | ||
"maximumLineLength": 78, | ||
"requireCapitalizedConstructors": true, | ||
"safeContextKeyword": "self", | ||
"requireDotNotation": true, | ||
"disallowYodaConditions": true, | ||
"validateJSDoc": { | ||
"checkParamNames": true, | ||
"checkRedundantParams": true, | ||
"requireParamTypes": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.* | ||
*.log | ||
bower_components/ | ||
build/ | ||
components/ | ||
coverage/ | ||
node_modules/ | ||
test/ | ||
build.js | ||
example.js | ||
mdast-toc.js | ||
mdast-toc.min.js | ||
bower.json | ||
component.json | ||
History.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
language: node_js | ||
script: npm run-script test-travis | ||
node_js: | ||
- '0.10' | ||
- '0.11' | ||
after_script: npm install coveralls@2.10.0 && cat ./coverage/lcov.info | coveralls | ||
deploy: | ||
provider: npm | ||
email: tituswormer@gmail.com | ||
api_key: | ||
secure: CNwyO4JhCmy3/XIDifXy1BuHuvrTZsnYoXXzm9CKt/mDg/29ZIRJlDCj/XNRcFl/mtq5KIzaYbaJKtSf+fm6pB1GD8RloFW9DAt04QNYW/VHCeoHcg1iag2znjmreTco2TpTqzQP2P820ZxqipVtJbQsK3R6W3tQvGDzSi5Mw2M= | ||
on: | ||
repo: wooorm/mdast-toc |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
(The MIT License) | ||
|
||
Copyright (c) 2015 Titus Wormer <tituswormer@gmail.com> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
'Software'), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
# mdast-toc [![Build Status](https://img.shields.io/travis/wooorm/mdast-toc.svg?style=flat)](https://travis-ci.org/wooorm/mdast-toc) [![Coverage Status](https://img.shields.io/coveralls/wooorm/mdast-toc.svg?style=flat)](https://coveralls.io/r/wooorm/mdast-toc?branch=master) | ||
|
||
Generate a Table of Contents (TOC) for [Markdown](http://daringfireball.net/projects/markdown/syntax) files with [mdast](https://github.com/wooorm/mdast). | ||
|
||
## Installation | ||
|
||
[npm](https://docs.npmjs.com/cli/install): | ||
|
||
```bash | ||
$ npm install mdast-toc | ||
``` | ||
|
||
[Component.js](https://github.com/componentjs/component): | ||
|
||
```bash | ||
$ component install wooorm/mdast-toc | ||
``` | ||
|
||
[Bower](http://bower.io/#install-packages): | ||
|
||
```bash | ||
$ bower install mdast-toc | ||
``` | ||
|
||
[Duo](http://duojs.org/#getting-started): | ||
|
||
```javascript | ||
var toc = require('wooorm/mdast-toc'); | ||
``` | ||
|
||
UMD (globals/AMD/CommonJS) ([uncompressed](mdast-toc.js) and [compressed](mdast-toc.min.js)): | ||
|
||
```html | ||
<script src="path/to/mdast.js"></script> | ||
<script src="path/to/mdast-toc.js"></script> | ||
<script> | ||
mdast.use(mdastTOC); | ||
</script> | ||
``` | ||
|
||
## Table of Contents | ||
|
||
- [Usage](#usage) | ||
- [API](#api) | ||
- [mdast.use(toc)](#mdastusetoc) | ||
- [CLI](#cli) | ||
- [License](#license) | ||
|
||
## Usage | ||
|
||
Require/read dependencies: | ||
|
||
```javascript | ||
var toc = require('mdast-toc'); | ||
var fs = require('fs'); | ||
var mdast = require('mdast').use(toc); | ||
var readme = fs.readFileSync('Readme.md', 'utf-8'); | ||
``` | ||
|
||
Parse markdown (this TOC is the 14th child). | ||
|
||
```javascript | ||
var contents = mdast.parse(readme).children[14]; | ||
``` | ||
|
||
Stringify: | ||
|
||
```javascript | ||
var doc = mdast.stringify(contents); | ||
``` | ||
|
||
Yields: | ||
|
||
```markdown | ||
- [Usage](#usage) | ||
- [API](#api) | ||
- [mdast.use(toc)](#mdastusetoc) | ||
- [CLI](#cli) | ||
- [License](#license) | ||
``` | ||
|
||
## API | ||
|
||
### [mdast](https://github.com/wooorm/mdast#api).[use](https://github.com/wooorm/mdast#mdastuseplugin)(toc) | ||
|
||
Adds a [Table of Contents](#table-of-contents) to a Markdown document. | ||
|
||
- Looks for the first heading containing `"Table of Contents"`, `"toc"`, or `table-of-contents` (case insensitive, supports alt/title attributes for links and images too); | ||
- Removes all following contents until an equal or higher heading is found; | ||
- Inserts a list representation of the hierarchy of following headings; | ||
- Adds links to following headings, using the same slugs as GitHub. | ||
|
||
## CLI | ||
|
||
A simple wrapper around `mdast --use mdast-toc`. | ||
|
||
Install: | ||
|
||
```bash | ||
$ npm install --global mdast-toc | ||
``` | ||
|
||
Use: | ||
|
||
```text | ||
Usage: mdast-toc [mdast options] | ||
Remove markdown formatting | ||
Options: | ||
-h, --help output usage information | ||
-v, --version output version number | ||
A wrapper around `mdast --use mdast-toc` | ||
Help for mdast: | ||
https://github.com/wooorm/mdast | ||
Usage: | ||
# Pass `Readme.md` through mdast-toc | ||
$ mdast-toc Readme.md -o Readme.md | ||
# Pass stdin through mdast-toc, with mdast options, and write to stdout | ||
$ cat Docs.md | mdast-toc --option setext > Docs-new.md | ||
# Use other plugins | ||
$ npm install mdast-usage | ||
$ mdast-toc --use mdast-usage Readme.md | ||
``` | ||
|
||
## License | ||
|
||
[MIT](LICENSE) © [Titus Wormer](http://wooorm.com) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"name": "mdast-toc", | ||
"main": "mdast-toc.js", | ||
"description": "Generate a Table of Contents (TOC) for Markdown files", | ||
"license": "MIT", | ||
"keywords": [ | ||
"text", | ||
"markdown", | ||
"plain", | ||
"text", | ||
"table", | ||
"of", | ||
"contents", | ||
"content", | ||
"toc", | ||
"generation", | ||
"mdast" | ||
], | ||
"dependencies": { | ||
"slug": "^0.8.0" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/wooorm/mdast-toc.git" | ||
}, | ||
"authors": [ | ||
"Titus Wormer <tituswormer@gmail.com>" | ||
], | ||
"ignore": [ | ||
".*", | ||
"*.log", | ||
"*.md", | ||
"build/", | ||
"components/", | ||
"coverage/", | ||
"node_modules/", | ||
"test/", | ||
"build.js", | ||
"cli.js", | ||
"example.js", | ||
"index.js", | ||
"component.json", | ||
"package.json" | ||
] | ||
} |
Oops, something went wrong.