@technote-space/anchor-markdown-header
Advanced tools
Comparing version 1.1.3 to 1.1.4
@@ -9,3 +9,3 @@ "use strict"; | ||
// https://github.com/joyent/node/blob/192192a09e2d2e0d6bdd0934f602d2dbbf10ed06/tools/doc/html.js#L172-L183 | ||
exports.getNodejsId = (text, repetition) => { | ||
const getNodejsId = (text, repetition) => { | ||
text = text.replace(/[^a-z0-9]+/g, '_'); | ||
@@ -21,3 +21,4 @@ text = text.replace(/^_+|_+$/, ''); | ||
}; | ||
exports.getBasicGithubId = (text) => { | ||
exports.getNodejsId = getNodejsId; | ||
const getBasicGithubId = (text) => { | ||
return text | ||
@@ -35,3 +36,4 @@ // numeric character references | ||
}; | ||
exports.getGithubId = (text, repetition) => { | ||
exports.getBasicGithubId = getBasicGithubId; | ||
const getGithubId = (text, repetition) => { | ||
text = exports.getBasicGithubId(text); | ||
@@ -46,3 +48,4 @@ // If no repetition, or if the repetition is 0 then ignore. Otherwise append '-' and the number. | ||
}; | ||
exports.getBitbucketId = (text, repetition) => { | ||
exports.getGithubId = getGithubId; | ||
const getBitbucketId = (text, repetition) => { | ||
text = 'markdown-header-' + exports.getBasicGithubId(text); | ||
@@ -58,3 +61,4 @@ // BitBucket condenses consecutive hyphens (GitHub doesn't) | ||
}; | ||
exports.getBasicGhostId = (text) => { | ||
exports.getBitbucketId = getBitbucketId; | ||
const getBasicGhostId = (text) => { | ||
return text.replace(/ /g, '') | ||
@@ -69,3 +73,4 @@ // escape codes are not removed | ||
}; | ||
exports.getGhostId = (text) => { | ||
exports.getBasicGhostId = getBasicGhostId; | ||
const getGhostId = (text) => { | ||
text = exports.getBasicGhostId(text); | ||
@@ -75,4 +80,5 @@ // Repetitions not supported | ||
}; | ||
exports.getGhostId = getGhostId; | ||
// see: https://github.com/gitlabhq/gitlabhq/blob/master/doc/user/markdown.md#header-ids-and-links | ||
exports.getGitlabId = (text, repetition) => { | ||
const getGitlabId = (text, repetition) => { | ||
text = text | ||
@@ -94,3 +100,4 @@ .replace(/<(.*)>(.*)<\/\1>/g, '$2') // html tags | ||
}; | ||
exports.getReplaceMethod = (mode, repetition, moduleName) => { | ||
exports.getGitlabId = getGitlabId; | ||
const getReplaceMethod = (mode, repetition, moduleName) => { | ||
switch (mode) { | ||
@@ -116,3 +123,4 @@ case 'github.com': | ||
}; | ||
exports.getEncodeUriMethod = (mode) => { | ||
exports.getReplaceMethod = getReplaceMethod; | ||
const getEncodeUriMethod = (mode) => { | ||
if (mode === 'github.com') { | ||
@@ -129,3 +137,4 @@ return (uri) => { | ||
}; | ||
exports.getUrlHash = (header, mode, repetition, moduleName) => { | ||
exports.getEncodeUriMethod = getEncodeUriMethod; | ||
const getUrlHash = (header, mode, repetition, moduleName) => { | ||
const asciiOnlyToLowerCase = (input) => { | ||
@@ -145,3 +154,5 @@ let result = ''; | ||
}; | ||
exports.anchor = (header, mode, repetition, moduleName) => '[' + header + '](#' + exports.getUrlHash(header, mode || 'github.com', repetition, moduleName) + ')'; | ||
exports.getUrlHash = getUrlHash; | ||
const anchor = (header, mode, repetition, moduleName) => '[' + header + '](#' + exports.getUrlHash(header, mode || 'github.com', repetition, moduleName) + ')'; | ||
exports.anchor = anchor; | ||
exports.default = exports.anchor; |
{ | ||
"name": "@technote-space/anchor-markdown-header", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "Generates an anchor for a markdown header.", | ||
@@ -50,12 +50,12 @@ "keywords": [ | ||
"@types/jest": "^26.0.15", | ||
"@types/node": "^14.14.7", | ||
"@typescript-eslint/eslint-plugin": "^4.8.0", | ||
"@typescript-eslint/parser": "^4.8.0", | ||
"eslint": "^7.13.0", | ||
"@types/node": "^14.14.10", | ||
"@typescript-eslint/eslint-plugin": "^4.9.0", | ||
"@typescript-eslint/parser": "^4.9.0", | ||
"eslint": "^7.14.0", | ||
"husky": "^4.3.0", | ||
"jest": "^26.6.3", | ||
"jest-circus": "^26.6.3", | ||
"lint-staged": "^10.5.1", | ||
"lint-staged": "^10.5.2", | ||
"ts-jest": "^26.4.4", | ||
"typescript": "^4.0.5" | ||
"typescript": "^4.1.2" | ||
}, | ||
@@ -62,0 +62,0 @@ "publishConfig": { |
12808
159