操作文档
更新文档属性
要更新文档属性,您需要使用 setAttribute
函数:
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'
javascript
取消文档属性
要取消文档属性,您需要使用 removeAttribute
函数:
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
javascript
接下来做什么?
您可以阅读 API 文档 以了解更多关于 API 的信息。