Manipulate a document
Update a document attribute
To update a document attribute, you will need to use the setAttribute
function:
var content = '== Title'
var doc = asciidoctor.load(content)
console.log(doc.getAttribute('data-uri')) // prints undefined
console.log(doc.getAttribute('data-uri', 'false')) // prints 'false'
doc.setAttribute('data-uri', 'true')
console.log(doc.getAttribute('data-uri')) // prints 'true'
Unset a document attribute
To unset a document attribute, you will need to use the removeAttribute
function:
var content = '== Title'
var doc = asciidoctor.load(content)
doc.setAttribute('data-uri', 'true')
console.log(doc.getAttribute('data-uri')) // prints 'true'
doc.removeAttribute('data-uri')
console.log(doc.getAttribute('data-uri')) // prints undefined
What’s next?
You can read the API docs to learn more about the API.