An open API service indexing awesome lists of open source software.

https://github.com/jili0/markdown-previewer

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

markedjs sass

Last synced: 6 months ago
JSON representation

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

Awesome Lists containing this project

README

          

# 📝 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](https://img.shields.io/badge/React-17.0.2-blue)
![GitHub language count](https://img.shields.io/badge/SASS-embedded-pink)
![GitHub language count](https://img.shields.io/badge/Vite-6.1.0-yellow)

## 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:

```javascript
marked(markdown.replace(/\n(?=\n)/g, "\n
\n"))
```

This solution enables the Markdown previewer to interpret line breaks and render them as `
` 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!