Skip to content

Instantly share code, notes, and snippets.

@mojavelinux
Created November 25, 2014 07:59
Show Gist options
  • Select an option

  • Save mojavelinux/2e17a6729b7df6ea561e to your computer and use it in GitHub Desktop.

Select an option

Save mojavelinux/2e17a6729b7df6ea561e to your computer and use it in GitHub Desktop.
Test script for Asciidoctor.js on various JavaScript implementations
if (typeof console === 'undefined') {
console = {
log: function(str) {
print(str);
},
warn: function(str) {
print(str);
}
};
}
var asciidoctor = false;
var pwd = '';
if (typeof load === 'function') {
load('./build/asciidoctor-all.js');
if (typeof Java === 'undefined') {
pwd = '../';
}
}
else {
Opal = require('opal-npm-wrapper').Opal;
asciidoctor = require('./build/npm/asciidoctor-core.js')(Opal).Asciidoctor();
}
//var data = 'testing...'
var data = "= Asciidoctor.js, AsciiDoc in JavaScript\nDoc Writer <docwriter@example.com>\n\nAsciidoctor and Opal come together to bring http://asciidoc.org[AsciiDoc] to the browser!.\n\n== Technologies\n* AsciiDoc\n* Asciidoctor\n* Opal\n\nNOTE: That's all she wrote!!!"
//var data = "include::" + pwd + "README.adoc[]"
var options = Opal.hash2(['safe', 'doctype', 'header_footer', 'attributes'], { safe: 'safe', doctype: 'article', header_footer: false, attributes: 'linkcss copycss!' });
//var doc = (asciidoctor ? asciidoctor : Opal.Asciidoctor).$load(data, options);
var html = (asciidoctor ? asciidoctor : Opal.Asciidoctor).$convert(data, options);
console.log(html);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment