v2.0.0
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
anddist/asciidoctor.min.js
- Added:
browser/asciidoctor.min.js
(optimized for the browser 170Ko gzipped)
- Removed:
Bug fixes
readAsset
now returnsundefined
if the file does not exist instead ofOpal.nil
(#619)Document.getSourcemap
now returnsundefined
instead ofOpal.nil
(#635)Document.getParentDocument
now returnsundefined
instead ofOpal.nil
(#635)Document.getExtensions
now returnsundefined
instead ofOpal.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
andListItem#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
andawait
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
- Fix typo in README and contributing guide (#612 #613) - thanks @LucianBuzzo
- Create a documentation page to list all the extensions available (#610)
- Explain how to create and register a custom converter (#620)
- Write the version and lifecycle policies (#622)
- Clarify the documentation on
Document#getHeader
📖 API documentation
📚 User Manual
Released on: 2019-04-12
Released by: @Mogztter
Published by: Travis