Merge branch 'test-markdown'

This commit is contained in:
Chris Wanstrath 2026-02-20 12:17:17 -08:00
commit 3c1f42e985
2 changed files with 119 additions and 31 deletions

View File

@ -1,34 +1,6 @@
import { renderMarkdown } from "./markdown"
const lines = [
"This is **bold** text",
"This is *italic* text",
"This is `inline code` text",
"Mix of **bold**, *italic*, and `code` in one line",
"**bold with `code` inside** bold",
"No markdown here",
"Multiple **bold one** and **bold two**",
"Nested-ish: **bold and *italic* together**",
]
const file = Bun.file("test/MARKDOWN.md")
const content = await file.text()
for (const line of lines) {
console.log(` ${line}`)
console.log(` ${renderMarkdown(line)}`)
console.log()
}
// Code fence tests
console.log("--- Code fence tests ---")
const fenceTests = [
"Here is some code:\n```typescript\nconst x = 1\n```\nDone.",
"```\nhello\n```",
"```js\nconsole.log('hi')\n```",
]
for (const test of fenceTests) {
console.log("INPUT:")
console.log(test)
console.log("OUTPUT:")
console.log(renderMarkdown(test))
console.log()
}
console.log(renderMarkdown(content))

116
test/MARKDOWN.md Normal file
View File

@ -0,0 +1,116 @@
# Test Markdown Document
This document exercises a variety of Markdown features for testing purposes.
## Inline Formatting
This is **bold**, this is *italic*, and this is ***bold italic***.
Here is `inline code` and ~~strikethrough~~ text.
## Links and Images
- [Example Link](https://example.com)
- [Link with title](https://example.com "Example Title")
- ![Alt text for image](https://via.placeholder.com/150)
## Lists
### Unordered
- Item one
- Item two
- Nested item A
- Nested item B
- Deep nested
- Item three
### Ordered
1. First
2. Second
3. Third
1. Sub-item
2. Sub-item
### Task List
- [x] Completed task
- [ ] Incomplete task
- [ ] Another incomplete task
## Blockquotes
> This is a blockquote.
>
> > This is a nested blockquote.
## Code Blocks
Inline: `console.log("hello")`
Fenced with language:
```typescript
function greet(name: string): string {
return `Hello, ${name}!`;
}
```
Fenced without language:
```
plain code block
no syntax highlighting
```
Indented code block:
four spaces
makes a code block
## Tables
| Left | Center | Right |
|:-----|:------:|------:|
| A1 | B1 | C1 |
| A2 | B2 | C2 |
| A3 | B3 | C3 |
## Horizontal Rules
---
***
___
## HTML (inline)
<details>
<summary>Click to expand</summary>
Hidden content inside a details block.
</details>
## Escapes and Special Characters
\*not italic\* and \`not code\`
Ampersand: &amp; | Less than: &lt; | Greater than: &gt;
## Footnotes
Here is a sentence with a footnote[^1].
[^1]: This is the footnote content.
## Heading Levels
### H3
#### H4
##### H5
###### H6