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

Postprocessor Extension Example

Purpose

Replace every occurrence of the word "digital" or "digitale" by "numérique"…​ Pretty useful right? :)

sample-digital-doc.adoc

= Le digital au service de la relation client

Comment la révolution digitale va transformer votre entreprise.

DigitalPostprocessor

digital-postprocessor.js
export default function (registry) {
  registry.postprocessor(function () {
    const self = this
    self.process(function (doc, output) {
      return output.replace(/digitale?/g, 'numérique')
    })
  })
}

Usage

import { Extensions, convertFile } from '@asciidoctor/core'
import registerDigitalPostprocessor from './digital-postprocessor.js'

const registry = Extensions.create()
registerDigitalPostprocessor(registry)

const html = await convertFile('sample-digital-doc.adoc', { to_file: false, extension_registry: registry })
console.log(html) // digital is gone... Long live numérique!