asciidoctor.js

1.5.5-5

Methods for parsing AsciiDoc input files and converting documents.

AsciiDoc documents comprise a header followed by zero or more sections. Sections are composed of blocks of content. For example:

  = Doc Title

  == Section 1

  This is a paragraph block in the first section.

  == Section 2

  This section has a paragraph block and an olist block.

  . Item 1
  . Item 2
Asciidoctor
Example
asciidoctor.convertFile('sample.adoc');
Static Members
getCoreVersion()
convert(input, options)
convertFile(filename, options)
load(input, options)
loadFile(filename, options)
getVersion()
AbstractBlock

Extends AbstractNode

Static Members
getTitle()
getCaptionedTitle()
getStyle()
getCaption()
setCaption(caption)
getLevel()
getBlocks()
getContent()
convert()
findBy(selector?, block?)
getLineNumber()
AbstractNode
Static Members
getAttributes()
getAttribute(name, defaultValue, inherit)
isAttribute(name, expectedValue, inherit)
setAttribute(name, value, overwrite)
removeAttribute(name)
getDocument()
isInline()
isRole(expected)
hasRole(name)
getRoles()
addRole(name)
removeRole(name)
isReftext()
getReftext()
getContext()
isOption(name)
setOption(name)
getIconUri(name)
getMediaUri(target, assetDirKey)
getImageUri(targetImage, assetDirKey)
getConverter()
readContents(target, options)
readAsset(path, options)
normalizeWebPath(target, start, preserveTargetUri)
normalizeSystemPath(target, start, jail, options)
normalizeAssetPath(assetRef, assetName, autoCorrect)
Document

Extends AbstractBlock

Static Members
getHeader()
setAttribute(name, value)
removeAttribute(name)
convert(options)
write(output, target)
getAuthor()
getSource()
getSourceLines()
isNested()
hasFootnotes()
getFootnotes()
isEmbedded()
hasExtensions()
getDoctype()
getBackend()
isBasebackend(base)
getTitle()
setTitle(title)
getDocumentTitle(options)
getDoctitle(options)
getCatalog()
getRevisionDate()
getRevdate()
getRevisionNumber()
getRevisionRemark()
hasRevisionInfo()
getNotitle()
getNoheader()
getNofooter()
hasHeader()
deleteAttribute(name)
isAttributeLocked(name)
parse(data)
getDocinfo(docinfoLocation, suffix)
hasDocinfoProcessors(docinfoLocation)
counterIncrement(counterName, block)
counter(name, seed)
getCompatMode()
getSourcemap()
getReferences()
getCounters()
getCallouts()
getBaseDir()
getOptions()
getOutfilesuffix()
getParentDocument()
getReader()
getConverter()
getExtensions()

Document/RevisionInfo

src/asciidoctor-core-api.js
Document/RevisionInfo
Static Members
getDate()
getNumber()
getRemark()
isEmpty()
Document/Title
Static Members
getCombined()
getSubtitle()
isSanitized()
hasSubtitle()
Inline

Extends AbstractNode

Static Members
convert()
getText()
getType()
getTarget()
Reader
Static Members
pushInclude(data, file, path, lineno, attributes)
getCursor()
getLines()

Extensions provide a way to participate in the parsing and converting phases of the AsciiDoc processor or extend the AsciiDoc syntax.

The various extensions participate in AsciiDoc processing as follows:

  1. After the source lines are normalized, {Extensions/Preprocessor}s modify or replace the source lines before parsing begins. {Extensions/IncludeProcessor}s are used to process include directives for targets which they claim to handle.
  2. The Parser parses the block-level content into an abstract syntax tree. Custom blocks and block macros are processed by associated {Extensions/BlockProcessor}s and {Extensions/BlockMacroProcessor}s, respectively.
  3. {Extensions/TreeProcessor}s are run on the abstract syntax tree.
  4. Conversion of the document begins, at which point inline markup is processed and converted. Custom inline macros are processed by associated {InlineMacroProcessor}s.
  5. {Extensions/Postprocessor}s modify or replace the converted document.
  6. The output is written to the output stream.

Extensions may be registered globally using the {Extensions.register} method or added to a custom {Registry} instance and passed as an option to a single Asciidoctor processor.

Extensions
Example
Opal.Asciidoctor.Extensions.register(function () {
  this.block(function () {
    var self = this;
    self.named('shout');
    self.onContext('paragraph');
    self.process(function (parent, reader) {
      var lines = reader.$lines().map(function (l) { return l.toUpperCase(); });
      return self.createBlock(parent, 'paragraph', lines);
    });
  });
});
Static Members
create(name, block)
register(name, block)
unregisterAll()
Extensions/Registry
Static Members
block(name, block)
inlineMacro(name, block)
includeProcessor(block)
blockMacro(name, block)
treeProcessor(name, block)
postprocessor(name, block)
preprocessor(name, block)
docinfoProcessor(name, block)
Extensions/Processor
Static Members
process(block)
named(name)
createBlock(parent, context, source, attrs, opts)
createInline(parent, context, text, opts)
parseContent(parent, content, attrs)
positionalAttributes(value)

Extensions/BlockProcessor

src/asciidoctor-extensions-api.js
Extensions/BlockProcessor
Static Members
onContext(context)

Extensions/BlockMacroProcessor

src/asciidoctor-extensions-api.js
Extensions/BlockMacroProcessor

Extensions/IncludeProcessor

src/asciidoctor-extensions-api.js
Extensions/IncludeProcessor
Static Members
handles(block)

Extensions/TreeProcessor

src/asciidoctor-extensions-api.js
Extensions/TreeProcessor

Extensions/Postprocessor

src/asciidoctor-extensions-api.js
Extensions/Postprocessor

Extensions/Preprocessor

src/asciidoctor-extensions-api.js
Extensions/Preprocessor

Extensions/DocinfoProcessor

src/asciidoctor-extensions-api.js
Extensions/DocinfoProcessor
Static Members
atLocation(value)