require 'asciidoctor/doctest/io/base' require 'corefines' using Corefines::Object[:blank?, :presence] using Corefines::String::concat! module Asciidoctor::DocTest module IO ## # Subclass of {IO::Base} for XML-based backends. # # @example Format of the example's header # #

The example's content in HTML.

# #
The trailing new line (below this) will be removed.
# class XML < Base def parse(input, group_name) examples = [] current = create_example(nil) in_comment = false input.each_line do |line| line.chomp! if line =~ /^').strip (current.desc ||= '').concat!(desc, "\n") unless desc.empty? end else current.content.concat!(line, "\n") end in_comment &= !line.end_with?('-->') end examples end def serialize(examples) Array(examples).map { |exmpl| header = [ ".#{exmpl.local_name}", exmpl.desc.presence, *format_options(exmpl.opts) ].compact header_str = header.one? ? (header.first + ' ') : (header.join("\n") + "\n") [ "", exmpl.content.presence ].compact.join("\n") + "\n" }.join("\n") end end end end