Skip to content

Releases: asciidoctor/asciidoctor.js

v2.2.5

08 Aug 10:40
Compare
Choose a tag to compare

Summary

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

An internal change was made to how lines are iterated by the reader (switching from a stack to a queue), which will substantially improve the performance when processing large files.
Please note that this change should be seamless unless you were accessing the lines property on the reader directly.

Release meta

Released on: 2021-08-08
Released by: @Mogztter
Published by: GitHub Actions

Logs: full diff

📖 API documentation
📚 User Manual

Changelog

Bug Fixes

  • Invoke LoggerManager#setLogger setter - thanks @mojavelinux (#1322)
  • Strip alternate BOM that uses char code 65279 when input passes through a Buffer - thanks @mojavelinux (#1344)
  • Properly cache the helpers file in the template converter - thanks @yGuy (#1373)

Improvements

  • Build against the latest release of Asciidoctor 2.0.16

Infrastructure

  • Run npm audit fix

v2.2.4

30 Apr 15:16
Compare
Choose a tag to compare

Summary

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

It includes all the fixes from Asciidoctor 2.0.15 without any additional changes in Asciidoctor.js.

Release meta

Released on: 2021-04-30
Released by: @Mogztter
Published by: GitHub Actions

Logs: full diff

📖 API documentation
📚 User Manual

v2.2.4-rc.2

28 Apr 20:20
Compare
Choose a tag to compare
2.2.4-rc.2

v2.2.4-rc.1

20 Apr 09:17
Compare
Choose a tag to compare
2.2.4-rc.1

v2.2.3

13 Apr 08:36
Compare
Choose a tag to compare

Summary

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

It includes all the fixes from Asciidoctor 2.0.13 without any additional changes in Asciidoctor.js.

Release meta

Released on: 2021-04-13
Released by: @Mogztter
Published by: GitHub Actions

Logs: full diff

📖 API documentation
📚 User Manual

v2.2.2

24 Mar 20:46
Compare
Choose a tag to compare

Summary

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

Release meta

Released on: 2021-03-24
Released by: @Mogztter
Published by: GitHub Actions

Logs: full diff

Changelog

Bug Fixes

  • Upgrade to Asciidoctor Opal runtime 0.3.2 (#1228)
    • Critical performance optimization for Node.js > 10 on Array.shift (when Array.prototype has been modified). See: opal/opal#2115
    • Check if Opal is already loaded. See: Mogztter/asciidoctor-opal-node-runtime#58
  • Backport bug fixes on v2.2.x branch (#1234)
  • Fix incorrect type definitions on AbstractNode#getImageUri, #getMediaUri, #getIconUri (#1193)
  • Fix type definitions on Document#getDocumentTitle, #getTitle (can return undefined) (#1150)
  • Fix type definitions on AbstractNode#getParent (can return undefined) (#1131)
  • Map AbstractBlock#alt (and Inline#alt) (#1192)
  • AbstractNode#resolveSubstitutions returns undefined (#1153)

Infrastructure

  • Post a release announcement on Zulip (#1235)

Documentation

📖 API documentation
📚 User Manual

v2.2.1

26 Nov 18:16
Compare
Choose a tag to compare

Summary

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

Highlights

This version includes all the bug fixes and improvements introduced in Asciidoctor Ruby 2.0.11 and 2.0.12 🎉
It also contains a few bug fixes and improvements related to the Asciidoctor.js API.

Release meta

Released on: 2020-11-26
Released by: @Mogztter
Published by: GitHub Actions

Logs: full diff

Changelog

Bug Fixes

  • Pass Opal.nil when title is undefined (#1010)

Improvements

  • Map AbstractBlock#assignCaption (#1011)
const doc = asciidoctor.load('= Title')
const image = asciidoctor.Block.create(doc, 'image', {
  content_model: 'empty',
  attributes: {
    target: `${testOptions.baseDir}/spec/fixtures/images/cat.png[]`,
    format: 'png'
  }
})
image.setTitle('A cat')
image.assignCaption('Figure I. ')
console.log(image.getCaptionedTitle()) // Figure I. A nice cat'
  • Map positional attributes (#1047)
const doc = asciidoctor.load('[positional1,positional2,attr=value]\ntext')
const block = doc.getBlocks()[0]
const attributes = block.getAttributes()
console.log(Object.getOwnPropertyNames(attributes)) // ['attr', 'style']
console.log(Object.getOwnPropertyNames(attributes)) // ['$positional', 'attr', 'style']
console.log(attributes.$positional) // ['positional1', 'positional2'])

Infrastructure

  • Build against the latest release of Asciidoctor 2.0.12 (#808)
  • Upgrade development dependencies
    • Bump http-server from 0.12.1 to 0.12.3 in /packages/core (#953)
    • Bump dtslint from 3.4.2 to 3.6.3 in /packages/core (#958) (#971) (#976)
    • Bump puppeteer from 3.0.1 to 3.1.0 in /packages/core (#956) (#961) (#963) (#974)
    • Bump @types/node from 13.13.4 to 13.13.5 in /packages/core (#960)
    • Bump standard from 14.3.3 to 14.3.4 (#966) (#965)
    • Bump ejs from 3.1.2 to 3.1.3 in /packages/core (#970)
  • Add an explicit dependency on typescript (development dependency)
  • Flag the macos runner as experimental and allow failures (#959)
  • Build against the current Node LTS and the latest stable version (#973)
  • Document how to compile a local asciidoctor Ruby code base - thanks @djenks (#978)
  • Run npm audit fix
  • Add a test case on externalized footnotes

📖 API documentation
📚 User Manual

v2.2.0

28 Apr 15:55
Compare
Choose a tag to compare

Summary

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

Highlights

The main feature highlight of the 2.2 release is the built-in template converter which supports out-of-the-box Pug, Nunjucks, EJS and Handlebars (optional dependency).
The quickest way to get started is to install one of the above template engine and to define a template directory. Here's a quick example on how to setup the template converter with Nunjucks:

install

$ npm i nunjucks

/path/to/templates/paragraph.njk

<p>{{ node.getContent() | safe }}</p>

convert.js

const options = { safe: 'safe', backend: 'html5', template_dir: '/path/to/templates' }
console.log(asciidoctor.convert('...', options))

Please note that we also provide all-in-one pack binaries that include the templates engines, so it's even easier to get started:

$ echo 'Hello *world*' | ./asciidoctor-linux -s -T ./templates -
<p>Hello <strong>world</strong></p>

If you want to learn more about the template converter, please read the documentation.

Release meta

Released on: 2020-04-28
Released by: @Mogztter
Published by: GitHub Actions

Logs: full diff

Changelog

Bug Fixes

  • asciidoctor command line installed from the package asciidoctor was throwing an exception (#849) - thanks @thorstenkampe
  • AbstractNode.hasSection now returns false for anything that isn’t itself a Section (#840) - thanks @henriette-einstein
  • Properly assign backend traits on converter instances (#904)
  • Bridge Converter.handles? method (#906)
  • Add or bridge the Converter.respond_to? method (#908)
  • Add or bridge the Converter.composed method (#907)
  • AbstractNode.getAttributes now returns undefined when the value is Opal.nil (#920)

Improvements

  • Upgrade @asciidoctor/cli in the asciidoctor package to 3.4.0 (#902)
  • Add a built-in template converter which supports out-of-the-box the following template engines (optional dependency):
    • Pug
    • Nunjucks
    • EJS
    • Handlebars
const options = { safe: 'safe', backend: 'html5', template_dir: '/path/to/templates' }
console.log(asciidoctor.convert('...', options))
  • Map Document.restoreAttributes (#843) (#851)
  • Map an internal API Document.playbackAttributes (#844) (#853)
  • Map Table, Column and Cell methods (#854) - many thanks to @henriette-einstein
  • Map Table.Cell.getInnerDocument (#901)
  • Map Substitutors.resolveSubstitutions, .resolveBlockSubstitutions and .resolvePassSubstitutions (#852)
  • Map ConverterFactory.getRegistry (#909)
class BlankConverter {
  convert () {
    return ''
  }
}
asciidoctor.ConverterFactory.register(new BlankConverter(), ['blank'])
const registry = asciidoctor.ConverterFactory.getRegistry()
registry.blank.convert()
  • Map ConverterFactory.for (#910)
const builtinHtml5Converter = asciidoctor.ConverterFactory.for('html5')
builtinHtml5Converter.convert()

asciidoctor.ConverterFactory.for('foo') // undefined

Infrastructure

  • Publish binaries of the asciidoctor CLI on GitHub releases (#929)
  • Update development dependencies
    • Bump libnpmpublish from 1.1.1 to 3.0.0 (#863)
    • Bump cross-env from 5.1.4 to 6.0.3 in /packages/core (#879)
    • Bump dtslint from 2.0.3 to 3.4.2 in /packages/core (#888) (#871) (#940)
    • Bump @types/node from 12.7.8 to 13.13.4 in /packages/core (#889) (#874) (#866) (#932) (#934) (#938) (#947)
    • Bump documentation from 12.1.3 to 12.1.4 in /packages/core (#882)
    • Bump sinon from 5.0.6 to 8.1.1 (#872)
    • Bump puppeteer from 1.18.0 to 3.0.1 in /packages/core (#876) (#931) (#939)
    • Bump eslint from 5.12.1 to 6.8.0 in /packages/core (#877)
    • Bump standard from 12.0.1 to 14.3.3 (#862)
    • Bump standard from 12.0.1 to 14.3.3 in /packages/core (#870)
    • Bump mocha from 6.1.4 to 7.1.2 in /packages/core (#864) (#946)
    • Bump mocha from 5.1.1 to 7.1.2 (#867) (#945)
    • Bump chai from 4.1.2 to 4.2.0 in /packages/core (#868)
    • Bump chai from 4.1.2 to 4.2.0 (#869)
    • Bump acorn from 5.7.3 to 5.7.4 in /packages/core (#860)
    • Bump acorn from 6.1.1 to 6.4.1 (#859)
    • Bump ejs from 3.0.1 to 3.0.2 in /packages/core (#922)
    • Bump pkg from 4.4.7 to 4.4.8 in /packages/asciidoctor (#948)
  • Add an explicit failure if the regular expression does not match in tests (#890)
  • Replace a Ruby example with a JavaScript example in the JSDoc (#856)
  • Increase tests timeout (#857)
  • Fix the test:graalvm task on macOS (#840)
  • Keep .dts directory to workaround an issue with npm/Travis (#842)
  • Test types against the built file (not the dist file) (#841)
  • Build on GitHub Actions (Windows) (#835)
  • Build the project on upstream changes (#839)
  • Fix newlines compatibility issues in tests (#838)
  • Add GitHub Actions badge (#836)
  • Run GitHub Actions on pull requests (#837)

📖 API documentation
📚 User Manual

v2.1.1

02 Feb 10:48
Compare
Choose a tag to compare

Summary

This release is based on Asciidoctor 2.0.10 and Opal 0.11.99.dev (31d26d69).
This release actually contains the TypeScript Declare File! It also includes a few bug fixes and improvements.

Release meta

Released on: 2020-02-01
Released by: @Mogztter
Published by: Travis

Logs: full diff

Changelog

Bug Fixes

  • Fix type definition for AbstractBlock.getCaption (#831) - thanks @cexbrayat
  • Return undefined if the style is Opal.nil on AbstractBlock.getCaption (#831) - thanks @cexbrayat
  • Add the missing SyntaxHighlighter type definition (#832)

Improvements

  • Deprecate SyntaxHighlighter.for, use SyntaxHighlighter.get instead (#832)
  • Upgrade @asciidoctor/cli in the asciidoctor package to 3.2.0

Infrastructure

  • Include the TypeScript Definition File in the npm packages 😅 (#827)

📖 API documentation
📚 User Manual

v2.1.0

26 Jan 14:10
Compare
Choose a tag to compare

Summary

This release is based on Asciidoctor 2.0.10 and Opal 0.11.99.dev (31d26d69).
It provides a TypeScript Declaration File, maps new functions and classes in the API and improves the registration of converters 🎉
In addition, it includes all the bug fixes and improvements made in Asciidoctor Ruby in 2.0.10.

Release meta

Released on: 2020-01-26
Released by: @Mogztter
Published by: Travis

Logs: full diff

Changelog

Bug Fixes

  • Return undefined if the style is Opal.nil on AbstractBlock.getStyle
  • Return undefined if the level is Opal.nil on AbstractBlock.getLevel
  • Processor.resolveAttributes can take a JSON, a boolean, a string, an array of strings or a list of strings as argument (#780)
const registry = asciidoctor.Extensions.create(function () {
  this.inlineMacro('deg', function () {
    this.resolveAttributes('1:units', 'precision=1')
    //this.resolveAttributes(['1:units', 'precision=1'])
    //this.resolveAttributes({ '1:units': undefined, 'precision': 1 })
    this.process(function (parent, target, attributes) {
      // ...
    })
  })
})
  • Return undefined if the reftext is Opal.nil on an AbstractNode.getReftext
  • Attach applySubstitutions to AbstractNode instead of AbstractBlock (#793)
  • Deprecate counterIncrement, use Document.incrementAndStoreCounter instead (#792)
  • Add chrome:// as a root path in a browser environment (#816)

Improvements

  • Processor.resolvesAttributes is deprecated (in favor of resolveAttributes)
  • Add a TypeScript Declaration File (#752, #775, #826, #825)
  • Map AbstractBlock.setStyle (#737)
  • Map AbstractBlock.setTitle (#737)
  • Map AbstractBlock.getSourceLocation (#737)
  • Map Section.setLevel (#737)
  • Map SyntaxProcessorDsl.defaultAttributes (#785)
registry.inlineMacro('attrs', function () {
  const self = this
  self.matchFormat('short')
  self.defaultAttributes({ 1: 'a', 2: 'b', 'foo': 'baz' })
  self.positionalAttributes('a', 'b')
  self.process((parent, target, attrs) => {
    // ...
  })
})
  • Initialize backend traits when registering a converter as an ES6 class or instance (#769)
// register a converter as an ES6 class
class TEIConverter {
  constructor (backend, _) {
    this.backend = backend
    this.backendTraits = {
      basebackend: 'xml',
      outfilesuffix: '.xml',
      filetype: 'xml',
      htmlsyntax: 'xml'
    }
  }
}
asciidoctor.ConverterFactory.register(TEIConverter, ['tei'])
// register a converter as an ES6 class instance
class TEIConverter {
  constructor () {
    this.backend = 'tei'
    this.basebackend = 'xml'
    this.outfilesuffix = '.xml'
    this.filetype = 'xml'
    this.htmlsyntax = 'xml'
  }
}
asciidoctor.ConverterFactory.register(new TEIConverter(), ['tei'])
  • Bridge ES6 class methods when registering a converter (#766)
class DelegateConverter {
  convert (node, transform) {
    // delegate to the class methods
    return this[`convert_${transform || node.node_name}`](node)
  }
  convert_embedded (node) {
    return `<delegate>${node.getContent()}</delegate>`
  }
  convert_paragraph (node) {
    return node.getContent()
  }
}
asciidoctor.ConverterFactory.register(new DelegateConverter(), ['delegate'])
  • Map Asciidoctor.SafeMode (#777)
console.log(asciidoctor.SafeMode.UNSAFE) // 0
console.log(asciidoctor.SafeMode.SAFE) // 1
console.log(asciidoctor.SafeMode.SERVER) // 10
console.log(asciidoctor.SafeMode.SECURE) // 20
console.log(asciidoctor.SafeMode.getValueForName('secure')) // 20
console.log(asciidoctor.SafeMode.getNameForValue(0)) // 'unsafe'
console.log(asciidoctor.SafeMode.getNames()) // ['unsafe', 'safe', 'server', 'secure']
  • Map Processor.createParagraph (#774)
  • Map Processor.createOpenBlock (#774)
  • Map Processor.createExampleBlock (#774)
  • Map Processor.createPassBlock (#774)
  • Map Processor.createListingBlock (#774)
  • Map Processor.createLiteralBlock (#774)
  • Map Processor.createAnchor (#774)
  • Map Processor.createInlinePass (#774)
  • Map AbstractNode.setId (#791)
  • Add Block.create to instantiate a new Block object (#796)
  • Add Section#create to instantiate a new Section object (#795)
  • Map Document.incrementAndStoreCounter (#792)
  • Map Reader.advance (#804)
  • Map Document.setSourcemap (#810)
doc.setSourcemap(true)
  • Map Processor.getConfig (#812)
  • Map Processor.option (#813)
registry.inlineMacro('package', function () {
  this.option('defaultPackageUrlFormat', 'https://packages.ubuntu.com/bionic/%s')
  this.process(function (parent, target) {
    const format = parent.getDocument().getAttribute('url-package-url-format', this.getConfig().defaultPackageUrlFormat)
    return this.createInline(parent, 'anchor', target, { type: 'link', target: format.replace('%s', target), attributes: { window: '_blank' } })
  })
})
  • Map Asciidoctor.Callouts (#814)
  • Map Processor.parseAttributes (#815)
  • Upgrade @asciidoctor/cli in the asciidoctor package to 3.1.1 (#820)
  • Add ES module interoperability when using TypeScript (#821)
  • Map InlineProcessor.match (#823)

Infrastructure

  • Run npm audit fix
  • Add tests on the docinfo feature (#734)
  • Add tests on a macro that creates a link (#745)
  • Upgrade development dependency documentation to 12.1.3 (#762)
  • Upgrade development dependency mocha to 6.1.4 (#739)
  • Upgrade development dependency puppeteer to 1.18.0 (#740)
  • Upgrade development dependency sinon to 7.3.2 (#741)
  • Upgrade development dependency eslint-utils from 1.3.1 to 1.4.2 (#749)
  • Add a sponsor button to GitHub that links to Open collective
  • Use a semantic versioning comparison in tests (#754)
  • Add tests on multiple single-item menu macros in single line (#754)
  • Upgrade GraalVM to 19.3.0 (#772)
  • Enable tests on findBy API (with reject) (#806)
  • Build against the latest release of Asciidoctor 2.0.10 (#808)
  • Add tests on the TypeScript Definition File (#800)

Documentation