faml is a markup language to allow safe and easy formatting of text, which is especially useful for websites that allow users to add contents (e.g., blog comments or forum postings).
|Input faml text||Rendered Output HTML|
As *an example*, this paragraph contains **some** faml markup.
If you were to include it either
* in your browser (`<script src="faml.js"></script>`)
* or your node.js application (`npm install faml`)
then it would render out like on the right.
It also supports [hyperlinks](http://mstum.github.io/faml/) and automatically links stuff like http://mstum.github.io/faml/
- Emphasis (Italic) and Strong Emphasis (Bold)
- Preformatted code, both as blocks (pre) or inline (code)
- Ordered and Unordered lists, nested however you want
- Block Quotes
- Headings (h1 to h6)
- Links, both automatic (for http, https and ftp) and through markup
- It does not support inline HTML (so you don't have to worry about blocking it), but HTML Entities (e.g., ©) are properly preserved.
Usage(In node.js, use
var faml = require("faml");, usage is otherwise the same)
<script src="faml.js"></script> <script> var parser = new faml.FamlParser(); var renderer = new faml.FamlRenderer(); var input = "This is *a test*!"; // Convert faml-text to Abstract syntax tree (AST) var parsed = parser.parse(input); // Render AST to HTML => <p>This is <em>a test</em>!</p> var html = renderer.render(parsed); // Put the HTML onto the page document.getElementById("rendered-html").innerHTML = html; </script>