mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-26 07:25:20 +00:00
strip links
This commit is contained in:
@@ -18,6 +18,10 @@ function walk(dir) {
|
||||
return results;
|
||||
}
|
||||
|
||||
function stripLinks(line) {
|
||||
return line.replace(/\[([^\]]+)\]\([^)]+\)/, (match, p1) => p1);
|
||||
}
|
||||
|
||||
function addHeaderID(line, slugger) {
|
||||
// check if we're a header at all
|
||||
if (!line.startsWith('#')) {
|
||||
@@ -27,7 +31,10 @@ function addHeaderID(line, slugger) {
|
||||
if (/\{#[^}]+\}/.test(line)) {
|
||||
return line;
|
||||
}
|
||||
const headingText = line.slice(line.indexOf(' ')).trim();
|
||||
if (/\[[^\]]+\]/.test(line)) {
|
||||
console.log(line);
|
||||
}
|
||||
const headingText = stripLinks(line.slice(line.indexOf(' ')).trim());
|
||||
const headingLevel = line.slice(0, line.indexOf(' '));
|
||||
return `${headingLevel} ${headingText} {#${slugger.slug(headingText)}}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user