DEV Community

mksunny1
mksunny1

Posted on

1

Why I Built Marksafe: A Safer, More Flexible Alternative to Markdown

Title: Why I Built Marksafe: A Safer, More Flexible Alternative to Markdown

Introduction
Markdown is a fantastic tool for formatting content, but it comes with limitations and security risks. As a developer and content creator, I wanted a more powerful yet secure alternative—so I built Marksafe.

What is Marksafe?
Marksafe is a lightweight, XSS-safe alternative to Markdown, designed for developers and content creators who need more flexibility without the security risks of raw HTML.

  • Secure by Design: No need to sanitize user input manually.
  • More Powerful than Markdown: Supports attributes, custom styling, and enhanced formatting.
  • Concise Syntax: Reduces boilerplate compared to HTML.
  • Lightweight and Fast: Small footprint and optimized performance.

Why Not Just Use Markdown?
While Markdown is great, it has some major drawbacks:

  • Limited control over attributes (e.g., no inline styles, classes, or data attributes).
  • Requires extensions for extra functionality.
  • Can be vulnerable to XSS attacks if improperly sanitized.

How Marksafe Solves These Problems
Marksafe gives you the power of HTML with a Markdown-like simplicity, while keeping security in check. Here’s a quick comparison:

Feature Markdown Marksafe
Secure by default ❌ No ✅ Yes
Supports attributes ❌ Limited ✅ Full control
Custom styling ❌ No ✅ Yes
Nested elements ❌ Limited ✅ Flexible

Marksafe Syntax in Action
Instead of writing verbose HTML, Marksafe lets you do this:

[div]
  class=container,,
  [h1] Welcome to Marksafe! [/h1]
  [p]
    This is the first paragraph. ;;
    This is the second one. ;;
    This is the third. ;;
    Then the 4th.
  [/p]
[/div]
Enter fullscreen mode Exit fullscreen mode

This prevents XSS vulnerabilities while still allowing attributes like class, style, and data-*.

Who Should Use Marksafe?

  • Developers building CMS platforms or documentation sites.
  • Writers who need more flexibility in their content.
  • Security-conscious teams who want safe formatting options.

Try Marksafe Today!
Marksafe is open-source and available on GitHub and npm.

💬 What do you think? Would you switch from Markdown to Marksafe? Let’s discuss in the comments!

Top comments (1)

Collapse
 
rdentato profile image
Remo Dentato • Edited

I don't get it. Using one of your examples, you claim that:

[h1]Shopping List[/h1]

[p]Here’s a list of things to buy:[/p]

[uli]Apples;;Bananas;;Carrots
  [uli]Carrot A;;Carrot B
    [uli]Carrot B1;;Carrot B2[/uli]
  [/uli]
;;Dates[/uli]

[p]For more details, visit [a]href=https://example.com,,Example[/a].[/p]

[bq]This is a blockquote.[/bq]
Enter fullscreen mode Exit fullscreen mode

is safer than:

# Shopping List

Here’s a list of things to buy:

  - Apples
  - Bananas
  - Carrots
    - Carrot A
    - Carrot B
       - Carrot B1
       - Carrot B2
 - Dates

For more details, visit [Example](https://example.com)

 > This is a blockquote.
Enter fullscreen mode Exit fullscreen mode

Can you elaborate?
Markdown is born to help creating simple documents that can be rendered in different ways (HTML is one).
It seems to me you're creating another markup language much more similar to HTML than Markdown but I might have missed something.

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs