注册一个或多个扩展

这些扩展是通过一个类似DSL的回调函数来为每个文档注册的。

Asciidoctor::Extensions.register do |document|
  preprocessor FrontMatterPreprocessor
  tree_processor ShellSessionTreeProcessor
  postprocessor CopyrightFooterPostprocessor
  docinfo_processor TrackingCodeDocinfoProcessor if document.basebackend? 'html'
  block ShoutBlock
  block_macro GistBlockMacro if document.basebackend? 'html'
  inline_macro ManInlineMacro
  include_processor UriIncludeProcessor
end
Caution
扩展类必须在注册块之外定义。一旦扩展类被注册,它就会被冻结,阻止进一步修改。如果你在注册块内部定义扩展类,在后续的调用中会导致错误。

您可以注册多个同类型的处理器,尽管每个自定义块或宏只能有一个处理器。每个注册的类都会在创建[.class]#Asciidoctor::Document#时实例化。