Skip to content

gustavodiasag/djotter

Repository files navigation

Djotter

ci Gem Version

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

Installation

Add this line to your application's Gemfile:

gem 'djotter'

and then execute:

$ bundle

Or install it yourself as:

$ gem install djotter

Usage

This gem expects to receive UTF-8 strings. Ensure your strings are the right encoding before passing them into Djotter.

Converting to HTML

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>

Correctness

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.

Development

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.

Contributing

Issues, bug reports and pull requests are welcome.

About

Shallow Ruby wrapper for the jotdown (Djot parser) Rust crate

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published