-
-
Notifications
You must be signed in to change notification settings - Fork 36.2k
Generate .md files for docs HTML pages
#32660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| tempText = tempText | ||
| // Convert links (must be before stripping tags) | ||
| .replace(/<a[^>]*href="([^"]*)"[^>]*>([^<]*)<\/a>/g, '[$2]($1)') | ||
| // Convert code blocks | ||
| .replace(/<code>/g, '`') | ||
| .replace(/<\/code>/g, '`') | ||
| // Convert lists | ||
| .replace(/<li>/g, '- ') | ||
| .replace(/<\/li>/g, '\n') | ||
| .replace(/<ul>/g, '\n') | ||
| .replace(/<\/ul>/g, '\n') | ||
| .replace(/<ol>/g, '\n') | ||
| .replace(/<\/ol>/g, '\n') | ||
| // Convert paragraphs | ||
| .replace(/<p>/g, '') | ||
| .replace(/<\/p>/g, '\n\n') | ||
| // Convert breaks | ||
| .replace(/<br\s*\/?>/g, '\n') | ||
| // Convert strong/em | ||
| .replace(/<strong>/g, '**') | ||
| .replace(/<\/strong>/g, '**') | ||
| .replace(/<em>/g, '_') | ||
| .replace(/<\/em>/g, '_') | ||
| .replace(/<b>/g, '**') | ||
| .replace(/<\/b>/g, '**') | ||
| .replace(/<i>/g, '_') | ||
| .replace(/<\/i>/g, '_') | ||
| // Remove remaining HTML tags | ||
| .replace(/<[^>]+>/g, '') |
Check failure
Code scanning / CodeQL
Incomplete multi-character sanitization High documentation
<script
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code here isn't sanitization - besides that It's very possible that. a lot of this can actually be removed (or removed altogether if another solution like plugins like jsdoc-to-markdown are preferred)
|
Sufficient for the markdown files per html? Maybe - I've tried it with the plugin at first (similar to the script you shared) but the output also seems to need some postprocessing to remove HTML or use a handlebars template: e.g. here or: So I tried if directly writing markdown from jsdoc would be easier (which turned into this PR). Maybe the HTML in there is also totally fine - I'm not 100% sure. |
|
Closing in favor of #32673. |
Related issue: 31933
Description
This PR adds a plugin to JSDoc to produce markdown files alongside the existing
.htmldocumentation pages and allows to append.mdto docs URL hashes to open the markdown file. These files can then be used by LLMs to lookup information.Example
Open questions
llms.txtthat contains links to the individual markdown files (similar to svelte llms.txt or stripe's llms.txt - the Stripe documentation works the same way https://docs.stripe.com/building-with-llms#llmstxt whereas Svelte does append/llms.txte.g. https://svelte.dev/docs/svelte/what-are-runes/llms.txt).Motiviation:
I'm thinking about displaying some docs directly into the Needle Inspector extension or at least making it easier to query the relevant pages as markdown content when AI requests it.
This contribution is funded by Needle