-
-
Notifications
You must be signed in to change notification settings - Fork 1
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 4fea402
Showing
18 changed files
with
680 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,15 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 4 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.{json,html,svg,css,mdastrc,eslintrc}] | ||
indent_size = 2 | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
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,6 @@ | ||
build/ | ||
components/ | ||
coverage/ | ||
build.js | ||
mdast-util-heading-style.js | ||
mdast-util-heading-style.min.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,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,152 @@ | ||
{ | ||
"excludeFiles": [ | ||
"build/", | ||
"components/", | ||
"coverage/", | ||
"node_modules/", | ||
"build.js", | ||
"mdast-util-heading-style.js", | ||
"mdast-util-heading-style.min.js" | ||
], | ||
"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,2 @@ | ||
bower_components/ | ||
components/ |
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,10 @@ | ||
{ | ||
"plugins": [ | ||
"lint", | ||
"github", | ||
"yaml-config" | ||
], | ||
"settings": { | ||
"bullet": "*" | ||
} | ||
} |
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 @@ | ||
language: node_js | ||
script: npm run-script test-travis | ||
node_js: | ||
- '0.10' | ||
- '0.11' | ||
- '0.12' | ||
- iojs | ||
sudo: false | ||
after_script: npm install coveralls@2.10.0 && cat ./coverage/lcov.info | coveralls |
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,36 @@ | ||
{ | ||
"name": "mdast-util-heading-style", | ||
"main": "mdast-util-heading-style.js", | ||
"description": "Utility to get the style of a heading.", | ||
"license": "MIT", | ||
"keywords": [ | ||
"mdast", | ||
"markdown", | ||
"node", | ||
"heading", | ||
"style", | ||
"util", | ||
"utility" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/wooorm/mdast-util-heading-style.git" | ||
}, | ||
"authors": [ | ||
"Titus Wormer <tituswormer@gmail.com>" | ||
], | ||
"ignore": [ | ||
".*", | ||
"*.log", | ||
"*.md", | ||
"build/", | ||
"components/", | ||
"coverage/", | ||
"node_modules/", | ||
"build.js", | ||
"index.js", | ||
"test.js", | ||
"component.json", | ||
"package.json" | ||
] | ||
} |
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,19 @@ | ||
{ | ||
"name": "mdast-util-heading-style", | ||
"version": "0.1.0", | ||
"description": "Utility to get the style of a heading.", | ||
"license": "MIT", | ||
"keywords": [ | ||
"mdast", | ||
"markdown", | ||
"node", | ||
"heading", | ||
"style", | ||
"util", | ||
"utility" | ||
], | ||
"repository": "wooorm/mdast-util-heading-style", | ||
"scripts": [ | ||
"index.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,6 @@ | ||
--- | ||
mdast: | ||
setext: true | ||
--- | ||
|
||
<!--lint disable no-multiple-toplevel-headings--> |
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,78 @@ | ||
/** | ||
* @author Titus Wormer | ||
* @copyright 2015 Titus Wormer. All rights reserved. | ||
* @module mdast-util-heading-style | ||
* @fileoverview Utility to get the style of a heading. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
/** | ||
* Get the probable style of an atx-heading, depending on | ||
* preferred style. | ||
* | ||
* @example | ||
* consolidate(1, 'setext') // 'atx' | ||
* consolidate(1, 'atx') // 'atx' | ||
* consolidate(3, 'setext') // 'setext' | ||
* consolidate(3, 'atx') // 'atx' | ||
* | ||
* @param {number} depth | ||
* @param {string?} relative | ||
* @return {string?} - Type. | ||
*/ | ||
function consolidate(depth, relative) { | ||
return depth < 3 ? 'atx' : | ||
relative === 'atx' || relative === 'setext' ? relative : null; | ||
} | ||
|
||
/** | ||
* Check the style of a heading. | ||
* | ||
* @param {Node} node | ||
* @param {string?} relative - Heading type which we'd wish | ||
* this to be. | ||
* @return {string?} - Type, either `'atx-closed'`, | ||
* `'atx'`, or `'setext'`. | ||
*/ | ||
function style(node, relative) { | ||
var last = node.children[node.children.length - 1]; | ||
var depth = node.depth; | ||
var pos = node && node.position && node.position.end; | ||
var final = last && last.position && last.position.end; | ||
|
||
if (!pos) { | ||
return null; | ||
} | ||
|
||
/* | ||
* This can only occur for atx and `'atx-closed'` | ||
* headings. This might incorrectly match `'atx'` | ||
* headings with lots of trailing white space as an | ||
* `'atx-closed'` heading. | ||
*/ | ||
|
||
if (!last) { | ||
if (pos.column - 1 <= depth * 2) { | ||
return consolidate(depth, relative); | ||
} | ||
|
||
return 'atx-closed'; | ||
} | ||
|
||
if (final.line + 1 === pos.line) { | ||
return 'setext'; | ||
} | ||
|
||
if (final.column + depth < pos.column) { | ||
return 'atx-closed'; | ||
} | ||
|
||
return consolidate(depth, relative); | ||
} | ||
|
||
/* | ||
* Expose. | ||
*/ | ||
|
||
module.exports = style; |
Oops, something went wrong.