module Asciidoctor::Extensions::SyntaxDsl - asciidoctor-1.5.6.2 Documentation

# module Asciidoctor::Extensions::SyntaxDsl

### Public Instance Methods

content_model(value) click to toggle source

    # File lib/asciidoctor/extensions.rb, line 247
    def content_model value
      option :content_model, value
    end

Also aliased as: parse_content_as, parses_content_as
default_attrs(value) click to toggle source

    # File lib/asciidoctor/extensions.rb, line 261
    def default_attrs value
      option :default_attrs, value
    end

match_name(value)

NOTE #match_name may get deprecated

Alias for: named
name_attributes(*value)
Alias for: positional_attrs
name_positional_attributes(*value)
Alias for: positional_attrs
named(value) click to toggle source

    # File lib/asciidoctor/extensions.rb, line 236
    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

Also aliased as: match_name
parse_content_as(value)
Alias for: content_model
parses_content_as(value)
Alias for: content_model
positional_attrs(*value) click to toggle source

alias parse_as #content_model alias parsed_as #content_model

    # File lib/asciidoctor/extensions.rb, line 255
    def positional_attrs *value
      option :pos_attrs, value.flatten
    end

Also aliased as: name_attributes, name_positional_attributes
resolve_attributes(*args)

NOTE we may decide to drop this alias

Alias for: resolves_attributes
resolves_attributes(*args) click to toggle source

    # File lib/asciidoctor/extensions.rb, line 265
    def resolves_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 :pos_attrs, []
        option :default_attrs, {}
      when ::Array
        names, defaults = [], {}
        args.each do |arg|
          if (arg = arg.to_s).include? '='
            name, value = arg.split '=', 2
            if name.include? ':'
              idx, name = name.split ':', 2
              idx = idx == '@' ? names.size : idx.to_i
              names[idx] = name
            end
            defaults[name] = value
          elsif arg.include? ':'
            idx, name = arg.split ':', 2
            idx = idx == '@' ? names.size : idx.to_i
            names[idx] = name
          else
            names << arg
          end
        end
        option :pos_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.split ':', 2
            idx = idx == '@' ? names.size : idx.to_i
            names[idx] = name
          end
          defaults[name] = val if val
        end
        option :pos_attrs, names.compact
        option :default_attrs, defaults
      else
        raise ::ArgumentError, %Q(unsupported attributes specification for macro: #{args.inspect})
      end
    end

Also aliased as: resolve_attributes