Sha256: 7351ab72634ad1db1aef20aa5e399206b85355ab7cc90fca3198382227a79c0c

Contents?: true

Size: 652 Bytes

Versions: 3

Compression:

Stored size: 652 Bytes

Contents

module Asciidoctor
module Pdf
module FormattedText
class Formatter
  FormattingSnifferPattern = /[<&]/
  EOL = "\n"

  def initialize options = {}
    @parser = MarkupParser.new
    @transform = Transform.new merge_adjacent_text_nodes: true, theme: options[:theme]
  end

  def format string, *args
    options = args[0] || {}
    string = string.tr_s(EOL, ' ') if options[:normalize]
    return [text: string] unless string.match(FormattingSnifferPattern)
    if (parsed = @parser.parse(string))
      @transform.apply(parsed.content)
    else
      warn %(Failed to parse formatted text: #{string})
      [text: string]
    end
  end
end
end
end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
asciidoctor-pdf-1.5.0.alpha.11 lib/asciidoctor-pdf/formatted_text/formatter.rb
asciidoctor-pdf-1.5.0.alpha.10 lib/asciidoctor-pdf/formatted_text/formatter.rb
asciidoctor-pdf-1.5.0.alpha.9 lib/asciidoctor-pdf/formatted_text/formatter.rb