Releases: asciidoctor/asciidoctor.js
v2.0.3
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
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
v2.0.1
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
v2.0.0-rc.3
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
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
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
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 isOpal.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 infindBy
(#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
andskip_children
to skip iteration infindBy
(#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
andBlockProcessor#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
andDocument#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()
Infrastructure
- Remove sudo:false as recommended by Travis (#604)
Released on: 2018-11-25
Released by: @Mogztter
Published by: Travis
v1.5.8
v1.5.7
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:
- how to use the built-in In-memory Logger,
- how to replace the default Logger,
- how to create a custom Logger,
- how to replace the default Logger formatter
- and much more...
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);
}
}));
- Map
AbstractBlock#hasBlocks
method in API (#534) thanks @mojavelinux
const doc = asciidoctor.load(source);
console.log(doc.hasBlocks());
- Map
AbstractBlock#append
method in API (#533) thanks @mojavelinux
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
Infrastructure
- The User Manual is now published with Antora on Netlify
- Switch back to npm and remove yarn.lock (#494)
- Run
npm audit fix
to fix security issues (74c22c1) - Replace
async
module withPromise
in npm tasks (#560)
Release Meta
Released on: 2018-10-30
Released by: @Mogztter
Published by: Travis