Markdown Body
GitHub-style typography for rendered markdown content with automatic theme support
Markdown Body
The .markdown-body class provides GitHub-style typography for rendered markdown content. It uses marked.js to parse markdown and automatically adapts to DuskMoonUI themes.
Live Demo
See how markdown is rendered with the .markdown-body class. Toggle between Preview, Markdown, and HTML tabs:
Complete Markdown Example
A full markdown document demonstrating all supported elements
Project Documentation
Welcome to the project! This document demonstrates all supported markdown elements.
Getting Started
Install the package using your preferred package manager:
npm install @duskmoon-dev/core
Then import the CSS in your stylesheet:
@import "@duskmoon-dev/core";
Features
Here's what this component supports:
- Typography: Headings, paragraphs, bold, italic, strikethrough
- Lists: Ordered, unordered, and nested lists
- Code: Inline
codeand code blocks - Tables: With header styling and zebra striping
- Blockquotes: For callouts and citations
Code Example
Use the useState hook for state management:
function Counter() {
const [count, setCount] = useState(0);
return <button onClick={() => setCount(count + 1)}>{count}</button>;
}
API Reference
| Method | Description | Returns |
|---|---|---|
init() |
Initialize the library | void |
configure(options) |
Set configuration | Config |
destroy() |
Clean up resources | void |
Note: Remember to call
destroy()when unmounting to prevent memory leaks.
Last updated: January 2026
# Project Documentation
Welcome to the project! This document demonstrates **all supported markdown elements**.
## Getting Started
Install the package using your preferred package manager:
```bash
npm install @duskmoon-dev/core
```
Then import the CSS in your stylesheet:
```css
@import "@duskmoon-dev/core";
```
## Features
Here's what this component supports:
- **Typography**: Headings, paragraphs, bold, italic, strikethrough
- **Lists**: Ordered, unordered, and nested lists
- **Code**: Inline `code` and code blocks
- **Tables**: With header styling and zebra striping
- **Blockquotes**: For callouts and citations
### Code Example
Use the `useState` hook for state management:
```javascript
function Counter() {
const [count, setCount] = useState(0);
return <button onClick={() => setCount(count + 1)}>{count}</button>;
}
```
### API Reference
| Method | Description | Returns |
|--------|-------------|---------|
| `init()` | Initialize the library | void |
| `configure(options)` | Set configuration | Config |
| `destroy()` | Clean up resources | void |
> **Note:** Remember to call `destroy()` when unmounting to prevent memory leaks.
---
*Last updated: January 2026*<article class="markdown-body">
<h1>Project Documentation</h1>
<p>Welcome to the project! This document demonstrates <strong>all supported markdown elements</strong>.</p>
<h2>Getting Started</h2>
<p>Install the package using your preferred package manager:</p>
<pre><code class="language-bash">npm install @duskmoon-dev/core
</code></pre>
<p>Then import the CSS in your stylesheet:</p>
<pre><code class="language-css">@import "@duskmoon-dev/core";
</code></pre>
<h2>Features</h2>
<p>Here's what this component supports:</p>
<ul>
<li><strong>Typography</strong>: Headings, paragraphs, bold, italic, strikethrough</li>
<li><strong>Lists</strong>: Ordered, unordered, and nested lists</li>
<li><strong>Code</strong>: Inline <code>code</code> and code blocks</li>
<li><strong>Tables</strong>: With header styling and zebra striping</li>
<li><strong>Blockquotes</strong>: For callouts and citations</li>
</ul>
<h3>Code Example</h3>
<p>Use the <code>useState</code> hook for state management:</p>
<pre><code class="language-javascript">function Counter() {
const [count, setCount] = useState(0);
return <button onClick={() => setCount(count + 1)}>{count}</button>;
}
</code></pre>
<h3>API Reference</h3>
<table>
<thead>
<tr>
<th>Method</th>
<th>Description</th>
<th>Returns</th>
</tr>
</thead>
<tbody><tr>
<td><code>init()</code></td>
<td>Initialize the library</td>
<td>void</td>
</tr>
<tr>
<td><code>configure(options)</code></td>
<td>Set configuration</td>
<td>Config</td>
</tr>
<tr>
<td><code>destroy()</code></td>
<td>Clean up resources</td>
<td>void</td>
</tr>
</tbody></table>
<blockquote>
<p><strong>Note:</strong> Remember to call <code>destroy()</code> when unmounting to prevent memory leaks.</p>
</blockquote>
<hr>
<p><em>Last updated: January 2026</em></p>
</article>Typography
Headings
Headings
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
# Heading 1
## Heading 2
### Heading 3
#### Heading 4
##### Heading 5
###### Heading 6<article class="markdown-body">
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
</article>Text Formatting
Text Formatting
Regular paragraph text with bold, italic, and bold italic formatting.
You can also use strikethrough for deleted text.
This has a link and some inline code.
Regular paragraph text with **bold**, *italic*, and ***bold italic*** formatting.
You can also use ~~strikethrough~~ for deleted text.
This has a [link](https://example.com) and some `inline code`.<article class="markdown-body">
<p>Regular paragraph text with <strong>bold</strong>, <em>italic</em>, and <em><strong>bold italic</strong></em> formatting.</p>
<p>You can also use <del>strikethrough</del> for deleted text.</p>
<p>This has a <a href="https://example.com">link</a> and some <code>inline code</code>.</p>
</article>Lists
Unordered Lists
Unordered Lists
- First item
- Second item
- Nested item
- Another nested item
- Deep nested item
- Third item
- First item
- Second item
- Nested item
- Another nested item
- Deep nested item
- Third item<article class="markdown-body">
<ul>
<li>First item</li>
<li>Second item</li>
<li>Nested item</li>
<li>Another nested item<ul>
<li>Deep nested item</li>
</ul>
</li>
<li>Third item</li>
</ul>
</article>Ordered Lists
Ordered Lists
- First step
- Second step
- Sub-step a
- Sub-step b
- Third step
1. First step
2. Second step
1. Sub-step a
2. Sub-step b
3. Third step<article class="markdown-body">
<ol>
<li>First step</li>
<li>Second step</li>
<li>Sub-step a</li>
<li>Sub-step b</li>
<li>Third step</li>
</ol>
</article>Code
Inline Code
Inline Code
Use the npm install command to install dependencies.
The useState hook returns a [state, setState] pair.
Use the `npm install` command to install dependencies.
The `useState` hook returns a `[state, setState]` pair.<article class="markdown-body">
<p>Use the <code>npm install</code> command to install dependencies.</p>
<p>The <code>useState</code> hook returns a <code>[state, setState]</code> pair.</p>
</article>Code Blocks
Code Blocks
function greet(name) {
console.log(`Hello, ${name}!`);
}
greet('World');
```javascript
function greet(name) {
console.log(`Hello, ${name}!`);
}
greet('World');
```<article class="markdown-body">
<pre><code class="language-javascript">function greet(name) {
console.log(`Hello, ${name}!`);
}
greet('World');
</code></pre>
</article>Tables
Tables
| Method | Description | Returns |
|---|---|---|
init() |
Initialize the library | void |
configure() |
Set configuration options | Config |
destroy() |
Clean up resources | void |
| Method | Description | Returns |
|--------|-------------|---------|
| `init()` | Initialize the library | void |
| `configure()` | Set configuration options | Config |
| `destroy()` | Clean up resources | void |<article class="markdown-body">
<table>
<thead>
<tr>
<th>Method</th>
<th>Description</th>
<th>Returns</th>
</tr>
</thead>
<tbody><tr>
<td><code>init()</code></td>
<td>Initialize the library</td>
<td>void</td>
</tr>
<tr>
<td><code>configure()</code></td>
<td>Set configuration options</td>
<td>Config</td>
</tr>
<tr>
<td><code>destroy()</code></td>
<td>Clean up resources</td>
<td>void</td>
</tr>
</tbody></table>
</article>Blockquotes
Blockquotes
This is a blockquote. It can contain multiple paragraphs.
Here's the second paragraph with bold text.
> This is a blockquote. It can contain multiple paragraphs.
>
> Here's the second paragraph with **bold** text.<article class="markdown-body">
<blockquote>
<p>This is a blockquote. It can contain multiple paragraphs.</p>
<p>Here's the second paragraph with <strong>bold</strong> text.</p>
</blockquote>
</article>Nested Blockquotes
Nested Blockquotes
Outer blockquote.
Nested blockquote with more context.
> Outer blockquote.
>
> > Nested blockquote with more context.<article class="markdown-body">
<blockquote>
<p>Outer blockquote.</p>
<blockquote>
<p>Nested blockquote with more context.</p>
</blockquote>
</blockquote>
</article>Horizontal Rules
Horizontal Rules
Content above the rule.
Content below the rule.
Content above the rule.
---
Content below the rule.<article class="markdown-body">
<p>Content above the rule.</p>
<hr>
<p>Content below the rule.</p>
</article>Images
Images
<article class="markdown-body">
<figure>
<img src="https://picsum.photos/600/300" alt="Sample image">
<figcaption>An example image with caption</figcaption>
</figure>
</article>Additional HTML Elements
These elements require HTML in your markdown or a markdown processor that supports them:
Keyboard Input
Keyboard Input
Press Ctrl + C to copy.
Use Cmd + Shift + P to open the command palette.
<article class="markdown-body">
<p>Press <kbd>Ctrl</kbd> + <kbd>C</kbd> to copy.</p>
<p>Use <kbd>Cmd</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd> to open the command palette.</p>
</article>Abbreviations
Abbreviations
The HTML specification is maintained by the W3C.
<article class="markdown-body">
<p>The <abbr title="HyperText Markup Language">HTML</abbr> specification is maintained by the <abbr title="World Wide Web Consortium">W3C</abbr>.</p>
</article>Highlights
Highlights
This is highlighted text for emphasis.
<article class="markdown-body">
<p>This is <mark>highlighted text</mark> for emphasis.</p>
</article>Details/Summary
Details/Summary
Click to expand
This is the hidden content that appears when expanded.
<article class="markdown-body">
<details>
<summary>Click to expand</summary>
<p>This is the hidden content that appears when expanded.</p>
</details>
</article>Usage
Import Options
Full Library:
@import "@duskmoon-dev/core";
Individual Component:
@import "@duskmoon-dev/core/components/markdown-body";
With marked.js
import { marked } from 'marked';
const markdown = `
# Hello World
Some **bold** text and \`inline code\`.
`;
// Render markdown to HTML
const html = marked(markdown);
// Apply to element with .markdown-body class
document.querySelector('.markdown-body').innerHTML = html;
With React
import { marked } from 'marked';
function MarkdownContent({ content }) {
const html = marked(content);
return (
<article
className="markdown-body"
dangerouslySetInnerHTML={{ __html: html }}
/>
);
}
With Astro
---
import { marked } from 'marked';
const markdown = `# Hello World`;
const html = await marked(markdown);
---
<article class="markdown-body" set:html={html} />
Container Sizing
For optimal readability, constrain the container width:
.markdown-body {
max-width: 980px;
margin-inline: auto;
padding-inline: 1rem;
}
Theme Support
The component automatically adapts to DuskMoonUI themes:
<!-- Light theme -->
<html data-theme="sunshine">
<article class="markdown-body">...</article>
</html>
<!-- Dark theme -->
<html data-theme="moonlight">
<article class="markdown-body">...</article>
</html>
Styled Elements Reference
| Element | Markdown Syntax | CSS Selector |
|---|---|---|
| Headings | # H1 to ###### H6 | h1 - h6 |
| Bold | **text** | strong |
| Italic | *text* | em |
| Strikethrough | ~~text~~ | del |
| Link | [text](url) | a |
| Inline Code | `code` | code |
| Code Block | ``` | pre > code |
| Unordered List | - item | ul > li |
| Ordered List | 1. item | ol > li |
| Blockquote | > quote | blockquote |
| Table | | a | b | | table |
| Horizontal Rule | --- | hr |
| Image |  | img |
Accessibility
- All colors use DuskMoonUI tokens that meet WCAG AA contrast requirements
- Focus states are clearly visible for keyboard navigation
- Reduced motion is respected via
prefers-reduced-motionmedia query - Semantic HTML elements are styled appropriately