convert markdown to html in under 5kb

Overview

micromarkdown.js

Build Status Flattr donate button

convert markdown to HTML in under 5kb
take a look at the to PHP translated version: https://github.com/SimonWaldherr/micromarkdown.php

about

License: MIT
Version: 0.3.5
Date: 10.2019

howto

browser

<script type="text/javascript" src="//simonwaldherr.github.io/micromarkdown.js/dist/micromarkdown.min.js"></script>
var input = document.getElementById('input').value,
    outputEle = document.getElementById('outEle');

outputEle.innerHTML = micromarkdown.parse(input);

node

install via npm

npm install micromarkdown
var mmd = require('micromarkdown');
console.log(mmd.parse('*foobar*\n**lorem** ***ipsum***\n\n* this\n* is a\n* list\n'));

or take a look at the nodemmd.js node example

node nodemmd.js

demo

Test this code on the associated github page simonwaldherr.github.io/micromarkdown.js/.
There is also a Testpage and a diff between the php and the js version.

contact

Feel free to contact me via eMail or on Twitter. Pull Requests are always welcome.

Comments
  • Multiple identical code-blocks go unparsed

    Multiple identical code-blocks go unparsed

    Thanks for the parser, it's very lightweight and easy to use.

    However, it seems to get confused if you have two identical code-blocks on different lines, or three identical code-blocks on the same line.

    screen shot 2016-05-26 at 1 04 50 pm

    Is it possible to fix this?

    opened by tabidots 1
  • All tests now pass

    All tests now pass

    The tests in test.html now pass with these updates. Most had issues because extra \n characters were being added and forcing <br><br> to be wrapping the elements.

    opened by mikegioia 1
  • Links break if they contain underscores or asterisks

    Links break if they contain underscores or asterisks

    Hello, I appreciate your library, very nice work. However I've encountered a bug and thought I'd let you know. This example:

    [markdown](http://en.wikipedia.org/wiki/_Markdown_)

    ... Will stop the link from rendering. The same is true with images:

    #![µmd.js](http://simonwaldherr.de/test_umd_.png)

    I guess its worth noting that two asterisks also break it, even if they are not a common thing in URLs

    [markdown](http://en.wikipedia.org/wiki/*Markdown*)

    Cheers.

    opened by pachanka 1
  • Inline URL

    Inline URL

    Hi,

    great parser! I can't add support for inline URL, may be somebody could help me?

    http://test.com -> <a href="http://test.com">http://test.com</a>"

    opened by maks-rafalko 1
  • Doesn't support reference style links yet.

    Doesn't support reference style links yet.

    I imagine they're a bit more complex to implement then inline links, but would love to see reference style links of the form:

    [Link][id]
    
    [id]: http://link.url
    
    opened by axodys 1
  • Fix for the table rendering issue described in #17 and added <thead> and <tbody> to the rendering of the table

    Fix for the table rendering issue described in #17 and added and to the rendering of the table

    This is a fix for #17. The regex for table matching is extended to allow spaces and tabs as prefixes for the horizontal divider between head and body. Also added the .. elements around the elements and the ... around the elements

    opened by joukestoel 0
  • Regular expression matches are not escaped before use in replace()

    Regular expression matches are not escaped before use in replace()

    (This is wrapped in a code block to not have the example markdown parsed)

    Input:
    ```before $& after```
    
    Expected output:
    <code>before&nbsp;$&amp;&nbsp;after</code>
    
    Actual output:
    <code>
    before&nbsp;
    ```before $&amp; after```amp;&nbsp;after</code>
    

    The special $& pattern which inserts a matched substring from a regex when present in the 2nd argument of replace() is being evaluated during execution.

    If 2 or more $& match substitution strings are present in the code block, they are recursively evaluated and will cause micromarkdown.js to hang the browser.

    Briefly examining the code,

    #before $& after
    _before $& after_
    [before $& after](http://example.com)             --warning: will hang browser
    

    will also trigger this behaviour.

    opened by lordastley 0
  • Cannot parse single characters

    Cannot parse single characters

    I know this project is dead, so I'm leaving this here more for anyone else that runs into the issue, rather than expecting it to be fixed. But the parser fails on single characters, for example:

    Am **I** bold? will not properly place the I into bold tags. You can observe this on the test page.

    This appears to fail for bold, italics and delete. Maybe others, but those were the ones I tested.

    opened by photonstorm 0
  • more than one underscore in the url is breaking the link interpretation

    more than one underscore in the url is breaking the link interpretation

    One only underscore in the url works but if you have an url with more than one underscore fail:

    http://something.com/something_more works ! but http://something.com/something_more_else does not work :(

    opened by yaplas 0
  • Change supporting Markdown standard line break isn't published to NPM

    Change supporting Markdown standard line break isn't published to NPM

    As mentioned at the bottom of this issue: https://github.com/SimonWaldherr/micromarkdown.js/issues/6

    The commit https://github.com/SimonWaldherr/micromarkdown.js/commit/e2ea70044f916edd0fcee76f66acadabf410c3f4 doesn't seem to have found its way into the NPM package.

    It would be lovely if this was updated.

    opened by scandox 0
  • Underscores in image URLs are being interpreted as italics!

    Underscores in image URLs are being interpreted as italics!

    ![alt](http://example.com/test_an_image.jpg) doesn't work, apparently because the two underscores in the URL are being interpreted as Markdown italics. Instead you get the verbatim text with underscores removed (or if viewed in the right context, "an" in italics)

    opened by davidearl 0
  • mmdCSSclass blows up on valid, relative urls

    mmdCSSclass blows up on valid, relative urls

    Partial URLs containing only one slash and no periods cause the Javascript to blow up. E.g. [example](/example) produces a Javascript error in mmdCSSclass because urlTmp only has one element, so you try to access urlTemp[-1]

    Actually [example](example) is perfectly valid too, and would blow up earlier because urlTemp[1] does not exist

    It looks like this is only trying to set a class on links, so I can probably work round this with strict=true, but that's not in your documentation.

    opened by davidearl 1
  • http:// links don't have space before and after

    http:// links don't have space before and after

    In line 249 there should be spaces before and after the link: str = str.replace(stra[0], ' <a ' + micromarkdown.mmdCSSclass(repstr, strict) + 'href="' + repstr + '">' + repstr + '</a> '); because the regex captures them and they get removed after replacement: url2: /[ \t\n]([a-zA-Z]{2,16}:\/\/[a-zA-Z0-9@:%_\+.~#?&=]{2,256}.[a-z]{2,4}\b(\/[\-a-zA-Z0-9@:%_\+.~#?&\/\/=]*)?)[ \t\n]/g

    opened by ershov 2
Owner
Simon Waldherr
curr. #DataAnalyst, orig. #MechatronicsEngineer, hobby #Programmer #ComputerScience, deputy #FireBrigade commander, hobby #Photographer, loving #OpenSource
Simon Waldherr
Convert MDX to Markdown.

mdx-to-md Convert MDX to Markdown. Why? This library is most useful for generating README.md files like the one you're reading. Install yarn add mdx-t

Travis Arnold 39 Dec 1, 2022
Here are the projects I completed under freeCodeCamp courses

freeCodeCamp Projects Here are the projects I completed under freeCodeCamp courses. For an overview of the course certifications, please visit my free

Quỳnh Vương 0 Mar 1, 2022
Blobernize your pictures with this all-new tool! Still under development, but it works for now.

Still under development, but in a usable state image-blobernizer A very simple image-blobernizer made for the webbrowser using p5.js Live demo Require

Sen van der Heide 3 Mar 23, 2022
API client to test endpoints over HTTP. Uses superagent under the hood

@japa/client API client to test endpoints over HTTP. Uses superagent under the hood The API client plugin of Japa makes it super simple to test your A

Japa.dev 8 Apr 13, 2022
A smart city community centered application I am building for the Hackers In Residence under the Nkwashi program

A smart city community centered application I am building for the Hackers In Residence under the Nkwashi program. Implementing solutions and automation for potential future problems in the city.

Blessed Jason Mwanza 4 Apr 25, 2022
useOverlay uses floating-ui and framer-moting under the hood, giving you an API that provides great usability.

Create floating things easily useOverlay uses floating-ui and framer-moting under the hood, giving you an API that provides great usability. Warning D

Nedim Arabacı 8 Oct 24, 2022
Website for HKU NLP group (under construction)

hkunlp.github.io A new website for HKU NLP group (under construction). For now this page will host our blog posts (get more info at this week's group

HKU NLP Group 8 Nov 1, 2022
Receive confessions and messages anonymously! (Under development)

About ⚠️ This project is under heavy development! ⚠️ umamin is an ad-free and open-source platform for sending and receiving anonymous confessions! Ea

Josh Daniel 65 Dec 11, 2022
Under the Sea is an official AWS workshop delivered by AWS SAs and AWS Partners to help customers and partners to learn about AIOps with serverless architectures on AWS.

Under the Sea - AIOps with Serverless Workshop Under the Sea is an exciting MMORPG developed by the famous entrepreneur behind Wild Rydes, the most po

AWS Samples 4 Nov 16, 2022
This blog is still under development! I present a project scope for science articles, it can now be used in production! But there are some details that need to be put up front.

Science-Blog ?? Attention! This blog is still under development! I present a project scope for science articles, it can now be used in production! But

Raissadev 2 Sep 19, 2022
A plugin for the Obsidian markdown note application, adding functionality to render markdown documents with multiple columns of text.

Multi-Column Markdown Take your boring markdown document and add some columns to it! With Multi Column Markdown rather than limiting your document lay

Cameron Robinson 91 Jan 2, 2023
A markdown-it plugin that process images through the eleventy-img plugin. Can be used in any projects that uses markdown-it.

markdown-it-eleventy-img A markdown-it plugin that process images through the eleventy-img plugin. Can be used in any projects that use markdown-it. F

null 25 Dec 20, 2022
An obsidian plugin for uploading local images embedded in markdown to remote store and export markdown for publishing to static site.

Obsidian Publish This plugin cloud upload all local images embedded in markdown to specified remote image store (support imgur only, currently) and ex

Addo.Zhang 7 Dec 13, 2022
Markdown Transformer. Transform markdown files to different formats

Mdtx Inspired by generative programming and weed :). So I was learning Elm language at home usually in the evening and now I am missing all this gener

Aexol 13 Jan 2, 2023
Yunisdev-table2csv - Lightweight library to convert HTML table to CSV file

Installation Add following HTML before body end: <script src="https://yunisdev.github.io/table2csv/table2csv.min.js"></script> <!-- or --> <script src

Yunis Huseynzade 2 Oct 19, 2020
Convert JSON to human readable HTML

json.human.js: Json Formatting for Human Beings A small library to convert a JSON object into a human readable HTML representation that is easy to sty

Mariano Guerra 955 Dec 3, 2022
Command line tool that converts HTML to markdown.

@wcj/html-to-markdown HTML conversion tool to markdown. command line tool => @wcj/html-to-markdown-cli. Installation This package is ESM only: Node 14

小弟调调™ 11 Nov 6, 2022
A Hackable Markdown Note Application for Programmers. Version control, AI completion, mind map, documents encryption, code snippet running, integrated terminal, chart embedding, HTML applets, plug-in, and macro replacement.

Yank Note A hackable markdown note application for programmers Download | Try it Online >>> Not ecommended English | 中文说明 [toc]{level: [2]} Highlights

洋子 4.3k Dec 31, 2022
🏗 Build static blog with lines of HTML and Markdown.

Nimblog Nimblog requires only a few lines of HTML to deploy and is suitable for lightweight bloggers. The official guide is built with Nimblog, check

Chell 7 Dec 19, 2022