This documentation covers a prerelease version of the software. Follow this link to view the documentation for the stable version (3.0) instead.

Manipulate a document

Update a document attribute

To update a document attribute, use the setAttribute function on the loaded document:

import { load } from '@asciidoctor/core'

const doc = await load('== Title')
console.log(doc.getAttribute('data-uri'))         // undefined
console.log(doc.getAttribute('data-uri', 'false')) // 'false'

doc.setAttribute('data-uri', 'true')
console.log(doc.getAttribute('data-uri'))          // 'true'

Unset a document attribute

To unset a document attribute, use the removeAttribute function:

import { load } from '@asciidoctor/core'

const doc = await load('== Title')
doc.setAttribute('data-uri', 'true')
console.log(doc.getAttribute('data-uri')) // 'true'

doc.removeAttribute('data-uri')
console.log(doc.getAttribute('data-uri')) // undefined

What’s next?

You can read the API docs to learn more about the API.