Sha256: 6253a71c21e18f615e3ffc3ef22b9a9c09eb02d0ef70abfe80dc2ff14e5eada2

Contents?: true

Size: 858 Bytes

Versions: 2

Compression:

Stored size: 858 Bytes

Contents

module Metanorma
  module ISO
    class EditorAdmonitionBlock < Asciidoctor::Extensions::BlockProcessor
      use_dsl
      named :EDITOR
      on_contexts :example, :paragraph

      def process(parent, reader, attrs)
        attrs["name"] = "editorial"
        attrs["caption"] = "EDITOR"
        create_block(parent, :admonition, reader.lines, attrs,
                     content_model: :compound)
      end
    end

    class EditorInlineAdmonitionBlock < Asciidoctor::Extensions::Treeprocessor
      def process(document)
        (document.find_by context: :paragraph).each do |para|
          next unless /^EDITOR: /.match? para.lines[0]

          para.set_attr("name", "editorial")
          para.set_attr("caption", "EDITOR")
          para.lines[0].sub!(/^EDITOR: /, "")
          para.context = :admonition
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
metanorma-iso-2.1.3 lib/metanorma/iso/macros.rb
metanorma-iso-2.1.2 lib/metanorma/iso/macros.rb