OscarGodson / EpicEditor

EpicEditor is an embeddable JavaScript Markdown editor with split fullscreen editing, live previewing, automatic draft saving, offline support, and more. For developers, it offers a robust API, can be easily themed, and allows you to swap out the bundled Markdown parser with anything you throw at it.
http://epiceditor.com
MIT License
4.25k stars 338 forks source link

Feature request: also support Asciidoc #380

Closed danhaywood closed 8 years ago

danhaywood commented 8 years ago

Apols if there's already an issue for this (couldn't see one) but it'd be awesome if a future version of EpicEditor also supported Asciidoc (by way of Asciidoctor.js, presumably)

OscarGodson commented 8 years ago

Is Asciidoctor.js just a parser? If its just a parser you can have EpicEditor support this very easily. EpicEditor won't include every parser out of the box but we try to make it super simple to change how content is parsed. Here's a Wiki example that uses Wiki2HTML:

var editor = new EpicEditor({
  parser: function (str) {
    return str.wiki2html();
  }
}).load();

If Asciidoc isn't a parser like that, sorry, let me know so I can google it. I'm just guessing based on the name :)

danhaywood commented 8 years ago

Asciidoctor.js does do the parsing, yes... though Asciidoctor ecosystem has a lot more to it than that (it's a Javascript cross-compilation of the original ruby scripts.

This post shows how it's API:

http://asciidoctor.org/news/2013/05/21/asciidoctor-js-render-asciidoc-in-the-browser/

Doing this sort of stuff is somewhat outside my comfort zone, but perhaps it's something you might easily incorporate? I would recommend you taking the time to google Asciidoc (the original implementation) and Asciidoctor; Dan Allen who heads up the Asciidoctor is super-helpful and supportive, thing you'd enjoy touching base with him.

OscarGodson commented 8 years ago

Looks like it should be super easy and I got it working on the demo site. I just included their script: https://raw.githubusercontent.com/asciidoctor/asciidoctor.js/master/dist/asciidoctor-all.js

Then I was able to set the parser to Asciidoctor like this:

var options = Opal.hash({doctype: 'inline', attributes: ['showtitle']});

editor.settings.parser = function (str) {
  return Opal.Asciidoctor.$convert(str, options); (1)
}

Then I pasted in this:

http://asciidoctor.org[*Asciidoctor*] running on http://opalrb.org[_Opal_]  brings AsciiDoc to the browser!

And got the links and stuff parsing

epiceditor - an embeddable javascript markdown editor 2015-11-23 03-32-05

danhaywood commented 8 years ago

Thanks for taking the time to explore this, great to see it was easy. I see you've left the ticket open, so will it you be incorporating Asciidoc support as an "out-of-the-box" feature? Or will some (fairly minimal, it looks like) "home assembly" be required?

OscarGodson commented 8 years ago

I left it open to see if that home assembly is what you needed for your stuff to work :) if it is I'll close it. Asciidoc has a lot of dependencies that are very large so I think it would be better off as an EpicEditor plugin

danhaywood commented 8 years ago

Fair enough. Will close this then. If I get stuck trying to pull this together I can always reopen or raise another ticket. Thanks again.