Skip to content

Commit ad2de47

Browse files
raifdmuellerclaude
andcommitted
fix: Fix bold regex and SPA anchor link in adocToMarkdown
- Fix bold regex: require \S after opening * to prevent matching list markers (* item) as bold delimiters (* *!* → ** **!* was wrong) - Fix link:#/[...] → absolute website URL for standalone llms.txt context Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent d175c5b commit ad2de47

File tree

2 files changed

+591
-588
lines changed

2 files changed

+591
-588
lines changed

scripts/generate-llms-txt.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,12 @@ function adocToMarkdown(adoc) {
100100
// AsciiDoc line continuation (+) → remove
101101
md = md.replace(/^\+\s*$/gm, '')
102102

103-
// Links: link:url[text] → [text](url), resolve relative .adoc paths to GitHub URLs
103+
// Links: link:url[text] → [text](url), resolve special URLs for standalone context
104104
md = md.replace(/link:([^[]+)\[([^\]]*)\]/g, (_, url, text) => {
105105
if (/^\.\.\/.*\.adoc$/.test(url)) {
106106
url = 'https://github.com/LLM-Coding/Semantic-Anchors/blob/main/' + url.slice(3)
107+
} else if (url === '#/') {
108+
url = 'https://llm-coding.github.io/Semantic-Anchors/'
107109
}
108110
return `[${text}](${url})`
109111
})
@@ -126,7 +128,8 @@ function adocToMarkdown(adoc) {
126128
)
127129

128130
// Bold: **text** stays, *text* → **text**
129-
md = md.replace(/(?<![*\w])\*([^*\n]+)\*(?![*\w])/g, '**$1**')
131+
// Require non-whitespace after opening * to avoid matching list markers (* item)
132+
md = md.replace(/(?<![*\w])\*(\S[^*\n]*\S|\S)\*(?![*\w])/g, '**$1**')
130133

131134
// Ordered list items: ". item" → "1. item"
132135
md = md.replace(/^\. /gm, '1. ')

0 commit comments

Comments
 (0)