Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mdast-util-heading-style

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mdast-util-heading-style - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

license

32

index.js

@@ -1,15 +0,13 @@

'use strict';
'use strict'
/* Expose. */
module.exports = style;
module.exports = style
/* Check the style of a heading. */
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;
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;
return null
}

@@ -23,17 +21,17 @@

if (pos.column - 1 <= depth * 2) {
return consolidate(depth, relative);
return consolidate(depth, relative)
}
return 'atx-closed';
return 'atx-closed'
}
if (final.line + 1 === pos.line) {
return 'setext';
return 'setext'
}
if (final.column + depth < pos.column) {
return 'atx-closed';
return 'atx-closed'
}
return consolidate(depth, relative);
return consolidate(depth, relative)
}

@@ -44,3 +42,7 @@

function consolidate(depth, relative) {
return depth < 3 ? 'atx' : relative === 'atx' || relative === 'setext' ? relative : null;
return depth < 3
? 'atx'
: relative === 'atx' || relative === 'setext'
? relative
: null
}
{
"name": "mdast-util-heading-style",
"version": "1.0.3",
"version": "1.0.4",
"description": "Utility to get the style of an mdast heading",

@@ -26,23 +26,31 @@ "license": "MIT",

"devDependencies": {
"browserify": "^14.0.0",
"esmangle": "^1.0.0",
"nyc": "^11.0.0",
"remark": "^7.0.0",
"remark-cli": "^3.0.0",
"remark-preset-wooorm": "^3.0.0",
"browserify": "^16.0.0",
"nyc": "^12.0.0",
"prettier": "^1.14.2",
"remark": "^9.0.0",
"remark-cli": "^5.0.0",
"remark-preset-wooorm": "^4.0.0",
"tape": "^4.4.0",
"xo": "^0.18.0"
"tinyify": "^2.4.3",
"xo": "^0.22.0"
},
"scripts": {
"build-md": "remark . --quiet --frail --output",
"build-bundle": "browserify index.js --no-builtins -s mdastUtilHeadingStyle > mdast-util-heading-style.js",
"build-mangle": "esmangle mdast-util-heading-style.js > mdast-util-heading-style.min.js",
"build": "npm run build-md && npm run build-bundle && npm run build-mangle",
"lint": "xo",
"test-api": "node test.js",
"format": "remark . -qfo && prettier --write '**/*.js' && xo --fix",
"build-bundle": "browserify . -s mdastUtilHeadingStyle > mdast-util-heading-style.js",
"build-mangle": "browserify . -s mdastUtilHeadingStyle -p tinyify > mdast-util-heading-style.min.js",
"build": "npm run build-bundle && npm run build-mangle",
"test-api": "node test",
"test-coverage": "nyc --reporter lcov tape test.js",
"test": "npm run build && npm run lint && npm run test-coverage"
"test": "npm run format && npm run build && npm run test-coverage"
},
"prettier": {
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"bracketSpacing": false,
"semi": false,
"trailingComma": "none"
},
"xo": {
"space": true,
"prettier": true,
"esnext": false,

@@ -49,0 +57,0 @@ "ignore": [

@@ -16,11 +16,11 @@ # mdast-util-heading-style [![Build Status][build-badge]][build-status] [![Coverage Status][coverage-badge]][coverage-status] [![Chat][chat-badge]][chat]

```js
var style = require('mdast-util-heading-style');
var remark = require('remark')();
var style = require('mdast-util-heading-style')
var remark = require('remark')()
style(remark.parse('# ATX').children[0]); // 'atx'
style(remark.parse('# ATX #\n').children[0]); // 'atx-closed'
style(remark.parse('ATX\n===').children[0]); // 'setext'
style(remark.parse('# ATX').children[0]) // => 'atx'
style(remark.parse('# ATX #\n').children[0]) // => 'atx-closed'
style(remark.parse('ATX\n===').children[0]) // => 'setext'
style(remark.parse('### ATX').children[0]); // null
style(remark.parse('### ATX').children[0], 'setext'); // 'setext'
style(remark.parse('### ATX').children[0]) // => null
style(remark.parse('### ATX').children[0], 'setext') // => 'setext'
```

@@ -45,2 +45,10 @@

## Contribute
See [`contributing.md` in `syntax-tree/mdast`][contributing] for ways to get
started.
This organisation has a [Code of Conduct][coc]. By interacting with this
repository, organisation, or community you agree to abide by its terms.
## License

@@ -64,3 +72,3 @@

[license]: LICENSE
[license]: license

@@ -74,1 +82,5 @@ [author]: http://wooorm.com

[node]: https://github.com/syntax-tree/unist#node
[contributing]: https://github.com/syntax-tree/mdast/blob/master/contributing.md
[coc]: https://github.com/syntax-tree/mdast/blob/master/code-of-conduct.md
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc