Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8" />
- <meta name="" content="">
- <title>Markdown to HTML</title>
- <style>
- *{padding:0px;margin:0px;box-sizing:border-box;}
- div{
- padding:1px;
- border:2px solid #dddddd;
- margin:1px;
- }
- .li-before{
- margin:0px;
- padding:0px;
- border:none;
- display:inline-block;
- color:transparent;
- width:14px;
- height:14px;
- background-image:conic-gradient(#000000 0deg,#222222 90deg,#777777 180deg,#222222 270deg,#000000 360deg);
- border-radius:7px;
- margin-left:4px;
- margin-right:4px;
- }
- .superscript{
- margin:0px;
- padding:0px;
- border:none;
- font-size:10px;
- display:inline;
- position:relative;
- bottom:10px;
- }
- .other{
- margin:0px;
- padding:0px;
- border:none;
- }
- </style>
- </head>
- <body>
- <script>
- var a=[
- />/g,
- /</g,
- /\\\\/g,
- /\\\[/g,
- /\\\]/g,
- /\\\*/g,
- /\\\|/g,
- /\\\//g,
- /\\-/g,
- /\\&/g,
- /\\\^/g,
- /\[(?<text>[^\]]+)\]\((http(?<safe>s?):\/\/)?(www\.)?(?<domain>(\w+\.)+(\w+))\)/g,
- /(?<text>(http(?<safe>s?):\/\/)?(www\.)?(?<domain>(\w+\.)+(\w+)))/g,
- /\*\*\*(?<text>[^*]+)\*\*\*/g,
- /\*\*(?<text>[^*]+)\*\*/g,
- /\*(?<text>[^*]+)\*/g,
- /^\s*(?<li>[+\-*]+ +(?<text>[^\n\r\s][^\n\r]*))/gm,
- /(?<text>((<li>)+((?!<\/li>).)+(<\/li>)+[\s\n\r]*)+)/g,
- /(?<=<\/li>)[\s\n\r]+(?=<\/ul>)/g,
- /(?<=<ul>)[\s\n\r]+(?=<li>)/g,
- /\n\n+/g,
- /\s\s+\n/g,
- /\^\((?<text>[^\n\r)]+)\)/g,
- /\^(?<text>[^\s\n\r)]+)/g
- ]
- var c=[
- ">",
- "<",
- "\",
- "[",
- "]",
- "*",
- "|",
- "/",
- "-",
- "&",
- "^",
- "<a href=\"http$<safe>://www.$<domain>\">$<text></a>",
- "<a href=\"http$<safe>://www.$<domain>\">$<text></a>",
- "<b><i>$<text></i></b>",
- "<b>$<text></b>",
- "<i>$<text></i>",
- "<li><div class=\"li-before\"></div>$<text></li>",
- "<ul>$<text></ul>",
- "",
- "",
- "</div><div>",
- "<br>",
- "<div class=\"superscript\">$<text></div>",
- "<div class=\"superscript\">$<text></div>"
- ]
- var b=`I like this [search engine](https://www.google.com), and this [video player](youtube.com).
- This <i> should be fine.
- My name here on Reddit ^(not this site) is Simanelix and I moderate on r/idlegamemaker.
- - this
- - is a simple
- - and also unordered
- - list of things
- I wnat to madk a *really* cool IGM tool, and a simple but **useful** markdown transformer. This text *start out in italics, but ****then goes bold, *****later exits italics, **and eventually returns to normal.
- I hope ***you*** have a great day.`;
- function markdownToHTML(){
- for(let i in a){
- b=b.replace(a[i],c[i]);
- }
- document.body.innerHTML="<div>"+b+"</div>";
- }
- markdownToHTML();
- /*
- .replace(/>/g,">").replace(/</g,"<")
- */
- </script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment