Markdown Previewer
How do I make an markdown previewer?
A simple Markdown previewer built for freeCodeCamp. Uses React to render the preview.. What is a markdown previewer? How do you make a markdown previewer? This script and codes were developed by Zac Clemans on 14 January 2023, Saturday.
Markdown Previewer - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Markdown Previewer</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <h1 id="title">Markdown Previewer</h1>
<div id="app"></div> <script src='http://cdnjs.cloudflare.com/ajax/libs/react/0.14.3/react.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/marked/0.3.5/marked.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Markdown Previewer - Script Codes CSS Codes
body { width: 1000px; margin: 0 auto;
}
@media screen and (max-width: 500px) { body { width: 300px; }
}
#title { text-align: center;
}
.raw-input { float: left; width: 500px; height: 700px; resize: none;
}
@media screen and (max-width: 500px) { .raw-input { float: none; width: 300px; height: 200px; }
}
.formatted-output { float: left; margin-left: 10px; vertical-align: top;
}
@media screen and (max-width: 500px) { .formatted-output { float: none; }
}
Markdown Previewer - Script Codes JS Codes
"use strict";
var MarkdownInput = React.createClass({ displayName: "MarkdownInput", getInitialState: function getInitialState() { return { rawText: "Heading\n=======\n\nSub-heading\n-----------\n\n### Another deeper heading\n\nParagraphs are separated\nby a blank line.\n\nLeave 2 spaces at the end of a line to do \nline break\nText attributes *italic*, **bold**,\n`monospace`, ~~strikethrough~~ .\n\nShopping list:\n * apples\n * oranges\n * pears\n\nNumbered list:\n\n 1. apples\n 2. oranges\n 3. pears\n\nThe rain---not the reign---in\nSpain.\n\n*[Zac Clemans](https://freecodecamp.com/zaclem01)*" }; }, handleTextChange: function handleTextChange(e) { this.setState({ rawText: e.target.value }); this.props.onUserInput(e.target.value); }, render: function render() { return React.createElement( "textarea", { className: "raw-input", onChange: this.handleTextChange }, this.state.rawText ); }
});
var MarkdownOutput = React.createClass({ displayName: "MarkdownOutput", rawMarkup: function rawMarkup() { var rawMarkup = marked(this.props.toFormat.toString(), { sanitize: true }); return { __html: rawMarkup }; }, render: function render() { return React.createElement( "div", { className: "formatted-output" }, React.createElement("span", { dangerouslySetInnerHTML: this.rawMarkup() }) ); }
});
var Previewer = React.createClass({ displayName: "Previewer", getInitialState: function getInitialState() { return { text: "Heading\n=======\n\nSub-heading\n-----------\n\n### Another deeper heading\n\nParagraphs are separated\nby a blank line.\n\nLeave 2 spaces at the end of a line to do \nline break\nText attributes *italic*, **bold**,\n`monospace`, ~~strikethrough~~ .\n\nShopping list:\n * apples\n * oranges\n * pears\n\nNumbered list:\n\n 1. apples\n 2. oranges\n 3. pears\n\nThe rain---not the reign---in\nSpain.\n\n*[Zac Clemans](https://freecodecamp.com/zaclem01)*" }; }, handleUserInput: function handleUserInput(input) { this.setState({ text: input }); }, render: function render() { return React.createElement( "div", null, React.createElement(MarkdownInput, { onUserInput: this.handleUserInput }), React.createElement(MarkdownOutput, { toFormat: this.state.text }) ); }
});
React.render(React.createElement(Previewer, null), document.getElementById("app"));
Developer | Zac Clemans |
Username | thalpha |
Uploaded | January 14, 2023 |
Rating | 3 |
Size | 3,771 Kb |
Views | 6,072 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
JQuery Calculator | 3,124 Kb |
OOLO Calculator - Vanilla JS | 5,734 Kb |
Simon Says | 3,674 Kb |
D3 Map Project | 3,119 Kb |
Local Weather App - Refactor | 5,264 Kb |
Hero arrow test | 1,482 Kb |
FCC Camper Leaderboard | 6,801 Kb |
Camper News | 3,157 Kb |
D3 Scatterplot Project | 3,150 Kb |
Recipe Box Redux Refactor | 11,597 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
A Pen by Huan Nghiem | Nightshade | 10,646 Kb |
Modal Dialog | Gigaleet | 2,251 Kb |
CSS Colors | Alexpate | 2,232 Kb |
Google Maps API Ground Overlay | Boycetrus | 2,961 Kb |
A Pen by aleen42 | Aleen42 | 11,473 Kb |
A Pen by Ben Babics | Benbabics | 2,957 Kb |
Starfield old school style | Bolloxim | 5,214 Kb |
Ionic Infinite outside ion-content with ion-pane | Felquis | 3,117 Kb |
Pure CSS read more toggle | Idered | 2,344 Kb |
A Pen by Gregory Potdevin | GregoryPotdevin | 1,713 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!