uniorg-slug
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -18,4 +18,6 @@ "use strict"; | ||
const props = (data.hProperties = data.hProperties || {}); | ||
const id = (_a = customId(node)) !== null && _a !== void 0 ? _a : slugger.slug(orgast_util_to_string_1.toString(node.title)); | ||
props.id = id; | ||
if (!props.id) { | ||
const id = (_a = customId(node)) !== null && _a !== void 0 ? _a : slugger.slug(orgast_util_to_string_1.toString(node.title)); | ||
props.id = id; | ||
} | ||
}); | ||
@@ -22,0 +24,0 @@ } |
@@ -18,3 +18,3 @@ "use strict"; | ||
}; | ||
describe('uniorg-extract-keywords', () => { | ||
describe('uniorg-slug', () => { | ||
test('does not crash on empty document', () => { | ||
@@ -65,3 +65,17 @@ const document = ``; | ||
}); | ||
test('preserves data.hProperties.id', () => { | ||
const processor = unified_1.default() | ||
.use(uniorg_parse_1.default) | ||
.use(() => (node) => { | ||
const headline = unist_util_find_1.default(node, { type: 'headline' }); | ||
headline.data = { hProperties: { id: 'my-custom-id' } }; | ||
}) | ||
.use(_1.uniorgSlug) | ||
.use(uniorg_rehype_1.default) | ||
.use(rehype_stringify_1.default); | ||
const document = `* some headline`; | ||
const s = processor.processSync(document).contents; | ||
expect(s).toMatchInlineSnapshot(`"<h1 id=\\"my-custom-id\\">some headline</h1>"`); | ||
}); | ||
}); | ||
//# sourceMappingURL=index.spec.js.map |
{ | ||
"name": "uniorg-slug", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "uniorg plugin to add `id` attributes to headlines", | ||
@@ -54,7 +54,7 @@ "keywords": [ | ||
"uniorg-parse": "^0.2.1", | ||
"uniorg-rehype": "^0.2.1", | ||
"uniorg-rehype": "^0.2.2", | ||
"unist-util-find": "^1.0.2", | ||
"vfile": "^4.2.1" | ||
}, | ||
"gitHead": "6497e86a0baea4535ba58ab58579575d54b3c1f2" | ||
"gitHead": "38e111005635ffb1b92392dac4c3d8913aaddb64" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
46534
117