Logo
Markdown and MDX demo

Markdown and MDX demo

Dec 13, 2024
4 min read

Welcome

This is a live demo of MDXEditor with all default features on.

The overriding design goal for Markdown’s formatting syntax is to make it as readable as possible. The idea is that a Markdown-formatted document should be publishable as-is, as plain text, without looking like it’s been marked up with tags or formatting instructions.

Daring Fireball

Supported markdown elements:

  • Headings
  • Lists
    • Unordered
    • Ordered
    • Check lists
    • Nested
  • Links
  • Bold, italic, and underline formatting
  • Tables
  • Code block editors
  • Math and diagrams

The editor content is styled using the @tailwindcss/typography plugin.

Test editor features

Use this space to test markdown rendering and editing behavior. Switch to source mode using the toggle in the top right, paste markdown content, and toggle back to rich text mode.

Things you can try:

  1. Add your own code sample
  2. Change heading levels
  3. Insert a table and add rows or columns
  4. Switch to raw markdown source to inspect output
  5. Test the diff feature to see changes
  6. Add frontmatter properties

Code sample

MDXEditor embeds CodeMirror for code editing:

export default function App() {
return (<div>Hello world</div>)
}

Live component example

The block below is a live React component. You can configure multiple live code presets that specify available npm packages and default imports:

src/App.tsx
export default function App() {
return (
<div>
<p>This is a React JSX in action</p>
</div>
)
}

Tables and math

Play with the table below: add rows, columns, and change column alignment. Navigate cells with Enter, Shift+Enter, Tab, and Shift+Tab.

ItemIn StockPrice
Python HatTrue23.99
SQL HatTrue23.99
Codecademy TeeFalse19.99
Codecademy HoodieFalse42.99

LaTeX is supported with KaTeX:

To solve the cubic equation t3+pt+q=0t^3 + pt + q = 0 (where the real numbers p,qp, q satisfy 4p3+27q2>0{4p^3 + 27q^2} > 0) one can use Cardano’s formula:

q2+q24+p3273+q2q24+p3273 \sqrt[{3}]{ -\frac{q}{2} +\sqrt{\frac{q^2}{4} + {\frac{p^{3}}{27}}} }+ \sqrt[{3}]{ -\frac{q}{2} -\sqrt{\frac{q^2}{4} + {\frac{p^{3}}{27}}} }

For any u1,,unCu_1, \dots, u_n \in \mathbb{C} and v1,,vnCv_1, \dots, v_n \in \mathbb{C}, the Cauchy-Bunyakovsky-Schwarz inequality can be written as follows:

k=1nukvkˉ2(k=1nuk)2(k=1nvk)2 \left| \sum_{k=1}^n {u_k \bar{v_k}} \right|^2 \leq { \left( \sum_{k=1}^n {|u_k|} \right)^2 \left( \sum_{k=1}^n {|v_k|} \right)^2 }

Finally, the determinant of a Vandermonde matrix can be calculated using the following expression:

1x1x12x1n11x2x22x2n11x3x32x3n11xnxn2xnn1=1i,jn(xixj) \begin{vmatrix} 1 & x_1 & x_1^2 & \dots & x_1^{n-1} \\ 1 & x_2 & x_2^2 & \dots & x_2^{n-1} \\ 1 & x_3 & x_3^2 & \dots & x_3^{n-1} \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 1 & x_n & x_n^2 & \dots & x_n^{n-1} \\ \end{vmatrix} = {\prod_{1 \leq {i,j} \leq n} {(x_i - x_j)}}Three famous mathematical formulas on MDN

Mermaid diagrams

Here is a test of Mermaid diagram support:

graph TD
    A[Start Development] --> B(Write Code)
    B --> C{Verify with typecheck?}
    C -->|Yes| D[Run Astro Build]
    C -->|No| E[Fix Errors]
    E --> B
    D --> F[Deploy to Hosting]

GitHub-style callouts

Here are tests for GitHub-style blockquote alerts:

[!NOTE] This is a useful note detailing background context or general information.

[!TIP] This is a helpful tip or optimization suggestion for improved performance.

[!IMPORTANT] This represents essential requirements or key steps critical for completion.

[!WARNING] This warning alerts you to potential breaking changes or security issues.

[!CAUTION] This caution represents high-risk actions that could cause data loss or bugs.

Emojis and task lists

Test emojis and checkboxes:

  • 🎉 Emojis are enabled.
  • 🚀 Fast loading times.
  • Check icon maps updated
  • Tested devicon integration
  • Deploy production build

Syntax highlighting with Expressive Code

This code block demonstrates line highlighting, focus states, and collapsible sections:

src/lib/demo.ts
// Highlight lines 1 and 5-7
import { getTechIconClass } from '@/lib/tech-icons';
export function demonstrateIcons() {
const reactIcon = getTechIconClass('react');
const tailwindIcon = getTechIconClass('tailwind');
const gcpIcon = getTechIconClass('gcp');
4 collapsed lines
// This section is collapsed by default
console.log('React icon class:', reactIcon);
console.log('Tailwind icon class:', tailwindIcon);
console.log('GCP icon class:', gcpIcon);
return { reactIcon, tailwindIcon, gcpIcon };
}

HTML details element

Click to expand and reveal hidden content

This is inside the details element. Markdown elements like bold text and code inline should be styled correctly here.