Introducing the Mtlite gem
The Mtlite gem was inspired by the Martile gem to facilitate transforming a kind of a loose Martile markdown.
It features the following:
- Making an unordered list into an Mtlite 1-liner list e.g. "a todo list:\n* line 1\n* line 2" => a todo list: [* line 1 * line 2]
- Adding br tags to checklist items e.g. todo list: [[x] line 1 [] line 2] => todo list: <br/>[x] line 1 <br/>[] line 2
- Convert square brackets to unicode check boxes; Replaces a [] with a unicode checkbox, and [x] with a unicode checked checkbox
- Convert fractions using their associated unicode character i.e. 1/4, 1/2, 3/4
- Adding strikethru to completed items e.g. -milk cow- becomes <del>milk cow</del>
- Appending a domain label after the URL
- Generate html lists from Mtlite 1-liner lists.
Examples
require 'mtlite'
MTLite.new("a todo list:\n* line 1\n* line 2").to_html
#=> "a todo list: <ul><li>line 1</li><li>line 2</li></ul>\n"
MTLite.new("todo list: [[x] line 1 [] line 2]").to_s
#=> "todo list: \n☑ line 1\n� line 2\n"
MTLite.new("todo list: [[x] line 1 [] line 2]").to_html
#=> "todo list: <br/>☑ line 1<br/>� line 2\n"
MTLite.new("2 apples and 1/2 teaspoon of cinamon powder").to_s
#=> "2 apples and ½ teaspoon of cinamon powder\n"
MTLite.new(" -milk cow- ").to_html
#=> " <del>milk cow</del>\n"
MTLite.new(" find out more from http://news.bbc.co.uk").to_html
#=> " find out more from <a target=\"_blank\" href=\"http://news.bbc.co.uk\">http://news.bbc.co.uk</a>\n"
Resources
mtlite gem markdown martile html