How to use
Web Browser (IE9+)
<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> |
node.js
npm install faml
var faml = require("faml");
var parser = new faml.FamlParser();
var renderer = new faml.FamlRenderer();
// Actual usage is the same as in the Web Browser
|
Properties and Methods
FamlParser.parse(input)Parse the faml input string and returns an AST
FamlRenderer.render(ast)Render the given AST to a HTML string
FamlRenderer.fencedClassThe CSS class that is prepended to code blocks with a CSS class.
var renderer = new faml.FamlRenderer(); renderer.fencedClass = "myClass-"; Input faml: ```ruby puts 'Hello world' ``` Output HTML: <pre><code class="myClass-ruby">puts 'Hello world' </code></pre> |