Skip to content

Releases: asciidoctor/asciidoctor.js

v2.0.3

01 May 09:41
Compare
Choose a tag to compare

Summary

This release is based on Asciidoctor 2.0.9 and Opal 0.11.99.dev (31d26d69).
It includes all the bug fixes and improvements made in Asciidoctor Ruby in 2.0.7, 2.0.8 and 2.0.9 🎉

Release meta

Released on: 2019-05-01
Released by: @Mogztter
Published by: Travis

Logs: resolved issues | full diff

Changelog

Bug Fixes

  • Map the missing method InlineMacro#matchFormat (#730)

Improvements

  • Build against Asciidoctor Ruby 2.0.9

v2.0.2

19 Apr 18:21
Compare
Choose a tag to compare

Summary

This release is based on Asciidoctor 2.0.6 and Opal 0.11.99.dev (31d26d69).

It fixes a major issue with the minified version of Asciidoctor.js. In fact, the file produced by Google Clojure Compiler and available at dist/browser/asciidoctor.min.js was invalid.
It also comes with a few improvements. Most notably, it's now possible to execute the CLI with npx:

npx asciidoctor doc.adoc

We've also added the project name, version and license in the browser distribution.

Release meta

Released on: 2019-04-19
Released by: @Mogztter
Published by: Travis

Logs: resolved issues | full diff

Changelog

Bug Fixes

  • Do not use an advanced compilation level (#719)
  • Add tests to make sure that embedded SVG is working (#725)

Improvements

  • Build against Asciidoctor Ruby 2.0.7 (#721)
  • Add a binary in the asciidoctor package (#727)
  • Upgrade the CLI to 2.0.1 (#727)
  • Add the project name, version and license in the browser file (#720)

v2.0.1

19 Apr 18:02
Compare
Choose a tag to compare

⚠️ This version has been unpublished from npmjs.

There was an issue in the package.json file, as result, the package asciidoctor was invalid. Please use version 2.0.2 📦

v2.0.0

12 Apr 08:35
Compare
Choose a tag to compare

2.0.0 🎉 🎉 🎉

This release is based on Asciidoctor 2.0.6 and Opal 0.11.99.dev (31d26d69).

What's new and noteworthy...

📦 In this release, we renamed the npm package to asciidoctor (dropping the .js suffix) and we've added a Command Line Interface (CLI). In fact, the asciidoctor package is now a meta package with the following dependencies:

  • @asciidoctor/core
  • @asciidoctor/cli

One nice thing is that it's now really easy to get started with Asciidoctor.js:

$ npm i asciidoctor
$ asciidoctor document.adoc

From now onwards, you can either install each dependency individually or install the meta package.
For instance, if you just want to use the Asciidoctor.js core library through the API, you can install @asciidoctor/core:

$ npm i @asciidoctor/core
const asciidoctor = require('@asciidoctor/core')()

We've also reduced the size of the browser distribution by ~20% and removed the Nashorn distribution:

dist
├── browser
│   ├── asciidoctor.js
│   └── asciidoctor.min.js
├── css
│   └── asciidoctor.css
├── graalvm
│   └── asciidoctor.js
└── node
    └── asciidoctor.js

4 directories, 5 files

Changelog

Breaking changes

  • Rename the npm package to asciidoctor
  • Remove Nashorn (and Rhino) support (#624)
  • Drop :ids table from document catalog (#672)
  • Attributes doesn't inherit by default (#671)
  • Modify asciidoctor.js packaging (#690)
    • Removed: dist/umd (the browser distribution is already packaged as an UMD)
    • Removed: dist/asciidoctor.js and dist/asciidoctor.min.js
    • Added: browser/asciidoctor.min.js (optimized for the browser 170Ko gzipped)

Bug fixes

  • readAsset now returns undefined if the file does not exist instead of Opal.nil (#619)
  • Document.getSourcemap now returns undefined instead of Opal.nil (#635)
  • Document.getParentDocument now returns undefined instead of Opal.nil (#635)
  • Document.getExtensions now returns undefined instead of Opal.nil (#635)
  • Fix an issue when embedding a remote image in Node.js (#662)

Improvements

  • Map SyntaxProcess#parseContentAs in the API (#615)
asciidoctor.Extensions.register(function () {
  this.block(function () {
    const self = this;
    self.named('chart');
    self.positionalAttributes(['size', 'width', 'height']);
    self.onContext('literal');
    self.parseContentAs('raw');
    self.process(function (parent, reader, attrs) {
      // ...
    })
})
  • Improve toHash function performance (#623)
  • Map List#hasItems, ListItem#hasText, ListItem#getMarker, ListItem#setMarker and ListItem#getList/getParent (#625)
const input = `
* fist
* second
* third`
const doc = asciidoctor.load(input)
const result = doc.findBy({context: 'ulist'})
const list = result[0]
console.log(list.hasItems()) // true
console.log(list.getItems().length) // 3

const listItems = doc.findBy({context: 'list_item'})
console.log(listItems.length) // 3
console.log(listItems[0].getMarker()) // '*'
listItems[0].setMarker('.')
console.log(listItems[0].getMarker()) // '.'

console.log(listItems[0].hasText()) // true
console.log(listItems[0].getText()) // 'a'
console.log(listItems[1].getText()) // 'b'
console.log(listItems[2].getText()) // 'c'
listItems[0].setText('x')
console.log(listItems[0].getText()) // 'x'

console.log(listItems[0].getList().getItems().length) // 3
console.log(listItems[0].getParent().getItems().length) // 3
  • Map missing Reader API (#631)
reader.hasMoreLines()
reader.isEmpty()
reader.peekLine()
reader.readLine()
reader.readLines()
reader.read()
  • Map Registry has and get extensions functions (#636)
const extensions = doc.getExtensions()
extensions.hasBlockMacros()
extensions.hasInlineMacros()
extensions.hasBlocks()
extensions.hasPreprocessors()
extensions.hasIncludeProcessors()
extensions.hasTreeProcessors()
extensions.hasPostprocessors()
const extensions = doc.getExtensions()
extensions.getBlockMacros()
extensions.getInlineMacros()
extensions.getBlocks()
extensions.getPreprocessors()
extensions.getIncludeProcessors()
extensions.getTreeProcessors()
extensions.getPostprocessors()
  • Map new SyntaxHighlighter API:
class HtmlPipelineAdapter {
  constructor () {
    this.defaultClass = 'prettyprint'
  }
  format (node, lang, opts) {
    return `<pre${lang ? ` lang="${lang}"` : ''} class="${this.defaultClass}"><code>${node.getContent()}</code></pre>`
  }
}
asciidoctor.SyntaxHighlighter.register('html-pipeline', HtmlPipelineAdapter)
  • Implement generate_data_uri_from_uri in a Browser environment for performance (#642)
  • Add a create alias on Opal's $new methods (#652)
  • Use an optimized version of Opal runtime to reduce the bundle size (#674)
  • Provide a JavaScript implementation for Parser#uniform? for performance (#685)

Infrastructure

  • Use JavaScript Standard Style (#626)
  • Rename npm directory to tasks (#638)
  • Remove the monkeypatch when reading include files (#637)
  • Use async and await in the npm tasks (#643)
  • Add a relative include test on Browser (#649)
  • Do not remove the build directory when calling 'npm run build' (#648)
  • Adds tests on doctime (#668)
  • Remove superfluous module override (opal_ext) (#641)
  • Remove logger.rb (now parts of Opal) (#667)
  • Run npm audit fix

Documentation

📖 API documentation
📚 User Manual

Released on: 2019-04-12
Released by: @Mogztter
Published by: Travis

v2.0.0-rc.3

06 Apr 13:17
Compare
Choose a tag to compare
v2.0.0-rc.3 Pre-release
Pre-release

A testing release in preparation for 2.0.0.

The full release notes will be deferred until the final version is available.

v2.0.0-rc.2

31 Mar 13:26
Compare
Choose a tag to compare
v2.0.0-rc.2 Pre-release
Pre-release

A testing release in preparation for 2.0.0.

The full release notes will be deferred until the final version is available.

v2.0.0-rc.1

24 Mar 14:35
Compare
Choose a tag to compare
v2.0.0-rc.1 Pre-release
Pre-release

A testing release in preparation for 2.0.0.

The full release notes will be deferred until the final version is available.

v1.5.9

25 Nov 18:01
Compare
Choose a tag to compare

This release is based on Asciidoctor 1.5.8 and Opal 0.11.99.dev (6703d8d).

Changelog

Bug fixes

  • Allow the name of the extension to be null/undefined (#591)
  • AbstractNode.getId should return undefined if the node id is Opal.nil (#593)
  • Include trailing slash on Windows path (#594)
  • Preserve built-in object methods Function, Error... (#594)

Improvements

  • Upgrade Opal to version 0.11.1.dev@6703d8d (#594)
  • Upgrade Asciidoctor to version 1.5.8 0c35ace
  • Map Processor#resolvesAttributes method in the API (#578)
asciidoctor.Extensions.create(function () {
  this.blockMacro(function () {
    this.named('attribute')
    this.resolvesAttributes('1:value')
    this.process((parent, target, attrs) => {
      parent.getDocument().setAttribute(target, attrs['value'])
    })
  })
})
  • Map Document#setHeaderAttribute method in the API (#579)
asciidoctor.Extensions.create(function () {
  this.blockMacro(function () {
    this.named('header_attribute')
    this.resolvesAttributes('1:value')
    this.process((parent, target, attrs) => {
      parent.getDocument().setHeaderAttribute(target, attrs['value'])
    })
  })
})
  • Map Processor#createList method in the API (#580)
asciidoctor.Extensions.register('test', function () {
  this.block(function () {
    this.named('test')
    this.onContext('paragraph')
    this.process((parent) => {
      parent.append(this.createList(parent, 'ulist'))
    })
  })
})
  • Map Processor#createListItem method in the API (#588)
asciidoctor.Extensions.register('test', function () {
  this.block(function () {
    this.named('test')
    this.onContext('paragraph')
    this.process((parent) => {
      const list = this.createList(parent, 'ulist')
      list.append(this.createListItem(list, 'foo'))
      list.append(this.createListItem(list, 'bar'))
      list.append(this.createListItem(list))
      parent.append(list)
    })
  })
})
  • Map Document#getAuthors method in the API (#581)
const input = `= Getting Real: The Smarter, Faster, Easier Way to Build a Successful Web Application
David Heinemeier Hansson <[email protected]>

Getting Real details the business, design, programming, and marketing principles of 37signals.`
const doc = asciidoctor.load(input)
const author = doc.getAuthors()[0]
console.log(author.getEmail()) // '[email protected]'
console.log(author.getName()) // 'David Heinemeier Hansson'
console.log(author.getFirstName()) // 'David'
console.log(author.getMiddleName()) // 'Heinemeier'
console.log(author.getLastName()) // 'Hansson'
console.log(author.getInitials()) // 'DHH'
  • Processor#createImageBlock should set title and caption if title attribute is set (#582)
  • Use Asciidoctor.StopIteration exception to stop iteration in findBy (#585)
let stop = false
const result = doc.findBy((candidate) =>  {
  if (stop) {
    throw new asciidoctor.StopIteration()
  }
  if (candidate.getContext() === 'paragraph') {
    if (candidate.getParent().getContext() === 'sidebar') {
      stop = true
    }
    return true
  }
})
  • Use skip and skip_children to skip iteration in findBy (#586)
const result = doc.findBy((candidate) => {
  const ctx = candidate.getContext()
  if (ctx === 'example') {
    return 'skip'
  } else if (ctx === 'paragraph') {
    return true
  }
})
const result = doc.findBy((candidate) => {
  if (candidate.getContext() === 'example') {
    return 'skip_children'
  }
})
  • Map AbstractBlock#hasTitle method in the API (#592)
console.log(doc.getBlocks()[0].hasTitle) // true or false
  • Introduce DSL method to mark document processor as preferred (#587)
const SelfSigningTreeProcessor = asciidoctor.Extensions.createTreeProcessor('SelfSigningTreeProcessor', {
  process: function (document) {
    document.append(this.createBlock(document, 'paragraph', 'SelfSigningTreeProcessor', {}))
  }
})
asciidoctor.Extensions.register(function () {
  this.treeProcessor(function () {
    const self = this
    self.process(function (doc) {
      doc.append(self.createBlock(doc, 'paragraph', 'd', {}))
    })
  })
  this.treeProcessor(function () {
    const self = this
    self.prefer()
    self.process(function (doc) {
      doc.append(self.createBlock(doc, 'paragraph', 'c', {}))
    })
  })
  this.prefer('tree_processor', asciidoctor.Extensions.newTreeProcessor('AwesomeTreeProcessor', {
    process: function (doc) {
      doc.append(this.createBlock(doc, 'paragraph', 'b', {}))
    }
  }))
  this.prefer('tree_processor', asciidoctor.Extensions.newTreeProcessor({
    process: function (doc) {
      doc.append(this.createBlock(doc, 'paragraph', 'a', {}))
    }
  }))
  this.prefer('tree_processor', SelfSigningTreeProcessor)
})

As a result, prepend function is now deprecated

  • Map Converter.Factory#register method in the API (#600)
asciidoctor.ConverterFactory.register(new DummyConverter(), ['dummy'])
  • Map AbstractNode#getNodeName method in the API (#599)
console.log(doc.getBlocks()[0].getNodeName()) // 'quote', 'image', 'ulist'...
  • Map BlockMacroProcessor#getName, InlineMacroProcessor#getName and BlockProcessor#getName methods in the API (#598)
const registry = asciidoctor.Extensions.create()
const shoutBlockProcessor = asciidoctor.Extensions.newBlockProcessor('ShoutBlockProcessor', {
  process: function (parent, reader) {
    const lines = reader.getLines().map((l) => l.toUpperCase())
    return this.createBlock(parent, 'paragraph', lines)
  }
})
console.log(shoutBlockProcessor.getName()) // undefined
registry.block('shout', shoutBlockProcessor)
console.log(shoutBlockProcessor.getName()) // 'shout'
  • Map the built-in Html5Converter in the API (#601)
asciidoctor.Html5Converter.$new() // instantiate the default HTML5 converter
  • Map Document#getIndexTerms, Document#getRefs, Document#getIds, Document#getLinks and Document#getImages methods in the API (#603)
const doc = asciidoctor.load(input, {'catalog_assets': true})
doc.convert()  // available only once the document has been converted
const linksCatalog = doc.getLinks()
const doc = asciidoctor.load(input, {catalog_assets: true})
const imagesCatalog = doc.getImages()
const doc = asciidoctor.load(input)
const refsCatalog = doc.getRefs()
const doc = asciidoctor.load(input)
const idsCatalog = doc.getIds()
const doc = asciidoctor.load(input)
doc.convert() // available only once the document has been converted
const indexTermsCatalog = doc.getIndexTerms()

📖 API documentation

Infrastructure

  • Remove sudo:false as recommended by Travis (#604)

Released on: 2018-11-25
Released by: @Mogztter
Published by: Travis

v1.5.8

25 Nov 17:20
Compare
Choose a tag to compare

⚠️ This version has been unpublished from npmjs.

There was an issue during the release process and, as result, the package published on npmjs was empty. Please use version 1.5.9 📦

v1.5.7

30 Oct 16:11
Compare
Choose a tag to compare

This release is based on Asciidoctor 1.5.7.1 and Opal 0.11.99.dev (e2167f4b).

What's new and noteworthy...

In this release, we added initial support for GraalVM. If you want to embed Asciidoctor.js in a JVM-based application with GraalVM, please read the dedicated section in the User Manual.

A complete set of API is available to take full advantage of the new logging system introduced in Asciidoctor 1.5.7. Everything you need to know about the new Logging API is described in the User Manual:

Changelog

Includes everything from 1.5.7-rc.1 and more!

Bug fixes

  • Processor could hang when parsing overlapping passthrough in monospaced text (#542) thanks @mojavelinux

Improvements

  • Update to Opal 0.11.1.dev@3c8d93e (#511)
  • Produce a GraalVM compatible version of Asciidoctor.js (#559)
  • Add a Logger API (#553)
const defaultLogger = asciidoctor.LoggerManager.getLogger();
console.log(defaultLogger.getLevel()); // 2
console.log(defaultLogger.getProgramName()); // asciidoctor
console.log(defaultLogger.getMaxSeverity()); // 2

defaultLogger.setProgramName('asciidoctor.js');
console.log(defaultLogger.getProgramName()); // asciidoctor.js

defaultLogger.setLevel(3);
console.log(defaultLogger.getLevel()); // 3
  • Add a LoggerManager API (#553)
defaultLogger.setFormatter(asciidoctor.LoggerManager.newFormatter('JsonFormatter', {
  call: function (severity, time, programName, message) {
    const text = message['text'];
    return JSON.stringify({
      programName: programName,
      message: text,
      severity: severity
    }) + '\n';
  }
});
  • Add a Logger API (#557)
asciidoctor.LoggerManager.setLogger(asciidoctor.LoggerManager.newLogger('AsyncFileLogger', {
  postConstruct: function () {
    this.writer = fs.createWriteStream(logFile, {
      flags: 'a'
    });
  },
  add: function (severity, _, message) {
    const log = this.formatter.call(severity, new Date(), this.progname, message);
    this.writer.write(log);
  }
}));
const doc = asciidoctor.load(source);
console.log(doc.hasBlocks());
parent.append(this.createBlock(parent, 'paragraph', 'this was only a test'));
  • Map AbstractBlock#numeral, AbstractBlock#getNumeral, AbstractBlock#setNumeral in the API (#548)
 const appendix = doc.getBlocks()[0];
console.log(appendix.getNumeral()) // A

appendix.setNumeral('B');
console.log(appendix.getNumeral()); // B
  • Map NullLogger class (#554)
  • Improve createInline function and extension initialization (#555)
  • Use simpler mechanism to convert from Opal hash to JavaScript object (#537) thanks @mojavelinux

📖 API documentation

Infrastructure

  • The User Manual is now published with Antora on Netlify
    • Improve the Getting Started section (#513)
    • Document each extension points (#519)
    • Document how to apply a theme (#520)
    • Document how to use the new Logging system introduced in Asciidoctor 1.5.7 (#551)
    • Document how to use Asciidoctor.js with GraalVM (#566)
  • Switch back to npm and remove yarn.lock (#494)
  • Run npm audit fix to fix security issues (74c22c1)
  • Replace async module with Promise in npm tasks (#560)

Release Meta

Released on: 2018-10-30
Released by: @Mogztter
Published by: Travis