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

uniorg-slug

Package Overview
Dependencies
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uniorg-slug - npm Package Compare versions

Comparing version 0.4.8 to 0.5.0

29

lib/index.js

@@ -1,16 +0,9 @@

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.uniorgSlug = void 0;
const unist_util_visit_1 = __importDefault(require("unist-util-visit"));
const github_slugger_1 = __importDefault(require("github-slugger"));
const orgast_util_to_string_1 = require("orgast-util-to-string");
const uniorgSlug = (options = {}) => {
import { visit } from 'unist-util-visit';
import GithubSlugger from 'github-slugger';
import { toString } from 'orgast-util-to-string';
export const uniorgSlug = (options = {}) => {
return transformer;
function transformer(tree, _file) {
const slugger = new github_slugger_1.default();
unist_util_visit_1.default(tree, 'section', (section) => {
var _a;
const slugger = new GithubSlugger();
visit(tree, 'section', (section) => {
const headline = section.children[0];

@@ -20,3 +13,3 @@ const data = (headline.data = headline.data || {});

if (!props.id) {
const id = (_a = customId(section)) !== null && _a !== void 0 ? _a : slugger.slug(orgast_util_to_string_1.toString(headline));
const id = customId(section) ?? slugger.slug(toString(headline));
props.id = id;

@@ -27,10 +20,8 @@ }

};
exports.uniorgSlug = uniorgSlug;
function customId(section) {
var _a;
const drawer = section.children.find((node) => node.type === 'property-drawer');
const property = (_a = drawer === null || drawer === void 0 ? void 0 : drawer.children) === null || _a === void 0 ? void 0 : _a.find((node) => node.type === 'node-property' && node.key === 'CUSTOM_ID');
return property === null || property === void 0 ? void 0 : property.value;
const property = drawer?.children?.find((node) => node.type === 'node-property' && node.key === 'CUSTOM_ID');
return property?.value;
}
exports.default = exports.uniorgSlug;
export default uniorgSlug;
//# sourceMappingURL=index.js.map
{
"name": "uniorg-slug",
"version": "0.4.8",
"version": "0.5.0",
"type": "module",
"description": "uniorg plugin to add `id` attributes to headlines",

@@ -40,21 +41,20 @@ "keywords": [

"github-slugger": "^1.3.0",
"orgast-util-to-string": "^0.4.5",
"unist-util-visit": "^2.0.3"
"orgast-util-to-string": "^0.5.0",
"unist-util-visit": "4.1.0"
},
"devDependencies": {
"@types/github-slugger": "^1.3.0",
"@types/jest": "^26.0.23",
"@types/unist": "^2.0.3",
"@types/vfile": "^4.0.0",
"jest": "^26.6.3",
"rehype-stringify": "^8.0.0",
"typescript": "^4.3.2",
"unified": "^9.2.1",
"uniorg": "^0.4.0",
"uniorg-parse": "^0.4.5",
"uniorg-rehype": "^0.4.8",
"@types/jest": "27.4.1",
"@types/unist": "2.0.6",
"jest": "27.5.1",
"rehype-stringify": "9.0.3",
"typescript": "4.6.3",
"unified": "10.1.2",
"uniorg": "^0.5.0",
"uniorg-parse": "^0.5.0",
"uniorg-rehype": "^0.5.0",
"unist-util-find": "^1.0.2",
"vfile": "^4.2.1"
"vfile": "5.3.2"
},
"gitHead": "14f804eaedebff32e74004498baa4c7c30a823b4"
"gitHead": "e77afd8255895985eaa8b0cf15de8edab81a89b6"
}

@@ -11,7 +11,6 @@ # `uniorg-slug`

## Use
```js
import unified from 'unified';
import { unified } from 'unified';
import uniorgParse from 'uniorg-parse';

@@ -44,2 +43,3 @@ import { uniorgSlug } from 'uniorg-slug';

will output:
```

@@ -52,5 +52,4 @@ <h1 id="headline">headline</h1>

## License
[GNU General Public License v3.0 or later](./LICENSE)

Sorry, the diff of this file is not supported yet

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