Ruby wrapper for Rust's jotdown crate.
Initially, djotter is designed to strictly generate HTML from a Djot document. The gem does not support features such as manipulating the AST generated by the underlying parser and the conversion of such intermediate representation to construct any type of output format other than HTML.
Note
Even though jotdown
aims to be feature complete and match the reference implementation, some edge cases are not yet dealt with. Since this wrapper mirrors the crate behavior, it is important to draw attention to that.
For more information, see the documentation below
Add this line to your application's Gemfile:
gem 'djotter'
and then execute:
$ bundle
Or install it yourself as:
$ gem install djotter
This gem expects to receive UTF-8 strings. Ensure your strings are the right encoding before passing them into Djotter
.
Call to_html
on a string to convert it to HTML:
require 'djotter'
puts Djotter.to_html('a *b{#id key="*"}*')
# <p>a <strong><span id="id" key="*">b</span></strong></p>
Even though the underlying implementation supports all the current features of the Djot syntax, the authors explicitly state that:
The HTML output is in some cases not exactly identical to the reference implementation.
Taking that into consideration, the test cases against which the crate is submitted to are not as exhaustive as the JavaScript and Lua versions. To address that, all the .test
files from those parsers were added to this wrapper for an extra layer of inspection. With that said, not all cases matched exactly the expected output, some just because of formatting shenanigans and others due to not completely handling edge cases. The exact cases where that happened were edited out.
Some of those are actually pointed out by the crate author, such as issue #51.
After cloning the repo:
$ bundle install
$ bundle exec rake compile
If there were no errors, that's it! Otherwise, make sure you have all the tools required for both Ruby and Rust: bundle
, cargo
.
Issues, bug reports and pull requests are welcome.