module Asciidoctor::Extensions::SyntaxProcessorDsl

Public Instance Methods

content_model(value) click to toggle source
# File lib/asciidoctor/extensions.rb, line 306
def content_model value
  option :content_model, value
end
Also aliased as: parse_content_as
default_attributes(value) click to toggle source
# File lib/asciidoctor/extensions.rb, line 318
def default_attributes value
  option :default_attrs, value
end
Also aliased as: default_attrs
default_attrs(value)

NOTE default_attrs alias is deprecated

Alias for: default_attributes
name_positional_attributes(*value)
named(value) click to toggle source
# File lib/asciidoctor/extensions.rb, line 297
def named value
  # NOTE due to how processors get initialized, we must defer this assignment in some scenarios
  if Processor === self
    @name = value
  else
    option :name, value
  end
end
parse_content_as(value)
Alias for: content_model
positional_attributes(*value) click to toggle source
# File lib/asciidoctor/extensions.rb, line 311
def positional_attributes *value
  option :positional_attrs, value.flatten
end
positional_attrs(*value)

NOTE positional_attrs alias is deprecated

resolve_attributes(*args) click to toggle source
# File lib/asciidoctor/extensions.rb, line 324
def resolve_attributes *args
  # NOTE assume true as default value; rewrap single-argument string or symbol
  if (args = args.fetch 0, true).respond_to? :to_sym
    args = [args]
  end unless args.size > 1
  case args
  when true
    option :positional_attrs, []
    option :default_attrs, {}
  when ::Array
    names, defaults = [], {}
    args.each do |arg|
      if (arg = arg.to_s).include? '='
        name, _, value = arg.partition '='
        if name.include? ':'
          idx, _, name = name.partition ':'
          idx = idx == '@' ? names.size : idx.to_i
          names[idx] = name
        end
        defaults[name] = value
      elsif arg.include? ':'
        idx, _, name = arg.partition ':'
        idx = idx == '@' ? names.size : idx.to_i
        names[idx] = name
      else
        names << arg
      end
    end
    option :positional_attrs, names.compact
    option :default_attrs, defaults
  when ::Hash
    names, defaults = [], {}
    args.each do |key, val|
      if (name = key.to_s).include? ':'
        idx, _, name = name.partition ':'
        idx = idx == '@' ? names.size : idx.to_i
        names[idx] = name
      end
      defaults[name] = val if val
    end
    option :positional_attrs, names.compact
    option :default_attrs, defaults
  else
    raise ::ArgumentError, %(unsupported attributes specification for macro: #{args.inspect})
  end
end
Also aliased as: resolves_attributes
resolves_attributes(*args)

NOTE resolves_attributes alias is deprecated

Alias for: resolve_attributes