Skip to content

A live markdown previewer that instantly shows your markdown syntax in real-time. Built with React and powered by `marked.js` for markdown parsing.

Notifications You must be signed in to change notification settings

jili0/markdown-previewer

Repository files navigation

📝 Markdown Previewer

An interactive Markdown editor and previewer, developed with React and SASS. This tool allows users to write Markdown syntax in real-time and see the rendered preview.

GitHub language count GitHub language count GitHub language count

Features

  • Live Preview: Instant rendering of Markdown text
  • Syntax Highlighting: Code blocks are highlighted with highlight.js
  • Responsive Design: Works on all screen sizes
  • Sanitized Output: Security through DOMPurify
  • Line Breaks: Correct interpretation of multiple line breaks

Technologies

  • Frontend Framework: React 17
  • Styling: SASS (with nested syntax)
  • Markdown Conversion: Marked
  • Code Highlighting: highlight.js
  • Security: DOMPurify
  • Build Tool: Vite

Technical Challenges

The biggest challenge in this project was handling multiple line breaks in the textarea that needed to be correctly displayed as line breaks in the previewer. This was solved through a special regex replacement:

marked(markdown.replace(/\n(?=\n)/g, "\n<br>\n"))

This solution enables the Markdown previewer to interpret line breaks and render them as <br> elements, which provides an improved user experience.

Preview

Markdown Previewer - Main View

Main view of the Markdown Previewer

Markdown Previewer - Code Highlighting

Text Styling, Lists and Tables

Markdown Previewer - Mobile View

Responsive Design for various screen sizes

Project Structure

markdown-previewer/
├── src/
│   ├── components/
│   │   ├── Editor.jsx       # Textarea component for Markdown input
│   │   └── Previewer.jsx    # Preview component with Marked integration
│   ├── App.jsx              # Main component
│   ├── App.scss             # Main styling file
│   ├── AppContextProvider.jsx # Context for state management
│   ├── _index.scss          # Base styling
│   └── main.jsx             # Application entry point
├── public/
└── ...configuration files

Try it out - It's fun!

About

A live markdown previewer that instantly shows your markdown syntax in real-time. Built with React and powered by `marked.js` for markdown parsing.

Topics

Resources

Stars

Watchers

Forks