summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.adoc1
-rw-r--r--features/step_definitions.rb6
-rw-r--r--lib/asciidoctor.rb38
-rw-r--r--lib/asciidoctor/abstract_block.rb12
-rw-r--r--lib/asciidoctor/abstract_node.rb11
-rw-r--r--lib/asciidoctor/attribute_list.rb13
-rw-r--r--lib/asciidoctor/block.rb34
-rw-r--r--lib/asciidoctor/callouts.rb2
-rw-r--r--lib/asciidoctor/cli/invoker.rb8
-rw-r--r--lib/asciidoctor/converter.rb8
-rw-r--r--lib/asciidoctor/converter/docbook5.rb46
-rw-r--r--lib/asciidoctor/converter/factory.rb2
-rw-r--r--lib/asciidoctor/converter/html5.rb36
-rw-r--r--lib/asciidoctor/converter/manpage.rb34
-rw-r--r--lib/asciidoctor/converter/template.rb14
-rw-r--r--lib/asciidoctor/document.rb28
-rw-r--r--lib/asciidoctor/extensions.rb6
-rw-r--r--lib/asciidoctor/logging.rb4
-rw-r--r--lib/asciidoctor/parser.rb130
-rw-r--r--lib/asciidoctor/path_resolver.rb2
-rw-r--r--lib/asciidoctor/reader.rb48
-rw-r--r--lib/asciidoctor/stylesheets.rb4
-rw-r--r--lib/asciidoctor/substitutors.rb122
-rw-r--r--lib/asciidoctor/table.rb16
-rw-r--r--test/api_test.rb168
-rw-r--r--test/attribute_list_test.rb54
-rw-r--r--test/attributes_test.rb102
-rw-r--r--test/blocks_test.rb212
-rw-r--r--test/converter_test.rb64
-rw-r--r--test/document_test.rb270
-rw-r--r--test/extensions_test.rb60
-rw-r--r--test/links_test.rb94
-rw-r--r--test/lists_test.rb90
-rw-r--r--test/logger_test.rb10
-rw-r--r--test/manpage_test.rb92
-rw-r--r--test/paragraphs_test.rb10
-rw-r--r--test/parser_test.rb24
-rw-r--r--test/paths_test.rb10
-rw-r--r--test/preamble_test.rb4
-rw-r--r--test/reader_test.rb226
-rw-r--r--test/sections_test.rb52
-rw-r--r--test/substitutions_test.rb268
-rw-r--r--test/tables_test.rb50
-rw-r--r--test/text_test.rb32
44 files changed, 1256 insertions, 1261 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc
index b9c50f88..97c49c04 100644
--- a/CHANGELOG.adoc
+++ b/CHANGELOG.adoc
@@ -24,6 +24,7 @@ Enhancements::
Improvements::
+ * refactor code to use modern Hash syntax
* define LIB_DIR constant; rename *_PATH constants to *_DIR constants to be consistent with RubyGems terminology (#2764)
* only define ROOT_DIR if not already defined (for compatibility with Asciidoctor.js)
diff --git a/features/step_definitions.rb b/features/step_definitions.rb
index ae1dc5b6..9c740887 100644
--- a/features/step_definitions.rb
+++ b/features/step_definitions.rb
@@ -22,7 +22,7 @@ When /it is converted to html/ do
end
When /it is converted to docbook/ do
- @output = Asciidoctor.convert @source, :backend => :docbook
+ @output = Asciidoctor.convert @source, backend: :docbook
end
Then /the result should (match|contain) the (HTML|XML) source/ do |matcher, format, expected|
@@ -33,9 +33,9 @@ end
Then /the result should (match|contain) the (HTML|XML) structure/ do |matcher, format, expected|
result = @output
if format == 'HTML'
- options = { :format => :html, :disable_escape => true, :sort_attrs => false }
+ options = { format: :html, disable_escape: true, sort_attrs: false }
else # format == 'XML'
- options = { :format => :xhtml, :disable_escape => true, :sort_attrs => false }
+ options = { format: :xhtml, disable_escape: true, sort_attrs: false }
result = result.gsub '"/>', '" />' if result.include? '"/>'
end
result = Slim::Template.new(options) { result.each_line.map {|l| (l.start_with? '<') ? l : %(|#{l}) }.join }.render
diff --git a/lib/asciidoctor.rb b/lib/asciidoctor.rb
index 53516809..3e183c6d 100644
--- a/lib/asciidoctor.rb
+++ b/lib/asciidoctor.rb
@@ -39,7 +39,7 @@ end
#
# Use custom (Tilt-supported) templates:
#
-# Asciidoctor.convert_file 'sample.adoc', :template_dir => 'path/to/templates'
+# Asciidoctor.convert_file 'sample.adoc', template_dir: 'path/to/templates'
#
module Asciidoctor
# alias the RUBY_ENGINE constant inside the Asciidoctor namespace and define a precomputed alias for runtime
@@ -331,13 +331,13 @@ module Asciidoctor
MATHJAX_VERSION = '2.7.4'
BLOCK_MATH_DELIMITERS = {
- :asciimath => ['\$', '\$'],
- :latexmath => ['\[', '\]'],
+ asciimath: ['\$', '\$'],
+ latexmath: ['\[', '\]'],
}
INLINE_MATH_DELIMITERS = {
- :asciimath => ['\$', '\$'],
- :latexmath => ['\(', '\)'],
+ asciimath: ['\$', '\$'],
+ latexmath: ['\(', '\)'],
}
(STEM_TYPE_ALIASES = {
@@ -661,12 +661,12 @@ module Asciidoctor
# Matches the ordinals for each type of ordered list.
OrderedListMarkerRxMap = {
- :arabic => /\d+\./,
- :loweralpha => /[a-z]\./,
- :lowerroman => /[ivx]+\)/,
- :upperalpha => /[A-Z]\./,
- :upperroman => /[IVX]+\)/
- #:lowergreek => /[a-z]\]/
+ arabic: /\d+\./,
+ loweralpha: /[a-z]\./,
+ lowerroman: /[ivx]+\)/,
+ upperalpha: /[A-Z]\./,
+ upperroman: /[IVX]+\)/,
+ #lowergreek: /[a-z]\]/,
}
# Matches a description list entry.
@@ -738,10 +738,10 @@ module Asciidoctor
# A Hash of regexps for lists used for dynamic access.
ListRxMap = {
- :ulist => UnorderedListRx,
- :olist => OrderedListRx,
- :dlist => DescriptionListRx,
- :colist => CalloutListRx
+ ulist: UnorderedListRx,
+ olist: OrderedListRx,
+ dlist: DescriptionListRx,
+ colist: CalloutListRx,
}
## Tables
@@ -1438,16 +1438,16 @@ module Asciidoctor
# QUESTION should the jail be the working_dir or doc.base_dir???
jail = doc.safe >= SafeMode::SAFE ? working_dir : nil
if to_dir
- outdir = doc.normalize_system_path(to_dir, working_dir, jail, :target_name => 'to_dir', :recover => false)
+ outdir = doc.normalize_system_path(to_dir, working_dir, jail, target_name: 'to_dir', recover: false)
if to_file
- outfile = doc.normalize_system_path(to_file, outdir, nil, :target_name => 'to_dir', :recover => false)
+ outfile = doc.normalize_system_path(to_file, outdir, nil, target_name: 'to_dir', recover: false)
# reestablish outdir as the final target directory (in the case to_file had directory segments)
outdir = ::File.dirname outfile
else
outfile = ::File.join outdir, %(#{doc.attributes['docname']}#{doc.outfilesuffix})
end
elsif to_file
- outfile = doc.normalize_system_path(to_file, working_dir, jail, :target_name => 'to_dir', :recover => false)
+ outfile = doc.normalize_system_path(to_file, working_dir, jail, target_name: 'to_dir', recover: false)
# establish outdir as the final target directory (in the case to_file had directory segments)
outdir = ::File.dirname outfile
end
@@ -1510,7 +1510,7 @@ module Asciidoctor
stylesheet_dest = doc.normalize_system_path stylesheet, stylesoutdir, (doc.safe >= SafeMode::SAFE ? outdir : nil)
# NOTE don't warn if src can't be read and dest already exists (see #2323)
if stylesheet_src != stylesheet_dest && (stylesheet_data = doc.read_asset stylesheet_src,
- :warn_on_failure => !(::File.file? stylesheet_dest), :label => 'stylesheet')
+ warn_on_failure: !(::File.file? stylesheet_dest), label: 'stylesheet')
::IO.write stylesheet_dest, stylesheet_data
end
end
diff --git a/lib/asciidoctor/abstract_block.rb b/lib/asciidoctor/abstract_block.rb
index 58d8178b..278ba85b 100644
--- a/lib/asciidoctor/abstract_block.rb
+++ b/lib/asciidoctor/abstract_block.rb
@@ -100,10 +100,10 @@ class AbstractBlock < AbstractNode
#
# Examples
#
- # block = Block.new(parent, :preamble, :content_model => :compound)
+ # block = Block.new(parent, :preamble, content_model: :compound)
#
- # block << Block.new(block, :paragraph, :source => 'p1')
- # block << Block.new(block, :paragraph, :source => 'p2')
+ # block << Block.new(block, :paragraph, source: 'p1')
+ # block << Block.new(block, :paragraph, source: 'p2')
# block.blocks?
# # => true
# block.blocks.size
@@ -233,12 +233,12 @@ class AbstractBlock < AbstractNode
#
# doc << (sect1 = Section.new doc, 1)
# sect1.title = 'Section 1'
- # para1 = Block.new sect1, :paragraph, :source => 'Paragraph 1'
- # para2 = Block.new sect1, :paragraph, :source => 'Paragraph 2'
+ # para1 = Block.new sect1, :paragraph, source: 'Paragraph 1'
+ # para2 = Block.new sect1, :paragraph, source: 'Paragraph 2'
# sect1 << para1 << para2
# sect1 << (sect1_1 = Section.new sect1, 2)
# sect1_1.title = 'Section 1.1'
- # sect1_1 << (Block.new sect1_1, :paragraph, :source => 'Paragraph 3')
+ # sect1_1 << (Block.new sect1_1, :paragraph, source: 'Paragraph 3')
# sect1.blocks?
# # => true
# sect1.blocks.size
diff --git a/lib/asciidoctor/abstract_node.rb b/lib/asciidoctor/abstract_node.rb
index d63e3479..629b4e9d 100644
--- a/lib/asciidoctor/abstract_node.rb
+++ b/lib/asciidoctor/abstract_node.rb
@@ -370,7 +370,7 @@ class AbstractNode
# QUESTION what if ext is empty?
mimetype = (ext == '.svg' ? 'image/svg+xml' : %(image/#{ext.slice 1, ext.length}))
if asset_dir_key
- image_path = normalize_system_path(target_image, @document.attr(asset_dir_key), nil, :target_name => 'image')
+ image_path = normalize_system_path(target_image, @document.attr(asset_dir_key), nil, target_name: 'image')
else
image_path = normalize_system_path(target_image)
end
@@ -427,8 +427,7 @@ class AbstractNode
# Delegates to normalize_system_path, with the start path set to the value of
# the base_dir instance variable on the Document object.
def normalize_asset_path(asset_ref, asset_name = 'path', autocorrect = true)
- normalize_system_path(asset_ref, @document.base_dir, nil,
- :target_name => asset_name, :recover => autocorrect)
+ normalize_system_path(asset_ref, @document.base_dir, nil, target_name: asset_name, recover: autocorrect)
end
# Public: Resolve and normalize a secure path from the target and start paths
@@ -502,7 +501,7 @@ class AbstractNode
# if the file does not exist.
def read_asset path, opts = {}
# remap opts for backwards compatibility
- opts = { :warn_on_failure => (opts != false) } unless ::Hash === opts
+ opts = { warn_on_failure: (opts != false) } unless ::Hash === opts
if ::File.readable? path
if opts[:normalize]
(Helpers.prepare_source_string ::File.open(path, FILE_READ_MODE) {|f| f.read }).join LF
@@ -553,8 +552,8 @@ class AbstractNode
return
end
else
- target = normalize_system_path target, opts[:start], nil, :target_name => (opts[:label] || 'asset')
- read_asset target, :normalize => opts[:normalize], :warn_on_failure => (opts.fetch :warn_on_failure, true), :label => opts[:label]
+ target = normalize_system_path target, opts[:start], nil, target_name: (opts[:label] || 'asset')
+ read_asset target, normalize: opts[:normalize], warn_on_failure: (opts.fetch :warn_on_failure, true), label: opts[:label]
end
end
diff --git a/lib/asciidoctor/attribute_list.rb b/lib/asciidoctor/attribute_list.rb
index 66c85016..53764661 100644
--- a/lib/asciidoctor/attribute_list.rb
+++ b/lib/asciidoctor/attribute_list.rb
@@ -10,15 +10,15 @@ module Asciidoctor
# attrlist = Asciidoctor::AttributeList.new('astyle')
#
# attrlist.parse
-# => {0 => 'astyle'}
+# => { 0 => 'astyle' }
#
# attrlist.rekey(['style'])
-# => {'style' => 'astyle'}
+# => { 'style' => 'astyle' }
#
# attrlist = Asciidoctor::AttributeList.new('quote, Famous Person, Famous Book (2001)')
#
# attrlist.parse(['style', 'attribution', 'citetitle'])
-# => {'style' => 'quote', 'attribution' => 'Famous Person', 'citetitle' => 'Famous Book (2001)'}
+# => { 'style' => 'quote', 'attribution' => 'Famous Person', 'citetitle' => 'Famous Book (2001)' }
#
class AttributeList
BACKSLASH = '\\'
@@ -43,11 +43,8 @@ class AttributeList
BlankRx = /[ \t]+/
- # Public: Regular expressions for skipping blanks and delimiters
- SkipRxs = {
- :blank => BlankRx,
- ',' => /[ \t]*(,|$)/
- }
+ # Public: Regular expressions for skipping delimiters
+ SkipRxs = { ',' => /[ \t]*(,|$)/ }
def initialize source, block = nil, delimiter = ','
@scanner = ::StringScanner.new source
diff --git a/lib/asciidoctor/block.rb b/lib/asciidoctor/block.rb
index c915b0db..78fc4bc0 100644
--- a/lib/asciidoctor/block.rb
+++ b/lib/asciidoctor/block.rb
@@ -3,23 +3,23 @@ module Asciidoctor
#
# Examples
#
-# block = Asciidoctor::Block.new(parent, :paragraph, :source => '_This_ is a <test>')
+# block = Asciidoctor::Block.new(parent, :paragraph, source: '_This_ is a <test>')
# block.content
# => "<em>This</em> is a &lt;test&gt;"
class Block < AbstractBlock
(DEFAULT_CONTENT_MODEL = {
# TODO should probably fill in all known blocks
- :audio => :empty,
- :image => :empty,
- :listing => :verbatim,
- :literal => :verbatim,
- :stem => :raw,
- :open => :compound,
- :page_break => :empty,
- :pass => :raw,
- :thematic_break => :empty,
- :video => :empty
+ audio: :empty,
+ image: :empty,
+ listing: :verbatim,
+ literal: :verbatim,
+ stem: :raw,
+ open: :compound,
+ page_break: :empty,
+ pass: :raw,
+ thematic_break: :empty,
+ video: :empty,
}).default = :simple
# Public: Create alias for context to be consistent w/ AsciiDoc
@@ -42,7 +42,7 @@ class Block < AbstractBlock
# the `lock_in_subs` method to resolve and assign the substitutions to this
# block (which are resolved from the `subs` attribute, if specified, or the
# default substitutions based on this block's context). If you want to use the
- # default subs for a block, pass the option `:subs => :default`. You can
+ # default subs for a block, pass the option `subs: :default`. You can
# override the default subs using the `:default_subs` option.
#--
# QUESTION should we store source_data as lines for blocks that have compound content models?
@@ -53,16 +53,16 @@ class Block < AbstractBlock
# FIXME feels funky; we have to be defensive to get lock_in_subs to honor override
# FIXME does not resolve substitution groups inside Array (e.g., [:normal])
if (subs = opts[:subs])
- # e.g., :subs => :defult
+ # e.g., subs: :defult
# subs attribute is honored; falls back to opts[:default_subs], then built-in defaults based on context
if subs == :default
@default_subs = opts[:default_subs]
- # e.g., :subs => [:quotes]
+ # e.g., subs: [:quotes]
# subs attribute is not honored
elsif ::Array === subs
@default_subs = subs.drop 0
@attributes.delete 'subs'
- # e.g., :subs => :normal or :subs => 'normal'
+ # e.g., subs: :normal or subs: 'normal'
# subs attribute is not honored
else
@default_subs = nil
@@ -71,7 +71,7 @@ class Block < AbstractBlock
end
# resolve the subs eagerly only if subs option is specified
lock_in_subs
- # e.g., :subs => nil
+ # e.g., subs: nil
else
# NOTE @subs is initialized as empty array by super constructor
# prevent subs from being resolved
@@ -100,7 +100,7 @@ class Block < AbstractBlock
#
# doc = Asciidoctor::Document.new
# block = Asciidoctor::Block.new(doc, :paragraph,
- # :source => '_This_ is what happens when you <meet> a stranger in the <alps>!')
+ # source: '_This_ is what happens when you <meet> a stranger in the <alps>!')
# block.content
# => "<em>This</em> is what happens when you &lt;meet&gt; a stranger in the &lt;alps&gt;!"
def content
diff --git a/lib/asciidoctor/callouts.rb b/lib/asciidoctor/callouts.rb
index 30f1044e..b554a2d5 100644
--- a/lib/asciidoctor/callouts.rb
+++ b/lib/asciidoctor/callouts.rb
@@ -27,7 +27,7 @@ class Callouts
#
# Returns The unique String id of this callout
def register li_ordinal
- current_list << { :ordinal => li_ordinal.to_i, :id => (id = generate_next_callout_id) }
+ current_list.push ordinal: li_ordinal.to_i, id: (id = generate_next_callout_id)
@co_index += 1
id
end
diff --git a/lib/asciidoctor/cli/invoker.rb b/lib/asciidoctor/cli/invoker.rb
index 4bf998a3..6e3d5b35 100644
--- a/lib/asciidoctor/cli/invoker.rb
+++ b/lib/asciidoctor/cli/invoker.rb
@@ -100,16 +100,16 @@ module Asciidoctor
if stdin
# allows use of block to supply stdin, particularly useful for tests
input = block_given? ? yield : STDIN
- input_opts = opts.merge :to_file => tofile
+ input_opts = opts.merge to_file: tofile
if show_timings
- @documents << (::Asciidoctor.convert input, (input_opts.merge :timings => (timings = Timings.new)))
+ @documents << (::Asciidoctor.convert input, (input_opts.merge timings: (timings = Timings.new)))
timings.print_report err, '-'
else
@documents << (::Asciidoctor.convert input, input_opts)
end
else
infiles.each do |infile|
- input_opts = opts.merge :to_file => tofile
+ input_opts = opts.merge to_file: tofile
if abs_srcdir_posix && (input_opts.key? :to_dir)
abs_indir = ::File.dirname ::File.expand_path infile
if non_posix_env
@@ -122,7 +122,7 @@ module Asciidoctor
end
end
if show_timings
- @documents << (::Asciidoctor.convert_file infile, (input_opts.merge :timings => (timings = Timings.new)))
+ @documents << (::Asciidoctor.convert_file infile, (input_opts.merge timings: (timings = Timings.new)))
timings.print_report err, infile
else
@documents << (::Asciidoctor.convert_file infile, input_opts)
diff --git a/lib/asciidoctor/converter.rb b/lib/asciidoctor/converter.rb
index 76261b45..0621ed17 100644
--- a/lib/asciidoctor/converter.rb
+++ b/lib/asciidoctor/converter.rb
@@ -85,10 +85,10 @@ module Asciidoctor
syntax = 'html'
end
{
- :basebackend => base,
- :outfilesuffix => ext,
- :filetype => type,
- :htmlsyntax => syntax
+ basebackend: base,
+ outfilesuffix: ext,
+ filetype: type,
+ htmlsyntax: syntax,
}
end
diff --git a/lib/asciidoctor/converter/docbook5.rb b/lib/asciidoctor/converter/docbook5.rb
index 7e2a9327..13b614f4 100644
--- a/lib/asciidoctor/converter/docbook5.rb
+++ b/lib/asciidoctor/converter/docbook5.rb
@@ -80,23 +80,23 @@ module Asciidoctor
(DLIST_TAGS = {
'qanda' => {
- :list => 'qandaset',
- :entry => 'qandaentry',
- :label => 'question',
- :term => 'simpara',
- :item => 'answer'
+ list: 'qandaset',
+ entry: 'qandaentry',
+ label: 'question',
+ term: 'simpara',
+ item: 'answer',
},
'glossary' => {
- :list => nil,
- :entry => 'glossentry',
- :term => 'glossterm',
- :item => 'glossdef'
- }
+ list: nil,
+ entry: 'glossentry',
+ term: 'glossterm',
+ item: 'glossdef',
+ },
}).default = { # default is variable
- :list => 'variablelist',
- :entry => 'varlistentry',
- :term => 'term',
- :item => 'listitem'
+ list: 'variablelist',
+ entry: 'varlistentry',
+ term: 'term',
+ item: 'listitem',
}
def dlist node
@@ -600,14 +600,14 @@ module Asciidoctor
end
(QUOTE_TAGS = {
- :monospaced => ['<literal>', '</literal>', false],
- :emphasis => ['<emphasis>', '</emphasis>', true],
- :strong => ['<emphasis role="strong">', '</emphasis>', true],
- :double => ['<quote>', '</quote>', true],
- :single => ['<quote>', '</quote>', true],
- :mark => ['<emphasis role="marked">', '</emphasis>', false],
- :superscript => ['<superscript>', '</superscript>', false],
- :subscript => ['<subscript>', '</subscript>', false]
+ monospaced: ['<literal>', '</literal>', false],
+ emphasis: ['<emphasis>', '</emphasis>', true],
+ strong: ['<emphasis role="strong">', '</emphasis>', true],
+ double: ['<quote>', '</quote>', true],
+ single: ['<quote>', '</quote>', true],
+ mark: ['<emphasis role="marked">', '</emphasis>', false],
+ superscript: ['<superscript>', '</superscript>', false],
+ subscript: ['<subscript>', '</subscript>', false],
}).default = ['', '', true]
def inline_quoted node
@@ -672,7 +672,7 @@ module Asciidoctor
info_tag_prefix = '' unless use_info_tag_prefix
result = []
result << %(<#{info_tag_prefix}info>)
- result << document_title_tags(doc.doctitle :partition => true, :use_fallback => true) unless doc.notitle
+ result << document_title_tags(doc.doctitle partition: true, use_fallback: true) unless doc.notitle
if (date = (doc.attr? 'revdate') ? (doc.attr 'revdate') : ((doc.attr? 'reproducible') ? nil : (doc.attr 'docdate')))
result << %(<date>#{date}</date>)
end
diff --git a/lib/asciidoctor/converter/factory.rb b/lib/asciidoctor/converter/factory.rb
index d8ff85cb..5dd35fd3 100644
--- a/lib/asciidoctor/converter/factory.rb
+++ b/lib/asciidoctor/converter/factory.rb
@@ -11,7 +11,7 @@ module Asciidoctor
# backend can be thought of as an intent to convert a document to a
# specified format. For example:
#
- # converter = Asciidoctor::Converter::Factory.create 'html5', :htmlsyntax => 'xml'
+ # converter = Asciidoctor::Converter::Factory.create 'html5', htmlsyntax: 'xml'
#
# Converter objects are thread safe. They only survive the lifetime of a single conversion.
#
diff --git a/lib/asciidoctor/converter/html5.rb b/lib/asciidoctor/converter/html5.rb
index 8f7a1ae3..f5dde8fd 100644
--- a/lib/asciidoctor/converter/html5.rb
+++ b/lib/asciidoctor/converter/html5.rb
@@ -3,19 +3,19 @@ module Asciidoctor
# consistent with the html5 backend from AsciiDoc Python.
class Converter::Html5Converter < Converter::BuiltIn
(QUOTE_TAGS = {
- :monospaced => ['<code>', '</code>', true],
- :emphasis => ['<em>', '</em>', true],
- :strong => ['<strong>', '</strong>', true],
- :double => ['&#8220;', '&#8221;', false],
- :single => ['&#8216;', '&#8217;', false],
- :mark => ['<mark>', '</mark>', true],
- :superscript => ['<sup>', '</sup>', true],
- :subscript => ['<sub>', '</sub>', true],
- :asciimath => ['\$', '\$', false],
- :latexmath => ['\(', '\)', false]
+ monospaced: ['<code>', '</code>', true],
+ emphasis: ['<em>', '</em>', true],
+ strong: ['<strong>', '</strong>', true],
+ double: ['&#8220;', '&#8221;', false],
+ single: ['&#8216;', '&#8217;', false],
+ mark: ['<mark>', '</mark>', true],
+ superscript: ['<sup>', '</sup>', true],
+ subscript: ['<sub>', '</sub>', true],
+ asciimath: ['\$', '\$', false],
+ latexmath: ['\(', '\)', false],
# Opal can't resolve these constants when referenced here
- #:asciimath => INLINE_MATH_DELIMITERS[:asciimath] + [false],
- #:latexmath => INLINE_MATH_DELIMITERS[:latexmath] + [false]
+ #asciimath: INLINE_MATH_DELIMITERS[:asciimath] + [false],
+ #latexmath: INLINE_MATH_DELIMITERS[:latexmath] + [false],
}).default = ['', '', false]
DropAnchorRx = /<(?:a[^>+]+|\/a)>/
@@ -59,7 +59,7 @@ module Asciidoctor
end
result << %(<link rel="icon" type="#{icon_type}" href="#{icon_href}"#{slash}>)
end
- result << %(<title>#{node.doctitle :sanitize => true, :use_fallback => true}</title>)
+ result << %(<title>#{node.doctitle sanitize: true, use_fallback: true}</title>)
if DEFAULT_STYLESHEET_KEYS.include?(node.attr 'stylesheet')
if (webfonts = node.attr 'webfonts')
@@ -75,7 +75,7 @@ module Asciidoctor
result << %(<link rel="stylesheet" href="#{node.normalize_web_path((node.attr 'stylesheet'), (node.attr 'stylesdir', ''))}"#{slash}>)
else
result << %(<style>
-#{node.read_asset node.normalize_system_path((node.attr 'stylesheet'), (node.attr 'stylesdir', '')), :warn_on_failure => true, :label => 'stylesheet'}
+#{node.read_asset node.normalize_system_path((node.attr 'stylesheet'), (node.attr 'stylesdir', '')), warn_on_failure: true, label: 'stylesheet'}
</style>)
end
end
@@ -309,7 +309,7 @@ MathJax.Hub.Config({
stitle = section.title
end
stitle = stitle.gsub DropAnchorRx, '' if stitle.include? '<a'
- if slevel < toclevels && (child_toc_level = outline section, :toclevels => toclevels, :sectnumlevels => sectnumlevels)
+ if slevel < toclevels && (child_toc_level = outline section, toclevels: toclevels, sectnumlevels: sectnumlevels)
result << %(<li><a href="##{section.id}">#{stitle}</a>)
result << child_toc_level
result << '</li>'
@@ -886,7 +886,7 @@ Your browser does not support the audio tag.
%(<div#{id_attr} class="#{role}">
<div#{title_id_attr} class="title">#{title}</div>
-#{outline doc, :toclevels => levels}
+#{outline doc, toclevels: levels}
</div>)
end
@@ -1117,7 +1117,7 @@ Your browser does not support the video tag.
def inline_image node
if (type = node.type) == 'icon' && (node.document.attr? 'icons', 'font')
class_attr_val = %(fa fa-#{node.target})
- {'size' => 'fa-', 'rotate' => 'fa-rotate-', 'flip' => 'fa-flip-'}.each do |key, prefix|
+ { 'size' => 'fa-', 'rotate' => 'fa-rotate-', 'flip' => 'fa-flip-' }.each do |key, prefix|
class_attr_val = %(#{class_attr_val} #{prefix}#{node.attr key}) if node.attr? key
end
title_attr = (node.attr? 'title') ? %( title="#{node.attr 'title'}") : ''
@@ -1229,7 +1229,7 @@ Your browser does not support the video tag.
end
def read_svg_contents node, target
- if (svg = node.read_contents target, :start => (node.document.attr 'imagesdir'), :normalize => true, :label => 'SVG')
+ if (svg = node.read_contents target, start: (node.document.attr 'imagesdir'), normalize: true, label: 'SVG')
svg = svg.sub SvgPreambleRx, '' unless svg.start_with? '<svg'
old_start_tag = new_start_tag = nil
# NOTE width, height and style attributes are removed if either width or height is specified
diff --git a/lib/asciidoctor/converter/manpage.rb b/lib/asciidoctor/converter/manpage.rb
index 380e3af1..2c7f8955 100644
--- a/lib/asciidoctor/converter/manpage.rb
+++ b/lib/asciidoctor/converter/manpage.rb
@@ -145,7 +145,7 @@ module Asciidoctor
if node.attr? 'manpurpose'
mannames = node.attr 'mannames', [manname]
result << %(.SH "#{(node.attr 'manname-title', 'NAME').upcase}"
-#{mannames.map {|n| manify n }.join ', '} \\- #{manify node.attr('manpurpose'), :whitespace => :normalize})
+#{mannames.map {|n| manify n }.join ', '} \\- #{manify node.attr('manpurpose'), whitespace: :normalize})
end
end
@@ -235,7 +235,7 @@ r lw(\n(.lu*75u/100u).'
num = 0
node.items.each do |item|
result << %(\\fB(#{num += 1})\\fP\\h'-2n':T{)
- result << (manify item.text, :whitespace => :normalize)
+ result << (manify item.text, whitespace: :normalize)
result << item.content if item.blocks?
result << 'T}'
end
@@ -259,11 +259,11 @@ r lw(\n(.lu*75u/100u).'
.RS 4)
else
result << %(.sp
-#{manify [*terms].map {|dt| dt.text }.join(', '), :whitespace => :normalize}
+#{manify [*terms].map {|dt| dt.text }.join(', '), whitespace: :normalize}
.RS 4)
end
if dd
- result << (manify dd.text, :whitespace => :normalize) if dd.text?
+ result << (manify dd.text, whitespace: :normalize) if dd.text?
result << dd.content if dd.blocks?
end
result << '.RE'
@@ -296,7 +296,7 @@ r lw(\n(.lu*75u/100u).'
result << %(.sp
.if n .RS 4
.nf
-#{manify node.content, :whitespace => :preserve}
+#{manify node.content, whitespace: :preserve}
.fi
.if n .RE)
result.join LF
@@ -310,7 +310,7 @@ r lw(\n(.lu*75u/100u).'
result << %(.sp
.if n .RS 4
.nf
-#{manify node.content, :whitespace => :preserve}
+#{manify node.content, whitespace: :preserve}
.fi
.if n .RE)
result.join LF
@@ -332,7 +332,7 @@ r lw(\n(.lu*75u/100u).'
. sp -1
. IP " #{idx + 1}." 4.2
.\\}
-#{manify item.text, :whitespace => :normalize})
+#{manify item.text, whitespace: :normalize})
result << item.content if item.blocks?
result << '.RE'
end
@@ -356,10 +356,10 @@ r lw(\n(.lu*75u/100u).'
%(.sp
.B #{manify node.title}
.br
-#{manify node.content, :whitespace => :normalize})
+#{manify node.content, whitespace: :normalize})
else
%(.sp
-#{manify node.content, :whitespace => :normalize})
+#{manify node.content, whitespace: :normalize})
end
end
@@ -458,7 +458,7 @@ allbox tab(:);'
row_header[row_index][cell_index + 1] ||= []
row_header[row_index][cell_index + 1] << %(#{cell_halign}tB)
end
- row_text[row_index] << %(#{manify cell.text, :whitespace => :normalize}#{LF})
+ row_text[row_index] << %(#{manify cell.text, whitespace: :normalize}#{LF})
elsif tsec == :body
if row_header[row_index].empty? || row_header[row_index][cell_index].empty?
row_header[row_index][cell_index] << %(#{cell_halign}t)
@@ -470,11 +470,11 @@ allbox tab(:);'
when :asciidoc
cell_content = cell.content
when :literal
- cell_content = %(.nf#{LF}#{manify cell.text, :whitespace => :preserve}#{LF}.fi)
+ cell_content = %(.nf#{LF}#{manify cell.text, whitespace: :preserve}#{LF}.fi)
when :verse
- cell_content = %(.nf#{LF}#{manify cell.text, :whitespace => :preserve}#{LF}.fi)
+ cell_content = %(.nf#{LF}#{manify cell.text, whitespace: :preserve}#{LF}.fi)
else
- cell_content = manify cell.content.join, :whitespace => :normalize
+ cell_content = manify cell.content.join, whitespace: :normalize
end
row_text[row_index] << %(#{cell_content}#{LF})
elsif tsec == :foot
@@ -484,7 +484,7 @@ allbox tab(:);'
row_header[row_index][cell_index + 1] ||= []
row_header[row_index][cell_index + 1] << %(#{cell_halign}tB)
end
- row_text[row_index] << %(#{manify cell.text, :whitespace => :normalize}#{LF})
+ row_text[row_index] << %(#{manify cell.text, whitespace: :normalize}#{LF})
end
if cell.colspan && cell.colspan > 1
(cell.colspan - 1).times do |i|
@@ -560,7 +560,7 @@ allbox tab(:);'
. sp -1
. IP \\(bu 2.3
.\\}
-#{manify item.text, :whitespace => :normalize}]
+#{manify item.text, whitespace: :normalize}]
result << item.content if item.blocks?
result << '.RE'
}
@@ -579,7 +579,7 @@ allbox tab(:);'
attribution_line = (node.attr? 'attribution') ? %[#{attribution_line}\\(em #{node.attr 'attribution'}] : nil
result << %(.sp
.nf
-#{manify node.content, :whitespace => :preserve}
+#{manify node.content, whitespace: :preserve}
.fi
.br)
if attribution_line
@@ -701,7 +701,7 @@ allbox tab(:);'
end
def resolve_content node
- node.content_model == :compound ? node.content : %(.sp#{LF}#{manify node.content, :whitespace => :normalize})
+ node.content_model == :compound ? node.content : %(.sp#{LF}#{manify node.content, whitespace: :normalize})
end
def write_alternate_pages mannames, manvolnum, target
diff --git a/lib/asciidoctor/converter/template.rb b/lib/asciidoctor/converter/template.rb
index 00a64f00..36957344 100644
--- a/lib/asciidoctor/converter/template.rb
+++ b/lib/asciidoctor/converter/template.rb
@@ -25,18 +25,18 @@ module Asciidoctor
# will be issued.
class Converter::TemplateConverter < Converter::Base
DEFAULT_ENGINE_OPTIONS = {
- :erb => { :trim => '<' },
+ erb: { trim: '<' },
# TODO line 466 of haml/compiler.rb sorts the attributes; file an issue to make this configurable
# NOTE AsciiDoc syntax expects HTML/XML output to use double quotes around attribute values
- :haml => { :format => :xhtml, :attr_wrapper => '"', :escape_attrs => false, :ugly => true },
- :slim => { :disable_escape => true, :sort_attrs => false, :pretty => false }
+ haml: { format: :xhtml, attr_wrapper: '"', escape_attrs: false, ugly: true },
+ slim: { disable_escape: true, sort_attrs: false, pretty: false }
}
begin
require 'concurrent/hash' unless defined? ::Concurrent::Hash
- @caches = { :scans => ::Concurrent::Hash.new, :templates => ::Concurrent::Hash.new }
+ @caches = { scans: ::Concurrent::Hash.new, templates: ::Concurrent::Hash.new }
rescue ::LoadError
- @caches = { :scans => {}, :templates => {} }
+ @caches = { scans: {}, templates: {} }
end
def self.caches
@@ -253,7 +253,7 @@ module Asciidoctor
unless @active_engines[extsym]
# NOTE slim doesn't get automatically loaded by Tilt
Helpers.require_library 'slim' unless defined? ::Slim::Engine
- ::Slim::Engine.define_options :asciidoc => {}
+ ::Slim::Engine.define_options asciidoc: {}
# align safe mode of AsciiDoc embedded in Slim template with safe mode of current document
# NOTE safe mode won't get updated if using template cache and changing safe mode
(@engine_options[extsym][:asciidoc] ||= {})[:safe] ||= @safe if @safe && ::Slim::VERSION >= '3.0'
@@ -297,7 +297,7 @@ module Asciidoctor
[::Tilt::ERBTemplate, {}]
elsif name == 'erubis'
Helpers.require_library 'erubis' unless defined? ::Erubis::FastEruby
- [::Tilt::ErubisTemplate, { :engine_class => ::Erubis::FastEruby }]
+ [::Tilt::ErubisTemplate, { engine_class: ::Erubis::FastEruby }]
else
raise ::ArgumentError, %(Unknown ERB implementation: #{name})
end
diff --git a/lib/asciidoctor/document.rb b/lib/asciidoctor/document.rb
index 0b03cac0..f79658aa 100644
--- a/lib/asciidoctor/document.rb
+++ b/lib/asciidoctor/document.rb
@@ -276,14 +276,14 @@ class Document < AbstractBlock
else
@parent_document = nil
@catalog = {
- :ids => {},
- :refs => {},
- :footnotes => [],
- :links => [],
- :images => [],
- :indexterms => [],
- :callouts => Callouts.new,
- :includes => {},
+ ids: {},
+ refs: {},
+ footnotes: [],
+ links: [],
+ images: [],
+ indexterms: [],
+ callouts: Callouts.new,
+ includes: {},
}
# copy attributes map and normalize keys
# attribute overrides are attributes that can only be set from the commandline
@@ -530,7 +530,7 @@ class Document < AbstractBlock
end
end
- @reader = PreprocessorReader.new self, data, (Reader::Cursor.new attrs['docfile'], @base_dir), :normalize => true
+ @reader = PreprocessorReader.new self, data, (Reader::Cursor.new attrs['docfile'], @base_dir), normalize: true
@source_location = @reader.cursor if @sourcemap
end
end
@@ -553,7 +553,7 @@ class Document < AbstractBlock
doc = self
# create reader if data is provided (used when data is not known at the time the Document object is created)
if data
- @reader = PreprocessorReader.new doc, data, (Reader::Cursor.new @attributes['docfile'], @base_dir), :normalize => true
+ @reader = PreprocessorReader.new doc, data, (Reader::Cursor.new @attributes['docfile'], @base_dir), normalize: true
@source_location = @reader.cursor if @sourcemap
end
@@ -564,7 +564,7 @@ class Document < AbstractBlock
end
# Now parse the lines in the reader into blocks
- Parser.parse @reader, doc, :header_only => @options[:parse_header_only]
+ Parser.parse @reader, doc, header_only: @options[:parse_header_only]
# should we call sort of post-parse function?
restore_attributes
@@ -740,7 +740,7 @@ class Document < AbstractBlock
end
if (separator = opts[:partition])
- Title.new val, opts.merge({ :separator => (separator == true ? @attributes['title-separator'] : separator) })
+ Title.new val, opts.merge({ separator: (separator == true ? @attributes['title-separator'] : separator) })
elsif opts[:sanitize] && val.include?('<')
val.gsub(XmlSanitizeRx, '').squeeze(' ').strip
else
@@ -1293,7 +1293,7 @@ class Document < AbstractBlock
unless (docinfo & ['shared', %(shared-#{location})]).empty?
docinfo_path = normalize_system_path docinfo_file, docinfo_dir
# NOTE normalizing the lines is essential if we're performing substitutions
- if (shd_content = (read_asset docinfo_path, :normalize => true))
+ if (shd_content = (read_asset docinfo_path, normalize: true))
content << (apply_subs shd_content, docinfo_subs)
end
end
@@ -1301,7 +1301,7 @@ class Document < AbstractBlock
unless @attributes['docname'].nil_or_empty? || (docinfo & ['private', %(private-#{location})]).empty?
docinfo_path = normalize_system_path %(#{@attributes['docname']}-#{docinfo_file}), docinfo_dir
# NOTE normalizing the lines is essential if we're performing substitutions
- if (pvt_content = (read_asset docinfo_path, :normalize => true))
+ if (pvt_content = (read_asset docinfo_path, normalize: true))
content << (apply_subs pvt_content, docinfo_subs)
end
end
diff --git a/lib/asciidoctor/extensions.rb b/lib/asciidoctor/extensions.rb
index c274918f..58a9e2e4 100644
--- a/lib/asciidoctor/extensions.rb
+++ b/lib/asciidoctor/extensions.rb
@@ -153,7 +153,7 @@ module Extensions
end
def create_block parent, context, source, attrs, opts = {}
- Block.new parent, context, { :source => source, :attributes => attrs }.merge(opts)
+ Block.new parent, context, { source: source, attributes: attrs }.merge(opts)
end
# Public: Creates a list node and links it to the specified parent.
@@ -962,7 +962,7 @@ module Extensions
# docinfo_processor MetaRobotsDocinfoProcessor
#
# # as an instance of a DocinfoProcessor subclass with an explicit location
- # docinfo_processor JQueryDocinfoProcessor.new, :location => :footer
+ # docinfo_processor JQueryDocinfoProcessor.new, location: :footer
#
# # as a name of a DocinfoProcessor subclass
# docinfo_processor 'MetaRobotsDocinfoProcessor'
@@ -1448,7 +1448,7 @@ module Extensions
def create name = nil, &block
if block_given?
- Registry.new({ (name || generate_name) => block })
+ Registry.new (name || generate_name) => block
else
Registry.new
end
diff --git a/lib/asciidoctor/logging.rb b/lib/asciidoctor/logging.rb
index ce4ded7f..5300b277 100644
--- a/lib/asciidoctor/logging.rb
+++ b/lib/asciidoctor/logging.rb
@@ -45,7 +45,7 @@ class MemoryLogger < ::Logger
def add severity, message = nil, progname = nil
message = block_given? ? yield : progname unless message
- @messages << { :severity => SEVERITY_LABELS[severity || UNKNOWN], :message => message }
+ @messages.push severity: SEVERITY_LABELS[severity || UNKNOWN], message: message
true
end
@@ -115,7 +115,7 @@ module Logging
end
def message_with_context text, context = {}
- ({ :text => text }.merge context).extend Logger::AutoFormattingMessage
+ ({ text: text }.merge context).extend Logger::AutoFormattingMessage
end
end
end
diff --git a/lib/asciidoctor/parser.rb b/lib/asciidoctor/parser.rb
index cf62a225..42b0c9fe 100644
--- a/lib/asciidoctor/parser.rb
+++ b/lib/asciidoctor/parser.rb
@@ -186,7 +186,7 @@ class Parser
doc_attrs['manvolnum'] = manvolnum = $2
doc_attrs['mantitle'] = (((mantitle = $1).include? ATTR_REF_HEAD) ? (document.sub_attributes mantitle) : mantitle).downcase
else
- logger.error message_with_context 'non-conforming manpage title', :source_location => (reader.cursor_at_line 1)
+ logger.error message_with_context 'non-conforming manpage title', source_location: (reader.cursor_at_line 1)
# provide sensible fallbacks
doc_attrs['mantitle'] = doc_attrs['doctitle'] || doc_attrs['docname'] || 'command'
doc_attrs['manvolnum'] = manvolnum = '1'
@@ -205,7 +205,7 @@ class Parser
if (name_section_level = is_next_line_section? reader, {})
if name_section_level == 1
name_section = initialize_section reader, document, {}
- name_section_buffer = (reader.read_lines_until :break_on_blank_lines => true, :skip_line_comments => true).map(&:lstrip).join ' '
+ name_section_buffer = (reader.read_lines_until break_on_blank_lines: true, skip_line_comments: true).map(&:lstrip).join ' '
if ManpageNamePurposeRx =~ name_section_buffer
doc_attrs['manname-title'] ||= name_section.title
doc_attrs['manname-id'] = name_section.id if name_section.id
@@ -235,7 +235,7 @@ class Parser
end
if error_msg
reader.restore_save
- logger.error message_with_context error_msg, :source_location => reader.cursor
+ logger.error message_with_context error_msg, source_location: reader.cursor
doc_attrs['manname'] = (manname = doc_attrs['docname'] || 'command')
doc_attrs['mannames'] = [manname]
if document.backend == 'manpage'
@@ -274,7 +274,7 @@ class Parser
# source
# # => "= Greetings\n\nThis is my doc.\n\n== Salutations\n\nIt is awesome."
#
- # reader = Reader.new source, nil, :normalize => true
+ # reader = Reader.new source, nil, normalize: true
# # create empty document to parent the section
# # and hold attributes extracted from header
# doc = Document.new
@@ -296,7 +296,7 @@ class Parser
(attributes.delete 'invalid-header') || !(is_next_line_section? reader, attributes))
book = (document = parent).doctype == 'book'
if has_header || (book && attributes[1] != 'abstract')
- preamble = intro = Block.new parent, :preamble, :content_model => :compound
+ preamble = intro = Block.new parent, :preamble, content_model: :compound
preamble.title = parent.attr 'preface-title' if book && (parent.attr? 'preface-title')
parent.blocks << preamble
end
@@ -345,16 +345,16 @@ class Parser
if expected_next_level
unless next_level == expected_next_level || (expected_next_level_alt && next_level == expected_next_level_alt) || expected_next_level < 0
expected_condition = expected_next_level_alt ? %(expected levels #{expected_next_level_alt} or #{expected_next_level}) : %(expected level #{expected_next_level})
- logger.warn message_with_context %(section title out of sequence: #{expected_condition}, got level #{next_level}), :source_location => reader.cursor
+ logger.warn message_with_context %(section title out of sequence: #{expected_condition}, got level #{next_level}), source_location: reader.cursor
end
else
- logger.error message_with_context %(#{sectname} sections do not support nested sections), :source_location => reader.cursor
+ logger.error message_with_context %(#{sectname} sections do not support nested sections), source_location: reader.cursor
end
new_section, attributes = next_section reader, section, attributes
section.assign_numeral new_section
section.blocks << new_section
elsif next_level == 0 && section == document
- logger.error message_with_context 'level 0 sections can only be used when doctype is book', :source_location => reader.cursor unless book
+ logger.error message_with_context 'level 0 sections can only be used when doctype is book', source_location: reader.cursor unless book
new_section, attributes = next_section reader, section, attributes
section.assign_numeral new_section
section.blocks << new_section
@@ -365,7 +365,7 @@ class Parser
else
# just take one block or else we run the risk of overrunning section boundaries
block_cursor = reader.cursor
- if (new_block = next_block reader, intro || section, attributes, :parse_metadata => false)
+ if (new_block = next_block reader, intro || section, attributes, parse_metadata: false)
# REVIEW this may be doing too much
if part
if !section.blocks?
@@ -377,7 +377,7 @@ class Parser
new_block.style = 'partintro'
# emulate [partintro] open block
else
- new_block.parent = (intro = Block.new section, :open, :content_model => :compound)
+ new_block.parent = (intro = Block.new section, :open, content_model: :compound)
intro.style = 'partintro'
section.blocks << intro
end
@@ -386,10 +386,10 @@ class Parser
first_block = section.blocks[0]
# open the [partintro] open block for appending
if !intro && first_block.content_model == :compound
- logger.error message_with_context 'illegal block content outside of partintro block', :source_location => block_cursor
+ logger.error message_with_context 'illegal block content outside of partintro block', source_location: block_cursor
# rebuild [partintro] paragraph as an open block
elsif first_block.content_model != :compound
- new_block.parent = (intro = Block.new section, :open, :content_model => :compound)
+ new_block.parent = (intro = Block.new section, :open, content_model: :compound)
intro.style = 'partintro'
section.blocks.shift
if first_block.style == 'partintro'
@@ -415,7 +415,7 @@ class Parser
if part
unless section.blocks? && section.blocks[-1].context == :section
- logger.error message_with_context 'invalid part, must have at least one section (e.g., chapter, appendix, etc.)', :source_location => reader.cursor
+ logger.error message_with_context 'invalid part, must have at least one section (e.g., chapter, appendix, etc.)', source_location: reader.cursor
end
# NOTE we could try to avoid creating a preamble in the first place, though
# that would require reworking assumptions in next_section since the preamble
@@ -508,7 +508,7 @@ class Parser
elsif block_extensions && extensions.registered_for_block?(style, block_context)
block_context = style.to_sym
else
- logger.warn message_with_context %(invalid style for #{block_context} block: #{style}), :source_location => reader.cursor_at_mark
+ logger.warn message_with_context %(invalid style for #{block_context} block: #{style}), source_location: reader.cursor_at_mark
style = block_context.to_s
end
end
@@ -539,7 +539,7 @@ class Parser
#!(this_line.start_with? ' ') &&
(MarkdownThematicBreakRx.match? this_line)
# NOTE we're letting break lines (horizontal rule, page_break, etc) have attributes
- block = Block.new(parent, :thematic_break, :content_model => :empty)
+ block = Block.new(parent, :thematic_break, content_model: :empty)
break
end
elsif this_line.start_with? TAB
@@ -550,14 +550,14 @@ class Parser
if (layout_break_chars.key? ch0) && (md_syntax ? (ExtLayoutBreakRx.match? this_line) :
(this_line == ch0 * (ll = this_line.length) && ll > 2))
# NOTE we're letting break lines (horizontal rule, page_break, etc) have attributes
- block = Block.new(parent, layout_break_chars[ch0], :content_model => :empty)
+ block = Block.new(parent, layout_break_chars[ch0], content_model: :empty)
break
# NOTE very rare that a text-only line will end in ] (e.g., inline macro), so check that first
elsif (this_line.end_with? ']') && (this_line.include? '::')
#if (this_line.start_with? 'image', 'video', 'audio') && BlockMediaMacroRx =~ this_line
if (ch0 == 'i' || (this_line.start_with? 'video:', 'audio:')) && BlockMediaMacroRx =~ this_line
blk_ctx, target, blk_attrs = $1.to_sym, $2, $3
- block = Block.new parent, blk_ctx, :content_model => :empty
+ block = Block.new parent, blk_ctx, content_model: :empty
if blk_attrs
case blk_ctx
when :video
@@ -567,14 +567,14 @@ class Parser
else # :image
posattrs = ['alt', 'width', 'height']
end
- block.parse_attributes blk_attrs, posattrs, :sub_input => true, :into => attributes
+ block.parse_attributes blk_attrs, posattrs, sub_input: true, into: attributes
end
# style doesn't have special meaning for media macros
attributes.delete 'style' if attributes.key? 'style'
- if (target.include? ATTR_REF_HEAD) && (target = block.sub_attributes target, :attribute_missing => 'drop-line').empty?
+ if (target.include? ATTR_REF_HEAD) && (target = block.sub_attributes target, attribute_missing: 'drop-line').empty?
# retain as unparsed if attribute-missing is skip
if (doc_attrs['attribute-missing'] || Compliance.attribute_missing) == 'skip'
- return Block.new(parent, :paragraph, :content_model => :simple, :source => [this_line])
+ return Block.new(parent, :paragraph, content_model: :simple, source: [this_line])
# otherwise, drop the line
else
attributes.clear
@@ -598,8 +598,8 @@ class Parser
break
elsif ch0 == 't' && (this_line.start_with? 'toc:') && BlockTocMacroRx =~ this_line
- block = Block.new parent, :toc, :content_model => :empty
- block.parse_attributes $1, [], :into => attributes if $1
+ block = Block.new parent, :toc, content_model: :empty
+ block.parse_attributes $1, [], into: attributes if $1
break
elsif block_macro_extensions && CustomBlockMacroRx =~ this_line &&
@@ -611,7 +611,7 @@ class Parser
return
end
if extension.config[:content_model] == :attributes
- document.parse_attributes content, extension.config[:pos_attrs] || [], :sub_input => true, :into => attributes if content
+ document.parse_attributes content, extension.config[:pos_attrs] || [], sub_input: true, into: attributes if content
else
attributes['text'] = content || ''
end
@@ -659,7 +659,7 @@ class Parser
reader.unshift_line this_line
float_id, float_reftext, float_title, float_level = parse_section_title reader, document, attributes['id']
attributes['reftext'] = float_reftext if float_reftext
- block = Block.new(parent, :floating_title, :content_model => :empty)
+ block = Block.new(parent, :floating_title, content_model: :empty)
block.title = float_title
attributes.delete 'title'
block.id = float_id || ((doc_attrs.key? 'sectids') ? (Section.generate_id block.title, document) : nil)
@@ -688,7 +688,7 @@ class Parser
# advance to block parsing =>
break
else
- logger.warn message_with_context %(invalid style for paragraph: #{style}), :source_location => reader.cursor_at_mark
+ logger.warn message_with_context %(invalid style for paragraph: #{style}), source_location: reader.cursor_at_mark
style = nil
# continue to process paragraph
end
@@ -699,27 +699,27 @@ class Parser
# a literal paragraph: contiguous lines starting with at least one whitespace character
# NOTE style can only be nil or "normal" at this point
if indented && !style
- lines = read_paragraph_lines reader, (in_list = ListItem === parent) && skipped == 0, :skip_line_comments => text_only
+ lines = read_paragraph_lines reader, (in_list = ListItem === parent) && skipped == 0, skip_line_comments: text_only
adjust_indentation! lines
- block = Block.new(parent, :literal, :content_model => :verbatim, :source => lines, :attributes => attributes)
+ block = Block.new(parent, :literal, content_model: :verbatim, source: lines, attributes: attributes)
# a literal gets special meaning inside of a description list
# TODO this feels hacky, better way to distinguish from explicit literal block?
block.set_option('listparagraph') if in_list
# a normal paragraph: contiguous non-blank/non-continuation lines (left-indented or normal style)
else
- lines = read_paragraph_lines reader, skipped == 0 && ListItem === parent, :skip_line_comments => true
+ lines = read_paragraph_lines reader, skipped == 0 && ListItem === parent, skip_line_comments: true
# NOTE don't check indented here since it's extremely rare
#if text_only || indented
if text_only
# if [normal] is used over an indented paragraph, shift content to left margin
# QUESTION do we even need to shift since whitespace is normalized by XML in this case?
adjust_indentation! lines if indented && style == 'normal'
- block = Block.new(parent, :paragraph, :content_model => :simple, :source => lines, :attributes => attributes)
+ block = Block.new(parent, :paragraph, content_model: :simple, source: lines, attributes: attributes)
elsif (ADMONITION_STYLE_HEADS.include? ch0) && (this_line.include? ':') && (AdmonitionParagraphRx =~ this_line)
lines[0] = $' # string after match
attributes['name'] = admonition_name = (attributes['style'] = $1).downcase
attributes['textlabel'] = (attributes.delete 'caption') || doc_attrs[%(#{admonition_name}-caption)]
- block = Block.new(parent, :admonition, :content_model => :simple, :source => lines, :attributes => attributes)
+ block = Block.new(parent, :admonition, content_model: :simple, source: lines, attributes: attributes)
elsif md_syntax && ch0 == '>' && this_line.start_with?('> ')
lines.map! {|line| line == '>' ? (line.slice 1, line.length) : ((line.start_with? '> ') ? (line.slice 2, line.length) : line) }
if lines[-1].start_with? '-- '
@@ -744,7 +744,7 @@ class Parser
lines.pop while lines[-1].empty?
lines << lines.pop.chop # strip trailing quote
attributes['style'] = 'quote'
- block = Block.new(parent, :quote, :content_model => :simple, :source => lines, :attributes => attributes)
+ block = Block.new(parent, :quote, content_model: :simple, source: lines, attributes: attributes)
attribution, citetitle = (block.apply_subs credit_line).split ', ', 2
attributes['attribution'] = attribution if attribution
attributes['citetitle'] = citetitle if citetitle
@@ -752,7 +752,7 @@ class Parser
# if [normal] is used over an indented paragraph, shift content to left margin
# QUESTION do we even need to shift since whitespace is normalized by XML in this case?
adjust_indentation! lines if indented && style == 'normal'
- block = Block.new(parent, :paragraph, :content_model => :simple, :source => lines, :attributes => attributes)
+ block = Block.new(parent, :paragraph, content_model: :simple, source: lines, attributes: attributes)
end
catalog_inline_anchors((lines.join LF), block, document, reader)
@@ -840,7 +840,7 @@ class Parser
when :table
block_cursor = reader.cursor
- block_reader = Reader.new reader.read_lines_until(:terminator => terminator, :skip_line_comments => true, :context => :table, :cursor => :at_mark), block_cursor
+ block_reader = Reader.new reader.read_lines_until(terminator: terminator, skip_line_comments: true, context: :table, cursor: :at_mark), block_cursor
# NOTE it's very rare that format is set when using a format hint char, so short-circuit
unless terminator.start_with? '|', '!'
# NOTE infer dsv once all other format hint chars are ruled out
@@ -864,7 +864,7 @@ class Parser
# QUESTION should we clone the extension for each cloaked context and set in config?
attributes['cloaked-context'] = cloaked_context
end
- block = build_block block_context, content_model, terminator, parent, reader, attributes, :extension => extension
+ block = build_block block_context, content_model, terminator, parent, reader, attributes, extension: extension
unless block
attributes.clear
return
@@ -885,7 +885,7 @@ class Parser
block.style = attributes['style']
if (block_id = (block.id ||= attributes['id']))
unless document.register :refs, [block_id, block, attributes['reftext'] || (block.title? ? block.title : nil)]
- logger.warn message_with_context %(id assigned to block already in use: #{block_id}), :source_location => reader.cursor_at_mark
+ logger.warn message_with_context %(id assigned to block already in use: #{block_id}), source_location: reader.cursor_at_mark
end
end
# FIXME remove the need for this update!
@@ -1001,16 +1001,16 @@ class Parser
if terminator.nil?
if parse_as_content_model == :verbatim
- lines = reader.read_lines_until :break_on_blank_lines => true, :break_on_list_continuation => true
+ lines = reader.read_lines_until break_on_blank_lines: true, break_on_list_continuation: true
else
content_model = :simple if content_model == :compound
# TODO we could also skip processing if we're able to detect reader is a BlockReader
- lines = read_paragraph_lines reader, false, :skip_line_comments => true, :skip_processing => skip_processing
+ lines = read_paragraph_lines reader, false, skip_line_comments: true, skip_processing: skip_processing
# QUESTION check for empty lines after grabbing lines for simple content model?
end
block_reader = nil
elsif parse_as_content_model != :compound
- lines = reader.read_lines_until :terminator => terminator, :skip_processing => skip_processing, :context => block_context, :cursor => :at_mark
+ lines = reader.read_lines_until terminator: terminator, skip_processing: skip_processing, context: block_context, cursor: :at_mark
block_reader = nil
# terminator is false when reader has already been prepared
elsif terminator == false
@@ -1019,7 +1019,7 @@ class Parser
else
lines = nil
block_cursor = reader.cursor
- block_reader = Reader.new reader.read_lines_until(:terminator => terminator, :skip_processing => skip_processing, :context => block_context, :cursor => :at_mark), block_cursor
+ block_reader = Reader.new reader.read_lines_until(terminator: terminator, skip_processing: skip_processing, context: block_context, cursor: :at_mark), block_cursor
end
if content_model == :verbatim
@@ -1049,7 +1049,7 @@ class Parser
return
end
else
- block = Block.new(parent, block_context, :content_model => content_model, :source => lines, :attributes => attributes)
+ block = Block.new(parent, block_context, content_model: content_model, source: lines, attributes: attributes)
end
# QUESTION should we have an explicit map or can we rely on check for *-caption attribute?
@@ -1133,9 +1133,9 @@ class Parser
def self.catalog_inline_anchor id, reftext, node, location, doc = nil
doc ||= node.document
reftext = doc.sub_attributes reftext if reftext && (reftext.include? ATTR_REF_HEAD)
- unless doc.register :refs, [id, (Inline.new node, :anchor, reftext, :type => :ref, :id => id), reftext]
+ unless doc.register :refs, [id, (Inline.new node, :anchor, reftext, type: :ref, id: id), reftext]
location = location.cursor if Reader === location
- logger.warn message_with_context %(id assigned to anchor already in use: #{id}), :source_location => location
+ logger.warn message_with_context %(id assigned to anchor already in use: #{id}), source_location: location
end
nil
end
@@ -1160,12 +1160,12 @@ class Parser
next if (reftext.include? ATTR_REF_HEAD) && (reftext = document.sub_attributes reftext).empty?
end
end
- unless document.register :refs, [id, (Inline.new block, :anchor, reftext, :type => :ref, :id => id), reftext]
+ unless document.register :refs, [id, (Inline.new block, :anchor, reftext, type: :ref, id: id), reftext]
location = reader.cursor_at_mark
if (offset = ($`.count LF) + (($&.start_with? LF) ? 1 : 0)) > 0
(location = location.dup).advance offset
end
- logger.warn message_with_context %(id assigned to anchor already in use: #{id}), :source_location => location
+ logger.warn message_with_context %(id assigned to anchor already in use: #{id}), source_location: location
end
end if (text.include? '[[') || (text.include? 'or:')
nil
@@ -1181,8 +1181,8 @@ class Parser
# Returns nothing
def self.catalog_inline_biblio_anchor id, reftext, node, reader
# QUESTION should we sub attributes in reftext (like with regular anchors)?
- unless node.document.register :refs, [id, (Inline.new node, :anchor, (styled_reftext = %([#{reftext || id}])), :type => :bibref, :id => id), styled_reftext]
- logger.warn message_with_context %(id assigned to bibliography anchor already in use: #{id}), :source_location => reader.cursor
+ unless node.document.register :refs, [id, (Inline.new node, :anchor, (styled_reftext = %([#{reftext || id}])), type: :bibref, id: id), styled_reftext]
+ logger.warn message_with_context %(id assigned to bibliography anchor already in use: #{id}), source_location: reader.cursor
end
nil
end
@@ -1236,12 +1236,12 @@ class Parser
end
# might want to move this check to a validate method
unless num == next_index.to_s
- logger.warn message_with_context %(callout list item index: expected #{next_index}, got #{num}), :source_location => reader.cursor_at_mark
+ logger.warn message_with_context %(callout list item index: expected #{next_index}, got #{num}), source_location: reader.cursor_at_mark
end
if (list_item = parse_list_item reader, list_block, match, '<1>')
list_block.items << list_item
if (coids = callouts.callout_ids list_block.items.size).empty?
- logger.warn message_with_context %(no callout found for <#{list_block.items.size}>), :source_location => reader.cursor_at_mark
+ logger.warn message_with_context %(no callout found for <#{list_block.items.size}>), source_location: reader.cursor_at_mark
else
list_item.attributes['coids'] = coids
end
@@ -1353,7 +1353,7 @@ class Parser
end
# reader is confined to boundaries of list, which means only blocks will be found (no sections)
- if (block = next_block(list_item_reader, list_item, {}, :text => !has_text))
+ if (block = next_block(list_item_reader, list_item, {}, text: !has_text))
list_item.blocks << block
end
@@ -1440,7 +1440,7 @@ class Parser
buffer << this_line
# grab all the lines in the block, leaving the delimiters in place
# we're being more strict here about the terminator, but I think that's a good thing
- buffer.concat reader.read_lines_until(:terminator => match.terminator, :read_last_line => true, :context => nil)
+ buffer.concat reader.read_lines_until(terminator: match.terminator, read_last_line: true, context: nil)
continuation = :inactive
else
break
@@ -1459,9 +1459,9 @@ class Parser
if LiteralParagraphRx.match? this_line
reader.unshift_line this_line
buffer.concat reader.read_lines_until(
- :preserve_last_line => true,
- :break_on_blank_lines => true,
- :break_on_list_continuation => true) {|line|
+ preserve_last_line: true,
+ break_on_blank_lines: true,
+ break_on_list_continuation: true) {|line|
# we may be in an indented list disguised as a literal paragraph
# so we need to make sure we don't slurp up a legitimate sibling
list_type == :dlist && is_sibling_list_item?(line, list_type, sibling_trait)
@@ -1513,9 +1513,9 @@ class Parser
elsif LiteralParagraphRx.match? this_line
reader.unshift_line this_line
buffer.concat reader.read_lines_until(
- :preserve_last_line => true,
- :break_on_blank_lines => true,
- :break_on_list_continuation => true) {|line|
+ preserve_last_line: true,
+ break_on_blank_lines: true,
+ break_on_list_continuation: true) {|line|
# we may be in an indented list disguised as a literal paragraph
# so we need to make sure we don't slurp up a legitimate sibling
list_type == :dlist && is_sibling_list_item?(line, list_type, sibling_trait)
@@ -1624,7 +1624,7 @@ class Parser
# generate an ID if one was not embedded or specified as anchor above section title
if (id = section.id ||= ((document.attributes.key? 'sectids') ? (Section.generate_id section.title, document) : nil))
unless document.register :refs, [id, section, sect_reftext || section.title]
- logger.warn message_with_context %(id assigned to section already in use: #{id}), :source_location => (reader.cursor_at_line reader.lineno - (sect_atx ? 1 : 2))
+ logger.warn message_with_context %(id assigned to section already in use: #{id}), source_location: (reader.cursor_at_line reader.lineno - (sect_atx ? 1 : 2))
end
end
@@ -1785,9 +1785,9 @@ class Parser
# Examples
#
# data = ["Author Name <author@example.org>\n", "v1.0, 2012-12-21: Coincide w/ end of world.\n"]
- # parse_header_metadata(Reader.new data, nil, :normalize => true)
- # # => {'author' => 'Author Name', 'firstname' => 'Author', 'lastname' => 'Name', 'email' => 'author@example.org',
- # # 'revnumber' => '1.0', 'revdate' => '2012-12-21', 'revremark' => 'Coincide w/ end of world.'}
+ # parse_header_metadata(Reader.new data, nil, normalize: true)
+ # # => { 'author' => 'Author Name', 'firstname' => 'Author', 'lastname' => 'Name', 'email' => 'author@example.org',
+ # # 'revnumber' => '1.0', 'revdate' => '2012-12-21', 'revremark' => 'Coincide w/ end of world.' }
def self.parse_header_metadata(reader, document = nil)
doc_attrs = document && document.attributes
# NOTE this will discard any comment lines, but not skip blank lines
@@ -2053,7 +2053,7 @@ class Parser
elsif (next_line.end_with? ']') && BlockAttributeListRx =~ next_line
current_style = attributes[1]
# extract id, role, and options from first positional attribute and remove, if present
- if (document.parse_attributes $1, [], :sub_input => true, :sub_result => true, :into => attributes)[1]
+ if (document.parse_attributes $1, [], sub_input: true, sub_result: true, into: attributes)[1]
attributes[1] = (parse_style_attribute attributes, reader) || current_style
end
return true
@@ -2070,7 +2070,7 @@ class Parser
return true
elsif normal && '/' * (ll = next_line.length) == next_line
unless ll == 3
- reader.read_lines_until :terminator => next_line, :skip_first_line => true, :preserve_last_line => true, :skip_processing => true, :context => :comment
+ reader.read_lines_until terminator: next_line, skip_first_line: true, preserve_last_line: true, skip_processing: true, context: :comment
return true
end
else
@@ -2252,7 +2252,7 @@ class Parser
end
if validate && expected != actual
- logger.warn message_with_context %(list item index: expected #{expected}, got #{actual}), :source_location => reader.cursor
+ logger.warn message_with_context %(list item index: expected #{expected}, got #{actual}), source_location: reader.cursor
end
[marker, style]
@@ -2580,7 +2580,7 @@ class Parser
if collector.empty?
unless type == :style
if reader
- logger.warn message_with_context %(invalid empty #{type} detected in style attribute), :source_location => reader.cursor_at_prev_line
+ logger.warn message_with_context %(invalid empty #{type} detected in style attribute), source_location: reader.cursor_at_prev_line
else
logger.warn %(invalid empty #{type} detected in style attribute)
end
@@ -2592,7 +2592,7 @@ class Parser
when :id
if parsed.key? :id
if reader
- logger.warn message_with_context 'multiple ids detected in style attribute', :source_location => reader.cursor_at_prev_line
+ logger.warn message_with_context 'multiple ids detected in style attribute', source_location: reader.cursor_at_prev_line
else
logger.warn 'multiple ids detected in style attribute'
end
diff --git a/lib/asciidoctor/path_resolver.rb b/lib/asciidoctor/path_resolver.rb
index b3c27a39..f5d3d5d9 100644
--- a/lib/asciidoctor/path_resolver.rb
+++ b/lib/asciidoctor/path_resolver.rb
@@ -83,7 +83,7 @@ module Asciidoctor
# => 'C:/data/docs/css'
#
# begin
-# resolver.system_path('../../../css', '../../..', '/path/to/docs', :recover => false)
+# resolver.system_path('../../../css', '../../..', '/path/to/docs', recover: false)
# rescue SecurityError => e
# puts e.message
# end
diff --git a/lib/asciidoctor/reader.rb b/lib/asciidoctor/reader.rb
index 985ac51d..31672a68 100644
--- a/lib/asciidoctor/reader.rb
+++ b/lib/asciidoctor/reader.rb
@@ -346,7 +346,7 @@ class Reader
if next_line.start_with? '//'
if next_line.start_with? '///'
if (ll = next_line.length) > 3 && next_line == '/' * ll
- read_lines_until :terminator => next_line, :skip_first_line => true, :read_last_line => true, :skip_processing => true, :context => :comment
+ read_lines_until terminator: next_line, skip_first_line: true, read_last_line: true, skip_processing: true, context: :comment
else
break
end
@@ -391,7 +391,7 @@ class Reader
end
# Public: Return all the lines from `@lines` until we (1) run out them,
- # (2) find a blank line with :break_on_blank_lines => true, or (3) find
+ # (2) find a blank line with `break_on_blank_lines: true`, or (3) find
# a line for which the given block evals to true.
#
# options - an optional Hash of processing options:
@@ -424,7 +424,7 @@ class Reader
# "\n",
# "Third line\n",
# ]
- # reader = Reader.new data, nil, :normalize => true
+ # reader = Reader.new data, nil, normalize: true
#
# reader.read_lines_until
# => ["First line", "Second line"]
@@ -479,7 +479,7 @@ class Reader
end
if terminator && terminator != line && (context = options.fetch :context, terminator)
start_cursor = cursor_at_mark if start_cursor == :at_mark
- logger.warn message_with_context %(unterminated #{context} block), :source_location => start_cursor
+ logger.warn message_with_context %(unterminated #{context} block), source_location: start_cursor
@unterminated = true
end
result
@@ -606,7 +606,7 @@ class PreprocessorReader < Reader
include_depth_default = document.attributes.fetch('max-include-depth', 64).to_i
include_depth_default = 0 if include_depth_default < 0
# track both absolute depth for comparing to size of include stack and relative depth for reporting
- @maxdepth = {:abs => include_depth_default, :rel => include_depth_default}
+ @maxdepth = { abs: include_depth_default, rel: include_depth_default }
@include_stack = []
@includes = document.catalog[:includes]
@skipping = false
@@ -758,12 +758,12 @@ class PreprocessorReader < Reader
if keyword == 'endif'
if @conditional_stack.empty?
- logger.error message_with_context %(unmatched macro: endif::#{target}[]), :source_location => cursor
+ logger.error message_with_context %(unmatched macro: endif::#{target}[]), source_location: cursor
elsif no_target || target == (pair = @conditional_stack[-1])[:target]
@conditional_stack.pop
@skipping = @conditional_stack.empty? ? false : @conditional_stack[-1][:skipping]
else
- logger.error message_with_context %(mismatched macro: endif::#{target}[], expected endif::#{pair[:target]}[]), :source_location => cursor
+ logger.error message_with_context %(mismatched macro: endif::#{target}[], expected endif::#{pair[:target]}[]), source_location: cursor
end
return true
end
@@ -817,7 +817,7 @@ class PreprocessorReader < Reader
# conditional inclusion block
if keyword == 'ifeval' || !text
@skipping = true if skip
- @conditional_stack << {:target => target, :skip => skip, :skipping => @skipping}
+ @conditional_stack << { target: target, skip: skip, skipping: @skipping }
# single line conditional inclusion
else
unless @skipping || skip
@@ -860,7 +860,7 @@ class PreprocessorReader < Reader
def preprocess_include_directive target, attrlist
doc = @document
if ((expanded_target = target).include? ATTR_REF_HEAD) &&
- (expanded_target = doc.sub_attributes target, :attribute_missing => 'drop-line').empty?
+ (expanded_target = doc.sub_attributes target, attribute_missing: 'drop-line').empty?
shift
if (doc.attributes['attribute-missing'] || Compliance.attribute_missing) == 'skip'
unshift %(Unresolved directive in #{@path} - include::#{target}[#{attrlist}])
@@ -869,7 +869,7 @@ class PreprocessorReader < Reader
elsif include_processors? && (ext = @include_processor_extensions.find {|candidate| candidate.instance.handles? expanded_target })
shift
# FIXME parse attributes only if requested by extension
- ext.process_method[doc, self, expanded_target, (doc.parse_attributes attrlist, [], :sub_input => true)]
+ ext.process_method[doc, self, expanded_target, (doc.parse_attributes attrlist, [], sub_input: true)]
true
# if running in SafeMode::SECURE or greater, don't process this directive
# however, be friendly and at least make it a link to the source document
@@ -878,11 +878,11 @@ class PreprocessorReader < Reader
replace_next_line %(link:#{expanded_target}[])
elsif (abs_maxdepth = @maxdepth[:abs]) > 0
if @include_stack.size >= abs_maxdepth
- logger.error message_with_context %(maximum include depth of #{@maxdepth[:rel]} exceeded), :source_location => cursor
+ logger.error message_with_context %(maximum include depth of #{@maxdepth[:rel]} exceeded), source_location: cursor
return
end
- parsed_attrs = doc.parse_attributes attrlist, [], :sub_input => true
+ parsed_attrs = doc.parse_attributes attrlist, [], sub_input: true
inc_path, target_type, relpath = resolve_include_path expanded_target, attrlist, parsed_attrs
if target_type == :file
reader = ::File.method :open
@@ -948,7 +948,7 @@ class PreprocessorReader < Reader
end
end
rescue
- logger.error message_with_context %(include #{target_type} not readable: #{inc_path}), :source_location => cursor
+ logger.error message_with_context %(include #{target_type} not readable: #{inc_path}), source_location: cursor
return replace_next_line %(Unresolved directive in #{@path} - include::#{expanded_target}[#{attrlist}])
end
shift
@@ -985,9 +985,9 @@ class PreprocessorReader < Reader
include_cursor = create_include_cursor inc_path, expanded_target, inc_lineno
if (idx = tag_stack.rindex {|key, _| key == this_tag })
idx == 0 ? tag_stack.shift : (tag_stack.delete_at idx)
- logger.warn message_with_context %(mismatched end tag (expected '#{active_tag}' but found '#{this_tag}') at line #{inc_lineno} of include #{target_type}: #{inc_path}), :source_location => cursor, :include_location => include_cursor
+ logger.warn message_with_context %(mismatched end tag (expected '#{active_tag}' but found '#{this_tag}') at line #{inc_lineno} of include #{target_type}: #{inc_path}), source_location: cursor, include_location: include_cursor
else
- logger.warn message_with_context %(unexpected end tag '#{this_tag}' at line #{inc_lineno} of include #{target_type}: #{inc_path}), :source_location => cursor, :include_location => include_cursor
+ logger.warn message_with_context %(unexpected end tag '#{this_tag}' at line #{inc_lineno} of include #{target_type}: #{inc_path}), source_location: cursor, include_location: include_cursor
end
end
elsif inc_tags.key? this_tag
@@ -1006,16 +1006,16 @@ class PreprocessorReader < Reader
end
end
rescue
- logger.error message_with_context %(include #{target_type} not readable: #{inc_path}), :source_location => cursor
+ logger.error message_with_context %(include #{target_type} not readable: #{inc_path}), source_location: cursor
return replace_next_line %(Unresolved directive in #{@path} - include::#{expanded_target}[#{attrlist}])
end
unless tag_stack.empty?
tag_stack.each do |tag_name, _, tag_lineno|
- logger.warn message_with_context %(detected unclosed tag '#{tag_name}' starting at line #{tag_lineno} of include #{target_type}: #{inc_path}), :source_location => cursor, :include_location => (create_include_cursor inc_path, expanded_target, tag_lineno)
+ logger.warn message_with_context %(detected unclosed tag '#{tag_name}' starting at line #{tag_lineno} of include #{target_type}: #{inc_path}), source_location: cursor, include_location: (create_include_cursor inc_path, expanded_target, tag_lineno)
end
end
unless (missing_tags = inc_tags.keys - tags_used.to_a).empty?
- logger.warn message_with_context %(tag#{missing_tags.size > 1 ? 's' : ''} '#{missing_tags.join ', '}' not found in include #{target_type}: #{inc_path}), :source_location => cursor
+ logger.warn message_with_context %(tag#{missing_tags.size > 1 ? 's' : ''} '#{missing_tags.join ', '}' not found in include #{target_type}: #{inc_path}), source_location: cursor
end
shift
if inc_offset
@@ -1030,7 +1030,7 @@ class PreprocessorReader < Reader
shift
push_include inc_content, inc_path, relpath, 1, parsed_attrs
rescue
- logger.error message_with_context %(include #{target_type} not readable: #{inc_path}), :source_location => cursor
+ logger.error message_with_context %(include #{target_type} not readable: #{inc_path}), source_location: cursor
return replace_next_line %(Unresolved directive in #{@path} - include::#{expanded_target}[#{attrlist}])
end
end
@@ -1071,13 +1071,13 @@ class PreprocessorReader < Reader
[(::URI.parse target), :uri, target]
else
# include file is resolved relative to dir of current include, or base_dir if within original docfile
- inc_path = doc.normalize_system_path target, @dir, nil, :target_name => 'include file'
+ inc_path = doc.normalize_system_path target, @dir, nil, target_name: 'include file'
unless ::File.file? inc_path
if attributes.key? 'optional-option'
shift
return true
else
- logger.error message_with_context %(include file not found: #{inc_path}), :source_location => cursor
+ logger.error message_with_context %(include file not found: #{inc_path}), source_location: cursor
return replace_next_line %(Unresolved directive in #{@path} - include::#{target}[#{attrlist}])
end
end
@@ -1136,11 +1136,11 @@ class PreprocessorReader < Reader
if attributes.key? 'depth'
depth = attributes['depth'].to_i
depth = 1 if depth <= 0
- @maxdepth = {:abs => (@include_stack.size - 1) + depth, :rel => depth}
+ @maxdepth = { abs: (@include_stack.size - 1) + depth, rel: depth }
end
# effectively fill the buffer
- if (@lines = prepare_lines data, :normalize => true, :condense => false, :indent => attributes['indent']).empty?
+ if (@lines = prepare_lines data, normalize: true, condense: false, indent: attributes['indent']).empty?
pop_include
else
# FIXME we eventually want to handle leveloffset without affecting the lines
@@ -1284,7 +1284,7 @@ class PreprocessorReader < Reader
# QUESTION should we substitute first?
# QUESTION should we also require string to be single quoted (like block attribute values?)
- val = @document.sub_attributes val, :attribute_missing => 'drop' if val.include? ATTR_REF_HEAD
+ val = @document.sub_attributes val, attribute_missing: 'drop' if val.include? ATTR_REF_HEAD
if quoted
val
diff --git a/lib/asciidoctor/stylesheets.rb b/lib/asciidoctor/stylesheets.rb
index 58ef952e..87d1229d 100644
--- a/lib/asciidoctor/stylesheets.rb
+++ b/lib/asciidoctor/stylesheets.rb
@@ -66,7 +66,7 @@ class Stylesheets
end
def pygments_background style = nil
- if load_pygments && PygmentsBgColorRx =~ (::Pygments.css '.pygments', :style => style || DEFAULT_PYGMENTS_STYLE)
+ if load_pygments && PygmentsBgColorRx =~ (::Pygments.css '.pygments', style: style || DEFAULT_PYGMENTS_STYLE)
$1
end
end
@@ -78,7 +78,7 @@ class Stylesheets
if load_pygments
style ||= DEFAULT_PYGMENTS_STYLE
(@pygments_stylesheet_data ||= {})[style] ||=
- ((::Pygments.css '.listingblock .pygments', :classprefix => 'tok-', :style => style) || '/* Failed to load Pygments CSS. */').
+ ((::Pygments.css '.listingblock .pygments', classprefix: 'tok-', style: style) || '/* Failed to load Pygments CSS. */').
sub('.listingblock .pygments {', '.listingblock .pygments, .listingblock .pygments code {')
else
'/* Pygments CSS disabled. Pygments is not available. */'
diff --git a/lib/asciidoctor/substitutors.rb b/lib/asciidoctor/substitutors.rb
index 4ee3ade7..5c06a877 100644
--- a/lib/asciidoctor/substitutors.rb
+++ b/lib/asciidoctor/substitutors.rb
@@ -18,26 +18,26 @@ module Substitutors
(VERBATIM_SUBS = [:specialcharacters, :callouts]).freeze
SUB_GROUPS = {
- :none => NONE_SUBS,
- :normal => NORMAL_SUBS,
- :verbatim => VERBATIM_SUBS,
- :specialchars => BASIC_SUBS
+ none: NONE_SUBS,
+ normal: NORMAL_SUBS,
+ verbatim: VERBATIM_SUBS,
+ specialchars: BASIC_SUBS,
}
SUB_HINTS = {
- :a => :attributes,
- :m => :macros,
- :n => :normal,
- :p => :post_replacements,
- :q => :quotes,
- :r => :replacements,
- :c => :specialcharacters,
- :v => :verbatim
+ a: :attributes,
+ m: :macros,
+ n: :normal,
+ p: :post_replacements,
+ q: :quotes,
+ r: :replacements,
+ c: :specialcharacters,
+ v: :verbatim,
}
SUB_OPTIONS = {
- :block => SUB_GROUPS.keys + NORMAL_SUBS + [:callouts],
- :inline => SUB_GROUPS.keys + NORMAL_SUBS
+ block: SUB_GROUPS.keys + NORMAL_SUBS + [:callouts],
+ inline: SUB_GROUPS.keys + NORMAL_SUBS,
}
SUB_HIGHLIGHT = ['coderay', 'pygments']
@@ -205,12 +205,12 @@ module Substitutors
pass_key = passes.size
if attributes
if old_behavior
- passes[pass_key] = {:text => content, :subs => NORMAL_SUBS, :type => :monospaced, :attributes => attributes}
+ passes[pass_key] = { text: content, subs: NORMAL_SUBS, type: :monospaced, attributes: attributes }
else
- passes[pass_key] = {:text => content, :subs => subs, :type => :unquoted, :attributes => attributes}
+ passes[pass_key] = { text: content, subs: subs, type: :unquoted, attributes: attributes }
end
else
- passes[pass_key] = {:text => content, :subs => subs}
+ passes[pass_key] = { text: content, subs: subs }
end
else # pass:[]
if $6 == RS
@@ -218,7 +218,7 @@ module Substitutors
next $&.slice 1, $&.length
end
- passes[pass_key = passes.size] = {:text => (unescape_brackets $8), :subs => ($7 ? (resolve_pass_subs $7) : nil)}
+ passes[pass_key = passes.size] = { text: (unescape_brackets $8), subs: ($7 ? (resolve_pass_subs $7) : nil) }
end
%(#{preceding}#{PASS_START}#{pass_key}#{PASS_END})
@@ -266,16 +266,16 @@ module Substitutors
pass_key = passes.size
if compat_mode
- passes[pass_key] = {:text => content, :subs => BASIC_SUBS, :attributes => attributes, :type => :monospaced}
+ passes[pass_key] = { text: content, subs: BASIC_SUBS, attributes: attributes, type: :monospaced }
elsif attributes
if old_behavior
subs = (format_mark == '`' ? BASIC_SUBS : NORMAL_SUBS)
- passes[pass_key] = {:text => content, :subs => subs, :attributes => attributes, :type => :monospaced}
+ passes[pass_key] = { text: content, subs: subs, attributes: attributes, type: :monospaced }
else
- passes[pass_key] = {:text => content, :subs => BASIC_SUBS, :attributes => attributes, :type => :unquoted}
+ passes[pass_key] = { text: content, subs: BASIC_SUBS, attributes: attributes, type: :unquoted }
end
else
- passes[pass_key] = {:text => content, :subs => BASIC_SUBS}
+ passes[pass_key] = { text: content, subs: BASIC_SUBS }
end
%(#{preceding}#{PASS_START}#{pass_key}#{PASS_END})
@@ -293,7 +293,7 @@ module Substitutors
end
content = unescape_brackets $3
subs = $2 ? (resolve_pass_subs $2) : ((@document.basebackend? 'html') ? BASIC_SUBS : nil)
- passes[pass_key = passes.size] = {:text => content, :subs => subs, :type => type}
+ passes[pass_key = passes.size] = { text: content, subs: subs, type: type }
%(#{PASS_START}#{pass_key}#{PASS_END})
} if (text.include? ':') && ((text.include? 'stem:') || (text.include? 'math:'))
@@ -306,8 +306,8 @@ module Substitutors
%(#{pre}`+#{$2}+`)
else
@passthroughs[pass_key = @passthroughs.size] = attributes ?
- { :text => $2, :subs => BASIC_SUBS, :attributes => attributes, :type => :unquoted } :
- { :text => $2, :subs => BASIC_SUBS }
+ { text: $2, subs: BASIC_SUBS, attributes: attributes, type: :unquoted } :
+ { text: $2, subs: BASIC_SUBS }
%(#{pre}`#{PASS_START}#{pass_key}#{PASS_END}`)
end
else
@@ -333,7 +333,7 @@ module Substitutors
pass = passes[$1.to_i]
subbed_text = apply_subs(pass[:text], pass[:subs])
if (type = pass[:type])
- subbed_text = Inline.new(self, :quoted, subbed_text, :type => type, :attributes => pass[:attributes]).convert
+ subbed_text = Inline.new(self, :quoted, subbed_text, type: type, attributes: pass[:attributes]).convert
end
subbed_text.include?(PASS_START) ? restore_passthroughs(subbed_text, false) : subbed_text
}
@@ -542,7 +542,7 @@ module Substitutors
else
keys = [keys]
end
- (Inline.new self, :kbd, nil, :attributes => { 'keys' => keys }).convert
+ (Inline.new self, :kbd, nil, attributes: { 'keys' => keys }).convert
else # $2 == 'btn'
(Inline.new self, :button, (unescape_bracketed_text $3)).convert
end
@@ -569,7 +569,7 @@ module Substitutors
submenus, menuitem = [], nil
end
- Inline.new(self, :menu, nil, :attributes => {'menu' => menu, 'submenus' => submenus, 'menuitem' => menuitem}).convert
+ Inline.new(self, :menu, nil, attributes: { 'menu' => menu, 'submenus' => submenus, 'menuitem' => menuitem }).convert
}
end
@@ -582,7 +582,7 @@ module Substitutors
menu, *submenus = $1.split('&gt;').map {|it| it.strip }
menuitem = submenus.pop
- Inline.new(self, :menu, nil, :attributes => {'menu' => menu, 'submenus' => submenus, 'menuitem' => menuitem}).convert
+ Inline.new(self, :menu, nil, attributes: { 'menu' => menu, 'submenus' => submenus, 'menuitem' => menuitem }).convert
}
end
end
@@ -610,7 +610,7 @@ module Substitutors
if extconf[:content_model] == :attributes
# QUESTION should we store the text in the _text key?
# NOTE bracked text has already been escaped
- parse_attributes content, extconf[:pos_attrs] || [], :into => attributes
+ parse_attributes content, extconf[:pos_attrs] || [], into: attributes
else
attributes['text'] = content
end
@@ -637,10 +637,10 @@ module Substitutors
# TODO remove this special case once titles use normal substitution order
target = sub_attributes target
end
- attrs = parse_attributes $2, posattrs, :unescape_input => true
+ attrs = parse_attributes $2, posattrs, unescape_input: true
doc.register :images, [target, (attrs['imagesdir'] = doc_attrs['imagesdir'])] unless type == 'icon'
attrs['alt'] ||= (attrs['default-alt'] = Helpers.basename(target, true).tr('_-', ' '))
- Inline.new(self, :image, nil, :type => type, :target => target, :attributes => attrs).convert
+ Inline.new(self, :image, nil, type: type, target: target, attributes: attrs).convert
}
end
@@ -660,7 +660,7 @@ module Substitutors
# indexterm:[Tigers,Big cats]
terms = split_simple_csv normalize_string text, true
doc.register :indexterms, terms
- (Inline.new self, :indexterm, nil, :attributes => { 'terms' => terms }).convert
+ (Inline.new self, :indexterm, nil, attributes: { 'terms' => terms }).convert
when 'indexterm2'
text = $2
# honor the escape
@@ -670,7 +670,7 @@ module Substitutors
# indexterm2:[Tigers]
term = normalize_string text, true
doc.register :indexterms, [term]
- (Inline.new self, :indexterm, term, :type => :visible).convert
+ (Inline.new self, :indexterm, term, type: :visible).convert
else
text = $3
# honor the escape
@@ -698,12 +698,12 @@ module Substitutors
# ((Tigers))
term = normalize_string text
doc.register :indexterms, [term]
- subbed_term = (Inline.new self, :indexterm, term, :type => :visible).convert
+ subbed_term = (Inline.new self, :indexterm, term, type: :visible).convert
else
# (((Tigers,Big cats)))
terms = split_simple_csv(normalize_string text)
doc.register :indexterms, terms
- subbed_term = (Inline.new self, :indexterm, nil, :attributes => { 'terms' => terms }).convert
+ subbed_term = (Inline.new self, :indexterm, nil, attributes: { 'terms' => terms }).convert
end
before ? %(#{before}#{subbed_term}#{after}) : subbed_term
end
@@ -761,7 +761,7 @@ module Substitutors
return captured if target.end_with? '://'
end
- attrs, link_opts = nil, { :type => :link }
+ attrs, link_opts = nil, { type: :link }
unless text.empty?
text = text.gsub ESC_R_SB, R_SB if text.include? R_SB
if !doc.compat_mode && (text.include? '=')
@@ -817,7 +817,7 @@ module Substitutors
else
target = $2
end
- attrs, link_opts = nil, { :type => :link }
+ attrs, link_opts = nil, { type: :link }
unless (text = $3).empty?
text = text.gsub ESC_R_SB, R_SB if text.include? R_SB
if mailto
@@ -893,7 +893,7 @@ module Substitutors
# QUESTION should this be registered as an e-mail address?
doc.register(:links, target)
- Inline.new(self, :anchor, $&, :type => :link, :target => target).convert
+ Inline.new(self, :anchor, $&, type: :link, target: target).convert
}
end
@@ -933,7 +933,7 @@ module Substitutors
else
next $&
end
- Inline.new(self, :footnote, text, :attributes => {'index' => index}, :id => id, :target => target, :type => type).convert
+ Inline.new(self, :footnote, text, attributes: { 'index' => index }, id: id, target: target, type: type).convert
}
end
@@ -945,7 +945,7 @@ module Substitutors
if @context == :list_item && @parent.style == 'bibliography'
text = text.sub(InlineBiblioAnchorRx) {
# NOTE target property on :bibref is deprecated
- Inline.new(self, :anchor, %([#{$2 || $1}]), :type => :bibref, :id => $1, :target => $1).convert
+ Inline.new(self, :anchor, %([#{$2 || $1}]), type: :bibref, id: $1, target: $1).convert
}
end
@@ -964,7 +964,7 @@ module Substitutors
end
end
# NOTE target property on :ref is deprecated
- Inline.new(self, :anchor, reftext, :type => :ref, :id => id, :target => id).convert
+ Inline.new(self, :anchor, reftext, type: :ref, id: id, target: id).convert
}
end
@@ -1054,7 +1054,7 @@ module Substitutors
logger.warn %(invalid reference: #{refid}) if $VERBOSE
end
attrs['path'], attrs['fragment'], attrs['refid'] = path, fragment, refid
- Inline.new(self, :anchor, text, :type => :xref, :target => target, :attributes => attrs).convert
+ Inline.new(self, :anchor, text, type: :xref, target: target, attributes: attrs).convert
}
end
@@ -1075,7 +1075,7 @@ module Substitutors
# use sub since it might be behind a line comment
$&.sub(RS, '')
else
- Inline.new(self, :callout, $4 == '.' ? (autonum += 1).to_s : $4, :id => @document.callouts.read_next_id, :attributes => { 'guard' => $1 }).convert
+ Inline.new(self, :callout, $4 == '.' ? (autonum += 1).to_s : $4, id: @document.callouts.read_next_id, attributes: { 'guard' => $1 }).convert
end
}
end
@@ -1091,10 +1091,10 @@ module Substitutors
return text if lines.size < 2
last = lines.pop
(lines.map {|line|
- Inline.new(self, :break, (line.end_with? HARD_LINE_BREAK) ? (line.slice 0, line.length - 2) : line, :type => :line).convert
+ Inline.new(self, :break, (line.end_with? HARD_LINE_BREAK) ? (line.slice 0, line.length - 2) : line, type: :line).convert
} << last).join LF
elsif (text.include? PLUS) && (text.include? HARD_LINE_BREAK)
- text.gsub(HardLineBreakRx) { Inline.new(self, :break, $1, :type => :line).convert }
+ text.gsub(HardLineBreakRx) { Inline.new(self, :break, $1, type: :line).convert }
else
text
end
@@ -1118,20 +1118,20 @@ module Substitutors
if scope == :constrained
if unescaped_attrs
- %(#{unescaped_attrs}#{Inline.new(self, :quoted, match[3], :type => type).convert})
+ %(#{unescaped_attrs}#{Inline.new(self, :quoted, match[3], type: type).convert})
else
if (attrlist = match[2])
id = (attributes = parse_quoted_text_attributes attrlist).delete 'id'
type = :unquoted if type == :mark
end
- %(#{match[1]}#{Inline.new(self, :quoted, match[3], :type => type, :id => id, :attributes => attributes).convert})
+ %(#{match[1]}#{Inline.new(self, :quoted, match[3], type: type, id: id, attributes: attributes).convert})
end
else
if (attrlist = match[1])
id = (attributes = parse_quoted_text_attributes attrlist).delete 'id'
type = :unquoted if type == :mark
end
- Inline.new(self, :quoted, match[2], :type => type, :id => id, :attributes => attributes).convert
+ Inline.new(self, :quoted, match[2], type: type, id: id, attributes: attributes).convert
end
end
@@ -1173,7 +1173,7 @@ module Substitutors
attrs['role'] = roles.join ' ' unless roles.empty?
attrs
else
- {'role' => str}
+ { 'role' => str }
end
end
@@ -1445,16 +1445,16 @@ module Substitutors
end
end
result = ::CodeRay::Duo[attr('language', :text, false).to_sym, :html, {
- :css => (@document.attributes['coderay-css'] || :class).to_sym,
- :line_numbers => linenums_mode,
- :line_number_start => start,
- :line_number_anchors => false,
- :highlight_lines => highlight_lines,
- :bold_every => false
+ css: (@document.attributes['coderay-css'] || :class).to_sym,
+ line_numbers: linenums_mode,
+ line_number_start: start,
+ line_number_anchors: false,
+ highlight_lines: highlight_lines,
+ bold_every: false,
}].highlight source
when 'pygments'
lexer = ::Pygments::Lexer.find_by_alias(attr 'language', 'text', false) || ::Pygments::Lexer.find_by_mimetype('text/plain')
- opts = { :cssclass => 'pyhl', :classprefix => 'tok-', :nobackground => true, :stripnl => false }
+ opts = { cssclass: 'pyhl', classprefix: 'tok-', nobackground: true, stripnl: false }
opts[:startinline] = !(option? 'mixed') if lexer.name == 'PHP'
unless (@document.attributes['pygments-css'] || 'class') == 'class'
opts[:noclasses] = true
@@ -1470,12 +1470,12 @@ module Substitutors
if (attr? 'linenums', nil, false) && (opts[:linenostart] = (start = attr 'start', 1, false).to_i < 1 ? 1 : start) &&
(opts[:linenos] = @document.attributes['pygments-linenums-mode'] || 'table') == 'table'
linenums_mode = :table
- if (result = lexer.highlight source, :options => opts)
+ if (result = lexer.highlight source, options: opts)
result = (result.sub PygmentsWrapperDivRx, '\1').gsub PygmentsWrapperPreRx, '\1'
else
result = sub_specialchars source
end
- elsif (result = lexer.highlight source, :options => opts)
+ elsif (result = lexer.highlight source, options: opts)
if PygmentsWrapperPreRx =~ result
result = $1
end
@@ -1508,9 +1508,9 @@ module Substitutors
end
if conums.size == 1
guard, conum = conums[0]
- %(#{line}#{Inline.new(self, :callout, conum == '.' ? (autonum += 1).to_s : conum, :id => @document.callouts.read_next_id, :attributes => { 'guard' => guard }).convert}#{tail})
+ %(#{line}#{Inline.new(self, :callout, conum == '.' ? (autonum += 1).to_s : conum, id: @document.callouts.read_next_id, attributes: { 'guard' => guard }).convert}#{tail})
else
- conums_markup = conums.map {|guard_it, conum_it| Inline.new(self, :callout, conum_it == '.' ? (autonum += 1).to_s : conum_it, :id => @document.callouts.read_next_id, :attributes => { 'guard' => guard_it }).convert }.join ' '
+ conums_markup = conums.map {|guard_it, conum_it| Inline.new(self, :callout, conum_it == '.' ? (autonum += 1).to_s : conum_it, id: @document.callouts.read_next_id, attributes: { 'guard' => guard_it }).convert }.join ' '
%(#{line}#{conums_markup}#{tail})
end
else
diff --git a/lib/asciidoctor/table.rb b/lib/asciidoctor/table.rb
index acc9eb89..41b3eba8 100644
--- a/lib/asciidoctor/table.rb
+++ b/lib/asciidoctor/table.rb
@@ -290,7 +290,7 @@ class Table::Cell < AbstractNode
inner_document_lines.unshift(*preprocessed_lines) unless preprocessed_lines.empty?
end
end unless inner_document_lines.empty?
- @inner_document = Document.new(inner_document_lines, :header_footer => false, :parent => @document, :cursor => inner_document_cursor)
+ @inner_document = Document.new(inner_document_lines, header_footer: false, parent: @document, cursor: inner_document_cursor)
@document.attributes['doctitle'] = parent_doctitle unless parent_doctitle.nil?
@subs = nil
elsif literal
@@ -336,7 +336,7 @@ class Table::Cell < AbstractNode
@inner_document.convert
else
text.split(BlankLineRx).map do |p|
- !@style || @style == :header ? p : Inline.new(parent, :quoted, p, :type => @style).convert
+ !@style || @style == :header ? p : Inline.new(parent, :quoted, p, type: @style).convert
end
end
end
@@ -376,7 +376,7 @@ class Table::ParserContext
'csv' => [',', /,/],
'dsv' => [':', /:/],
'tsv' => [%(\t), /\t/],
- '!sv' => ['!', /!/]
+ '!sv' => ['!', /!/],
}
# Public: The Table currently being parsed
@@ -414,7 +414,7 @@ class Table::ParserContext
xsv = '!sv'
end
else
- logger.error message_with_context %(illegal table format: #{xsv}), :source_location => reader.cursor_at_prev_line
+ logger.error message_with_context %(illegal table format: #{xsv}), source_location: reader.cursor_at_prev_line
@format, xsv = 'psv', (table.document.nested? ? '!sv' : 'psv')
end
else
@@ -569,7 +569,7 @@ class Table::ParserContext
if (cellspec = take_cellspec)
repeat = cellspec.delete('repeatcol') || 1
else
- logger.error message_with_context 'table missing leading separator; recovering automatically', :source_location => Reader::Cursor.new(*@start_cursor_data)
+ logger.error message_with_context 'table missing leading separator; recovering automatically', source_location: Reader::Cursor.new(*@start_cursor_data)
cellspec = {}
repeat = 1
end
@@ -586,7 +586,7 @@ class Table::ParserContext
# trim whitespace and collapse escaped quotes
cell_text = cell_text.strip.squeeze('"')
else
- logger.error message_with_context 'unclosed quote in CSV data; setting cell to empty', :source_location => @reader.cursor_at_prev_line
+ logger.error message_with_context 'unclosed quote in CSV data; setting cell to empty', source_location: @reader.cursor_at_prev_line
cell_text = ''
end
else
@@ -609,12 +609,12 @@ class Table::ParserContext
else
# QUESTION is this right for cells that span columns?
unless (column = @table.columns[@current_row.size])
- logger.error message_with_context 'dropping cell because it exceeds specified number of columns', :source_location => @reader.cursor_before_mark
+ logger.error message_with_context 'dropping cell because it exceeds specified number of columns', source_location: @reader.cursor_before_mark
return
end
end
- cell = Table::Cell.new(column, cell_text, cellspec, :cursor => @reader.cursor_before_mark)
+ cell = Table::Cell.new(column, cell_text, cellspec, cursor: @reader.cursor_before_mark)
@reader.mark
unless !cell.rowspan || cell.rowspan == 1
activate_rowspan(cell.rowspan, (cell.colspan || 1))
diff --git a/test/api_test.rb b/test/api_test.rb
index 048d40bb..fd8cafb6 100644
--- a/test/api_test.rb
+++ b/test/api_test.rb
@@ -4,7 +4,7 @@ context 'API' do
context 'Load' do
test 'should load input file' do
sample_input_path = fixture_path('sample.asciidoc')
- doc = File.open(sample_input_path) {|file| Asciidoctor.load file, :safe => Asciidoctor::SafeMode::SAFE }
+ doc = File.open(sample_input_path) {|file| Asciidoctor.load file, safe: Asciidoctor::SafeMode::SAFE }
assert_equal 'Document Title', doc.doctitle
assert_equal File.expand_path(sample_input_path), doc.attr('docfile')
assert_equal File.expand_path(File.dirname(sample_input_path)), doc.attr('docdir')
@@ -13,7 +13,7 @@ context 'API' do
test 'should load input file from filename' do
sample_input_path = fixture_path('sample.asciidoc')
- doc = Asciidoctor.load_file(sample_input_path, :safe => Asciidoctor::SafeMode::SAFE)
+ doc = Asciidoctor.load_file(sample_input_path, safe: Asciidoctor::SafeMode::SAFE)
assert_equal 'Document Title', doc.doctitle
assert_equal File.expand_path(sample_input_path), doc.attr('docfile')
assert_equal File.expand_path(File.dirname(sample_input_path)), doc.attr('docdir')
@@ -28,7 +28,7 @@ context 'API' do
$VERBOSE = nil # disable warnings since we have to modify constants
input_path = fixture_path 'encoding.asciidoc'
Encoding.default_external = Encoding.default_internal = Encoding::IBM437
- output = Asciidoctor.convert_file input_path, :to_file => false, :safe => :safe
+ output = Asciidoctor.convert_file input_path, to_file: false, safe: :safe
assert_equal Encoding::UTF_8, output.encoding
assert_includes output, 'Romé'
ensure
@@ -45,7 +45,7 @@ context 'API' do
tmp_input.write %(ƒ\n)
tmp_input.close
exception = assert_raises ArgumentError do
- Asciidoctor.load_file tmp_input.path, :safe => :safe
+ Asciidoctor.load_file tmp_input.path, safe: :safe
end
assert_match(/Failed to load AsciiDoc document - invalid byte sequence in UTF-8/, exception.message)
ensure
@@ -56,7 +56,7 @@ context 'API' do
test 'should not load invalid file' do
sample_input_path = fixture_path('hello-asciidoctor.pdf')
exception = assert_raises ArgumentError do
- Asciidoctor.load_file(sample_input_path, :safe => Asciidoctor::SafeMode::SAFE)
+ Asciidoctor.load_file(sample_input_path, safe: Asciidoctor::SafeMode::SAFE)
end
assert_match(/Failed to load AsciiDoc document/, exception.message)
# verify we have the correct backtrace (should be in at least first 5 lines)
@@ -74,7 +74,7 @@ context 'API' do
tmp_input.close
Encoding.default_external = Encoding.default_internal = Encoding::IBM437
tmp_output = tmp_input.path.sub '.adoc', '.html'
- Asciidoctor.convert_file tmp_input.path, :safe => :safe, :attributes => 'linkcss !copycss'
+ Asciidoctor.convert_file tmp_input.path, safe: :safe, attributes: 'linkcss !copycss'
assert File.exist? tmp_output
output = File.read tmp_output, mode: 'rb', encoding: 'utf-8:utf-8'
assert_equal ::Encoding::UTF_8, output.encoding
@@ -96,7 +96,7 @@ Document Title
preamble
EOS
- doc = Asciidoctor.load(input, :safe => Asciidoctor::SafeMode::SAFE)
+ doc = Asciidoctor.load(input, safe: Asciidoctor::SafeMode::SAFE)
assert_equal 'Document Title', doc.doctitle
refute doc.attr?('docfile')
assert_equal doc.base_dir, doc.attr('docdir')
@@ -109,7 +109,7 @@ Document Title
preamble
EOS
- doc = Asciidoctor.load(input, :safe => Asciidoctor::SafeMode::SAFE)
+ doc = Asciidoctor.load(input, safe: Asciidoctor::SafeMode::SAFE)
assert_equal 'Document Title', doc.doctitle
refute doc.attr?('docfile')
assert_equal doc.base_dir, doc.attr('docdir')
@@ -122,7 +122,7 @@ Document Title
preamble
EOS
- doc = Asciidoctor.load(input.lines, :safe => Asciidoctor::SafeMode::SAFE)
+ doc = Asciidoctor.load(input.lines, safe: Asciidoctor::SafeMode::SAFE)
assert_equal 'Document Title', doc.doctitle
refute doc.attr?('docfile')
assert_equal doc.base_dir, doc.attr('docdir')
@@ -130,7 +130,7 @@ preamble
test 'should accept attributes as array' do
# NOTE there's a tab character before idseparator
- doc = Asciidoctor.load('text', :attributes => %w(toc sectnums source-highlighter=coderay idprefix idseparator=-))
+ doc = Asciidoctor.load('text', attributes: %w(toc sectnums source-highlighter=coderay idprefix idseparator=-))
assert_kind_of Hash, doc.attributes
assert doc.attr?('toc')
assert_equal '', doc.attr('toc')
@@ -145,12 +145,12 @@ preamble
end
test 'should accept attributes as empty array' do
- doc = Asciidoctor.load('text', :attributes => [])
+ doc = Asciidoctor.load('text', attributes: [])
assert_kind_of Hash, doc.attributes
end
test 'should accept attributes as string' do
- doc = Asciidoctor.load('text', :attributes => 'toc sectnums
+ doc = Asciidoctor.load('text', attributes: 'toc sectnums
source-highlighter=coderay
idprefix
idseparator=-')
@@ -168,7 +168,7 @@ idseparator=-')
end
test 'should accept values containing spaces in attributes string' do
- doc = Asciidoctor.load('text', :attributes => %(idprefix idseparator=- note-caption=Note\\ to\\\tself toc))
+ doc = Asciidoctor.load('text', attributes: %(idprefix idseparator=- note-caption=Note\\ to\\\tself toc))
assert_kind_of Hash, doc.attributes
assert doc.attr?('idprefix')
assert_equal '', doc.attr('idprefix')
@@ -179,19 +179,19 @@ idseparator=-')
end
test 'should accept attributes as empty string' do
- doc = Asciidoctor.load('text', :attributes => '')
+ doc = Asciidoctor.load('text', attributes: '')
assert_kind_of Hash, doc.attributes
end
test 'should accept attributes as nil' do
- doc = Asciidoctor.load('text', :attributes => nil)
+ doc = Asciidoctor.load('text', attributes: nil)
assert_kind_of Hash, doc.attributes
end
test 'should accept attributes if hash like' do
class Hashish
def initialize
- @table = {'toc' => ''}
+ @table = { 'toc' => '' }
end
def keys
@@ -203,14 +203,14 @@ idseparator=-')
end
end
- doc = Asciidoctor.load('text', :attributes => Hashish.new)
+ doc = Asciidoctor.load('text', attributes: Hashish.new)
assert_kind_of Hash, doc.attributes
assert doc.attributes.has_key?('toc')
end
test 'should not expand value of docdir attribute if specified via API' do
docdir = 'virtual/directory'
- doc = document_from_string '', :safe => :safe, :attributes => { 'docdir' => docdir }
+ doc = document_from_string '', safe: :safe, attributes: { 'docdir' => docdir }
assert_equal docdir, (doc.attr 'docdir')
assert_equal docdir, doc.base_dir
end
@@ -238,12 +238,12 @@ paragraph text
([doc] + doc.blocks).each do |block|
assert_equal block.method(:convert), block.method(:render)
end
- inline = Asciidoctor::Inline.new doc.blocks[0], :image, nil, :type => 'image', :target => 'tiger.png'
+ inline = Asciidoctor::Inline.new doc.blocks[0], :image, nil, type: 'image', target: 'tiger.png'
assert_equal inline.method(:convert), inline.method(:render)
end
test 'should output timestamps by default' do
- doc = document_from_string 'text', :backend => :html5, :attributes => nil
+ doc = document_from_string 'text', backend: :html5, attributes: nil
result = doc.convert
assert doc.attr?('docdate')
refute doc.attr? 'reproducible'
@@ -251,7 +251,7 @@ paragraph text
end
test 'should not output timestamps if reproducible attribute is set in HTML 5' do
- doc = document_from_string 'text', :backend => :html5, :attributes => { 'reproducible' => '' }
+ doc = document_from_string 'text', backend: :html5, attributes: { 'reproducible' => '' }
result = doc.convert
assert doc.attr?('docdate')
assert doc.attr?('reproducible')
@@ -259,7 +259,7 @@ paragraph text
end
test 'should not output timestamps if reproducible attribute is set in DocBook' do
- doc = document_from_string 'text', :backend => :docbook, :attributes => { 'reproducible' => '' }
+ doc = document_from_string 'text', backend: :docbook, attributes: { 'reproducible' => '' }
result = doc.convert
assert doc.attr?('docdate')
assert doc.attr?('reproducible')
@@ -267,9 +267,7 @@ paragraph text
end
test 'should not modify options argument' do
- options = {
- :safe => Asciidoctor::SafeMode::SAFE
- }
+ options = { safe: Asciidoctor::SafeMode::SAFE }
options.freeze
sample_input_path = fixture_path('sample.asciidoc')
begin
@@ -283,8 +281,8 @@ paragraph text
attributes = {}
attributes.freeze
options = {
- :safe => Asciidoctor::SafeMode::SAFE,
- :attributes => attributes
+ safe: Asciidoctor::SafeMode::SAFE,
+ attributes: attributes,
}
sample_input_path = fixture_path('sample.asciidoc')
begin
@@ -314,7 +312,7 @@ content
end
test 'should track file and line information with blocks if sourcemap option is set' do
- doc = Asciidoctor.load_file fixture_path('sample.asciidoc'), :sourcemap => true
+ doc = Asciidoctor.load_file fixture_path('sample.asciidoc'), sourcemap: true
refute_nil doc.source_location
assert_equal 'sample.asciidoc', doc.file
@@ -369,7 +367,7 @@ content
assert_equal 'sample.asciidoc', list_items[2].file
assert_equal 30, list_items[2].lineno
- doc = Asciidoctor.load_file fixture_path('master.adoc'), :sourcemap => true, :safe => :safe
+ doc = Asciidoctor.load_file fixture_path('master.adoc'), sourcemap: true, safe: :safe
section_1 = doc.sections[0]
assert_equal 'Chapter A', section_1.title
@@ -379,21 +377,21 @@ content
end
test 'should track file and line information on list items if sourcemap option is set' do
- doc = Asciidoctor.load_file fixture_path('lists.adoc'), :sourcemap => true
+ doc = Asciidoctor.load_file fixture_path('lists.adoc'), sourcemap: true
first_section = doc.blocks[1]
unordered_basic_list = first_section.blocks[0]
assert_equal 11, unordered_basic_list.lineno
- unordered_basic_list_items = unordered_basic_list.find_by :context => :list_item
+ unordered_basic_list_items = unordered_basic_list.find_by context: :list_item
assert_equal 11, unordered_basic_list_items[0].lineno
assert_equal 12, unordered_basic_list_items[1].lineno
assert_equal 13, unordered_basic_list_items[2].lineno
unordered_max_nesting = first_section.blocks[1]
assert_equal 16, unordered_max_nesting.lineno
- unordered_max_nesting_items = unordered_max_nesting.find_by :context => :list_item
+ unordered_max_nesting_items = unordered_max_nesting.find_by context: :list_item
assert_equal 16, unordered_max_nesting_items[0].lineno
assert_equal 17, unordered_max_nesting_items[1].lineno
assert_equal 18, unordered_max_nesting_items[2].lineno
@@ -403,7 +401,7 @@ content
checklist = first_section.blocks[2]
assert_equal 24, checklist.lineno
- checklist_list_items = checklist.find_by :context => :list_item
+ checklist_list_items = checklist.find_by context: :list_item
assert_equal 24, checklist_list_items[0].lineno
assert_equal 25, checklist_list_items[1].lineno
assert_equal 26, checklist_list_items[2].lineno
@@ -411,14 +409,14 @@ content
ordered_basic = first_section.blocks[3]
assert_equal 30, ordered_basic.lineno
- ordered_basic_list_items = ordered_basic.find_by :context => :list_item
+ ordered_basic_list_items = ordered_basic.find_by context: :list_item
assert_equal 30, ordered_basic_list_items[0].lineno
assert_equal 31, ordered_basic_list_items[1].lineno
assert_equal 32, ordered_basic_list_items[2].lineno
ordered_nested = first_section.blocks[4]
assert_equal 35, ordered_nested.lineno
- ordered_nested_list_items = ordered_nested.find_by :context => :list_item
+ ordered_nested_list_items = ordered_nested.find_by context: :list_item
assert_equal 35, ordered_nested_list_items[0].lineno
assert_equal 36, ordered_nested_list_items[1].lineno
assert_equal 37, ordered_nested_list_items[2].lineno
@@ -427,7 +425,7 @@ content
ordered_max_nesting = first_section.blocks[5]
assert_equal 42, ordered_max_nesting.lineno
- ordered_max_nesting_items = ordered_max_nesting.find_by :context => :list_item
+ ordered_max_nesting_items = ordered_max_nesting.find_by context: :list_item
assert_equal 42, ordered_max_nesting_items[0].lineno
assert_equal 43, ordered_max_nesting_items[1].lineno
assert_equal 44, ordered_max_nesting_items[2].lineno
@@ -437,7 +435,7 @@ content
labeled_singleline = first_section.blocks[6]
assert_equal 50, labeled_singleline.lineno
- labeled_singleline_items = labeled_singleline.find_by :context => :list_item
+ labeled_singleline_items = labeled_singleline.find_by context: :list_item
assert_equal 50, labeled_singleline_items[0].lineno
assert_equal 50, labeled_singleline_items[1].lineno
assert_equal 51, labeled_singleline_items[2].lineno
@@ -445,7 +443,7 @@ content
labeled_multiline = first_section.blocks[7]
assert_equal 54, labeled_multiline.lineno
- labeled_multiline_items = labeled_multiline.find_by :context => :list_item
+ labeled_multiline_items = labeled_multiline.find_by context: :list_item
assert_equal 54, labeled_multiline_items[0].lineno
assert_equal 55, labeled_multiline_items[1].lineno
assert_equal 56, labeled_multiline_items[2].lineno
@@ -453,7 +451,7 @@ content
qanda = first_section.blocks[8]
assert_equal 61, qanda.lineno
- qanda_items = qanda.find_by :context => :list_item
+ qanda_items = qanda.find_by context: :list_item
assert_equal 61, qanda_items[0].lineno
assert_equal 62, qanda_items[1].lineno
assert_equal 63, qanda_items[2].lineno
@@ -461,7 +459,7 @@ content
mixed = first_section.blocks[9]
assert_equal 66, mixed.lineno
- mixed_items = mixed.find_by(:context => :list_item) {|block| block.text? }
+ mixed_items = mixed.find_by(context: :list_item) {|block| block.text? }
assert_equal 66, mixed_items[0].lineno
assert_equal 67, mixed_items[1].lineno
assert_equal 68, mixed_items[2].lineno
@@ -482,7 +480,7 @@ content
unordered_complex_list = first_section.blocks[10]
assert_equal 86, unordered_complex_list.lineno
- unordered_complex_items = unordered_complex_list.find_by :context => :list_item
+ unordered_complex_items = unordered_complex_list.find_by context: :list_item
assert_equal 86, unordered_complex_items[0].lineno
assert_equal 87, unordered_complex_items[1].lineno
assert_equal 88, unordered_complex_items[2].lineno
@@ -501,12 +499,12 @@ content
== Section B
EOS
- doc = document_from_string input, :sourcemap => true
- assert_equal [1, 3, 7], (doc.find_by :context => :section).map(&:lineno)
+ doc = document_from_string input, sourcemap: true
+ assert_equal [1, 3, 7], (doc.find_by context: :section).map(&:lineno)
end
test 'should allow sourcemap option on document to be modified' do
- doc = Asciidoctor.load_file fixture_path('sample.asciidoc'), :parse => false
+ doc = Asciidoctor.load_file fixture_path('sample.asciidoc'), parse: false
doc.sourcemap = true
doc = doc.parse
@@ -542,7 +540,7 @@ paragraph
EOS
doc = Asciidoctor.load input
- result = doc.find_by :context => :image
+ result = doc.find_by context: :image
assert_equal 2, result.size
assert_equal :image, result[0].context
assert_equal 'tiger.png', result[0].attr('target')
@@ -555,7 +553,7 @@ paragraph
paragraph
EOS
doc = Asciidoctor.load input
- result = doc.find_by :context => :section
+ result = doc.find_by context: :section
refute_nil result
assert_equal 0, result.size
end
@@ -575,7 +573,7 @@ paragraph
EOS
doc = Asciidoctor.load input
- result = doc.find_by :context => :ulist, :style => 'square'
+ result = doc.find_by context: :ulist, style: 'square'
assert_equal 1, result.size
assert_equal :ulist, result[0].context
end
@@ -589,7 +587,7 @@ image::shoe.png[Shoe]
EOS
doc = Asciidoctor.load input
- result = doc.find_by :context => :image, :role => 'animal'
+ result = doc.find_by context: :image, role: 'animal'
assert_equal 1, result.size
assert_equal :image, result[0].context
assert_equal 'tiger.png', result[0].attr('target')
@@ -606,7 +604,7 @@ preamble
content
EOS
doc = Asciidoctor.load input
- result = doc.find_by :context => :section
+ result = doc.find_by context: :section
refute_nil result
assert_equal 2, result.size
assert_equal :section, result[0].context
@@ -624,7 +622,7 @@ content
content
EOS
doc = Asciidoctor.load input
- result = doc.find_by(:context => :section) {|sect| sect.level == 1 }
+ result = doc.find_by(context: :section) {|sect| sect.level == 1 }
refute_nil result
assert_equal 1, result.size
assert_equal :section, result[0].context
@@ -727,7 +725,7 @@ content
content
EOS
doc = Asciidoctor.load input
- result = doc.find_by(:context => :section, :id => 'subsection')
+ result = doc.find_by(context: :section, id: 'subsection')
refute_nil result
assert_equal 1, result.size
assert_equal :section, result[0].context
@@ -748,7 +746,7 @@ content
EOS
doc = Asciidoctor.load input
visited_last = false
- result = doc.find_by(:id => 'subsection') do |candidate|
+ result = doc.find_by(id: 'subsection') do |candidate|
visited_last = true if candidate.id == 'last'
true
end
@@ -769,7 +767,7 @@ content
content
EOS
doc = Asciidoctor.load input
- result = doc.find_by(:context => :section, :id => 'subsection') {|sect| false }
+ result = doc.find_by(context: :section, id: 'subsection') {|sect| false }
refute_nil result
assert_equal 0, result.size
end
@@ -789,7 +787,7 @@ term without description::
test 'timings are recorded for each step when load and convert are called separately' do
sample_input_path = fixture_path 'asciidoc_index.txt'
- (Asciidoctor.load_file sample_input_path, :timings => (timings = Asciidoctor::Timings.new)).convert
+ (Asciidoctor.load_file sample_input_path, timings: (timings = Asciidoctor::Timings.new)).convert
refute_equal '0.00000', '%05.5f' % timings.read_parse.to_f
refute_equal '0.00000', '%05.5f' % timings.convert.to_f
refute_equal timings.read_parse, timings.total
@@ -808,7 +806,7 @@ term without description::
test 'should convert source document to string when to_file is false' do
sample_input_path = fixture_path('sample.asciidoc')
- output = Asciidoctor.convert_file sample_input_path, :header_footer => true, :to_file => false
+ output = Asciidoctor.convert_file sample_input_path, header_footer: true, to_file: false
refute_empty output
assert_xpath '/html', output, 1
assert_xpath '/html/head', output, 1
@@ -820,7 +818,7 @@ term without description::
test 'lines in output should be separated by line feed' do
sample_input_path = fixture_path('sample.asciidoc')
- output = Asciidoctor.convert_file sample_input_path, :header_footer => true, :to_file => false
+ output = Asciidoctor.convert_file sample_input_path, header_footer: true, to_file: false
refute_empty output
lines = output.split("\n")
assert_equal lines.size, output.split(/\r\n|\r|\n/).size
@@ -831,19 +829,19 @@ term without description::
test 'should accept attributes as array' do
sample_input_path = fixture_path('sample.asciidoc')
- output = Asciidoctor.convert_file sample_input_path, :attributes => %w(sectnums idprefix idseparator=-), :to_file => false
+ output = Asciidoctor.convert_file sample_input_path, attributes: %w(sectnums idprefix idseparator=-), to_file: false
assert_css '#section-a', output, 1
end
test 'should accept attributes as string' do
sample_input_path = fixture_path('sample.asciidoc')
- output = Asciidoctor.convert_file sample_input_path, :attributes => 'sectnums idprefix idseparator=-', :to_file => false
+ output = Asciidoctor.convert_file sample_input_path, attributes: 'sectnums idprefix idseparator=-', to_file: false
assert_css '#section-a', output, 1
end
test 'should link to default stylesheet by default when safe mode is SECURE or greater' do
sample_input_path = fixture_path('basic.asciidoc')
- output = Asciidoctor.convert_file sample_input_path, :header_footer => true, :to_file => false
+ output = Asciidoctor.convert_file sample_input_path, header_footer: true, to_file: false
assert_css 'html:root > head > link[rel="stylesheet"][href^="https://fonts.googleapis.com"]', output, 1
assert_css 'html:root > head > link[rel="stylesheet"][href="./asciidoctor.css"]', output, 1
end
@@ -855,7 +853,7 @@ term without description::
text
EOS
- output = Asciidoctor.convert input, :safe => Asciidoctor::SafeMode::SERVER, :header_footer => true
+ output = Asciidoctor.convert input, safe: Asciidoctor::SafeMode::SERVER, header_footer: true
assert_css 'html:root > head > link[rel="stylesheet"][href^="https://fonts.googleapis.com"]', output, 1
assert_css 'html:root > head > link[rel="stylesheet"][href="./asciidoctor.css"]', output, 0
stylenode = xmlnodes_at_css 'html:root > head > style', output, 1
@@ -872,7 +870,7 @@ text
text
EOS
- output = Asciidoctor.convert input, :header_footer => true
+ output = Asciidoctor.convert input, header_footer: true
assert_css 'html:root > head > link[rel="stylesheet"][href^="https://fonts.googleapis.com"]', output, 1
assert_css 'html:root > head > link[rel="stylesheet"][href="./asciidoctor.css"]', output, 1
end
@@ -886,7 +884,7 @@ text
#[{ 'linkcss!' => '' }, { 'linkcss' => nil }, { 'linkcss' => false }].each do |attrs|
[{ 'linkcss!' => '' }, { 'linkcss' => nil }].each do |attrs|
- output = Asciidoctor.convert input, :header_footer => true, :attributes => attrs
+ output = Asciidoctor.convert input, header_footer: true, attributes: attrs
assert_css 'html:root > head > link[rel="stylesheet"][href^="https://fonts.googleapis.com"]', output, 1
assert_css 'html:root > head > link[rel="stylesheet"][href="./asciidoctor.css"]', output, 0
stylenode = xmlnodes_at_css 'html:root > head > style', output, 1
@@ -898,8 +896,8 @@ text
test 'should embed default stylesheet if safe mode is less than SECURE and linkcss is unset from API' do
sample_input_path = fixture_path('basic.asciidoc')
- output = Asciidoctor.convert_file sample_input_path, :header_footer => true, :to_file => false,
- :safe => Asciidoctor::SafeMode::SAFE, :attributes => {'linkcss!' => ''}
+ output = Asciidoctor.convert_file sample_input_path, header_footer: true, to_file: false,
+ safe: Asciidoctor::SafeMode::SAFE, attributes: { 'linkcss!' => '' }
assert_css 'html:root > head > style', output, 1
stylenode = xmlnodes_at_css 'html:root > head > style', output, 1
styles = stylenode.content
@@ -914,7 +912,7 @@ text
text
EOS
- output = Asciidoctor.convert input, :header_footer => true, :attributes => {'stylesheet!' => ''}
+ output = Asciidoctor.convert input, header_footer: true, attributes: { 'stylesheet!' => '' }
assert_css 'html:root > head > link[rel="stylesheet"][href^="https://fonts.googleapis.com"]', output, 0
assert_css 'html:root > head > link[rel="stylesheet"]', output, 0
end
@@ -926,11 +924,11 @@ text
text
EOS
- output = Asciidoctor.convert input, :header_footer => true, :attributes => {'stylesheet' => './custom.css'}
+ output = Asciidoctor.convert input, header_footer: true, attributes: { 'stylesheet' => './custom.css' }
assert_css 'html:root > head > link[rel="stylesheet"][href^="https://fonts.googleapis.com"]', output, 0
assert_css 'html:root > head > link[rel="stylesheet"][href="./custom.css"]', output, 1
- output = Asciidoctor.convert input, :header_footer => true, :attributes => {'stylesheet' => 'file:///home/username/custom.css'}
+ output = Asciidoctor.convert input, header_footer: true, attributes: { 'stylesheet' => 'file:///home/username/custom.css' }
assert_css 'html:root > head > link[rel="stylesheet"][href="file:///home/username/custom.css"]', output, 1
end
@@ -941,14 +939,14 @@ text
text
EOS
- output = Asciidoctor.convert input, :header_footer => true, :attributes => {'stylesheet' => 'custom.css', 'stylesdir' => './stylesheets'}
+ output = Asciidoctor.convert input, header_footer: true, attributes: { 'stylesheet' => 'custom.css', 'stylesdir' => './stylesheets' }
assert_css 'html:root > head > link[rel="stylesheet"][href="./stylesheets/custom.css"]', output, 1
end
test 'should resolve custom stylesheet to embed relative to stylesdir' do
sample_input_path = fixture_path('basic.asciidoc')
- output = Asciidoctor.convert_file sample_input_path, :header_footer => true, :safe => Asciidoctor::SafeMode::SAFE, :to_file => false,
- :attributes => {'stylesheet' => 'custom.css', 'stylesdir' => './stylesheets', 'linkcss!' => ''}
+ output = Asciidoctor.convert_file sample_input_path, header_footer: true, safe: Asciidoctor::SafeMode::SAFE, to_file: false,
+ attributes: { 'stylesheet' => 'custom.css', 'stylesdir' => './stylesheets', 'linkcss!' => '' }
stylenode = xmlnodes_at_css 'html:root > head > style', output, 1
styles = stylenode.content
refute_nil styles
@@ -977,7 +975,7 @@ text
sample_input_path = fixture_path('sample.asciidoc')
sample_output_path = fixture_path('result.html')
begin
- Asciidoctor.convert_file sample_input_path, :to_file => sample_output_path
+ Asciidoctor.convert_file sample_input_path, to_file: sample_output_path
assert File.exist?(sample_output_path)
output = IO.read(sample_output_path)
refute_empty output
@@ -996,7 +994,7 @@ text
sample_output_path = fixture_path('result.html')
fixture_dir = fixture_path('')
begin
- Asciidoctor.convert_file sample_input_path, :to_file => 'result.html', :base_dir => fixture_dir
+ Asciidoctor.convert_file sample_input_path, to_file: 'result.html', base_dir: fixture_dir
assert File.exist?(sample_output_path)
output = IO.read(sample_output_path)
refute_empty output
@@ -1008,7 +1006,7 @@ text
rescue => e
flunk e.message
ensure
- FileUtils.rm(sample_output_path, :force => true)
+ FileUtils.rm(sample_output_path, force: true)
end
end
@@ -1016,7 +1014,7 @@ text
sample_input_path = fixture_path('sample.asciidoc')
sample_output_path = fixture_path('result.html')
begin
- Asciidoctor.convert_file sample_input_path, :to_file => sample_output_path, :in_place => true
+ Asciidoctor.convert_file sample_input_path, to_file: sample_output_path, in_place: true
assert File.exist?(sample_output_path)
ensure
FileUtils.rm(sample_output_path) if File.exist? sample_output_path
@@ -1027,7 +1025,7 @@ text
sample_input_path = fixture_path('sample.asciidoc')
sample_output_path = fixture_path('sample.html')
begin
- Asciidoctor.convert_file sample_input_path, :to_dir => File.dirname(sample_output_path), :in_place => true
+ Asciidoctor.convert_file sample_input_path, to_dir: File.dirname(sample_output_path), in_place: true
assert File.exist?(sample_output_path)
ensure
FileUtils.rm(sample_output_path) if File.exist? sample_output_path
@@ -1038,7 +1036,7 @@ text
sample_input = '{outfilesuffix}'
sample_output_path = fixture_path('result.htm')
begin
- Asciidoctor.convert sample_input, :to_file => sample_output_path, :header_footer => false
+ Asciidoctor.convert sample_input, to_file: sample_output_path, header_footer: false
assert File.exist?(sample_output_path)
output = IO.read(sample_output_path)
refute_empty output
@@ -1054,7 +1052,7 @@ text
Dir.mkdir output_dir if !File.exist? output_dir
sample_output_path = File.join(output_dir, 'sample.html')
begin
- Asciidoctor.convert_file sample_input_path, :to_dir => output_dir
+ Asciidoctor.convert_file sample_input_path, to_dir: output_dir
assert File.exist? sample_output_path
ensure
FileUtils.rm(sample_output_path) if File.exist? sample_output_path
@@ -1067,7 +1065,7 @@ text
output_dir = File.join(File.join(File.dirname(sample_input_path), 'test_output'), 'subdir')
sample_output_path = File.join(output_dir, 'sample.html')
begin
- Asciidoctor.convert_file sample_input_path, :to_dir => output_dir, :mkdirs => true
+ Asciidoctor.convert_file sample_input_path, to_dir: output_dir, mkdirs: true
assert File.exist? sample_output_path
ensure
FileUtils.rm(sample_output_path) if File.exist? sample_output_path
@@ -1081,7 +1079,7 @@ text
sample_input_path = fixture_path('sample.asciidoc')
assert_raises IOError do
- Asciidoctor.convert_file sample_input_path, :attributes => { 'outfilesuffix' => '.asciidoc' }
+ Asciidoctor.convert_file sample_input_path, attributes: { 'outfilesuffix' => '.asciidoc' }
end
end
@@ -1093,7 +1091,7 @@ text
Dir.mkdir output_dir if !File.exist? output_dir
sample_output_path = File.join(base_dir, sample_rel_output_path)
begin
- Asciidoctor.convert_file sample_input_path, :to_dir => base_dir, :to_file => sample_rel_output_path
+ Asciidoctor.convert_file sample_input_path, to_dir: base_dir, to_file: sample_rel_output_path
assert File.exist? sample_output_path
ensure
FileUtils.rm(sample_output_path) if File.exist? sample_output_path
@@ -1103,8 +1101,8 @@ text
test 'should not modify options argument' do
options = {
- :safe => Asciidoctor::SafeMode::SAFE,
- :to_file => false
+ safe: Asciidoctor::SafeMode::SAFE,
+ to_file: false,
}
options.freeze
sample_input_path = fixture_path('sample.asciidoc')
@@ -1119,7 +1117,7 @@ text
sample_input_path = fixture_path 'basic.asciidoc'
sample_output_path = fixture_path 'basic.html'
begin
- doc = Asciidoctor.convert_file sample_input_path, :to_file => sample_output_path
+ doc = Asciidoctor.convert_file sample_input_path, to_file: sample_output_path
assert_equal File.dirname(sample_output_path), doc.options[:to_dir]
ensure
FileUtils.rm(sample_output_path)
@@ -1133,7 +1131,7 @@ text
fixture_parent_path = File.dirname fixture_base_path
sample_output_relpath = File.join 'fixtures', 'basic.html'
begin
- doc = Asciidoctor.convert_file sample_input_path, :to_dir => fixture_parent_path, :to_file => sample_output_relpath
+ doc = Asciidoctor.convert_file sample_input_path, to_dir: fixture_parent_path, to_file: sample_output_relpath
assert_equal fixture_base_path, doc.options[:to_dir]
ensure
FileUtils.rm(sample_output_path)
@@ -1142,7 +1140,7 @@ text
test 'timings are recorded for each step' do
sample_input_path = fixture_path 'asciidoc_index.txt'
- Asciidoctor.convert_file sample_input_path, :timings => (timings = Asciidoctor::Timings.new), :to_file => false
+ Asciidoctor.convert_file sample_input_path, timings: (timings = Asciidoctor::Timings.new), to_file: false
refute_equal '0.00000', '%05.5f' % timings.read_parse.to_f
refute_equal '0.00000', '%05.5f' % timings.convert.to_f
refute_equal timings.read_parse, timings.total
diff --git a/test/attribute_list_test.rb b/test/attribute_list_test.rb
index 9335df6b..f4873093 100644
--- a/test/attribute_list_test.rb
+++ b/test/attribute_list_test.rb
@@ -4,7 +4,7 @@ context 'AttributeList' do
test 'collect unnamed attribute' do
attributes = {}
line = 'quote'
- expected = {1 => 'quote'}
+ expected = { 1 => 'quote' }
Asciidoctor::AttributeList.new(line).parse_into(attributes)
assert_equal expected, attributes
end
@@ -12,7 +12,7 @@ context 'AttributeList' do
test 'collect unnamed attribute double-quoted' do
attributes = {}
line = '"quote"'
- expected = {1 => 'quote'}
+ expected = { 1 => 'quote' }
Asciidoctor::AttributeList.new(line).parse_into(attributes)
assert_equal expected, attributes
end
@@ -20,7 +20,7 @@ context 'AttributeList' do
test 'collect empty unnamed attribute double-quoted' do
attributes = {}
line = '""'
- expected = {1 => ''}
+ expected = { 1 => '' }
Asciidoctor::AttributeList.new(line).parse_into(attributes)
assert_equal expected, attributes
end
@@ -28,7 +28,7 @@ context 'AttributeList' do
test 'collect unnamed attribute double-quoted containing escaped quote' do
attributes = {}
line = '"ba\"zaar"'
- expected = {1 => 'ba"zaar'}
+ expected = { 1 => 'ba"zaar' }
Asciidoctor::AttributeList.new(line).parse_into(attributes)
assert_equal expected, attributes
end
@@ -36,7 +36,7 @@ context 'AttributeList' do
test 'collect unnamed attribute single-quoted' do
attributes = {}
line = '\'quote\''
- expected = {1 => 'quote'}
+ expected = { 1 => 'quote' }
Asciidoctor::AttributeList.new(line).parse_into(attributes)
assert_equal expected, attributes
end
@@ -44,7 +44,7 @@ context 'AttributeList' do
test 'collect empty unnamed attribute single-quoted' do
attributes = {}
line = '\'\''
- expected = {1 => ''}
+ expected = { 1 => '' }
Asciidoctor::AttributeList.new(line).parse_into(attributes)
assert_equal expected, attributes
end
@@ -77,7 +77,7 @@ context 'AttributeList' do
attributes = {}
line = 'name=\'{val}'
expected = { 'name' => '\'{val}' }
- doc = empty_document :attributes => { 'val' => 'val' }
+ doc = empty_document attributes: { 'val' => 'val' }
def doc.apply_subs *args
fail 'apply_subs should not be called'
end
@@ -88,7 +88,7 @@ context 'AttributeList' do
test 'collect unnamed attribute single-quoted containing escaped quote' do
attributes = {}
line = '\'ba\\\'zaar\''
- expected = {1 => 'ba\'zaar'}
+ expected = { 1 => 'ba\'zaar' }
Asciidoctor::AttributeList.new(line).parse_into(attributes)
assert_equal expected, attributes
end
@@ -96,7 +96,7 @@ context 'AttributeList' do
test 'collect unnamed attribute with dangling delimiter' do
attributes = {}
line = 'quote , '
- expected = {1 => 'quote'}
+ expected = { 1 => 'quote' }
Asciidoctor::AttributeList.new(line).parse_into(attributes)
assert_equal expected, attributes
end
@@ -104,7 +104,7 @@ context 'AttributeList' do
test 'collect unnamed attribute in second position after empty attribute' do
attributes = {}
line = ', John Smith'
- expected = {1 => nil, 2 => 'John Smith'}
+ expected = { 1 => nil, 2 => 'John Smith' }
Asciidoctor::AttributeList.new(line).parse_into(attributes)
assert_equal expected, attributes
end
@@ -112,7 +112,7 @@ context 'AttributeList' do
test 'collect unnamed attributes' do
attributes = {}
line = 'first, second one, third'
- expected = {1 => 'first', 2 => 'second one', 3 => 'third'}
+ expected = { 1 => 'first', 2 => 'second one', 3 => 'third' }
Asciidoctor::AttributeList.new(line).parse_into(attributes)
assert_equal expected, attributes
end
@@ -120,7 +120,7 @@ context 'AttributeList' do
test 'collect named attribute' do
attributes = {}
line = 'foo=bar'
- expected = {'foo' => 'bar'}
+ expected = { 'foo' => 'bar' }
Asciidoctor::AttributeList.new(line).parse_into(attributes)
assert_equal expected, attributes
end
@@ -128,7 +128,7 @@ context 'AttributeList' do
test 'collect named attribute double-quoted' do
attributes = {}
line = 'foo="bar"'
- expected = {'foo' => 'bar'}
+ expected = { 'foo' => 'bar' }
Asciidoctor::AttributeList.new(line).parse_into(attributes)
assert_equal expected, attributes
end
@@ -136,7 +136,7 @@ context 'AttributeList' do
test 'collect named attribute with double-quoted empty value' do
attributes = {}
line = 'height=100,caption="",link="images/octocat.png"'
- expected = {'height' => '100', 'caption' => '', 'link' => 'images/octocat.png'}
+ expected = { 'height' => '100', 'caption' => '', 'link' => 'images/octocat.png' }
Asciidoctor::AttributeList.new(line).parse_into(attributes)
assert_equal expected, attributes
end
@@ -144,7 +144,7 @@ context 'AttributeList' do
test 'collect named attribute single-quoted' do
attributes = {}
line = 'foo=\'bar\''
- expected = {'foo' => 'bar'}
+ expected = { 'foo' => 'bar' }
Asciidoctor::AttributeList.new(line).parse_into(attributes)
assert_equal expected, attributes
end
@@ -152,7 +152,7 @@ context 'AttributeList' do
test 'collect named attribute with single-quoted empty value' do
attributes = {}
line = %(height=100,caption='',link='images/octocat.png')
- expected = {'height' => '100', 'caption' => '', 'link' => 'images/octocat.png'}
+ expected = { 'height' => '100', 'caption' => '', 'link' => 'images/octocat.png' }
Asciidoctor::AttributeList.new(line).parse_into(attributes)
assert_equal expected, attributes
end
@@ -160,7 +160,7 @@ context 'AttributeList' do
test 'collect single named attribute with empty value' do
attributes = {}
line = 'foo='
- expected = {'foo' => ''}
+ expected = { 'foo' => '' }
Asciidoctor::AttributeList.new(line).parse_into(attributes)
assert_equal expected, attributes
end
@@ -168,7 +168,7 @@ context 'AttributeList' do
test 'collect single named attribute with empty value when followed by other attributes' do
attributes = {}
line = 'foo=,bar=baz'
- expected = {'foo' => '', 'bar' => 'baz'}
+ expected = { 'foo' => '', 'bar' => 'baz' }
Asciidoctor::AttributeList.new(line).parse_into(attributes)
assert_equal expected, attributes
end
@@ -176,7 +176,7 @@ context 'AttributeList' do
test 'collect named attributes unquoted' do
attributes = {}
line = 'first=value, second=two, third=3'
- expected = {'first' => 'value', 'second' => 'two', 'third' => '3'}
+ expected = { 'first' => 'value', 'second' => 'two', 'third' => '3' }
Asciidoctor::AttributeList.new(line).parse_into(attributes)
assert_equal expected, attributes
end
@@ -184,7 +184,7 @@ context 'AttributeList' do
test 'collect named attributes quoted' do
attributes = {}
line = %(first='value', second="value two", third=three)
- expected = {'first' => 'value', 'second' => 'value two', 'third' => 'three'}
+ expected = { 'first' => 'value', 'second' => 'value two', 'third' => 'three' }
Asciidoctor::AttributeList.new(line).parse_into(attributes)
assert_equal expected, attributes
end
@@ -192,7 +192,7 @@ context 'AttributeList' do
test 'collect named attributes quoted containing non-semantic spaces' do
attributes = {}
line = %( first = 'value', second ="value two" , third= three )
- expected = {'first' => 'value', 'second' => 'value two', 'third' => 'three'}
+ expected = { 'first' => 'value', 'second' => 'value two', 'third' => 'three' }
Asciidoctor::AttributeList.new(line).parse_into(attributes)
assert_equal expected, attributes
end
@@ -200,7 +200,7 @@ context 'AttributeList' do
test 'collect mixed named and unnamed attributes' do
attributes = {}
line = %(first, second="value two", third=three, Sherlock Holmes)
- expected = {1 => 'first', 'second' => 'value two', 'third' => 'three', 4 => 'Sherlock Holmes'}
+ expected = { 1 => 'first', 'second' => 'value two', 'third' => 'three', 4 => 'Sherlock Holmes' }
Asciidoctor::AttributeList.new(line).parse_into(attributes)
assert_equal expected, attributes
end
@@ -208,7 +208,7 @@ context 'AttributeList' do
test 'collect options attribute' do
attributes = {}
line = %(quote, options='opt1,opt2 , opt3')
- expected = {1 => 'quote', 'options' => 'opt1,opt2,opt3', 'opt1-option' => '', 'opt2-option' => '', 'opt3-option' => ''}
+ expected = { 1 => 'quote', 'options' => 'opt1,opt2,opt3', 'opt1-option' => '', 'opt2-option' => '', 'opt3-option' => '' }
Asciidoctor::AttributeList.new(line).parse_into(attributes)
assert_equal expected, attributes
end
@@ -216,7 +216,7 @@ context 'AttributeList' do
test 'collect opts attribute as options' do
attributes = {}
line = %(quote, opts='opt1,opt2 , opt3')
- expected = {1 => 'quote', 'options' => 'opt1,opt2,opt3', 'opt1-option' => '', 'opt2-option' => '', 'opt3-option' => ''}
+ expected = { 1 => 'quote', 'options' => 'opt1,opt2,opt3', 'opt1-option' => '', 'opt2-option' => '', 'opt3-option' => '' }
Asciidoctor::AttributeList.new(line).parse_into(attributes)
assert_equal expected, attributes
end
@@ -224,14 +224,14 @@ context 'AttributeList' do
test 'collect and rekey unnamed attributes' do
attributes = {}
line = 'first, second one, third, fourth'
- expected = {1 => 'first', 2 => 'second one', 3 => 'third', 4 => 'fourth', 'a' => 'first', 'b' => 'second one', 'c' => 'third'}
+ expected = { 1 => 'first', 2 => 'second one', 3 => 'third', 4 => 'fourth', 'a' => 'first', 'b' => 'second one', 'c' => 'third' }
Asciidoctor::AttributeList.new(line).parse_into(attributes, ['a', 'b', 'c'])
assert_equal expected, attributes
end
test 'rekey positional attributes' do
- attributes = {1 => 'source', 2 => 'java'}
- expected = {1 => 'source', 2 => 'java', 'style' => 'source', 'language' => 'java'}
+ attributes = { 1 => 'source', 2 => 'java' }
+ expected = { 1 => 'source', 2 => 'java', 'style' => 'source', 'language' => 'java' }
Asciidoctor::AttributeList.rekey(attributes, ['style', 'language', 'linenums'])
assert_equal expected, attributes
end
diff --git a/test/attributes_test.rb b/test/attributes_test.rb
index 4fc6b673..2bcdc102 100644
--- a/test/attributes_test.rb
+++ b/test/attributes_test.rb
@@ -93,7 +93,7 @@ linus.torvalds@example.com
{title} + \\
{email}]
EOS
- doc = document_from_string str, :attributes => { 'author' => 'Linus Torvalds', 'title' => 'Linux Hacker', 'email' => 'linus.torvalds@example.com' }
+ doc = document_from_string str, attributes: { 'author' => 'Linus Torvalds', 'title' => 'Linux Hacker', 'email' => 'linus.torvalds@example.com' }
assert_equal %(Linus Torvalds +\nLinux Hacker +\nlinus.torvalds@example.com), (doc.attr 'signature')
end
@@ -103,7 +103,7 @@ linus.torvalds@example.com
end
test 'should delete an attribute that ends with ! set via API' do
- doc = document_from_string(":frog: Tanglefoot", :attributes => {'frog!' => ''})
+ doc = document_from_string(":frog: Tanglefoot", attributes: { 'frog!' => '' })
assert_nil doc.attributes['frog']
end
@@ -113,12 +113,12 @@ linus.torvalds@example.com
end
test 'should delete an attribute that begins with ! set via API' do
- doc = document_from_string(":frog: Tanglefoot", :attributes => {'!frog' => ''})
+ doc = document_from_string(":frog: Tanglefoot", attributes: { '!frog' => '' })
assert_nil doc.attributes['frog']
end
test 'should delete an attribute set via API to nil value' do
- doc = document_from_string(":frog: Tanglefoot", :attributes => {'frog' => nil})
+ doc = document_from_string(":frog: Tanglefoot", attributes: { 'frog' => nil })
assert_nil doc.attributes['frog']
end
@@ -139,7 +139,7 @@ linus.torvalds@example.com
test 'assigns attribute to empty string if substitution fails to resolve attribute' do
input = ':release: Asciidoctor {version}'
- document_from_string input, :attributes => { 'attribute-missing' => 'drop-line' }
+ document_from_string input, attributes: { 'attribute-missing' => 'drop-line' }
assert_message @logger, :WARN, 'dropping line containing reference to missing attribute: version'
end
@@ -148,7 +148,7 @@ linus.torvalds@example.com
:release: Asciidoctor +
{version}
EOS
- doc = document_from_string input, :attributes => { 'attribute-missing' => 'drop-line' }
+ doc = document_from_string input, attributes: { 'attribute-missing' => 'drop-line' }
assert_equal '', doc.attributes['release']
assert_message @logger, :WARN, 'dropping line containing reference to missing attribute: version'
end
@@ -202,7 +202,7 @@ content
{name}
EOS
- result = convert_inline_string input, :attributes => { 'max-attribute-value-size' => 6 }
+ result = convert_inline_string input, attributes: { 'max-attribute-value-size' => 6 }
assert_equal expected, result
assert_equal 6, result.bytesize
end
@@ -215,7 +215,7 @@ content
{name}
EOS
- result = convert_inline_string input, :attributes => { 'max-attribute-value-size' => 8 }
+ result = convert_inline_string input, attributes: { 'max-attribute-value-size' => 8 }
assert_equal expected, result
assert_equal 6, result.bytesize
end
@@ -228,7 +228,7 @@ content
{name}
EOS
- result = convert_inline_string input, :attributes => { 'max-attribute-value-size' => nil }
+ result = convert_inline_string input, attributes: { 'max-attribute-value-size' => nil }
assert_equal expected, result
assert_equal 5000, result.bytesize
end
@@ -239,7 +239,7 @@ content
{imagesdir}
EOS
- output = convert_inline_string input, :safe => :safe
+ output = convert_inline_string input, safe: :safe
assert_equal %(#{Asciidoctor::USER_HOME}/etc/images), output
end
@@ -249,7 +249,7 @@ EOS
{imagesdir}
EOS
- output = convert_inline_string input, :safe => :server
+ output = convert_inline_string input, safe: :server
assert_equal './etc/images', output
end
@@ -288,34 +288,34 @@ endif::holygrail[]
end
test 'attribute set via API overrides attribute set in document' do
- doc = document_from_string(':cash: money', :attributes => {'cash' => 'heroes'})
+ doc = document_from_string(':cash: money', attributes: { 'cash' => 'heroes' })
assert_equal 'heroes', doc.attributes['cash']
end
test 'attribute set via API cannot be unset by document' do
- doc = document_from_string(':cash!:', :attributes => {'cash' => 'heroes'})
+ doc = document_from_string(':cash!:', attributes: { 'cash' => 'heroes' })
assert_equal 'heroes', doc.attributes['cash']
end
test 'attribute soft set via API using modifier on name can be overridden by document' do
- doc = document_from_string(':cash: money', :attributes => {'cash@' => 'heroes'})
+ doc = document_from_string(':cash: money', attributes: { 'cash@' => 'heroes' })
assert_equal 'money', doc.attributes['cash']
end
test 'attribute soft set via API using modifier on value can be overridden by document' do
- doc = document_from_string(':cash: money', :attributes => {'cash' => 'heroes@'})
+ doc = document_from_string(':cash: money', attributes: { 'cash' => 'heroes@' })
assert_equal 'money', doc.attributes['cash']
end
test 'attribute soft set via API using modifier on name can be unset by document' do
- doc = document_from_string(':cash!:', :attributes => {'cash@' => 'heroes'})
+ doc = document_from_string(':cash!:', attributes: { 'cash@' => 'heroes' })
assert_nil doc.attributes['cash']
- doc = document_from_string(':cash!:', :attributes => {'cash@' => true})
+ doc = document_from_string(':cash!:', attributes: { 'cash@' => true })
assert_nil doc.attributes['cash']
end
test 'attribute soft set via API using modifier on value can be unset by document' do
- doc = document_from_string(':cash!:', :attributes => {'cash' => 'heroes@'})
+ doc = document_from_string(':cash!:', attributes: { 'cash' => 'heroes@' })
assert_nil doc.attributes['cash']
end
@@ -325,7 +325,7 @@ endif::holygrail[]
{ '!cash' => '' },
{ 'cash' => nil },
].each do |attributes|
- doc = document_from_string(':cash: money', :attributes => attributes)
+ doc = document_from_string(':cash: money', attributes: attributes)
assert_nil doc.attributes['cash']
end
end
@@ -338,7 +338,7 @@ endif::holygrail[]
{ '!cash' => '@' },
{ 'cash' => false },
].each do |attributes|
- doc = document_from_string(':cash: money', :attributes => attributes)
+ doc = document_from_string(':cash: money', attributes: attributes)
assert_equal 'money', doc.attributes['cash']
end
end
@@ -351,12 +351,12 @@ endif::holygrail[]
{ '!sectids' => '@' },
{ 'sectids' => false },
].each do |attributes|
- doc = document_from_string '== Heading', :attributes => attributes
+ doc = document_from_string '== Heading', attributes: attributes
refute doc.attr?('sectids')
- assert_css '#_heading', (doc.convert :header_footer => false), 0
- doc = document_from_string %(:sectids:\n\n== Heading), :attributes => attributes
+ assert_css '#_heading', (doc.convert header_footer: false), 0
+ doc = document_from_string %(:sectids:\n\n== Heading), attributes: attributes
assert doc.attr?('sectids')
- assert_css '#_heading', (doc.convert :header_footer => false), 1
+ assert_css '#_heading', (doc.convert header_footer: false), 1
end
end
@@ -380,7 +380,7 @@ content
'doctype' => 'article',
'doctype-article' => '',
'filetype' => 'html',
- 'filetype-html' => ''
+ 'filetype-html' => '',
}
expect.each do |key, val|
assert doc.attributes.key? key
@@ -396,7 +396,7 @@ Author Name
content
EOS
- doc = document_from_string input, :doctype => 'book', :backend => 'docbook'
+ doc = document_from_string input, doctype: 'book', backend: 'docbook'
expect = {
'backend' => 'docbook5',
'backend-docbook5' => '',
@@ -408,7 +408,7 @@ content
'doctype' => 'book',
'doctype-book' => '',
'filetype' => 'xml',
- 'filetype-xml' => ''
+ 'filetype-xml' => '',
}
expect.each do |key, val|
assert doc.attributes.key? key
@@ -426,7 +426,7 @@ Author Name
content
EOS
- doc = document_from_string input, :safe => Asciidoctor::SafeMode::SAFE
+ doc = document_from_string input, safe: Asciidoctor::SafeMode::SAFE
expect = {
'backend' => 'docbook5',
'backend-docbook5' => '',
@@ -438,7 +438,7 @@ content
'doctype' => 'book',
'doctype-book' => '',
'filetype' => 'xml',
- 'filetype-xml' => ''
+ 'filetype-xml' => '',
}
expect.each do |key, val|
assert doc.attributes.key?(key)
@@ -454,7 +454,7 @@ content
end
test 'backend attributes defined in document options overrides backend attribute in document' do
- doc = document_from_string(':backend: docbook45', :safe => Asciidoctor::SafeMode::SAFE, :attributes => {'backend' => 'html5'})
+ doc = document_from_string(':backend: docbook45', safe: Asciidoctor::SafeMode::SAFE, attributes: { 'backend' => 'html5' })
assert_equal 'html5', doc.attributes['backend']
assert doc.attributes.has_key? 'backend-html5'
assert_equal 'html', doc.attributes['basebackend']
@@ -462,34 +462,34 @@ content
end
test 'can only access a positional attribute from the attributes hash' do
- node = Asciidoctor::Block.new nil, :paragraph, :attributes => { 1 => 'position 1' }
+ node = Asciidoctor::Block.new nil, :paragraph, attributes: { 1 => 'position 1' }
assert_nil node.attr(1)
refute node.attr?(1)
assert_equal 'position 1', node.attributes[1]
end
test 'set_attr should set value to empty string if no value is specified' do
- node = Asciidoctor::Block.new nil, :paragraph, :attributes => {}
+ node = Asciidoctor::Block.new nil, :paragraph, attributes: {}
node.set_attr 'foo'
assert_equal '', (node.attr 'foo')
end
test 'remove_attr should remove attribute and return previous value' do
doc = empty_document
- node = Asciidoctor::Block.new doc, :paragraph, :attributes => { 'foo' => 'bar' }
+ node = Asciidoctor::Block.new doc, :paragraph, attributes: { 'foo' => 'bar' }
assert_equal 'bar', (node.remove_attr 'foo')
assert_nil node.attr('foo')
end
test 'set_attr should not overwrite existing key if overwrite is false' do
- node = Asciidoctor::Block.new nil, :paragraph, :attributes => { 'foo' => 'bar' }
+ node = Asciidoctor::Block.new nil, :paragraph, attributes: { 'foo' => 'bar' }
assert_equal 'bar', (node.attr 'foo')
node.set_attr 'foo', 'baz', false
assert_equal 'bar', (node.attr 'foo')
end
test 'set_attr should overwrite existing key by default' do
- node = Asciidoctor::Block.new nil, :paragraph, :attributes => { 'foo' => 'bar' }
+ node = Asciidoctor::Block.new nil, :paragraph, attributes: { 'foo' => 'bar' }
assert_equal 'bar', (node.attr 'foo')
node.set_attr 'foo', 'baz'
assert_equal 'baz', (node.attr 'foo')
@@ -502,7 +502,7 @@ content
{uri}
EOS
- doc = Asciidoctor.load input, :attributes => { 'uri' => 'https://github.com' }
+ doc = Asciidoctor.load input, attributes: { 'uri' => 'https://github.com' }
doc.set_attr 'uri', 'https://google.com'
output = doc.convert
assert_xpath '//a[@href="https://google.com"]', output, 1
@@ -517,7 +517,7 @@ content
end
test 'set_attribute should not set key if key is locked' do
- doc = empty_document :attributes => { 'foo' => 'bar' }
+ doc = empty_document attributes: { 'foo' => 'bar' }
assert_equal 'bar', (doc.attr 'foo')
res = doc.set_attribute 'foo', 'baz'
refute res
@@ -525,7 +525,7 @@ content
end
test 'set_attribute should update backend attributes' do
- doc = empty_document :attributes => { 'backend' => 'html5@' }
+ doc = empty_document attributes: { 'backend' => 'html5@' }
assert_equal '', (doc.attr 'backend-html5')
res = doc.set_attribute 'backend', 'docbook5'
assert res
@@ -556,7 +556,7 @@ toc toc-placement! | |content |macro |nil
expected.each do |expect|
raw_attrs, toc, toc_position, toc_placement, toc_class = expect
attrs = Hash[*raw_attrs.split.map {|e| e.include?('=') ? e.split('=', 2) : [e, ''] }.flatten]
- doc = document_from_string '', :attributes => attrs
+ doc = document_from_string '', attributes: attrs
toc ? (assert doc.attr?('toc', toc)) : (refute doc.attr?('toc'))
toc_position ? (assert doc.attr?('toc-position', toc_position)) : (refute doc.attr?('toc-position'))
toc_placement ? (assert doc.attr?('toc-placement', toc_placement)) : (refute doc.attr?('toc-placement'))
@@ -581,7 +581,7 @@ He-Man: {He-Man}
She-Ra: {She-Ra}
EOS
- result = convert_string_to_embedded input, :attributes => {'She-Ra' => 'The Princess of Power'}
+ result = convert_string_to_embedded input, attributes: { 'She-Ra' => 'The Princess of Power' }
assert_xpath '//p[text()="He-Man: The most powerful man in the universe"]', result, 1
assert_xpath '//p[text()="She-Ra: The Princess of Power"]', result, 1
end
@@ -697,7 +697,7 @@ Line 1
Line 2
EOS
- output = convert_string_to_embedded input, :attributes => { 'attribute-missing' => 'drop' }
+ output = convert_string_to_embedded input, attributes: { 'attribute-missing' => 'drop' }
assert_xpath %(//p[text()="Line 1\nLine 2"]), output, 1
end
@@ -723,7 +723,7 @@ Author Name
preamble
EOS
- doc = document_from_string(input, :parse_header_only => true)
+ doc = document_from_string(input, parse_header_only: true)
assert_equal 'value', doc.attributes['attribute-b']
end
@@ -735,7 +735,7 @@ Author Name
preamble
EOS
- doc = document_from_string(input, :parse_header_only => true)
+ doc = document_from_string(input, parse_header_only: true)
assert_equal 'Author Name', doc.attributes['name']
end
@@ -748,7 +748,7 @@ Author Name
preamble
EOS
- doc = document_from_string(input, :parse_header_only => true)
+ doc = document_from_string(input, parse_header_only: true)
assert_equal '2013-01-01', doc.attributes['date']
end
@@ -798,7 +798,7 @@ content
.Require the +{gem_name}+ gem
To use {gem_name}, the first thing to do is to import it in your Ruby source file.
EOS
- output = convert_string_to_embedded input, :attributes => {'compat-mode' => ''}
+ output = convert_string_to_embedded input, attributes: { 'compat-mode' => '' }
assert_xpath '//*[@class="title"]/code[text()="asciidoctor"]', output, 1
input = <<-EOS
@@ -844,7 +844,7 @@ Belly up to the {foo}.
`{foo}`
EOS
- result = convert_string_to_embedded input, :attributes => {'compat-mode' => '@'}
+ result = convert_string_to_embedded input, attributes: { 'compat-mode' => '@' }
assert_xpath '/*[@id="paragraph-a"]//code[text()="{foo}"]', result, 1
assert_xpath '/*[@id="paragraph-b"]//code[text()="bar"]', result, 1
assert_xpath '/*[@id="paragraph-c"]//code[text()="{foo}"]', result, 1
@@ -895,7 +895,7 @@ of the attribute named foo in your document.
docdir = Dir.pwd
docfile = File.join(docdir, 'sample.asciidoc')
- output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SERVER, :attributes => {'docdir' => docdir, 'docfile' => docfile}
+ output = convert_string_to_embedded input, safe: Asciidoctor::SafeMode::SERVER, attributes: { 'docdir' => docdir, 'docfile' => docfile }
assert_xpath '//li[1]/p[text()="docdir: "]', output, 1
assert_xpath '//li[2]/p[text()="docfile: sample.asciidoc"]', output, 1
end
@@ -908,7 +908,7 @@ of the attribute named foo in your document.
docdir = Dir.pwd
docfile = File.join(docdir, 'sample.asciidoc')
- output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SAFE, :attributes => {'docdir' => docdir, 'docfile' => docfile}
+ output = convert_string_to_embedded input, safe: Asciidoctor::SafeMode::SAFE, attributes: { 'docdir' => docdir, 'docfile' => docfile }
assert_xpath %(//li[1]/p[text()="docdir: #{docdir}"]), output, 1
assert_xpath %(//li[2]/p[text()="docfile: #{docfile}"]), output, 1
end
@@ -1050,7 +1050,7 @@ of the attribute named foo in your document.
EOS
doc = document_from_string input
- output = doc.convert :header_footer => false
+ output = doc.convert header_footer: false
assert_equal 1, doc.attributes['mycounter']
assert_xpath '//p[text()="1"]', output, 2
end
@@ -1067,7 +1067,7 @@ after: {counter:mycounter}
EOS
doc = document_from_string input
- output = doc.convert :header_footer => false
+ output = doc.convert header_footer: false
assert_equal 1, doc.attributes['mycounter']
assert_xpath '//p[text()="before: 1 2 3"]', output, 1
assert_xpath '//p[text()="after: 1"]', output, 1
@@ -1535,7 +1535,7 @@ Content.
content
EOS
- doc = document_from_string input, :backend => 'docbook45'
+ doc = document_from_string input, backend: 'docbook45'
section = doc.blocks[0]
refute_nil section
assert_equal :section, section.context
diff --git a/test/blocks_test.rb b/test/blocks_test.rb
index 26abd1c0..b7179c21 100644
--- a/test/blocks_test.rb
+++ b/test/blocks_test.rb
@@ -396,7 +396,7 @@ ____
A famous quote.
____
EOS
- output = convert_string input, :backend => :docbook
+ output = convert_string input, backend: :docbook
assert_css 'blockquote', output, 1
assert_css 'blockquote > simpara', output, 1
assert_css 'blockquote > attribution', output, 1
@@ -406,7 +406,7 @@ ____
author = attribution.children.first
assert_equal 'Famous Person', author.text.strip
end
-
+
test 'epigraph quote block with attribution converted to DocBook' do
input = <<-EOS
[.epigraph, Famous Person, Famous Book (1999)]
@@ -414,7 +414,7 @@ ____
A famous quote.
____
EOS
- output = convert_string input, :backend => :docbook
+ output = convert_string input, backend: :docbook
assert_css 'epigraph', output, 1
assert_css 'epigraph > simpara', output, 1
assert_css 'epigraph > attribution', output, 1
@@ -613,7 +613,7 @@ ____
A famous verse.
____
EOS
- output = convert_string input, :backend => :docbook
+ output = convert_string input, backend: :docbook
assert_css 'blockquote', output, 1
assert_css 'blockquote simpara', output, 0
assert_css 'blockquote > literallayout', output, 1
@@ -624,7 +624,7 @@ ____
author = attribution.children.first
assert_equal 'Famous Poet', author.text.strip
end
-
+
test 'single-line epigraph verse block with attribution converted to DocBook' do
input = <<-EOS
[verse.epigraph, Famous Poet, Famous Poem]
@@ -632,7 +632,7 @@ ____
A famous verse.
____
EOS
- output = convert_string input, :backend => :docbook
+ output = convert_string input, backend: :docbook
assert_css 'epigraph', output, 1
assert_css 'epigraph simpara', output, 0
assert_css 'epigraph > literallayout', output, 1
@@ -919,7 +919,7 @@ line three
....
EOS
[true, false].each {|header_footer|
- output = convert_string input, :header_footer => header_footer
+ output = convert_string input, header_footer: header_footer
assert_xpath '//pre', output, 1
assert_xpath '//pre/text()', output, 1
text = xmlnodes_at_xpath('//pre/text()', output, 1).text
@@ -944,7 +944,7 @@ line three
----
EOS
[true, false].each {|header_footer|
- output = convert_string input, header_footer => header_footer
+ output = convert_string input, header_footer: header_footer
assert_xpath '//pre/code', output, 1
assert_xpath '//pre/code/text()', output, 1
text = xmlnodes_at_xpath('//pre/code/text()', output, 1).text
@@ -971,7 +971,7 @@ ____
--
EOS
[true, false].each {|header_footer|
- output = convert_string input, :header_footer => header_footer
+ output = convert_string input, header_footer: header_footer
assert_xpath '//*[@class="verseblock"]/pre', output, 1
assert_xpath '//*[@class="verseblock"]/pre/text()', output, 1
text = xmlnodes_at_xpath('//*[@class="verseblock"]/pre/text()', output, 1).text
@@ -999,7 +999,7 @@ last line
....
EOS
- doc = document_from_string input, :header_footer => false
+ doc = document_from_string input, header_footer: false
block = doc.blocks.first
assert_equal ['', '', ' first line', '', 'last line', '', '{empty}', ''], block.lines
result = doc.convert
@@ -1270,7 +1270,7 @@ listing block
----
EOS
- output = convert_string_to_embedded input, :backend => 'docbook'
+ output = convert_string_to_embedded input, backend: 'docbook'
assert_xpath '/screen[text()="listing block"]', output, 1
end
@@ -1282,7 +1282,7 @@ listing block
----
EOS
- output = convert_string_to_embedded input, :backend => 'docbook'
+ output = convert_string_to_embedded input, backend: 'docbook'
assert_xpath '/formalpara', output, 1
assert_xpath '/formalpara/title[text()="title"]', output, 1
assert_xpath '/formalpara/para/screen[text()="listing block"]', output, 1
@@ -1296,7 +1296,7 @@ listing block
----
EOS
- output = convert_string_to_embedded input, :backend => 'docbook'
+ output = convert_string_to_embedded input, backend: 'docbook'
assert_xpath '/screen[text()="listing block"]', output, 1
end
@@ -1309,7 +1309,7 @@ listing block
----
EOS
- output = convert_string_to_embedded input, :backend => 'docbook'
+ output = convert_string_to_embedded input, backend: 'docbook'
assert_xpath '/formalpara', output, 1
assert_xpath '/formalpara/title[text()="title"]', output, 1
assert_xpath '/formalpara/para/screen[text()="listing block"]', output, 1
@@ -1362,7 +1362,7 @@ TIP: An open block can have other blocks inside of it.
Back to our regularly scheduled programming.
EOS
- output = convert_string input, :backend => :docbook, :keep_namespaces => true
+ output = convert_string input, backend: :docbook, keep_namespaces: true
assert_css 'article > simpara', output, 2
assert_css 'article > para', output, 1
assert_css 'article > para > simpara', output, 1
@@ -1383,7 +1383,7 @@ Back to our regularly scheduled programming.
This is an open paragraph.
EOS
- output = convert_string input, :backend => :docbook, :keep_namespaces => true
+ output = convert_string input, backend: :docbook, keep_namespaces: true
assert_css 'article > simpara', output, 1
open = xmlnodes_at_xpath '/xmlns:article/xmlns:simpara', output, 1
open = xmlnodes_at_xpath '/xmlns:article/xmlns:simpara[text()="This is an open paragraph."]', output, 1
@@ -1404,7 +1404,7 @@ This is an open block with a title.
--
EOS
- output = convert_string input, :backend => :docbook
+ output = convert_string input, backend: :docbook
assert_css 'article > formalpara', output, 1
assert_css 'article > formalpara > *', output, 2
assert_css 'article > formalpara > title', output, 1
@@ -1419,7 +1419,7 @@ This is an open block with a title.
This is an open paragraph with a title.
EOS
- output = convert_string input, :backend => :docbook
+ output = convert_string input, backend: :docbook
assert_css 'article > formalpara', output, 1
assert_css 'article > formalpara > *', output, 2
assert_css 'article > formalpara > title', output, 1
@@ -1437,7 +1437,7 @@ It holds stuff.
--
EOS
- output = convert_string input, :backend => :docbook
+ output = convert_string input, backend: :docbook
assert_css 'article > para[role=container]', output, 1
assert_css 'article > para[role=container] > simpara', output, 1
end
@@ -1449,7 +1449,7 @@ This is an open block.
It holds stuff.
EOS
- output = convert_string input, :backend => :docbook
+ output = convert_string input, backend: :docbook
assert_css 'article > simpara[role=container]', output, 1
end
end
@@ -1538,7 +1538,7 @@ line below
++++
EOS
- doc = document_from_string input, :header_footer => false
+ doc = document_from_string input, header_footer: false
block = doc.blocks[1]
assert_equal ['', '', ' first line', '', 'last line', '', ''], block.lines
result = doc.convert
@@ -1590,7 +1590,7 @@ line below
</informalequation>
EOS
- output = convert_string_to_embedded input, :backend => :docbook
+ output = convert_string_to_embedded input, backend: :docbook
assert_equal expect.strip, output.strip
end
@@ -1718,7 +1718,7 @@ x+b/(2a)<+-sqrt((b^2)/(4a^2)-c/a)
</informalequation>)
using_memory_logger do |logger|
- doc = document_from_string input, :backend => :docbook, :header_footer => false
+ doc = document_from_string input, backend: :docbook, header_footer: false
actual = doc.convert
if asciimath_available
assert_equal expect.strip, actual.strip
@@ -1774,11 +1774,11 @@ sqrt(3x-1)+(1+x)^2 < y
[
{},
- {'stem' => ''},
- {'stem' => 'asciimath'},
- {'stem' => 'bogus'}
+ { 'stem' => '' },
+ { 'stem' => 'asciimath' },
+ { 'stem' => 'bogus' },
].each do |attributes|
- output = convert_string_to_embedded input, :attributes => attributes
+ output = convert_string_to_embedded input, attributes: attributes
assert_css '.stemblock', output, 1
nodes = xmlnodes_at_xpath '//*[@class="content"]/child::text()', output
assert_equal '\$sqrt(3x-1)+(1+x)^2 &lt; y\$', nodes.first.to_s.strip
@@ -1794,11 +1794,11 @@ sqrt(3x-1)+(1+x)^2 < y
EOS
[
- {'stem' => 'latexmath'},
- {'stem' => 'latex'},
- {'stem' => 'tex'}
+ { 'stem' => 'latexmath' },
+ { 'stem' => 'latex' },
+ { 'stem' => 'tex' },
].each do |attributes|
- output = convert_string_to_embedded input, :attributes => attributes
+ output = convert_string_to_embedded input, attributes: attributes
assert_css '.stemblock', output, 1
nodes = xmlnodes_at_xpath '//*[@class="content"]/child::text()', output
assert_equal '\[\sqrt{3x-1}+(1+x)^2 &lt; y\]', nodes.first.to_s.strip
@@ -1819,7 +1819,7 @@ sqrt(3x-1)+(1+x)^2 < y
stemblock = doc.blocks[0]
assert_equal :stem, stemblock.context
assert_equal 'asciimath', stemblock.attributes['style']
- output = doc.convert :header_footer => false
+ output = doc.convert header_footer: false
assert_css '.stemblock', output, 1
nodes = xmlnodes_at_xpath '//*[@class="content"]/child::text()', output
assert_equal '\$sqrt(3x-1)+(1+x)^2 &lt; y\$', nodes.first.to_s.strip
@@ -1915,7 +1915,7 @@ image::images/tiger.png[Tiger]
image::tiger.svg[Tiger]
EOS
- output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SERVER
+ output = convert_string_to_embedded input, safe: Asciidoctor::SafeMode::SERVER
assert_xpath '/*[@class="imageblock"]//img[@src="tiger.svg"][@alt="Tiger"]', output, 1
end
@@ -1927,7 +1927,7 @@ image::tiger.svg[Tiger]
image::tiger.svg[Tiger,100]
EOS
- output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SERVER
+ output = convert_string_to_embedded input, safe: Asciidoctor::SafeMode::SERVER
assert_xpath '/*[@class="imageblock"]//object[@type="image/svg+xml"][@data="images/tiger.svg"][@width="100"]/span[@class="alt"][text()="Tiger"]', output, 1
end
@@ -1949,7 +1949,7 @@ image::images/tiger.svg[Tiger,100]
image::tiger.svg[Tiger,100,fallback=tiger.png]
EOS
- output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SERVER
+ output = convert_string_to_embedded input, safe: Asciidoctor::SafeMode::SERVER
assert_xpath '/*[@class="imageblock"]//object[@type="image/svg+xml"][@data="images/tiger.svg"][@width="100"]/img[@src="images/tiger.png"][@width="100"]', output, 1
end
@@ -1961,7 +1961,7 @@ image::tiger.svg[Tiger,100,fallback=tiger.png]
image::http://example.org/tiger.svg?foo=bar[Tiger,100]
EOS
- output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SERVER
+ output = convert_string_to_embedded input, safe: Asciidoctor::SafeMode::SERVER
assert_xpath '/*[@class="imageblock"]//object[@type="image/svg+xml"][@data="http://example.org/tiger.svg?foo=bar"][@width="100"]/span[@class="alt"][text()="Tiger"]', output, 1
end
@@ -1973,7 +1973,7 @@ image::http://example.org/tiger.svg?foo=bar[Tiger,100]
image::http://example.org/tiger-svg[Tiger,100,format=svg]
EOS
- output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SERVER
+ output = convert_string_to_embedded input, safe: Asciidoctor::SafeMode::SERVER
assert_xpath '/*[@class="imageblock"]//object[@type="image/svg+xml"][@data="http://example.org/tiger-svg"][@width="100"]/span[@class="alt"][text()="Tiger"]', output, 1
end
@@ -1985,7 +1985,7 @@ image::http://example.org/tiger-svg[Tiger,100,format=svg]
image::circle.svg[Tiger,100]
EOS
- output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SERVER, :attributes => { 'docdir' => testdir }
+ output = convert_string_to_embedded input, safe: Asciidoctor::SafeMode::SERVER, attributes: { 'docdir' => testdir }
assert_match(/<svg\s[^>]*width="100px"[^>]*>/, output, 1)
refute_match(/<svg\s[^>]*width="500px"[^>]*>/, output)
refute_match(/<svg\s[^>]*height="500px"[^>]*>/, output)
@@ -2001,7 +2001,7 @@ image::circle.svg[Tiger,100]
image::circle.svg[Tiger,100]
EOS
- output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SERVER, :attributes => { 'docdir' => testdir }
+ output = convert_string_to_embedded input, safe: Asciidoctor::SafeMode::SERVER, attributes: { 'docdir' => testdir }
assert_match(/<svg\s[^>]*width="100px">/, output, 1)
end
@@ -2011,7 +2011,7 @@ image::http://#{resolve_localhost}:9876/fixtures/circle.svg[Circle,100,100,opts=
EOS
output = using_test_webserver do
- convert_string_to_embedded input, :safe => :safe, :attributes => {'allow-uri-read' => ''}
+ convert_string_to_embedded input, safe: :safe, attributes: { 'allow-uri-read' => '' }
end
assert_css 'svg', output, 1
@@ -2027,7 +2027,7 @@ image::http://#{resolve_localhost}:9876/fixtures/circle.svg[Circle,100,100,opts=
image::no-such-image.svg[Alt Text]
EOS
- output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SERVER
+ output = convert_string_to_embedded input, safe: Asciidoctor::SafeMode::SERVER
assert_xpath '//span[@class="alt"][text()="Alt Text"]', output, 1
assert_message @logger, :WARN, '~SVG does not exist or cannot be read'
end
@@ -2136,7 +2136,7 @@ image::images/tiger.png[Tiger]
test 'should not encode double quotes in alt text when converting to DocBook' do
input = 'Select "File > Open"'
expected = 'Select "File &gt; Open"'
- result = convert_string_to_embedded %(image::images/open.png[#{input}]), :backend => :docbook
+ result = convert_string_to_embedded %(image::images/open.png[#{input}]), backend: :docbook
assert_includes result, %(<phrase>#{expected}</phrase>)
end
@@ -2231,7 +2231,7 @@ image::images/tiger.png[Tiger]
image::images/sunset.jpg[Sunset,align=right]
EOS
- output = convert_string_to_embedded input, :backend => :docbook
+ output = convert_string_to_embedded input, backend: :docbook
assert_xpath '//imagedata', output, 1
assert_xpath '//imagedata[@align="right"]', output, 1
end
@@ -2241,7 +2241,7 @@ image::images/sunset.jpg[Sunset,align=right]
image::images/sunset.jpg[Sunset,500,332]
EOS
- output = convert_string_to_embedded input, :backend => :docbook
+ output = convert_string_to_embedded input, backend: :docbook
assert_xpath '//imagedata', output, 1
assert_xpath '//imagedata[@contentwidth="500"]', output, 1
assert_xpath '//imagedata[@contentdepth="332"]', output, 1
@@ -2254,7 +2254,7 @@ image::images/sunset.jpg[Sunset,500,332]
image::images/sunset.jpg[Sunset,500,332,scale=200]
EOS
- output = convert_string_to_embedded input, :backend => :docbook
+ output = convert_string_to_embedded input, backend: :docbook
assert_xpath '//imagedata', output, 1
assert_xpath '//imagedata[@scale="200"]', output, 1
assert_xpath '//imagedata[@width]', output, 0
@@ -2268,7 +2268,7 @@ image::images/sunset.jpg[Sunset,500,332,scale=200]
image::images/sunset.jpg[Sunset,500,332,scaledwidth=25%]
EOS
- output = convert_string_to_embedded input, :backend => :docbook
+ output = convert_string_to_embedded input, backend: :docbook
assert_xpath '//imagedata', output, 1
assert_xpath '//imagedata[@width="25%"]', output, 1
assert_xpath '//imagedata[@depth]', output, 0
@@ -2281,7 +2281,7 @@ image::images/sunset.jpg[Sunset,500,332,scaledwidth=25%]
image::images/sunset.jpg[Sunset,scaledwidth=25]
EOS
- output = convert_string_to_embedded input, :backend => :docbook
+ output = convert_string_to_embedded input, backend: :docbook
assert_xpath '//imagedata', output, 1
assert_xpath '//imagedata[@width="25%"]', output, 1
end
@@ -2377,7 +2377,7 @@ image::tiger.png[Tiger]
image::dot.gif[Dot]
EOS
- doc = document_from_string input, :safe => Asciidoctor::SafeMode::SAFE, :attributes => {'docdir' => testdir }
+ doc = document_from_string input, safe: Asciidoctor::SafeMode::SAFE, attributes: { 'docdir' => testdir }
assert_equal 'fixtures', doc.attributes['imagesdir']
output = doc.convert
assert_xpath '//img[@src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="][@alt="Dot"]', output, 1
@@ -2391,7 +2391,7 @@ image::dot.gif[Dot]
image::unreadable.gif[Dot]
EOS
- doc = document_from_string input, :safe => Asciidoctor::SafeMode::SAFE, :attributes => {'docdir' => testdir }
+ doc = document_from_string input, safe: Asciidoctor::SafeMode::SAFE, attributes: { 'docdir' => testdir }
assert_equal 'fixtures', doc.attributes['imagesdir']
output = doc.convert
assert_xpath '//img[@src="data:image/gif;base64,"]', output, 1
@@ -2406,7 +2406,7 @@ image::http://#{resolve_localhost}:9876/fixtures/dot.gif[Dot]
EOS
output = using_test_webserver do
- convert_string_to_embedded input, :safe => :safe, :attributes => {'allow-uri-read' => ''}
+ convert_string_to_embedded input, safe: :safe, attributes: { 'allow-uri-read' => '' }
end
assert_xpath '//img[@src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="][@alt="Dot"]', output, 1
@@ -2421,7 +2421,7 @@ image::dot.gif[Dot]
EOS
output = using_test_webserver do
- convert_string_to_embedded input, :safe => :safe, :attributes => {'allow-uri-read' => ''}
+ convert_string_to_embedded input, safe: :safe, attributes: { 'allow-uri-read' => '' }
end
assert_xpath '//img[@src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="][@alt="Dot"]', output, 1
@@ -2436,7 +2436,7 @@ image::#{image_uri}[Missing image]
EOS
output = using_test_webserver do
- convert_string_to_embedded input, :safe => :safe, :attributes => {'allow-uri-read' => ''}
+ convert_string_to_embedded input, safe: :safe, attributes: { 'allow-uri-read' => '' }
end
assert_xpath %(/*[@class="imageblock"]//img[@src="#{image_uri}"][@alt="Missing image"]), output, 1
@@ -2452,7 +2452,7 @@ image::#{image_uri}[Dot]
EOS
output = using_test_webserver do
- convert_string_to_embedded input, :safe => :safe
+ convert_string_to_embedded input, safe: :safe
end
assert_xpath %(/*[@class="imageblock"]//img[@src="#{image_uri}"][@alt="Dot"]), output, 1
@@ -2486,7 +2486,7 @@ image::data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=[Do
image::dot.gif[Dot]
EOS
- doc = document_from_string input, :safe => Asciidoctor::SafeMode::SAFE, :attributes => {'docdir' => testdir }
+ doc = document_from_string input, safe: Asciidoctor::SafeMode::SAFE, attributes: { 'docdir' => testdir }
assert_equal '../..//fixtures/./../../fixtures', doc.attributes['imagesdir']
output = doc.convert
# image target resolves to fixtures/dot.gif relative to docdir (which is explicitly set to the directory of this file)
@@ -2503,7 +2503,7 @@ image::dot.gif[Dot]
image::../..//fixtures/./../../fixtures/dot.gif[Dot]
EOS
- doc = document_from_string input, :safe => Asciidoctor::SafeMode::SAFE, :attributes => { 'docdir' => testdir }
+ doc = document_from_string input, safe: Asciidoctor::SafeMode::SAFE, attributes: { 'docdir' => testdir }
assert_equal './', doc.attributes['imagesdir']
output = doc.convert
# image target resolves to fixtures/dot.gif relative to docdir (which is explicitly set to the directory of this file)
@@ -2732,7 +2732,7 @@ audio::podcast.mp3[start=1,end=2]
You can use icons for admonitions by setting the 'icons' attribute.
EOS
- output = convert_string input, :safe => Asciidoctor::SafeMode::SERVER
+ output = convert_string input, safe: Asciidoctor::SafeMode::SERVER
assert_xpath '//*[@class="admonitionblock tip"]//*[@class="icon"]/img[@src="./images/icons/tip.png"][@alt="Tip"]', output, 1
end
@@ -2745,7 +2745,7 @@ You can use icons for admonitions by setting the 'icons' attribute.
You can use icons for admonitions by setting the 'icons' attribute.
EOS
- output = convert_string input, :safe => Asciidoctor::SafeMode::SERVER
+ output = convert_string input, safe: Asciidoctor::SafeMode::SERVER
assert_xpath '//*[@class="admonitionblock tip"]//*[@class="icon"]/img[@src="icons/tip.png"][@alt="Tip"]', output, 1
end
@@ -2758,7 +2758,7 @@ You can use icons for admonitions by setting the 'icons' attribute.
Override the icon of an admonition block using an attribute
EOS
- output = convert_string input, :safe => Asciidoctor::SafeMode::SERVER
+ output = convert_string input, safe: Asciidoctor::SafeMode::SERVER
assert_xpath '//*[@class="admonitionblock tip"]//*[@class="icon"]/img[@src="images/icons/a.png"]', output, 1
end
@@ -2773,7 +2773,7 @@ Override the icon of an admonition block using an attribute
You can use icons for admonitions by setting the 'icons' attribute.
EOS
- output = convert_string input, :safe => Asciidoctor::SafeMode::SAFE, :attributes => { 'docdir' => testdir }
+ output = convert_string input, safe: Asciidoctor::SafeMode::SAFE, attributes: { 'docdir' => testdir }
assert_xpath '//*[@class="admonitionblock tip"]//*[@class="icon"]/img[@src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="][@alt="Tip"]', output, 1
end
@@ -2788,7 +2788,7 @@ You can use icons for admonitions by setting the 'icons' attribute.
You can set a custom icon using the icon attribute on the block.
EOS
- output = convert_string input, :safe => Asciidoctor::SafeMode::SAFE, :attributes => { 'docdir' => testdir }
+ output = convert_string input, safe: Asciidoctor::SafeMode::SAFE, attributes: { 'docdir' => testdir }
assert_xpath '//*[@class="admonitionblock tip"]//*[@class="icon"]/img[@src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="][@alt="Tip"]', output, 1
end
@@ -2803,7 +2803,7 @@ You can set a custom icon using the icon attribute on the block.
You can use icons for admonitions by setting the 'icons' attribute.
EOS
- output = convert_string input, :attributes => {'icons' => ''}
+ output = convert_string input, attributes: { 'icons' => '' }
assert_xpath '//*[@class="admonitionblock tip"]//*[@class="icon"]/img[@src="fixtures/tip.gif"][@alt="Tip"]', output, 1
end
@@ -2818,7 +2818,7 @@ You can use icons for admonitions by setting the 'icons' attribute.
You can use icons for admonitions by setting the 'icons' attribute.
EOS
- output = convert_string input, :safe => Asciidoctor::SafeMode::SAFE, :attributes => { 'docdir' => testdir }
+ output = convert_string input, safe: Asciidoctor::SafeMode::SAFE, attributes: { 'docdir' => testdir }
assert_xpath '//*[@class="admonitionblock tip"]//*[@class="icon"]/img[@src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="][@alt="Tip"]', output, 1
assert_message @logger, :WARN, 'image has illegal reference to ancestor of jail; recovering automatically'
end
@@ -2831,7 +2831,7 @@ You can use icons for admonitions by setting the 'icons' attribute.
You can use icons for admonitions by setting the 'icons' attribute.
EOS
- output = convert_string input, :safe => Asciidoctor::SafeMode::SERVER
+ output = convert_string input, safe: Asciidoctor::SafeMode::SERVER
assert_css %(html > head > link[rel="stylesheet"][href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/#{Asciidoctor::FONT_AWESOME_VERSION}/css/font-awesome.min.css"]), output, 1
assert_xpath '//*[@class="admonitionblock tip"]//*[@class="icon"]/i[@class="fa icon-tip"]', output, 1
end
@@ -2845,7 +2845,7 @@ You can use icons for admonitions by setting the 'icons' attribute.
Override the icon of an admonition block using an attribute
EOS
- output = convert_string input, :safe => Asciidoctor::SafeMode::SERVER
+ output = convert_string input, safe: Asciidoctor::SafeMode::SERVER
assert_xpath '//*[@class="admonitionblock tip"]//*[@class="icon"]/i[@class="fa icon-tip"]', output, 0
assert_xpath '//*[@class="admonitionblock tip"]//*[@class="icon"]/img[@src="images/icons/a.png"]', output, 1
end
@@ -2862,7 +2862,7 @@ TIP: You can control the URI scheme used for assets with the asset-uri-scheme at
puts "AsciiDoc, FTW!"
EOS
- output = convert_string input, :safe => Asciidoctor::SafeMode::SAFE
+ output = convert_string input, safe: Asciidoctor::SafeMode::SAFE
assert_css %(html > head > link[rel="stylesheet"][href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/#{Asciidoctor::FONT_AWESOME_VERSION}/css/font-awesome.min.css"]), output, 1
assert_css 'html > body > script[src="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/highlight.min.js"]', output, 1
end
@@ -2879,7 +2879,7 @@ TIP: You can control the URI scheme used for assets with the asset-uri-scheme at
puts "AsciiDoc, FTW!"
EOS
- output = convert_string input, :safe => Asciidoctor::SafeMode::SAFE
+ output = convert_string input, safe: Asciidoctor::SafeMode::SAFE
assert_css %(html > head > link[rel="stylesheet"][href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/#{Asciidoctor::FONT_AWESOME_VERSION}/css/font-awesome.min.css"]), output, 1
assert_css 'html > body > script[src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/highlight.min.js"]', output, 1
end
@@ -2891,7 +2891,7 @@ puts "AsciiDoc, FTW!"
image::asciidoctor.png[Asciidoctor]
EOS
basedir = testdir
- block = block_from_string input, :attributes => {'docdir' => basedir}
+ block = block_from_string input, attributes: { 'docdir' => basedir }
doc = block.document
assert doc.safe >= Asciidoctor::SafeMode::SAFE
@@ -2905,7 +2905,7 @@ image::asciidoctor.png[Asciidoctor]
image::asciidoctor.png[Asciidoctor]
EOS
basedir = testdir
- block = block_from_string input, :safe => Asciidoctor::SafeMode::UNSAFE, :attributes => {'docdir' => basedir}
+ block = block_from_string input, safe: Asciidoctor::SafeMode::UNSAFE, attributes: { 'docdir' => basedir }
doc = block.document
assert doc.safe == Asciidoctor::SafeMode::UNSAFE
@@ -2988,10 +2988,10 @@ alert("Hello, World!")
----
require 'coderay'
-html = CodeRay.scan("puts 'Hello, world!'", :ruby).div(:line_numbers => :table)
+html = CodeRay.scan("puts 'Hello, world!'", :ruby).div line_numbers: :table
----
EOS
- output = convert_string input, :safe => Asciidoctor::SafeMode::SAFE, :linkcss_default => true
+ output = convert_string input, safe: Asciidoctor::SafeMode::SAFE, linkcss_default: true
assert_xpath '//pre[@class="CodeRay highlight"]/code[@data-lang="ruby"]//span[@class = "constant"][text() = "CodeRay"]', output, 1
assert_match(/\.CodeRay *\{/, output)
end
@@ -3005,7 +3005,7 @@ html = CodeRay.scan("puts 'Hello, world!'", :ruby).div(:line_numbers => :table)
puts 'Hello, World!'
----
EOS
- output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SAFE
+ output = convert_string_to_embedded input, safe: Asciidoctor::SafeMode::SAFE
assert_xpath '//td[@class="line-numbers"]', output, 1
end
@@ -3018,7 +3018,7 @@ puts 'Hello, World!'
puts 'Hello, World!'
----
EOS
- output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SAFE
+ output = convert_string_to_embedded input, safe: Asciidoctor::SafeMode::SAFE
assert_xpath '//td[@class="line-numbers"]', output, 1
end
@@ -3032,7 +3032,7 @@ puts 'Hello, World!'
puts 'Hello, World!'
----
EOS
- output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SAFE
+ output = convert_string_to_embedded input, safe: Asciidoctor::SafeMode::SAFE
assert_xpath '//td[@class="line-numbers"]', output, 1
end
@@ -3046,7 +3046,7 @@ puts 'Hello, World!'
puts 'Hello, World!'
----
EOS
- output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SAFE
+ output = convert_string_to_embedded input, safe: Asciidoctor::SafeMode::SAFE
assert_xpath '//span[@class="line-numbers"]', output, 1
assert_xpath '//span[@class="line-numbers"][text()="10"]', output, 1
end
@@ -3063,7 +3063,7 @@ public class HelloWorld {
----
EOS
- output = convert_string_to_embedded input, :backend => :docbook, :safe => Asciidoctor::SafeMode::SAFE
+ output = convert_string_to_embedded input, backend: :docbook, safe: Asciidoctor::SafeMode::SAFE
assert_css 'programlisting[startinglinenumber]', output, 1
assert_css 'programlisting[startinglinenumber="3"]', output, 1
end
@@ -3084,7 +3084,7 @@ public class HelloWorld {
}
----
EOS
- output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SAFE
+ output = convert_string_to_embedded input, safe: Asciidoctor::SafeMode::SAFE
assert_css 'strong.highlighted', output, 4
assert_xpath '//strong[@class="highlighted"][text()="1"]', output, 1
assert_xpath '//strong[@class="highlighted"][text()="2"]', output, 0
@@ -3105,10 +3105,10 @@ public class HelloWorld {
----
require 'coderay'
-html = CodeRay.scan("puts 'Hello, world!'", :ruby).div(:line_numbers => :table)
+html = CodeRay.scan("puts 'Hello, world!'", :ruby).div line_numbers: :table
----
EOS
- output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SAFE, :linkcss_default => true
+ output = convert_string_to_embedded input, safe: Asciidoctor::SafeMode::SAFE, linkcss_default: true
assert_xpath '//pre[@class="CodeRay highlight"]/code[@data-lang="ruby"]//span[@class = "constant"][text() = "CodeRay"]', output, 1
end
@@ -3119,7 +3119,7 @@ html = CodeRay.scan("puts 'Hello, world!'", :ruby).div(:line_numbers => :table)
{source-language}
EOS
- assert_equal 'ruby', (convert_inline_string input, :attributes => {'compat-mode' => ''})
+ assert_equal 'ruby', (convert_inline_string input, attributes: { 'compat-mode' => '' })
input = <<-EOS
:language: ruby
@@ -3138,7 +3138,7 @@ html = CodeRay.scan("puts 'Hello, world!'", :ruby).div(:line_numbers => :table)
----
require 'coderay' # <1>
-html = CodeRay.scan("puts 'Hello, world!'", :ruby).div(:line_numbers => :table) # <2>
+html = CodeRay.scan("puts 'Hello, world!'", :ruby).div line_numbers: :table # <2>
puts html # <3> <4>
exit 0 # <5><6>
----
@@ -3149,7 +3149,7 @@ exit 0 # <5><6>
<5> Exit program
<6> Reports success
EOS
- output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SAFE
+ output = convert_string_to_embedded input, safe: Asciidoctor::SafeMode::SAFE
assert_match(/<span class="content">coderay<\/span>.* # <b class="conum">\(1\)<\/b>$/, output)
assert_match(/<span class="content">puts 'Hello, world!'<\/span>.* # <b class="conum">\(2\)<\/b>$/, output)
assert_match(/puts html.* # <b class="conum">\(3\)<\/b> <b class="conum">\(4\)<\/b>$/, output)
@@ -3164,7 +3164,7 @@ exit 0 # <5><6>
----
require 'coderay' # <.><.>
-html = CodeRay.scan("puts 'Hello, world!'", :ruby).div(:line_numbers => :table) # <.>
+html = CodeRay.scan("puts 'Hello, world!'", :ruby).div line_numbers: :table # <.>
puts html # <.>
----
<.> Load library
@@ -3172,7 +3172,7 @@ puts html # <.>
<.> Highlight source
<.> Print to stdout
EOS
- output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SAFE
+ output = convert_string_to_embedded input, safe: Asciidoctor::SafeMode::SAFE
assert_match(/<span class="content">coderay<\/span>.* # <b class="conum">\(1\)<\/b> <b class="conum">\(2\)<\/b>$/, output)
assert_match(/<span class="content">puts 'Hello, world!'<\/span>.* # <b class="conum">\(3\)<\/b>$/, output)
assert_match(/puts html.* # <b class="conum">\(4\)<\/b><\/code>/, output)
@@ -3189,7 +3189,7 @@ puts html # <.>
----
require 'coderay' # <1>
-html = CodeRay.scan("puts 'Hello, world!'", :ruby).div(:line_numbers => :table) # <2>
+html = CodeRay.scan("puts 'Hello, world!'", :ruby).div line_numbers: :table # <2>
puts html # <3> <4>
exit 0 # <5><6>
----
@@ -3200,7 +3200,7 @@ exit 0 # <5><6>
<5> Exit program
<6> Reports success
EOS
- output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SAFE
+ output = convert_string_to_embedded input, safe: Asciidoctor::SafeMode::SAFE
assert_match(/<span class="content">coderay<\/span>.* # <b class="conum">\(1\)<\/b>$/, output)
assert_match(/<span class="content">puts 'Hello, world!'<\/span>.* # <b class="conum">\(2\)<\/b>$/, output)
assert_match(/puts html.* # <b class="conum">\(3\)<\/b> <b class="conum">\(4\)<\/b>$/, output)
@@ -3238,7 +3238,7 @@ print 'value' #<1>
EOS
inputs.each do |input|
- output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SAFE, :attributes => { 'source-highlighter' => 'coderay' }
+ output = convert_string_to_embedded input, safe: Asciidoctor::SafeMode::SAFE, attributes: { 'source-highlighter' => 'coderay' }
output = output.gsub(/<\/?span.*?>/, '')
assert_includes output, '\'value\' #<b class="conum">(1)</b>'
end
@@ -3258,7 +3258,7 @@ public class Printer {
}
----
EOS
- output = convert_string input, :safe => Asciidoctor::SafeMode::SAFE
+ output = convert_string input, safe: Asciidoctor::SafeMode::SAFE
assert_match(/\.<em>out<\/em>\./, output, 1)
assert_match(/\*asterisks\*/, output, 1)
assert_match(/<strong>bold<\/strong>/, output, 1)
@@ -3273,10 +3273,10 @@ public class Printer {
----
require 'coderay'
-html = CodeRay.scan("puts 'Hello, world!'", :ruby).div(:line_numbers => :table)
+html = CodeRay.scan("puts 'Hello, world!'", :ruby).div line_numbers: :table
----
EOS
- output = convert_string input, :safe => Asciidoctor::SafeMode::SAFE, :attributes => {'linkcss' => ''}
+ output = convert_string input, safe: Asciidoctor::SafeMode::SAFE, attributes: { 'linkcss' => '' }
assert_xpath '//pre[@class="CodeRay highlight"]/code[@data-lang="ruby"]//span[@class = "constant"][text() = "CodeRay"]', output, 1
assert_css 'link[rel="stylesheet"][href="./coderay-asciidoctor.css"]', output, 1
end
@@ -3290,10 +3290,10 @@ html = CodeRay.scan("puts 'Hello, world!'", :ruby).div(:line_numbers => :table)
----
require 'coderay'
-html = CodeRay.scan("puts 'Hello, world!'", :ruby).div(:line_numbers => :table)
+html = CodeRay.scan("puts 'Hello, world!'", :ruby).div line_numbers: :table
----
EOS
- output = convert_string input, :safe => Asciidoctor::SafeMode::SAFE, :linkcss_default => true
+ output = convert_string input, safe: Asciidoctor::SafeMode::SAFE, linkcss_default: true
assert_xpath '//pre[@class="CodeRay highlight"]/code[@data-lang="ruby"]//span[@style = "color:#036;font-weight:bold"][text() = "CodeRay"]', output, 1
refute_match(/\.CodeRay \{/, output)
end
@@ -3309,7 +3309,7 @@ html = CodeRay.scan("puts 'Hello, world!'", :ruby).div(:line_numbers => :table)
<script>hljs.initHighlightingOnLoad();</script>
----
EOS
- output = convert_string input, :safe => Asciidoctor::SafeMode::SAFE
+ output = convert_string input, safe: Asciidoctor::SafeMode::SAFE
assert_match(/<link .*highlight\.js/, output)
assert_match(/<script .*highlight\.js/, output)
assert_match(/hljs.initHighlightingOnLoad/, output)
@@ -3323,7 +3323,7 @@ puts "foo"
----
EOS
- output = convert_string_to_embedded input, :attributes => {'source-highlighter' => 'prettify'}
+ output = convert_string_to_embedded input, attributes: { 'source-highlighter' => 'prettify' }
assert_css 'pre[class="prettyprint highlight"]', output, 1
assert_css 'pre > code.language-ruby[data-lang="ruby"]', output, 1
end
@@ -3336,7 +3336,7 @@ puts "foo"
----
EOS
- output = convert_string_to_embedded input, :attributes => {'source-highlighter' => 'prettify'}
+ output = convert_string_to_embedded input, attributes: { 'source-highlighter' => 'prettify' }
assert_css 'pre[class="prettyprint highlight linenums:5"]', output, 1
assert_css 'pre > code.language-ruby[data-lang="ruby"]', output, 1
end
@@ -3355,7 +3355,7 @@ puts HTML::Pipeline.new(filters, {}).call(input)[:output]
----
EOS
- output = convert_string input, :attributes => {'source-highlighter' => 'html-pipeline'}
+ output = convert_string input, attributes: { 'source-highlighter' => 'html-pipeline' }
assert_css 'pre[lang="ruby"]', output, 1
assert_css 'pre[lang="ruby"] > code', output, 1
assert_css 'pre[class]', output, 0
@@ -3366,7 +3366,7 @@ puts HTML::Pipeline.new(filters, {}).call(input)[:output]
input = <<-EOS
:source-highlighter: coderay
EOS
- doc = document_from_string input, :safe => Asciidoctor::SafeMode::SERVER
+ doc = document_from_string input, safe: Asciidoctor::SafeMode::SERVER
assert_nil doc.attributes['source-highlighter']
end
@@ -3475,7 +3475,7 @@ And other stuff.
--
EOS
- output = convert_string input, :backend => 'docbook'
+ output = convert_string input, backend: 'docbook'
assert_css 'abstract', output, 1
assert_css 'abstract > simpara', output, 2
end
@@ -3491,7 +3491,7 @@ This article is about stuff.
--
EOS
- output = convert_string input, :backend => 'docbook'
+ output = convert_string input, backend: 'docbook'
assert_css 'abstract', output, 1
assert_css 'abstract > title', output, 1
assert_css 'abstract > title + simpara', output, 1
@@ -3506,7 +3506,7 @@ This article is about stuff.
Abstract for book with title is valid
EOS
- output = convert_string input, :backend => 'docbook'
+ output = convert_string input, backend: 'docbook'
assert_css 'abstract', output, 1
end
@@ -3518,7 +3518,7 @@ Abstract for book with title is valid
Abstract for book is invalid.
EOS
- output = convert_string input, :backend => 'docbook'
+ output = convert_string input, backend: 'docbook'
assert_css 'abstract', output, 0
assert_message @logger, :WARN, 'abstract block cannot be used in a document without a title when doctype is book. Excluding block content.'
end
@@ -3624,7 +3624,7 @@ It can have multiple paragraphs.
content
EOS
- output = convert_string input, :backend => 'docbook45'
+ output = convert_string input, backend: 'docbook45'
assert_css 'partintro', output, 1
assert_css 'part#_part_1 > partintro', output, 1
assert_css 'partintro > simpara', output, 2
@@ -3648,7 +3648,7 @@ This is a part intro with a title.
content
EOS
- output = convert_string input, :backend => 'docbook45'
+ output = convert_string input, backend: 'docbook45'
assert_css 'partintro', output, 1
assert_css 'part#_part_1 > partintro', output, 1
assert_css 'partintro > title', output, 1
@@ -3664,7 +3664,7 @@ content
part intro paragraph
EOS
- output = convert_string input, :backend => 'docbook'
+ output = convert_string input, backend: 'docbook'
assert_css 'partintro', output, 0
assert_message @logger, :ERROR, 'partintro block can only be used when doctype is book and must be a child of a book part. Excluding block content.'
end
@@ -3675,7 +3675,7 @@ part intro paragraph
part intro paragraph
EOS
- output = convert_string input, :backend => 'docbook'
+ output = convert_string input, backend: 'docbook'
assert_css 'partintro', output, 0
assert_message @logger, :ERROR, 'partintro block can only be used when doctype is book and must be a child of a book part. Excluding block content.'
end
@@ -3746,7 +3746,7 @@ https://{application}.org[{gt}{gt}] <1>
....
EOS
- doc = document_from_string input, :header_footer => false
+ doc = document_from_string input, header_footer: false
block = doc.blocks.first
assert_equal [:attributes, :specialcharacters, :macros], block.subs
result = doc.convert
@@ -3759,7 +3759,7 @@ https://{application}.org[{gt}{gt}] <1>
_hey now_ <1>
EOS
- doc = document_from_string input, :header_footer => false
+ doc = document_from_string input, header_footer: false
block = doc.blocks.first
assert_equal [:specialcharacters], block.subs
result = doc.convert
diff --git a/test/converter_test.rb b/test/converter_test.rb
index 82bbe067..53829434 100644
--- a/test/converter_test.rb
+++ b/test/converter_test.rb
@@ -5,7 +5,7 @@ context 'Converter' do
context 'View options' do
test 'should set Haml format to html5 for html5 backend' do
- doc = Asciidoctor::Document.new [], :template_dir => (fixture_path 'custom-backends/haml'), :template_cache => false
+ doc = Asciidoctor::Document.new [], template_dir: (fixture_path 'custom-backends/haml'), template_cache: false
assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter
selected = doc.converter.find_converter('paragraph')
assert_kind_of Asciidoctor::Converter::TemplateConverter, selected
@@ -14,7 +14,7 @@ context 'Converter' do
end
test 'should set Haml format to xhtml for docbook backend' do
- doc = Asciidoctor::Document.new [], :backend => 'docbook45', :template_dir => (fixture_path 'custom-backends/haml'), :template_cache => false
+ doc = Asciidoctor::Document.new [], backend: 'docbook45', template_dir: (fixture_path 'custom-backends/haml'), template_cache: false
assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter
selected = doc.converter.find_converter('paragraph')
assert_kind_of Asciidoctor::Converter::TemplateConverter, selected
@@ -24,7 +24,7 @@ context 'Converter' do
test 'should configure Slim to resolve includes in specified template dirs' do
template_dirs = [(fixture_path 'custom-backends/slim'), (fixture_path 'custom-backends/slim-overrides')]
- doc = Asciidoctor::Document.new [], :template_dirs => template_dirs, :template_cache => false
+ doc = Asciidoctor::Document.new [], template_dirs: template_dirs, template_cache: false
assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter
selected = doc.converter.find_converter('paragraph')
assert_kind_of Asciidoctor::Converter::TemplateConverter, selected
@@ -34,7 +34,7 @@ context 'Converter' do
test 'should coerce template_dirs option to an Array' do
template_dirs = fixture_path 'custom-backends/slim'
- doc = Asciidoctor::Document.new [], :template_dirs => template_dirs, :template_cache => false
+ doc = Asciidoctor::Document.new [], template_dirs: template_dirs, template_cache: false
assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter
selected = doc.converter.find_converter('paragraph')
assert_kind_of Asciidoctor::Converter::TemplateConverter, selected
@@ -42,7 +42,7 @@ context 'Converter' do
end
test 'should set Slim format to html for html5 backend' do
- doc = Asciidoctor::Document.new [], :template_dir => (fixture_path 'custom-backends/slim'), :template_cache => false
+ doc = Asciidoctor::Document.new [], template_dir: (fixture_path 'custom-backends/slim'), template_cache: false
assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter
selected = doc.converter.find_converter('paragraph')
assert_kind_of Asciidoctor::Converter::TemplateConverter, selected
@@ -51,7 +51,7 @@ context 'Converter' do
end
test 'should set Slim format to nil for docbook backend' do
- doc = Asciidoctor::Document.new [], :backend => 'docbook45', :template_dir => (fixture_path 'custom-backends/slim'), :template_cache => false
+ doc = Asciidoctor::Document.new [], backend: 'docbook45', template_dir: (fixture_path 'custom-backends/slim'), template_cache: false
assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter
selected = doc.converter.find_converter('paragraph')
assert_kind_of Asciidoctor::Converter::TemplateConverter, selected
@@ -60,20 +60,20 @@ context 'Converter' do
end
test 'should set safe mode of Slim AsciiDoc engine to match document safe mode when Slim >= 3' do
- doc = Asciidoctor::Document.new [], :template_dir => (fixture_path 'custom-backends/slim'), :template_cache => false, :safe => :unsafe
+ doc = Asciidoctor::Document.new [], template_dir: (fixture_path 'custom-backends/slim'), template_cache: false, safe: :unsafe
assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter
selected = doc.converter.find_converter('paragraph')
assert_kind_of Asciidoctor::Converter::TemplateConverter, selected
slim_asciidoc_opts = selected.instance_variable_get(:@engine_options)[:slim][:asciidoc]
if ::Slim::VERSION >= '3.0'
- assert_equal({ :safe => Asciidoctor::SafeMode::UNSAFE }, slim_asciidoc_opts)
+ assert_equal({ safe: Asciidoctor::SafeMode::UNSAFE }, slim_asciidoc_opts)
else
assert_nil slim_asciidoc_opts
end
end
test 'should support custom template engine options for known engine' do
- doc = Asciidoctor::Document.new [], :template_dir => (fixture_path 'custom-backends/slim'), :template_cache => false, :template_engine_options => { :slim => { :pretty => true } }
+ doc = Asciidoctor::Document.new [], template_dir: (fixture_path 'custom-backends/slim'), template_cache: false, template_engine_options: { slim: { pretty: true } }
assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter
selected = doc.converter.find_converter('paragraph')
assert_kind_of Asciidoctor::Converter::TemplateConverter, selected
@@ -82,7 +82,7 @@ context 'Converter' do
end
test 'should support custom template engine options' do
- doc = Asciidoctor::Document.new [], :template_dir => (fixture_path 'custom-backends/slim'), :template_cache => false, :template_engine_options => { :slim => { :pretty => true } }
+ doc = Asciidoctor::Document.new [], template_dir: (fixture_path 'custom-backends/slim'), template_cache: false, template_engine_options: { slim: { pretty: true } }
assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter
selected = doc.converter.find_converter('paragraph')
assert_kind_of Asciidoctor::Converter::TemplateConverter, selected
@@ -94,7 +94,7 @@ context 'Converter' do
context 'Custom backends' do
test 'should load Haml templates for default backend' do
- doc = Asciidoctor::Document.new [], :template_dir => (fixture_path 'custom-backends/haml'), :template_cache => false
+ doc = Asciidoctor::Document.new [], template_dir: (fixture_path 'custom-backends/haml'), template_cache: false
assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter
['paragraph', 'sidebar'].each do |node_name|
selected = doc.converter.find_converter node_name
@@ -109,23 +109,23 @@ context 'Converter' do
doc.convert
assert_equal '.html', doc.attributes['outfilesuffix']
- doc = Asciidoctor.load 'content', :template_dir => (fixture_path 'custom-backends/haml'), :template_cache => false
+ doc = Asciidoctor.load 'content', template_dir: (fixture_path 'custom-backends/haml'), template_cache: false
doc.convert
assert_equal '.html', doc.attributes['outfilesuffix']
end
test 'should not override outfilesuffix attribute if locked' do
- doc = Asciidoctor.load 'content', :attributes => {'outfilesuffix' => '.foo'}
+ doc = Asciidoctor.load 'content', attributes: { 'outfilesuffix' => '.foo' }
doc.convert
assert_equal '.foo', doc.attributes['outfilesuffix']
- doc = Asciidoctor.load 'content', :template_dir => (fixture_path 'custom-backends/haml'), :template_cache => false, :attributes => {'outfilesuffix' => '.foo'}
+ doc = Asciidoctor.load 'content', template_dir: (fixture_path 'custom-backends/haml'), template_cache: false, attributes: { 'outfilesuffix' => '.foo' }
doc.convert
assert_equal '.foo', doc.attributes['outfilesuffix']
end
test 'should load Haml templates for docbook45 backend' do
- doc = Asciidoctor::Document.new [], :backend => 'docbook45', :template_dir => (fixture_path 'custom-backends/haml'), :template_cache => false
+ doc = Asciidoctor::Document.new [], backend: 'docbook45', template_dir: (fixture_path 'custom-backends/haml'), template_cache: false
assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter
['paragraph'].each do |node_name|
selected = doc.converter.find_converter node_name
@@ -150,7 +150,7 @@ Sidebar content
****
EOS
- output = convert_string_to_embedded input, :template_dir => (fixture_path 'custom-backends/haml'), :template_cache => false
+ output = convert_string_to_embedded input, template_dir: (fixture_path 'custom-backends/haml'), template_cache: false
assert_xpath '/*[@class="sect1"]/*[@class="sectionbody"]/p', output, 1
assert_xpath '//aside', output, 1
assert_xpath '/*[@class="sect1"]/*[@class="sectionbody"]/p/following-sibling::aside', output, 1
@@ -164,7 +164,7 @@ Sidebar content
Asciidoctor::Converter::TemplateConverter.clear_caches if defined? Asciidoctor::Converter::TemplateConverter
template_dir = fixture_path 'custom-backends/haml'
- doc = Asciidoctor::Document.new [], :template_dir => template_dir
+ doc = Asciidoctor::Document.new [], template_dir: template_dir
doc.converter
caches = Asciidoctor::Converter::TemplateConverter.caches
if defined? ::Concurrent::Hash
@@ -174,14 +174,14 @@ Sidebar content
refute_nil paragraph_template_before
# should use cache
- doc = Asciidoctor::Document.new [], :template_dir => template_dir
+ doc = Asciidoctor::Document.new [], template_dir: template_dir
template_converter = doc.converter.find_converter('paragraph')
paragraph_template_after = template_converter.templates['paragraph']
refute_nil paragraph_template_after
assert paragraph_template_before.eql?(paragraph_template_after)
# should not use cache
- doc = Asciidoctor::Document.new [], :template_dir => template_dir, :template_cache => false
+ doc = Asciidoctor::Document.new [], template_dir: template_dir, template_cache: false
template_converter = doc.converter.find_converter('paragraph')
paragraph_template_after = template_converter.templates['paragraph']
refute_nil paragraph_template_after
@@ -198,8 +198,8 @@ Sidebar content
test 'should use custom cache to cache templates' do
template_dir = fixture_path 'custom-backends/haml'
Asciidoctor::PathResolver.new.system_path(File.join(template_dir, 'html5', 'block_paragraph.html.haml'), nil)
- caches = { :scans => {}, :templates => {} }
- doc = Asciidoctor::Document.new [], :template_dir => template_dir, :template_cache => caches
+ caches = { scans: {}, templates: {} }
+ doc = Asciidoctor::Document.new [], template_dir: template_dir, template_cache: caches
doc.converter
refute_empty caches[:scans]
refute_empty caches[:templates]
@@ -213,7 +213,7 @@ Sidebar content
# clear out any cache, just to be sure
Asciidoctor::Converter::TemplateConverter.clear_caches if defined? Asciidoctor::Converter::TemplateConverter
- doc = Asciidoctor::Document.new [], :template_dir => (fixture_path 'custom-backends/haml'), :template_cache => false
+ doc = Asciidoctor::Document.new [], template_dir: (fixture_path 'custom-backends/haml'), template_cache: false
doc.converter
caches = Asciidoctor::Converter::TemplateConverter.caches
assert caches.empty? || caches[:scans].empty?
@@ -225,7 +225,7 @@ Sidebar content
end
test 'should load ERB templates using ERBTemplate if eruby is not set' do
- doc = Asciidoctor::Document.new [], :template_dir => (fixture_path 'custom-backends/erb'), :template_cache => false
+ doc = Asciidoctor::Document.new [], template_dir: (fixture_path 'custom-backends/erb'), template_cache: false
assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter
['paragraph'].each do |node_name|
selected = doc.converter.find_converter node_name
@@ -239,7 +239,7 @@ Sidebar content
end
test 'should load ERB templates using ErubisTemplate if eruby is set to erubis' do
- doc = Asciidoctor::Document.new [], :template_dir => (fixture_path 'custom-backends/erb'), :template_cache => false, :eruby => 'erubis'
+ doc = Asciidoctor::Document.new [], template_dir: (fixture_path 'custom-backends/erb'), template_cache: false, eruby: 'erubis'
assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter
['paragraph'].each do |node_name|
selected = doc.converter.find_converter node_name
@@ -253,7 +253,7 @@ Sidebar content
end
test 'should load Slim templates for default backend' do
- doc = Asciidoctor::Document.new [], :template_dir => (fixture_path 'custom-backends/slim'), :template_cache => false
+ doc = Asciidoctor::Document.new [], template_dir: (fixture_path 'custom-backends/slim'), template_cache: false
assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter
['paragraph', 'sidebar'].each do |node_name|
selected = doc.converter.find_converter node_name
@@ -264,7 +264,7 @@ Sidebar content
end
test 'should load Slim templates for docbook45 backend' do
- doc = Asciidoctor::Document.new [], :backend => 'docbook45', :template_dir => (fixture_path 'custom-backends/slim'), :template_cache => false
+ doc = Asciidoctor::Document.new [], backend: 'docbook45', template_dir: (fixture_path 'custom-backends/slim'), template_cache: false
assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter
['paragraph'].each do |node_name|
selected = doc.converter.find_converter node_name
@@ -289,7 +289,7 @@ Sidebar content
****
EOS
- output = convert_string_to_embedded input, :template_dir => (fixture_path 'custom-backends/slim'), :template_cache => false
+ output = convert_string_to_embedded input, template_dir: (fixture_path 'custom-backends/slim'), template_cache: false
assert_xpath '/*[@class="sect1"]/*[@class="sectionbody"]/p', output, 1
assert_xpath '//aside', output, 1
assert_xpath '/*[@class="sect1"]/*[@class="sectionbody"]/p/following-sibling::aside', output, 1
@@ -321,7 +321,7 @@ content
end
end
- output = convert_string input, :converter => CustomConverterA
+ output = convert_string input, converter: CustomConverterA
assert 'document', output
end
@@ -344,7 +344,7 @@ content
converters = Asciidoctor::Converter::Factory.converters
assert converters.size == 1
assert converters['foobar'] == CustomConverterB
- output = convert_string input, :backend => 'foobar'
+ output = convert_string input, backend: 'foobar'
assert 'foobar content', output
ensure
Asciidoctor::Converter::Factory.unregister_all
@@ -388,7 +388,7 @@ paragraph
end
end
- doc = document_from_string input, :backend => 'myhtml', :template_dir => (fixture_path 'custom-backends/slim/html5'), :template_cache => false
+ doc = document_from_string input, backend: 'myhtml', template_dir: (fixture_path 'custom-backends/slim/html5'), template_cache: false
assert_kind_of CustomConverterD, doc.converter
refute doc.converter.supports_templates?
output = doc.convert
@@ -428,7 +428,7 @@ paragraph
end
end
- doc = document_from_string input, :backend => 'myhtml', :template_dir => (fixture_path 'custom-backends/slim/html5'), :template_cache => false
+ doc = document_from_string input, backend: 'myhtml', template_dir: (fixture_path 'custom-backends/slim/html5'), template_cache: false
assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter
output = doc.convert
assert_xpath '//*[@class="paragraph"]/p[text()="paragraph"]', output, 0
@@ -456,7 +456,7 @@ content
converters = Asciidoctor::Converter::Factory.converters
assert converters['*'] == CustomConverterF
- output = convert_string input, :backend => 'foobaz'
+ output = convert_string input, backend: 'foobaz'
assert 'foobaz content', output
ensure
Asciidoctor::Converter::Factory.unregister_all
diff --git a/test/document_test.rb b/test/document_test.rb
index 68bc0fc0..98d2631a 100644
--- a/test/document_test.rb
+++ b/test/document_test.rb
@@ -29,26 +29,26 @@ context 'Document' do
end
test 'safe mode level set using string' do
- doc = empty_document :safe => 'server'
+ doc = empty_document safe: 'server'
assert_equal Asciidoctor::SafeMode::SERVER, doc.safe
- doc = empty_document :safe => 'foo'
+ doc = empty_document safe: 'foo'
assert_equal Asciidoctor::SafeMode::SECURE, doc.safe
end
test 'safe mode level set using symbol' do
- doc = empty_document :safe => :server
+ doc = empty_document safe: :server
assert_equal Asciidoctor::SafeMode::SERVER, doc.safe
- doc = empty_document :safe => :foo
+ doc = empty_document safe: :foo
assert_equal Asciidoctor::SafeMode::SECURE, doc.safe
end
test 'safe mode level set using integer' do
- doc = empty_document :safe => 10
+ doc = empty_document safe: 10
assert_equal Asciidoctor::SafeMode::SERVER, doc.safe
- doc = empty_document :safe => 100
+ doc = empty_document safe: 100
assert_equal 100, doc.safe
end
@@ -63,7 +63,7 @@ context 'Document' do
end
test 'safe mode level can be set in the constructor' do
- doc = Asciidoctor::Document.new [], :safe => Asciidoctor::SafeMode::SAFE
+ doc = Asciidoctor::Document.new [], safe: Asciidoctor::SafeMode::SAFE
assert_equal Asciidoctor::SafeMode::SAFE, doc.safe
end
@@ -77,7 +77,7 @@ context 'Document' do
end
test 'toc and sectnums should be enabled by default for DocBook backend' do
- doc = document_from_string 'content', :backend => 'docbook', :parse => true
+ doc = document_from_string 'content', backend: 'docbook', parse: true
assert doc.attr?('toc')
assert doc.attr?('sectnums')
result = doc.convert
@@ -86,7 +86,7 @@ context 'Document' do
end
test 'maxdepth attribute should be set on asciidoc-toc and asciidoc-numbered processing instructions in DocBook backend' do
- doc = document_from_string 'content', :backend => 'docbook', :parse => true, :attributes => {'toclevels' => '1', 'sectnumlevels' => '1' }
+ doc = document_from_string 'content', backend: 'docbook', parse: true, attributes: { 'toclevels' => '1', 'sectnumlevels' => '1' }
assert doc.attr?('toc')
assert doc.attr?('sectnums')
result = doc.convert
@@ -100,7 +100,7 @@ context 'Document' do
:toc!:
:sectnums!:
EOS
- doc = document_from_string input, :backend => 'docbook'
+ doc = document_from_string input, backend: 'docbook'
refute doc.attr?('toc')
refute doc.attr?('sectnums')
end
@@ -112,7 +112,7 @@ context 'Document' do
content
EOS
- result = convert_string input, :backend => 'docbook'
+ result = convert_string input, backend: 'docbook'
assert_xpath '/article', result, 1
assert_xpath '/article/info', result, 0
end
@@ -122,7 +122,7 @@ content
= Document Title
:numbered!:
EOS
- doc = document_from_string input, :backend => 'docbook'
+ doc = document_from_string input, backend: 'docbook'
refute doc.attr?('sectnums')
end
end
@@ -132,23 +132,23 @@ content
sample_input_path = fixture_path('basic.asciidoc')
cases = {
- 'docinfo' => { :head_script => 1, :meta => 0, :top_link => 0, :footer_script => 1 },
- 'docinfo=private' => { :head_script => 1, :meta => 0, :top_link => 0, :footer_script => 1 },
- 'docinfo1' => { :head_script => 0, :meta => 1, :top_link => 1, :footer_script => 0 },
- 'docinfo=shared' => { :head_script => 0, :meta => 1, :top_link => 1, :footer_script => 0 },
- 'docinfo2' => { :head_script => 1, :meta => 1, :top_link => 1, :footer_script => 1 },
- 'docinfo docinfo2' => { :head_script => 1, :meta => 1, :top_link => 1, :footer_script => 1 },
- 'docinfo=private,shared' => { :head_script => 1, :meta => 1, :top_link => 1, :footer_script => 1 },
- 'docinfo=private-head' => { :head_script => 1, :meta => 0, :top_link => 0, :footer_script => 0 },
- 'docinfo=shared-head' => { :head_script => 0, :meta => 1, :top_link => 0, :footer_script => 0 },
- 'docinfo=private-footer' => { :head_script => 0, :meta => 0, :top_link => 0, :footer_script => 1 },
- 'docinfo=shared-footer' => { :head_script => 0, :meta => 0, :top_link => 1, :footer_script => 0 },
- 'docinfo=private-head\ ,\ shared-footer' => { :head_script => 1, :meta => 0, :top_link => 1, :footer_script => 0 }
+ 'docinfo' => { head_script: 1, meta: 0, top_link: 0, footer_script: 1 },
+ 'docinfo=private' => { head_script: 1, meta: 0, top_link: 0, footer_script: 1 },
+ 'docinfo1' => { head_script: 0, meta: 1, top_link: 1, footer_script: 0 },
+ 'docinfo=shared' => { head_script: 0, meta: 1, top_link: 1, footer_script: 0 },
+ 'docinfo2' => { head_script: 1, meta: 1, top_link: 1, footer_script: 1 },
+ 'docinfo docinfo2' => { head_script: 1, meta: 1, top_link: 1, footer_script: 1 },
+ 'docinfo=private,shared' => { head_script: 1, meta: 1, top_link: 1, footer_script: 1 },
+ 'docinfo=private-head' => { head_script: 1, meta: 0, top_link: 0, footer_script: 0 },
+ 'docinfo=shared-head' => { head_script: 0, meta: 1, top_link: 0, footer_script: 0 },
+ 'docinfo=private-footer' => { head_script: 0, meta: 0, top_link: 0, footer_script: 1 },
+ 'docinfo=shared-footer' => { head_script: 0, meta: 0, top_link: 1, footer_script: 0 },
+ 'docinfo=private-head\ ,\ shared-footer' => { head_script: 1, meta: 0, top_link: 1, footer_script: 0 },
}
cases.each do |attr_val, markup|
- output = Asciidoctor.convert_file sample_input_path, :to_file => false,
- :header_footer => true, :safe => Asciidoctor::SafeMode::SERVER, :attributes => %(linkcss copycss! #{attr_val})
+ output = Asciidoctor.convert_file sample_input_path, to_file: false,
+ header_footer: true, safe: Asciidoctor::SafeMode::SERVER, attributes: %(linkcss copycss! #{attr_val})
refute_empty output
assert_css 'script[src="modernizr.js"]', output, markup[:head_script]
assert_css 'meta[http-equiv="imagetoolbar"]', output, markup[:meta]
@@ -159,8 +159,8 @@ content
test 'should include docinfo footer even if nofooter attribute is set' do
sample_input_path = fixture_path('basic.asciidoc')
- output = Asciidoctor.convert_file sample_input_path, :to_file => false,
- :header_footer => true, :safe => Asciidoctor::SafeMode::SERVER, :attributes => {'docinfo1' => '', 'nofooter' => ''}
+ output = Asciidoctor.convert_file sample_input_path, to_file: false,
+ header_footer: true, safe: Asciidoctor::SafeMode::SERVER, attributes: { 'docinfo1' => '', 'nofooter' => '' }
refute_empty output
assert_css 'body > a#top', output, 1
end
@@ -168,26 +168,26 @@ content
test 'should include docinfo files for html backend with custom docinfodir' do
sample_input_path = fixture_path('basic.asciidoc')
- output = Asciidoctor.convert_file sample_input_path, :to_file => false,
- :header_footer => true, :safe => Asciidoctor::SafeMode::SERVER, :attributes => {'docinfo' => '', 'docinfodir' => 'custom-docinfodir'}
+ output = Asciidoctor.convert_file sample_input_path, to_file: false,
+ header_footer: true, safe: Asciidoctor::SafeMode::SERVER, attributes: { 'docinfo' => '', 'docinfodir' => 'custom-docinfodir' }
refute_empty output
assert_css 'script[src="bootstrap.js"]', output, 1
assert_css 'meta[name="robots"]', output, 0
- output = Asciidoctor.convert_file sample_input_path, :to_file => false,
- :header_footer => true, :safe => Asciidoctor::SafeMode::SERVER, :attributes => {'docinfo1' => '', 'docinfodir' => 'custom-docinfodir'}
+ output = Asciidoctor.convert_file sample_input_path, to_file: false,
+ header_footer: true, safe: Asciidoctor::SafeMode::SERVER, attributes: { 'docinfo1' => '', 'docinfodir' => 'custom-docinfodir' }
refute_empty output
assert_css 'script[src="bootstrap.js"]', output, 0
assert_css 'meta[name="robots"]', output, 1
- output = Asciidoctor.convert_file sample_input_path, :to_file => false,
- :header_footer => true, :safe => Asciidoctor::SafeMode::SERVER, :attributes => {'docinfo2' => '', 'docinfodir' => './custom-docinfodir'}
+ output = Asciidoctor.convert_file sample_input_path, to_file: false,
+ header_footer: true, safe: Asciidoctor::SafeMode::SERVER, attributes: { 'docinfo2' => '', 'docinfodir' => './custom-docinfodir' }
refute_empty output
assert_css 'script[src="bootstrap.js"]', output, 1
assert_css 'meta[name="robots"]', output, 1
- output = Asciidoctor.convert_file sample_input_path, :to_file => false,
- :header_footer => true, :safe => Asciidoctor::SafeMode::SERVER, :attributes => {'docinfo2' => '', 'docinfodir' => 'custom-docinfodir/subfolder'}
+ output = Asciidoctor.convert_file sample_input_path, to_file: false,
+ header_footer: true, safe: Asciidoctor::SafeMode::SERVER, attributes: { 'docinfo2' => '', 'docinfodir' => 'custom-docinfodir/subfolder' }
refute_empty output
assert_css 'script[src="bootstrap.js"]', output, 0
assert_css 'meta[name="robots"]', output, 0
@@ -196,14 +196,14 @@ content
test 'should include docinfo files for docbook backend' do
sample_input_path = fixture_path('basic.asciidoc')
- output = Asciidoctor.convert_file sample_input_path, :to_file => false,
- :header_footer => true, :backend => 'docbook', :safe => Asciidoctor::SafeMode::SERVER, :attributes => {'docinfo' => ''}
+ output = Asciidoctor.convert_file sample_input_path, to_file: false,
+ header_footer: true, backend: 'docbook', safe: Asciidoctor::SafeMode::SERVER, attributes: { 'docinfo' => '' }
refute_empty output
assert_css 'productname', output, 0
assert_css 'copyright', output, 1
- output = Asciidoctor.convert_file sample_input_path, :to_file => false,
- :header_footer => true, :backend => 'docbook', :safe => Asciidoctor::SafeMode::SERVER, :attributes => {'docinfo1' => ''}
+ output = Asciidoctor.convert_file sample_input_path, to_file: false,
+ header_footer: true, backend: 'docbook', safe: Asciidoctor::SafeMode::SERVER, attributes: { 'docinfo1' => '' }
refute_empty output
assert_css 'productname', output, 1
assert_xpath '//xmlns:productname[text()="Asciidoctor™"]', output, 1
@@ -211,8 +211,8 @@ content
assert_xpath '//xmlns:edition[text()="1.0"]', output, 1 # verifies substitutions are performed
assert_css 'copyright', output, 0
- output = Asciidoctor.convert_file sample_input_path, :to_file => false,
- :header_footer => true, :backend => 'docbook', :safe => Asciidoctor::SafeMode::SERVER, :attributes => {'docinfo2' => ''}
+ output = Asciidoctor.convert_file sample_input_path, to_file: false,
+ header_footer: true, backend: 'docbook', safe: Asciidoctor::SafeMode::SERVER, attributes: { 'docinfo2' => '' }
refute_empty output
assert_css 'productname', output, 1
assert_xpath '//xmlns:productname[text()="Asciidoctor™"]', output, 1
@@ -224,20 +224,20 @@ content
test 'should include docinfo footer files for html backend' do
sample_input_path = fixture_path('basic.asciidoc')
- output = Asciidoctor.convert_file sample_input_path, :to_file => false,
- :header_footer => true, :safe => Asciidoctor::SafeMode::SERVER, :attributes => {'docinfo' => ''}
+ output = Asciidoctor.convert_file sample_input_path, to_file: false,
+ header_footer: true, safe: Asciidoctor::SafeMode::SERVER, attributes: { 'docinfo' => '' }
refute_empty output
assert_css 'body script', output, 1
assert_css 'a#top', output, 0
- output = Asciidoctor.convert_file sample_input_path, :to_file => false,
- :header_footer => true, :safe => Asciidoctor::SafeMode::SERVER, :attributes => {'docinfo1' => ''}
+ output = Asciidoctor.convert_file sample_input_path, to_file: false,
+ header_footer: true, safe: Asciidoctor::SafeMode::SERVER, attributes: { 'docinfo1' => '' }
refute_empty output
assert_css 'body script', output, 0
assert_css 'a#top', output, 1
- output = Asciidoctor.convert_file sample_input_path, :to_file => false,
- :header_footer => true, :safe => Asciidoctor::SafeMode::SERVER, :attributes => {'docinfo2' => ''}
+ output = Asciidoctor.convert_file sample_input_path, to_file: false,
+ header_footer: true, safe: Asciidoctor::SafeMode::SERVER, attributes: { 'docinfo2' => '' }
refute_empty output
assert_css 'body script', output, 1
assert_css 'a#top', output, 1
@@ -246,21 +246,21 @@ content
test 'should include docinfo footer files for docbook backend' do
sample_input_path = fixture_path('basic.asciidoc')
- output = Asciidoctor.convert_file sample_input_path, :to_file => false,
- :header_footer => true, :backend => 'docbook', :safe => Asciidoctor::SafeMode::SERVER, :attributes => {'docinfo' => ''}
+ output = Asciidoctor.convert_file sample_input_path, to_file: false,
+ header_footer: true, backend: 'docbook', safe: Asciidoctor::SafeMode::SERVER, attributes: { 'docinfo' => '' }
refute_empty output
assert_css 'article > revhistory', output, 1
assert_xpath '/xmlns:article/xmlns:revhistory/xmlns:revision/xmlns:revnumber[text()="1.0"]', output, 1 # verifies substitutions are performed
assert_css 'glossary#_glossary', output, 0
- output = Asciidoctor.convert_file sample_input_path, :to_file => false,
- :header_footer => true, :backend => 'docbook', :safe => Asciidoctor::SafeMode::SERVER, :attributes => {'docinfo1' => ''}
+ output = Asciidoctor.convert_file sample_input_path, to_file: false,
+ header_footer: true, backend: 'docbook', safe: Asciidoctor::SafeMode::SERVER, attributes: { 'docinfo1' => '' }
refute_empty output
assert_css 'article > revhistory', output, 0
assert_css 'glossary#_glossary', output, 1
- output = Asciidoctor.convert_file sample_input_path, :to_file => false,
- :header_footer => true, :backend => 'docbook', :safe => Asciidoctor::SafeMode::SERVER, :attributes => {'docinfo2' => ''}
+ output = Asciidoctor.convert_file sample_input_path, to_file: false,
+ header_footer: true, backend: 'docbook', safe: Asciidoctor::SafeMode::SERVER, attributes: { 'docinfo2' => '' }
refute_empty output
assert_css 'article > revhistory', output, 1
assert_xpath '/xmlns:article/xmlns:revhistory/xmlns:revision/xmlns:revnumber[text()="1.0"]', output, 1 # verifies substitutions are performed
@@ -276,8 +276,8 @@ content
$VERBOSE = nil # disable warnings since we have to modify constants
Encoding.default_external = Encoding.default_internal = Encoding::IBM437
sample_input_path = fixture_path('basic.asciidoc')
- output = Asciidoctor.convert_file sample_input_path, :to_file => false, :header_footer => true,
- :backend => 'docbook', :safe => Asciidoctor::SafeMode::SERVER, :attributes => { 'docinfo' => 'private,shared' }
+ output = Asciidoctor.convert_file sample_input_path, to_file: false, header_footer: true,
+ backend: 'docbook', safe: Asciidoctor::SafeMode::SERVER, attributes: { 'docinfo' => 'private,shared' }
refute_empty output
assert_css 'productname', output, 1
assert_includes output, '<productname>Asciidoctor™</productname>'
@@ -294,14 +294,14 @@ content
test 'should not include docinfo files by default' do
sample_input_path = fixture_path('basic.asciidoc')
- output = Asciidoctor.convert_file sample_input_path, :to_file => false,
- :header_footer => true, :safe => Asciidoctor::SafeMode::SERVER
+ output = Asciidoctor.convert_file sample_input_path, to_file: false,
+ header_footer: true, safe: Asciidoctor::SafeMode::SERVER
refute_empty output
assert_css 'script[src="modernizr.js"]', output, 0
assert_css 'meta[http-equiv="imagetoolbar"]', output, 0
- output = Asciidoctor.convert_file sample_input_path, :to_file => false,
- :header_footer => true, :backend => 'docbook', :safe => Asciidoctor::SafeMode::SERVER
+ output = Asciidoctor.convert_file sample_input_path, to_file: false,
+ header_footer: true, backend: 'docbook', safe: Asciidoctor::SafeMode::SERVER
refute_empty output
assert_css 'productname', output, 0
assert_css 'copyright', output, 0
@@ -310,14 +310,14 @@ content
test 'should not include docinfo files if safe mode is SECURE or greater' do
sample_input_path = fixture_path('basic.asciidoc')
- output = Asciidoctor.convert_file sample_input_path, :to_file => false,
- :header_footer => true, :attributes => {'docinfo2' => ''}
+ output = Asciidoctor.convert_file sample_input_path, to_file: false,
+ header_footer: true, attributes: { 'docinfo2' => '' }
refute_empty output
assert_css 'script[src="modernizr.js"]', output, 0
assert_css 'meta[http-equiv="imagetoolbar"]', output, 0
- output = Asciidoctor.convert_file sample_input_path, :to_file => false,
- :header_footer => true, :backend => 'docbook', :attributes => {'docinfo2' => ''}
+ output = Asciidoctor.convert_file sample_input_path, to_file: false,
+ header_footer: true, backend: 'docbook', attributes: { 'docinfo2' => '' }
refute_empty output
assert_css 'productname', output, 0
assert_css 'copyright', output, 0
@@ -327,10 +327,10 @@ content
sample_input_path = fixture_path 'subs.adoc'
using_memory_logger do |logger|
output = Asciidoctor.convert_file sample_input_path,
- :to_file => false,
- :header_footer => true,
- :safe => :server,
- :attributes => { 'docinfo' => '', 'bootstrap-version' => nil, 'linkcss' => '', 'attribute-missing' => 'drop-line' }
+ to_file: false,
+ header_footer: true,
+ safe: :server,
+ attributes: { 'docinfo' => '', 'bootstrap-version' => nil, 'linkcss' => '', 'attribute-missing' => 'drop-line' }
refute_empty output
assert_css 'script', output, 0
assert_xpath %(//meta[@name="copyright"][@content="(C) OpenDevise"]), output, 1
@@ -341,10 +341,10 @@ content
test 'should apply explicit substitutions to docinfo files' do
sample_input_path = fixture_path 'subs.adoc'
output = Asciidoctor.convert_file sample_input_path,
- :to_file => false,
- :header_footer => true,
- :safe => :server,
- :attributes => { 'docinfo' => '', 'docinfosubs' => 'attributes,replacements', 'linkcss' => '' }
+ to_file: false,
+ header_footer: true,
+ safe: :server,
+ attributes: { 'docinfo' => '', 'docinfosubs' => 'attributes,replacements', 'linkcss' => '' }
refute_empty output
assert_css 'script[src="bootstrap.3.2.0.min.js"]', output, 1
assert_xpath %(//meta[@name="copyright"][@content="#{decode_char 169} OpenDevise"]), output, 1
@@ -353,7 +353,7 @@ content
context 'MathJax' do
test 'should add MathJax script to HTML head if stem attribute is set' do
- output = convert_string '', :attributes => {'stem' => ''}
+ output = convert_string '', attributes: { 'stem' => '' }
assert_match('<script type="text/x-mathjax-config">', output)
assert_match('inlineMath: [["\\\\(", "\\\\)"]]', output)
assert_match('displayMath: [["\\\\[", "\\\\]"]]', output)
@@ -376,7 +376,7 @@ content
end
test 'built-in DocBook45 views are registered when backend is docbook45' do
- doc = document_from_string '', :attributes => {'backend' => 'docbook45'}
+ doc = document_from_string '', attributes: { 'backend' => 'docbook45' }
converter = doc.converter
assert_equal 'docbook45', doc.attributes['backend']
assert doc.attributes.has_key? 'backend-docbook45'
@@ -390,7 +390,7 @@ content
end
test 'built-in DocBook5 views are registered when backend is docbook5' do
- doc = document_from_string '', :attributes => {'backend' => 'docbook5'}
+ doc = document_from_string '', attributes: { 'backend' => 'docbook5' }
converter = doc.converter
assert_equal 'docbook5', doc.attributes['backend']
assert doc.attributes.has_key? 'backend-docbook5'
@@ -407,9 +407,9 @@ content
{
'' => %w(favicon.ico image/x-icon),
'/favicon.ico' => %w(/favicon.ico image/x-icon),
- '/img/favicon.png' => %w(/img/favicon.png image/png)
+ '/img/favicon.png' => %w(/img/favicon.png image/png),
}.each {|val, (href, type)|
- result = convert_string %(= Untitled), :attributes => { 'favicon' => val }
+ result = convert_string '= Untitled', attributes: { 'favicon' => val }
assert_css 'link[rel="icon"]', result, 1
assert_css %(link[rel="icon"][href="#{href}"]), result, 1
assert_css %(link[rel="icon"][type="#{type}"]), result, 1
@@ -463,7 +463,7 @@ Document Title
+content+
EOS
- doc = document_from_string input, :attributes => { 'compat-mode' => nil }
+ doc = document_from_string input, attributes: { 'compat-mode' => nil }
assert(doc.attribute_locked? 'compat-mode')
assert_nil(doc.attr 'compat-mode')
result = doc.convert
@@ -477,7 +477,7 @@ Document Title
end
test 'title partition API with custom separator' do
- title = Asciidoctor::Document::Title.new 'Main Title:: And More:: Subtitle', :separator => '::'
+ title = Asciidoctor::Document::Title.new 'Main Title:: And More:: Subtitle', separator: '::'
assert_equal 'Main Title:: And More', title.main
assert_equal 'Subtitle', title.subtitle
end
@@ -491,7 +491,7 @@ content
EOS
doc = document_from_string input
- title = doc.doctitle :partition => true, :sanitize => true
+ title = doc.doctitle partition: true, sanitize: true
assert title.subtitle?
assert title.sanitized?
assert_equal 'Main Title', title.main
@@ -508,7 +508,7 @@ content
EOS
doc = document_from_string input
- title = doc.doctitle :partition => true, :sanitize => true
+ title = doc.doctitle partition: true, sanitize: true
assert title.subtitle?
assert title.sanitized?
assert_equal 'Main Title', title.main
@@ -524,8 +524,8 @@ Author Name
content
EOS
- doc = document_from_string input, :attributes => { 'title-separator' => ' -' }
- title = doc.doctitle :partition => true, :sanitize => true
+ doc = document_from_string input, attributes: { 'title-separator' => ' -' }
+ title = doc.doctitle partition: true, sanitize: true
assert title.subtitle?
assert title.sanitized?
assert_equal 'Main Title', title.main
@@ -668,7 +668,7 @@ preamble
text
EOS
- output = convert_string input, :safe => Asciidoctor::SafeMode::SAFE
+ output = convert_string input, safe: Asciidoctor::SafeMode::SAFE
assert_css '#header h1', output, 1
assert_css '#content h1', output, 0
end
@@ -759,7 +759,7 @@ Author Name
content
EOS
- output = convert_string input, :backend => 'docbook'
+ output = convert_string input, backend: 'docbook'
assert_css 'revhistory', output, 1
assert_css 'revhistory > revision', output, 1
assert_css 'revhistory > revision > date', output, 1
@@ -776,7 +776,7 @@ Author Name
content
EOS
- output = convert_string input, :backend => 'docbook'
+ output = convert_string input, backend: 'docbook'
assert_css 'revhistory', output, 1
assert_css 'revhistory > revision', output, 1
assert_css 'revhistory > revision > date', output, 1
@@ -792,7 +792,7 @@ Author Name
content
EOS
- output = convert_string input, :backend => 'docbook'
+ output = convert_string input, backend: 'docbook'
assert_css 'revhistory', output, 0
end
@@ -806,7 +806,7 @@ v8.6.8, 2012-07-12: See changelog.
more info...
EOS
- output = convert_string input, :backend => 'docbook45'
+ output = convert_string input, backend: 'docbook45'
assert_xpath '/article/articleinfo', output, 1
assert_xpath '/article/articleinfo/title[text() = "AsciiDoc"]', output, 1
assert_xpath '/article/articleinfo/date[text() = "2012-07-12"]', output, 1
@@ -830,7 +830,7 @@ Stuart Rackham <founder@asciidoc.org>
more info...
EOS
- output = convert_string input, :backend => 'docbook5'
+ output = convert_string input, backend: 'docbook5'
assert_xpath '/article/info', output, 1
assert_xpath '/article/info/title[text() = "AsciiDoc"]', output, 1
assert_xpath '/article/info/author/personname', output, 1
@@ -848,7 +848,7 @@ more info...
content
EOS
- output = convert_string input, :backend => 'docbook45'
+ output = convert_string input, backend: 'docbook45'
assert_xpath '//articleinfo/author', output, 1
assert_xpath '//articleinfo/author/firstname[text() = "Doc"]', output, 1
assert_xpath '//articleinfo/author/surname[text() = "Writer"]', output, 1
@@ -909,7 +909,7 @@ Doc Writer <thedoctor@asciidoc.org>; Junior Writer <junior@asciidoctor.org>
content
EOS
- output = convert_string input, :backend => 'docbook45'
+ output = convert_string input, backend: 'docbook45'
assert_xpath '//articleinfo/author', output, 0
assert_xpath '//articleinfo/authorgroup', output, 1
assert_xpath '//articleinfo/authorgroup/author', output, 2
@@ -940,7 +940,7 @@ content
content
EOS
- output = convert_string input, :backend => 'docbook45'
+ output = convert_string input, backend: 'docbook45'
assert_xpath '//articleinfo/author', output, 0
assert_xpath '//articleinfo/authorgroup', output, 1
assert_xpath '//articleinfo/authorgroup/author', output, 2
@@ -957,7 +957,7 @@ content
Essential for catching road runners.
EOS
- output = convert_string input, :backend => 'docbook5'
+ output = convert_string input, backend: 'docbook5'
assert_xpath '/article/info/copyright', output, 1
assert_xpath '/article/info/copyright/holder[text()="ACME, Inc."]', output, 1
end
@@ -969,7 +969,7 @@ Essential for catching road runners.
Essential for catching road runners.
EOS
- output = convert_string input, :backend => 'docbook5'
+ output = convert_string input, backend: 'docbook5'
assert_xpath '/article/info/copyright', output, 1
assert_xpath '/article/info/copyright/holder[text()="ACME, Inc."]', output, 1
assert_xpath '/article/info/copyright/year', output, 1
@@ -983,7 +983,7 @@ Essential for catching road runners.
Essential for catching road runners.
EOS
- output = convert_string input, :backend => 'docbook5'
+ output = convert_string input, backend: 'docbook5'
assert_xpath '/article/info/copyright', output, 1
assert_xpath '/article/info/copyright/holder[text()="ACME, Inc."]', output, 1
assert_xpath '/article/info/copyright/year', output, 1
@@ -1013,14 +1013,14 @@ content
end
test 'can disable last updated in footer' do
- doc = document_from_string "= Document Title\n\npreamble", :attributes => {'last-update-label!' => ''}
+ doc = document_from_string "= Document Title\n\npreamble", attributes: { 'last-update-label!' => '' }
result = doc.convert
assert_xpath '//*[@id="footer-text"]', result, 1
assert_xpath '//*[@id="footer-text"][normalize-space(text())=""]', result, 1
end
test 'no header footer' do
- doc = document_from_string "= Document Title\n\ncontent", :header_footer => false
+ doc = document_from_string "= Document Title\n\ncontent", header_footer: false
assert doc.attr?('embedded')
result = doc.convert
assert_xpath '/html', result, 0
@@ -1037,7 +1037,7 @@ content
content
EOS
- result = convert_string_to_embedded input, :attributes => {'notitle!' => ''}
+ result = convert_string_to_embedded input, attributes: { 'notitle!' => '' }
assert_xpath '/html', result, 0
assert_xpath '/h1', result, 1
assert_xpath '/*[@id="header"]', result, 0
@@ -1054,7 +1054,7 @@ content
content
EOS
- result = convert_string_to_embedded input, :attributes => {'showtitle' => ''}
+ result = convert_string_to_embedded input, attributes: { 'showtitle' => '' }
assert_xpath '/html', result, 0
assert_xpath '/h1', result, 1
assert_xpath '/*[@id="header"]', result, 0
@@ -1073,7 +1073,7 @@ Author Name
preamble
EOS
- doc = document_from_string input, :parse_header_only => true
+ doc = document_from_string input, parse_header_only: true
assert_equal 'Document Title', doc.doctitle
assert_equal 'Author Name', doc.author
assert_equal 'bar', doc.attributes['foo']
@@ -1120,7 +1120,7 @@ Text that has supporting information{empty}footnote:[An example footnote.].
Text that has supporting information{empty}footnote:[An example footnote.].
EOS
- output = convert_string_to_embedded input, :attributes => {'nofootnotes' => ''}
+ output = convert_string_to_embedded input, attributes: { 'nofootnotes' => '' }
assert_css '#footnotes', output, 0
end
end
@@ -1158,7 +1158,7 @@ image::inner.png[]
|===
EOS
- doc = document_from_string input, :catalog_assets => true
+ doc = document_from_string input, catalog_assets: true
images = doc.catalog[:images]
refute_empty images
assert_equal 2, images.size
@@ -1168,7 +1168,7 @@ image::inner.png[]
context 'Backends and Doctypes' do
test 'html5 backend doctype article' do
- result = convert_string("= Title\n\nparagraph", :attributes => {'backend' => 'html5'})
+ result = convert_string("= Title\n\nparagraph", attributes: { 'backend' => 'html5' })
assert_xpath '/html', result, 1
assert_xpath '/html/body[@class="article"]', result, 1
assert_xpath '/html//*[@id="header"]/h1[text() = "Title"]', result, 1
@@ -1176,7 +1176,7 @@ image::inner.png[]
end
test 'html5 backend doctype book' do
- result = convert_string("= Title\n\nparagraph", :attributes => {'backend' => 'html5', 'doctype' => 'book'})
+ result = convert_string("= Title\n\nparagraph", attributes: { 'backend' => 'html5', 'doctype' => 'book' })
assert_xpath '/html', result, 1
assert_xpath '/html/body[@class="book"]', result, 1
assert_xpath '/html//*[@id="header"]/h1[text() = "Title"]', result, 1
@@ -1187,7 +1187,7 @@ image::inner.png[]
input = <<-EOS
content
EOS
- doc = document_from_string input, :backend => :xhtml5
+ doc = document_from_string input, backend: :xhtml5
assert_equal 'html5', doc.backend
assert_equal 'xml', (doc.attr 'htmlsyntax')
end
@@ -1196,7 +1196,7 @@ content
input = <<-EOS
content
EOS
- doc = document_from_string input, :backend => :xhtml
+ doc = document_from_string input, backend: :xhtml
assert_equal 'html5', doc.backend
assert_equal 'xml', (doc.attr 'htmlsyntax')
end
@@ -1205,10 +1205,10 @@ content
input = <<-EOS
---
EOS
- doc = document_from_string input, :safe => :safe, :attributes => { 'htmlsyntax' => 'xml' }
+ doc = document_from_string input, safe: :safe, attributes: { 'htmlsyntax' => 'xml' }
assert_equal 'html5', doc.backend
assert_equal 'xml', (doc.attr 'htmlsyntax')
- result = doc.convert :header_footer => false
+ result = doc.convert header_footer: false
assert_equal '<hr/>', result
end
@@ -1219,10 +1219,10 @@ content
---
EOS
- doc = document_from_string input, :safe => :safe
+ doc = document_from_string input, safe: :safe
assert_equal 'html5', doc.backend
assert_equal 'xml', (doc.attr 'htmlsyntax')
- result = doc.convert :header_footer => false
+ result = doc.convert header_footer: false
assert_equal '<hr/>', result
end
@@ -1233,7 +1233,7 @@ content
---
EOS
- result = convert_string_to_embedded input, :safe => :safe
+ result = convert_string_to_embedded input, safe: :safe
assert_equal '<hr>', result
end
@@ -1284,7 +1284,7 @@ two
'''
EOS
- result = convert_string input, :safe => :safe, :backend => :xhtml
+ result = convert_string input, safe: :safe, backend: :xhtml
begin
Nokogiri::XML::Document.parse(result) {|config|
config.options = Nokogiri::XML::ParseOptions::STRICT | Nokogiri::XML::ParseOptions::NONET
@@ -1298,7 +1298,7 @@ two
input = <<-EOS
content
EOS
- result = convert_string input, :safe => :safe, :backend => :xhtml, :keep_namespaces => true
+ result = convert_string input, safe: :safe, backend: :xhtml, keep_namespaces: true
assert_xpath '//*[not(namespace-uri() = "http://www.w3.org/1999/xhtml")]', result, 0
end
@@ -1312,7 +1312,7 @@ preamble
section body
EOS
- result = convert_string(input, :attributes => {'backend' => 'docbook45'})
+ result = convert_string(input, attributes: { 'backend' => 'docbook45' })
assert_xpath '/article', result, 1
assert_xpath '/article/articleinfo/title[text() = "Title"]', result, 1
assert_xpath '/article/simpara[text() = "preamble"]', result, 1
@@ -1322,14 +1322,14 @@ section body
end
test 'docbook45 backend doctype article no title' do
- result = convert_string('text', :attributes => {'backend' => 'docbook45'})
+ result = convert_string('text', attributes: { 'backend' => 'docbook45' })
assert_xpath '/article', result, 1
assert_xpath '/article/articleinfo/date', result, 1
assert_xpath '/article/simpara[text() = "text"]', result, 1
end
test 'docbook45 backend doctype article no xmlns' do
- result = convert_string('text', :keep_namespaces => true, :attributes => {'backend' => 'docbook45', 'doctype' => 'article'})
+ result = convert_string('text', keep_namespaces: true, attributes: { 'backend' => 'docbook45', 'doctype' => 'article' })
refute_match(RE_XMLNS_ATTRIBUTE, result)
end
@@ -1349,7 +1349,7 @@ some text
section body
EOS
- result = convert_string(input, :attributes => {'backend' => 'docbook45', 'doctype' => 'manpage'})
+ result = convert_string(input, attributes: { 'backend' => 'docbook45', 'doctype' => 'manpage' })
assert_xpath '/refentry', result, 1
assert_xpath '/refentry/refentryinfo/title[text() = "asciidoctor(1)"]', result, 1
assert_xpath '/refentry/refmeta/refentrytitle[text() = "asciidoctor"]', result, 1
@@ -1373,7 +1373,7 @@ preamble
chapter body
EOS
- result = convert_string(input, :attributes => {'backend' => 'docbook45', 'doctype' => 'book'})
+ result = convert_string(input, attributes: { 'backend' => 'docbook45', 'doctype' => 'book' })
assert_xpath '/book', result, 1
assert_xpath '/book/bookinfo/title[text() = "Title"]', result, 1
assert_xpath '/book/preface/simpara[text() = "preamble"]', result, 1
@@ -1383,7 +1383,7 @@ chapter body
end
test 'docbook45 backend doctype book no title' do
- result = convert_string('text', :attributes => {'backend' => 'docbook45', 'doctype' => 'book'})
+ result = convert_string('text', attributes: { 'backend' => 'docbook45', 'doctype' => 'book' })
assert_xpath '/book', result, 1
assert_xpath '/book/bookinfo/date', result, 1
# NOTE simpara cannot be a direct child of book, so content must be treated as a preface
@@ -1391,7 +1391,7 @@ chapter body
end
test 'docbook45 backend doctype book no xmlns' do
- result = convert_string('text', :keep_namespaces => true, :attributes => {'backend' => 'docbook45', 'doctype' => 'book'})
+ result = convert_string('text', keep_namespaces: true, attributes: { 'backend' => 'docbook45', 'doctype' => 'book' })
refute_match(RE_XMLNS_ATTRIBUTE, result)
end
@@ -1402,7 +1402,7 @@ chapter body
text
EOS
- result = convert_string input, :backend => 'docbook45'
+ result = convert_string input, backend: 'docbook45'
assert_xpath '/book', result, 1
assert_xpath '/book/bookinfo/title[text() = "Document Title"]', result, 1
assert_xpath '/book/bookinfo/subtitle[text() = "Subtitle"]', result, 1
@@ -1419,7 +1419,7 @@ preamble
section body
EOS
- result = convert_string(input, :keep_namespaces => true, :attributes => {'backend' => 'docbook5'})
+ result = convert_string(input, keep_namespaces: true, attributes: { 'backend' => 'docbook5' })
assert_xpath '/xmlns:article', result, 1
doc = xmlnodes_at_xpath('/xmlns:article', result, 1)
assert_equal 'http://docbook.org/ns/docbook', doc.namespaces['xmlns']
@@ -1455,7 +1455,7 @@ some text
section body
EOS
- result = convert_string(input, :keep_namespaces => true, :attributes => {'backend' => 'docbook5', 'doctype' => 'manpage'})
+ result = convert_string(input, keep_namespaces: true, attributes: { 'backend' => 'docbook5', 'doctype' => 'manpage' })
assert_xpath '/xmlns:refentry', result, 1
doc = xmlnodes_at_xpath('/xmlns:refentry', result, 1)
assert_equal 'http://docbook.org/ns/docbook', doc.namespaces['xmlns']
@@ -1492,7 +1492,7 @@ asciidoctor - Process text
some text
EOS
- result = convert_string(input, :keep_namespaces => true, :attributes => {'backend' => 'docbook5', 'doctype' => 'manpage'})
+ result = convert_string(input, keep_namespaces: true, attributes: { 'backend' => 'docbook5', 'doctype' => 'manpage' })
assert_xpath %(/xmlns:refentry/xmlns:refmeta/xmlns:refmiscinfo[@class="source"][text() = "#{decode_char 160}"]), result, 1
assert_xpath %(/xmlns:refentry/xmlns:refmeta/xmlns:refmiscinfo[@class="manual"][text() = "#{decode_char 160}"]), result, 1
end
@@ -1508,7 +1508,7 @@ preamble
chapter body
EOS
- result = convert_string(input, :keep_namespaces => true, :attributes => {'backend' => 'docbook5', 'doctype' => 'book'})
+ result = convert_string(input, keep_namespaces: true, attributes: { 'backend' => 'docbook5', 'doctype' => 'book' })
assert_xpath '/xmlns:book', result, 1
doc = xmlnodes_at_xpath('/xmlns:book', result, 1)
assert_equal 'http://docbook.org/ns/docbook', doc.namespaces['xmlns']
@@ -1544,7 +1544,7 @@ eve, islifeform - analyzes an image to determine if it's a picture of a life for
*eve* ['OPTION']... 'FILE'...
EOS
- result = convert_string input, :backend => 'docbook5'
+ result = convert_string input, backend: 'docbook5'
assert_xpath '/refentry/refnamediv/refname', result, 2
assert_xpath '(/refentry/refnamediv/refname)[1][text()="eve"]', result, 1
assert_xpath '(/refentry/refnamediv/refname)[2][text()="islifeform"]', result, 1
@@ -1565,7 +1565,7 @@ preamble
chapter body
EOS
- result = convert_string input, :attributes => {'backend' => 'docbook5'}
+ result = convert_string input, attributes: { 'backend' => 'docbook5' }
assert_xpath '//info/cover[@role="front"]', result, 1
assert_xpath '//info/cover[@role="front"]//imagedata[@fileref="images/front-cover.jpg"]', result, 1
assert_xpath '//info/cover[@role="back"]', result, 1
@@ -1573,22 +1573,22 @@ chapter body
end
test 'should be able to set backend using :backend option key' do
- doc = empty_document :backend => 'html5'
+ doc = empty_document backend: 'html5'
assert_equal 'html5', doc.attributes['backend']
end
test ':backend option should override backend attribute' do
- doc = empty_document :backend => 'html5', :attributes => {'backend' => 'docbook45'}
+ doc = empty_document backend: 'html5', attributes: { 'backend' => 'docbook45' }
assert_equal 'html5', doc.attributes['backend']
end
test 'should be able to set doctype using :doctype option key' do
- doc = empty_document :doctype => 'book'
+ doc = empty_document doctype: 'book'
assert_equal 'book', doc.attributes['doctype']
end
test ':doctype option should override doctype attribute' do
- doc = empty_document :doctype => 'book', :attributes => {'doctype' => 'article'}
+ doc = empty_document doctype: 'book', attributes: { 'doctype' => 'article' }
assert_equal 'book', doc.attributes['doctype']
end
@@ -1600,7 +1600,7 @@ Stuart Rackham <founder@asciidoc.org>
more info...
EOS
- output = convert_string input, :attributes => {'backend' => 'docbook45'}
+ output = convert_string input, attributes: { 'backend' => 'docbook45' }
assert_xpath '/article/articleinfo/authorinitials[text()="SJR"]', output, 1
end
@@ -1689,7 +1689,7 @@ asciidoctor - converts AsciiDoc source files to HTML, DocBook and other formats
asciidoctor - converts AsciiDoc source files to HTML, DocBook and other formats
EOS
- doc = document_from_string input, :backend => 'manpage'
+ doc = document_from_string input, backend: 'manpage'
assert_equal 'asciidoctor', doc.attributes['docname']
assert_equal '.1', doc.attributes['outfilesuffix']
end
@@ -1799,7 +1799,7 @@ asciidoctor - converts AsciiDoc source files to HTML, DocBook and other formats
text
EOS
exception = assert_raises NotImplementedError do
- Asciidoctor.convert input, :backend => 'unknownBackend'
+ Asciidoctor.convert input, backend: 'unknownBackend'
end
assert_includes exception.message, 'missing converter for backend \'unknownBackend\''
end
@@ -1813,7 +1813,7 @@ text
text
EOS
exception = assert_raises NotImplementedError do
- Asciidoctor.convert input, :backend => 'unknownBackend'
+ Asciidoctor.convert input, backend: 'unknownBackend'
end
assert_includes exception.message, 'missing converter for backend \'unknownBackend\''
end
diff --git a/test/extensions_test.rb b/test/extensions_test.rb
index c1344832..085e36e4 100644
--- a/test/extensions_test.rb
+++ b/test/extensions_test.rb
@@ -124,7 +124,7 @@ end
class SnippetMacro < Asciidoctor::Extensions::BlockMacroProcessor
def process parent, target, attributes
- create_pass_block parent, %(<script src="http://example.com/#{target}.js?_mode=#{attributes['mode']}"></script>), {}, :content_model => :raw
+ create_pass_block parent, %(<script src="http://example.com/#{target}.js?_mode=#{attributes['mode']}"></script>), {}, content_model: :raw
end
end
@@ -575,7 +575,7 @@ context 'Extensions' do
tree_processor SampleTreeProcessor
end
- doc = document_from_string %(= Document Title\n\ncontent), :extension_registry => registry
+ doc = document_from_string %(= Document Title\n\ncontent), extension_registry: registry
refute_nil doc.extensions
assert_equal 1, doc.extensions.groups.size
assert doc.extensions.tree_processors?
@@ -588,7 +588,7 @@ context 'Extensions' do
registry = Asciidoctor::Extensions.create
registry.tree_processor SampleTreeProcessor
- doc = document_from_string %(= Document Title\n\ncontent), :extension_registry => registry
+ doc = document_from_string %(= Document Title\n\ncontent), extension_registry: registry
refute_nil doc.extensions
assert_equal 0, doc.extensions.groups.size
assert doc.extensions.tree_processors?
@@ -597,7 +597,7 @@ context 'Extensions' do
end
test 'can provide extensions proc as option' do
- doc = document_from_string %(= Document Title\n\ncontent), :extensions => proc {
+ doc = document_from_string %(= Document Title\n\ncontent), extensions: proc {
tree_processor SampleTreeProcessor
}
refute_nil doc.extensions
@@ -646,7 +646,7 @@ after
end
# a custom include processor is not affected by the safe mode
- result = convert_string input, :safe => :secure
+ result = convert_string input, safe: :secure
assert_css '.paragraph > p', result, 3
assert_includes result, 'before'
assert_includes result, 'Lorem ipsum'
@@ -695,8 +695,8 @@ last line
end
end
# safe mode only required for built-in include processor
- document = empty_document :base_dir => testdir, :extension_registry => registry, :safe => :safe
- reader = Asciidoctor::PreprocessorReader.new document, input, nil, :normalize => true
+ document = empty_document base_dir: testdir, extension_registry: registry, safe: :safe
+ reader = Asciidoctor::PreprocessorReader.new document, input, nil, normalize: true
lines = []
lines << reader.read_line
assert_equal 'line after skip', lines.last
@@ -746,7 +746,7 @@ content
end
sample_doc = fixture_path 'sample.asciidoc'
- doc = Asciidoctor.load_file sample_doc, :sourcemap => true
+ doc = Asciidoctor.load_file sample_doc, sourcemap: true
assert_includes doc.convert, 'file: sample.asciidoc, lineno: 1'
ensure
Asciidoctor::Extensions.unregister_all
@@ -789,7 +789,7 @@ example block content
Asciidoctor::Extensions.register do
tree_processor do
process do |doc|
- ex = (doc.find_by :context => :example)[0]
+ ex = (doc.find_by context: :example)[0]
old_title = ex.title
ex.title = 'New block title'
end
@@ -798,7 +798,7 @@ example block content
doc = document_from_string input
assert_equal 'Old block title', old_title
- assert_equal 'New block title', (doc.find_by :context => :example)[0].title
+ assert_equal 'New block title', (doc.find_by context: :example)[0].title
ensure
Asciidoctor::Extensions.unregister_all
end
@@ -960,7 +960,7 @@ snippet::{gist-id}[mode=edit]
block_macro SnippetMacro, :snippet
end
- output = convert_string_to_embedded input, :attributes => { 'gist-id' => '12345' }
+ output = convert_string_to_embedded input, attributes: { 'gist-id' => '12345' }
assert_includes output, '<script src="http://example.com/12345.js?_mode=edit"></script>'
ensure
Asciidoctor::Extensions.unregister_all
@@ -982,7 +982,7 @@ following paragraph
doc, output = nil, nil
using_memory_logger do |logger|
- doc = document_from_string input, :attributes => { 'attribute-missing' => 'drop-line' }
+ doc = document_from_string input, attributes: { 'attribute-missing' => 'drop-line' }
assert_equal 1, doc.blocks.size
assert_equal :paragraph, doc.blocks[0].context
output = doc.convert
@@ -1031,7 +1031,7 @@ custom-toc::[]
named 'custom-toc'
process do |parent, target, attrs|
resolved_target = target
- create_pass_block parent, '<!-- custom toc goes here -->', {}, :content_model => :raw
+ create_pass_block parent, '<!-- custom toc goes here -->', {}, content_model: :raw
end
end
end
@@ -1104,10 +1104,10 @@ header_attribute::foo[bar]
inline_macro TemperatureMacro, :deg
end
- output = convert_string_to_embedded 'Room temperature is deg:25[C,precision=0].', :attributes => { 'temperature-unit' => 'F' }
+ output = convert_string_to_embedded 'Room temperature is deg:25[C,precision=0].', attributes: { 'temperature-unit' => 'F' }
assert_includes output, 'Room temperature is 25 &#176;C.'
- output = convert_string_to_embedded 'Normal body temperature is deg:37[].', :attributes => { 'temperature-unit' => 'F' }
+ output = convert_string_to_embedded 'Normal body temperature is deg:37[].', attributes: { 'temperature-unit' => 'F' }
assert_includes output, 'Normal body temperature is 98.6 &#176;F.'
ensure
Asciidoctor::Extensions.unregister_all
@@ -1223,7 +1223,7 @@ target="target", attributes=[]
if (text = attrs['text']).empty?
text = %(@#{target})
end
- create_anchor parent, text, :type => :link, :target => %(https://github.com/#{target})
+ create_anchor parent, text, type: :link, target: %(https://github.com/#{target})
end
end
end
@@ -1369,7 +1369,7 @@ content
block_macro do
named :sect
process do |parent, target, attrs|
- opts = (level = attrs.delete 'level') ? { :level => level.to_i } : {}
+ opts = (level = attrs.delete 'level') ? { level: level.to_i } : {}
attrs['id'] = false if attrs['id'] == 'false'
parent = parent.parent if parent.context == :preamble
sect = create_section parent, 'Section Title', attrs, opts
@@ -1399,7 +1399,7 @@ sect::[%s]
'id=false' => ['chapter', 1, false, true, nil]
}.each do |attrlist, (expect_sectname, expect_level, expect_special, expect_numbered, expect_id, extra_attrs)|
input = input_tpl % attrlist
- document_from_string input, :safe => :server, :attributes => extra_attrs
+ document_from_string input, safe: :server, attributes: extra_attrs
assert_equal expect_sectname, sect.sectname
assert_equal expect_level, sect.level
assert_equal expect_special, sect.special
@@ -1427,7 +1427,7 @@ sample content
docinfo_processor MetaRobotsDocinfoProcessor
end
- doc = document_from_string input, :safe => :server
+ doc = document_from_string input, safe: :server
assert_equal '<meta name="robots" content="index,follow">', doc.docinfo
ensure
Asciidoctor::Extensions.unregister_all
@@ -1444,7 +1444,7 @@ sample content
begin
Asciidoctor::Extensions.register do
docinfo_processor MetaAppDocinfoProcessor
- docinfo_processor MetaRobotsDocinfoProcessor, :position => :>>
+ docinfo_processor MetaRobotsDocinfoProcessor, position: :>>
docinfo_processor do
at_location :footer
process do |doc|
@@ -1453,7 +1453,7 @@ sample content
end
end
- doc = document_from_string input, :safe => :server
+ doc = document_from_string input, safe: :server
assert_equal '<meta name="robots" content="index,follow">
<meta name="application-name" content="Asciidoctor App">', doc.docinfo
assert_equal '<script><!-- analytics code --></script>', doc.docinfo(:footer)
@@ -1469,10 +1469,10 @@ sample content
end
sample_input_path = fixture_path('basic.asciidoc')
- output = Asciidoctor.convert_file sample_input_path, :to_file => false,
- :header_footer => true,
- :safe => Asciidoctor::SafeMode::SERVER,
- :attributes => {'docinfo' => ''}
+ output = Asciidoctor.convert_file sample_input_path, to_file: false,
+ header_footer: true,
+ safe: Asciidoctor::SafeMode::SERVER,
+ attributes: { 'docinfo' => '' }
refute_empty output
assert_css 'script[src="modernizr.js"]', output, 1
assert_css 'meta[name="robots"]', output, 1
@@ -1506,7 +1506,7 @@ sample content
cat_in_sink::[]
EOS
exception = assert_raises ArgumentError do
- convert_string_to_embedded input, :extension_registry => create_cat_in_sink_block_macro
+ convert_string_to_embedded input, extension_registry: create_cat_in_sink_block_macro
end
assert_match(/target attribute is required/, exception.message)
end
@@ -1515,7 +1515,7 @@ cat_in_sink::[]
input = <<-EOS
cat_in_sink::25[]
EOS
- doc = document_from_string input, :header_footer => false, :extension_registry => create_cat_in_sink_block_macro
+ doc = document_from_string input, header_footer: false, extension_registry: create_cat_in_sink_block_macro
image = doc.blocks[0]
assert_equal 'cat in sink day 25', (image.attr 'alt')
assert_equal 'cat in sink day 25', (image.attr 'default-alt')
@@ -1527,7 +1527,7 @@ cat_in_sink::25[]
input = <<-EOS
cat_in_sink::30[cat in sink (yes)]
EOS
- doc = document_from_string input, :header_footer => false, :extension_registry => create_cat_in_sink_block_macro
+ doc = document_from_string input, header_footer: false, extension_registry: create_cat_in_sink_block_macro
image = doc.blocks[0]
assert_equal 'cat in sink (yes)', (image.attr 'alt')
refute(image.attr? 'default-alt')
@@ -1539,7 +1539,7 @@ cat_in_sink::30[cat in sink (yes)]
input = <<-EOS
cat_in_sink::30[]
EOS
- doc = document_from_string input, :header_footer => false, :extension_registry => create_cat_in_sink_block_macro
+ doc = document_from_string input, header_footer: false, extension_registry: create_cat_in_sink_block_macro
output = doc.convert
assert_xpath '/*[@class="imageblock"]/*[@class="title"]', output, 0
end
@@ -1549,7 +1549,7 @@ cat_in_sink::30[]
.Cat in Sink?
cat_in_sink::30[]
EOS
- doc = document_from_string input, :header_footer => false, :extension_registry => create_cat_in_sink_block_macro
+ doc = document_from_string input, header_footer: false, extension_registry: create_cat_in_sink_block_macro
output = doc.convert
assert_xpath '/*[@class="imageblock"]/*[@class="title"][text()="Figure 1. Cat in Sink?"]', output, 1
end
diff --git a/test/links_test.rb b/test/links_test.rb
index b0c13c81..72715d6d 100644
--- a/test/links_test.rb
+++ b/test/links_test.rb
@@ -11,7 +11,7 @@ context 'Links' do
end
test 'qualified http url inline with hide-uri-scheme set' do
- assert_xpath "//a[@href='http://asciidoc.org'][@class='bare'][text() = 'asciidoc.org']", convert_string("The AsciiDoc project is located at http://asciidoc.org.", :attributes => {'hide-uri-scheme' => ''})
+ assert_xpath "//a[@href='http://asciidoc.org'][@class='bare'][text() = 'asciidoc.org']", convert_string("The AsciiDoc project is located at http://asciidoc.org.", attributes: { 'hide-uri-scheme' => '' })
end
test 'qualified file url inline with label' do
@@ -19,15 +19,15 @@ context 'Links' do
end
test 'qualified file url inline with hide-uri-scheme set' do
- assert_xpath "//a[@href='file:///etc/app.conf'][text() = '/etc/app.conf']", convert_string('Edit the configuration file link:file:///etc/app.conf[]', :attributes => {'hide-uri-scheme' => ''})
+ assert_xpath "//a[@href='file:///etc/app.conf'][text() = '/etc/app.conf']", convert_string('Edit the configuration file link:file:///etc/app.conf[]', attributes: { 'hide-uri-scheme' => '' })
end
test 'should not hide bare URI scheme in implicit text of link macro when hide-uri-scheme is set' do
{
'link:https://[]' => 'https://',
- 'link:ssh://[]' => 'ssh://'
+ 'link:ssh://[]' => 'ssh://',
}.each do |input, expected|
- assert_xpath %(/a[text() = "#{expected}"]), (convert_inline_string input, :attributes => { 'hide-uri-scheme' => '' })
+ assert_xpath %(/a[text() = "#{expected}"]), (convert_inline_string input, attributes: { 'hide-uri-scheme' => '' })
end
end
@@ -57,11 +57,11 @@ context 'Links' do
test 'qualified url with label containing square brackets using link macro' do
str = 'http://example.com[[bracket1\]]'
- doc = document_from_string str, :header_footer => false, :doctype => 'inline'
+ doc = document_from_string str, header_footer: false, doctype: 'inline'
assert_match '<a href="http://example.com">[bracket1]</a>', doc.convert, 1
- doc = document_from_string str, :header_footer => false, :backend => 'docbook', :doctype => 'inline'
+ doc = document_from_string str, header_footer: false, backend: 'docbook', doctype: 'inline'
assert_match '<link xl:href="http://example.com">[bracket1]</link>', doc.convert, 1
- doc = document_from_string str, :header_footer => false, :backend => 'docbook45', :doctype => 'inline'
+ doc = document_from_string str, header_footer: false, backend: 'docbook45', doctype: 'inline'
assert_match '<ulink url="http://example.com">[bracket1]</ulink>', doc.convert, 1
end
@@ -321,13 +321,13 @@ context 'Links' do
test 'should encode double quotes in reftext of anchor macro in DocBook output' do
input = 'anchor:uncola[the "un"-cola]'
- result = convert_inline_string input, :backend => :docbook
+ result = convert_inline_string input, backend: :docbook
assert_equal '<anchor xml:id="uncola" xreflabel="the &quot;un&quot;-cola"/>', result
end
test 'should substitute attribute references in reftext when registering inline ref' do
%w([[tigers,{label-tigers}]] anchor:tigers[{label-tigers}]).each do |anchor|
- doc = document_from_string %(Here you can read about tigers.#{anchor}), :attributes => { 'label-tigers' => 'Tigers' }
+ doc = document_from_string %(Here you can read about tigers.#{anchor}), attributes: { 'label-tigers' => 'Tigers' }
doc.convert
assert_kind_of Asciidoctor::Inline, doc.catalog[:refs]['tigers']
assert_equal 'Tigers', doc.catalog[:refs]['tigers'].text
@@ -337,8 +337,8 @@ context 'Links' do
test 'inline ref with reftext converted to DocBook' do
%w([[tigers,<Tigers>]] anchor:tigers[<Tigers>]).each do |anchor|
- doc = document_from_string %(Here you can read about tigers.#{anchor}), :backend => :docbook45
- output = doc.convert :header_footer => false
+ doc = document_from_string %(Here you can read about tigers.#{anchor}), backend: :docbook45
+ output = doc.convert header_footer: false
assert_kind_of Asciidoctor::Inline, doc.catalog[:refs]['tigers']
assert_equal '<Tigers>', doc.catalog[:refs]['tigers'].text
assert_equal '<Tigers>', doc.references[:ids]['tigers']
@@ -366,7 +366,7 @@ context 'Links' do
test 'assigns xreflabel value for anchor macro without reftext in DocBook output' do
input = 'anchor:foo[]'
- result = convert_inline_string input, :backend => :docbook
+ result = convert_inline_string input, backend: :docbook
assert_equal '<anchor xml:id="foo" xreflabel="[foo]"/>', result
end
@@ -380,19 +380,19 @@ anchor:foo[b[a\]r]text'
test 'unescapes square bracket in reftext of anchor macro in DocBook output' do
input = 'anchor:foo[b[a\]r]'
- result = convert_inline_string input, :backend => :docbook
+ result = convert_inline_string input, backend: :docbook
assert_equal '<anchor xml:id="foo" xreflabel="b[a]r"/>', result
end
test 'xref using angled bracket syntax' do
doc = document_from_string '<<tigers>>'
- doc.register :refs, ['tigers', (Asciidoctor::Inline.new doc, :anchor, '[tigers]', :type => :ref, :target => 'tigers'), '[tigers]']
+ doc.register :refs, ['tigers', (Asciidoctor::Inline.new doc, :anchor, '[tigers]', type: :ref, target: 'tigers'), '[tigers]']
assert_xpath '//a[@href="#tigers"][text() = "[tigers]"]', doc.convert, 1
end
test 'xref using angled bracket syntax with explicit hash' do
doc = document_from_string '<<#tigers>>'
- doc.register :refs, ['tigers', (Asciidoctor::Inline.new doc, :anchor, 'Tigers', :type => :ref, :target => 'tigers'), 'Tigers']
+ doc.register :refs, ['tigers', (Asciidoctor::Inline.new doc, :anchor, 'Tigers', type: :ref, target: 'tigers'), 'Tigers']
assert_xpath '//a[@href="#tigers"][text() = "Tigers"]', doc.convert, 1
end
@@ -418,20 +418,20 @@ anchor:foo[b[a\]r]text'
test 'should not interpret path sans extension in xref with angled bracket syntax in compat mode' do
using_memory_logger do |logger|
- doc = document_from_string '<<tigers#>>', :header_footer => false, :attributes => { 'compat-mode' => '' }
+ doc = document_from_string '<<tigers#>>', header_footer: false, attributes: { 'compat-mode' => '' }
assert_xpath '//a[@href="#tigers#"][text() = "[tigers#]"]', doc.convert, 1
end
end
test 'xref using angled bracket syntax with path sans extension' do
- doc = document_from_string '<<tigers#>>', :header_footer => false
+ doc = document_from_string '<<tigers#>>', header_footer: false
assert_xpath '//a[@href="tigers.html"][text() = "tigers.html"]', doc.convert, 1
end
test 'inter-document xref should not add suffix to path with a non-AsciiDoc extension' do
{
'using-.net-web-services' => 'Using .NET web services',
- '../file.pdf' => 'Download the .pdf file'
+ '../file.pdf' => 'Download the .pdf file',
}.each do |path, text|
result = convert_string_to_embedded %(<<#{path}#,#{text}>>)
assert_xpath %(//a[@href="#{path}"][text() = "#{text}"]), result, 1
@@ -444,77 +444,77 @@ anchor:foo[b[a\]r]text'
end
test 'xref using angled bracket syntax with path sans extension using docbook backend' do
- doc = document_from_string '<<tigers#>>', :header_footer => false, :backend => 'docbook'
+ doc = document_from_string '<<tigers#>>', header_footer: false, backend: 'docbook'
assert_match '<link xl:href="tigers.xml">tigers.xml</link>', doc.convert, 1
- doc = document_from_string '<<tigers#>>', :header_footer => false, :backend => 'docbook45'
+ doc = document_from_string '<<tigers#>>', header_footer: false, backend: 'docbook45'
assert_match '<ulink url="tigers.xml">tigers.xml</ulink>', doc.convert, 1
end
test 'xref using angled bracket syntax with ancestor path sans extension' do
- doc = document_from_string '<<../tigers#,tigers>>', :header_footer => false
+ doc = document_from_string '<<../tigers#,tigers>>', header_footer: false
assert_xpath '//a[@href="../tigers.html"][text() = "tigers"]', doc.convert, 1
end
test 'xref using angled bracket syntax with absolute path sans extension' do
- doc = document_from_string '<</path/to/tigers#,tigers>>', :header_footer => false
+ doc = document_from_string '<</path/to/tigers#,tigers>>', header_footer: false
assert_xpath '//a[@href="/path/to/tigers.html"][text() = "tigers"]', doc.convert, 1
end
test 'xref using angled bracket syntax with path and extension' do
using_memory_logger do |logger|
- doc = document_from_string '<<tigers.adoc>>', :header_footer => false
+ doc = document_from_string '<<tigers.adoc>>', header_footer: false
assert_xpath '//a[@href="#tigers.adoc"][text() = "[tigers.adoc]"]', doc.convert, 1
end
end
test 'xref using angled bracket syntax with path and extension with hash' do
- doc = document_from_string '<<tigers.adoc#>>', :header_footer => false
+ doc = document_from_string '<<tigers.adoc#>>', header_footer: false
assert_xpath '//a[@href="tigers.html"][text() = "tigers.html"]', doc.convert, 1
end
test 'xref using angled bracket syntax with path and extension with fragment' do
- doc = document_from_string '<<tigers.adoc#id>>', :header_footer => false
+ doc = document_from_string '<<tigers.adoc#id>>', header_footer: false
assert_xpath '//a[@href="tigers.html#id"][text() = "tigers.html"]', doc.convert, 1
end
test 'xref using macro syntax with path and extension in compat mode' do
using_memory_logger do |logger|
- doc = document_from_string 'xref:tigers.adoc[]', :header_footer => false, :attributes => { 'compat-mode' => '' }
+ doc = document_from_string 'xref:tigers.adoc[]', header_footer: false, attributes: { 'compat-mode' => '' }
assert_xpath '//a[@href="#tigers.adoc"][text() = "[tigers.adoc]"]', doc.convert, 1
end
end
test 'xref using macro syntax with path and extension' do
- doc = document_from_string 'xref:tigers.adoc[]', :header_footer => false
+ doc = document_from_string 'xref:tigers.adoc[]', header_footer: false
assert_xpath '//a[@href="tigers.html"][text() = "tigers.html"]', doc.convert, 1
end
test 'xref using angled bracket syntax with path and fragment' do
- doc = document_from_string '<<tigers#about>>', :header_footer => false
+ doc = document_from_string '<<tigers#about>>', header_footer: false
assert_xpath '//a[@href="tigers.html#about"][text() = "tigers.html"]', doc.convert, 1
end
test 'xref using angled bracket syntax with path, fragment and text' do
- doc = document_from_string '<<tigers#about,About Tigers>>', :header_footer => false
+ doc = document_from_string '<<tigers#about,About Tigers>>', header_footer: false
assert_xpath '//a[@href="tigers.html#about"][text() = "About Tigers"]', doc.convert, 1
end
test 'xref using angled bracket syntax with path and custom relfilesuffix and outfilesuffix' do
- attributes = {'relfileprefix' => '../', 'outfilesuffix' => '/'}
- doc = document_from_string '<<tigers#about,About Tigers>>', :header_footer => false, :attributes => attributes
+ attributes = { 'relfileprefix' => '../', 'outfilesuffix' => '/' }
+ doc = document_from_string '<<tigers#about,About Tigers>>', header_footer: false, attributes: attributes
assert_xpath '//a[@href="../tigers/#about"][text() = "About Tigers"]', doc.convert, 1
end
test 'xref using angled bracket syntax with path and custom relfilesuffix' do
attributes = { 'relfilesuffix' => '/' }
- doc = document_from_string '<<tigers#about,About Tigers>>', :header_footer => false, :attributes => attributes
+ doc = document_from_string '<<tigers#about,About Tigers>>', header_footer: false, attributes: attributes
assert_xpath '//a[@href="tigers/#about"][text() = "About Tigers"]', doc.convert, 1
end
test 'xref using angled bracket syntax with path which has been included in this document' do
using_memory_logger do |logger|
in_verbose_mode do
- doc = document_from_string '<<tigers#about,About Tigers>>', :header_footer => false
+ doc = document_from_string '<<tigers#about,About Tigers>>', header_footer: false
doc.catalog[:includes]['tigers'] = true
output = doc.convert
assert_xpath '//a[@href="#about"][text() = "About Tigers"]', output, 1
@@ -526,7 +526,7 @@ anchor:foo[b[a\]r]text'
test 'xref using angled bracket syntax with nested path which has been included in this document' do
using_memory_logger do |logger|
in_verbose_mode do
- doc = document_from_string '<<part1/tigers#about,About Tigers>>', :header_footer => false
+ doc = document_from_string '<<part1/tigers#about,About Tigers>>', header_footer: false
doc.catalog[:includes]['part1/tigers'] = true
output = doc.convert
assert_xpath '//a[@href="#about"][text() = "About Tigers"]', output, 1
@@ -587,7 +587,7 @@ A summary of the first lesson.
test 'xref using macro syntax' do
doc = document_from_string 'xref:tigers[]'
- doc.register :refs, ['tigers', (Asciidoctor::Inline.new doc, :anchor, '[tigers]', :type => :ref, :target => 'tigers'), '[tigers]']
+ doc.register :refs, ['tigers', (Asciidoctor::Inline.new doc, :anchor, '[tigers]', type: :ref, target: 'tigers'), '[tigers]']
assert_xpath '//a[@href="#tigers"][text() = "[tigers]"]', doc.convert, 1
end
@@ -608,7 +608,7 @@ This document has two sections, xref:sect-a[] and xref:sect-b[].
test 'xref using macro syntax with explicit hash' do
doc = document_from_string 'xref:#tigers[]'
- doc.register :refs, ['tigers', (Asciidoctor::Inline.new doc, :anchor, 'Tigers', :type => :ref, :target => 'tigers'), 'Tigers']
+ doc.register :refs, ['tigers', (Asciidoctor::Inline.new doc, :anchor, 'Tigers', type: :ref, target: 'tigers'), 'Tigers']
assert_xpath '//a[@href="#tigers"][text() = "Tigers"]', doc.convert, 1
end
@@ -675,7 +675,7 @@ see <<foo>>'
test 'xref using invalid macro syntax does not create link' do
doc = document_from_string 'xref:tigers'
- doc.register :refs, ['tigers', (Asciidoctor::Inline.new doc, :anchor, 'Tigers', :type => :ref, :target => 'tigers'), 'Tigers']
+ doc.register :refs, ['tigers', (Asciidoctor::Inline.new doc, :anchor, 'Tigers', type: :ref, target: 'tigers'), 'Tigers']
assert_xpath '//a', doc.convert, 0
end
@@ -730,7 +730,7 @@ Read <<other-chapters.adoc#ch2>> to find out what happens next!
include::other-chapters.adoc[]
EOS
- doc = document_from_string input, :safe => :safe, :base_dir => fixturedir
+ doc = document_from_string input, safe: :safe, base_dir: fixturedir
assert doc.catalog[:includes].key?('other-chapters')
assert doc.catalog[:includes]['other-chapters']
output = doc.convert
@@ -752,7 +752,7 @@ Read <<other-chapters.adoc#ch2>> to find out what happens next!
include::other-chapters.adoc[tags=**]
EOS
- output = convert_string_to_embedded input, :safe => :safe, :base_dir => fixturedir
+ output = convert_string_to_embedded input, safe: :safe, base_dir: fixturedir
assert_xpath '//a[@href="#ch2"][text()="Chapter 2"]', output, 1
end
@@ -771,7 +771,7 @@ Read <<other-chapters.adoc#ch2,the next chapter>> to find out what happens next!
include::other-chapters.adoc[tags=ch2]
EOS
- doc = document_from_string input, :safe => :safe, :base_dir => fixturedir
+ doc = document_from_string input, safe: :safe, base_dir: fixturedir
assert doc.catalog[:includes].key?('other-chapters')
refute doc.catalog[:includes]['other-chapters']
output = doc.convert
@@ -789,7 +789,7 @@ See <<test.adoc#foobaz>>.
EOS
using_memory_logger do |logger|
in_verbose_mode do
- output = convert_string_to_embedded input, :attributes => { 'docname' => 'test' }
+ output = convert_string_to_embedded input, attributes: { 'docname' => 'test' }
assert_xpath '//a[@href="#foobaz"][text() = "[foobaz]"]', output, 1
assert_message logger, :WARN, 'invalid reference: foobaz'
end
@@ -805,9 +805,9 @@ See <<../section-a.adoc#section-a>>.
include::../section-a.adoc[]
EOS
- doc = document_from_string input, :safe => :unsafe, :base_dir => (File.join fixturedir, 'subdir')
+ doc = document_from_string input, safe: :unsafe, base_dir: (File.join fixturedir, 'subdir')
assert_includes doc.catalog[:includes], '../section-a'
- output = doc.convert :header_footer => false
+ output = doc.convert header_footer: false
assert_xpath '//a[@href="#section-a"][text()="Section A"]', output, 1
end
@@ -831,21 +831,21 @@ include::../section-a.adoc[]
test 'anchor creates reference' do
doc = document_from_string "[[tigers]]Tigers roam here."
- assert_equal({'tigers' => '[tigers]'}, doc.catalog[:ids])
+ assert_equal({ 'tigers' => '[tigers]' }, doc.catalog[:ids])
end
test 'anchor with label creates reference' do
doc = document_from_string "[[tigers,Tigers]]Tigers roam here."
- assert_equal({'tigers' => 'Tigers'}, doc.catalog[:ids])
+ assert_equal({ 'tigers' => 'Tigers' }, doc.catalog[:ids])
end
test 'anchor with quoted label creates reference with quoted label text' do
doc = document_from_string %([[tigers,"Tigers roam here"]]Tigers roam here.)
- assert_equal({'tigers' => '"Tigers roam here"'}, doc.catalog[:ids])
+ assert_equal({ 'tigers' => '"Tigers roam here"' }, doc.catalog[:ids])
end
test 'anchor with label containing a comma creates reference' do
doc = document_from_string %([[tigers,Tigers, scary tigers, roam here]]Tigers roam here.)
- assert_equal({'tigers' => 'Tigers, scary tigers, roam here'}, doc.catalog[:ids])
+ assert_equal({ 'tigers' => 'Tigers, scary tigers, roam here' }, doc.catalog[:ids])
end
end
diff --git a/test/lists_test.rb b/test/lists_test.rb
index bebdb3ec..91cab51a 100644
--- a/test/lists_test.rb
+++ b/test/lists_test.rb
@@ -388,7 +388,7 @@ NOTE: This is a note.
colist = doc.blocks[0].items[0].blocks[-1]
assert_equal :colist, colist.context
refute_equal 'source', colist.style
- output = doc.convert :header_footer => false
+ output = doc.convert header_footer: false
assert_css 'ul', output, 1
assert_css 'ul > li', output, 1
assert_css 'ul > li > p', output, 1
@@ -801,7 +801,7 @@ Grays Peak rises to 14,278 feet, making it the highest summit in the Front Range
refs = doc.catalog[:refs]
assert refs.key?('mount-evans')
assert refs.key?('grays-peak')
- output = doc.convert :header_footer => false
+ output = doc.convert header_footer: false
assert_xpath '(//p)[1]/a[@href="#grays-peak"][text()="Grays Peak"]', output, 1
assert_xpath '(//p)[1]/a[@href="#mount-evans"][text()="Mount Evans"]', output, 1
end
@@ -821,7 +821,7 @@ This is a cross-reference to <<step-4>>.
refs = doc.catalog[:refs]
assert refs.key?('step-2')
assert refs.key?('step-4')
- output = doc.convert :header_footer => false
+ output = doc.convert header_footer: false
assert_xpath '(//p)[1]/a[@href="#step-2"][text()="Step 2"]', output, 1
assert_xpath '(//p)[1]/a[@href="#step-4"][text()="Step 4"]', output, 1
end
@@ -978,7 +978,7 @@ List
EOS
doc = document_from_string input
- lists = doc.find_by :context => :ulist
+ lists = doc.find_by context: :ulist
assert_equal 1, lists[0].level
assert_equal 1, lists[1].level
assert_equal 1, lists[2].level
@@ -1053,7 +1053,7 @@ List
EOS
doc = document_from_string input
- lists = doc.find_by :context => :olist
+ lists = doc.find_by context: :olist
assert_equal 1, lists[0].level
assert_equal 1, lists[1].level
assert_equal 1, lists[2].level
@@ -1965,7 +1965,7 @@ List
. item 8
EOS
- output = convert_string_to_embedded input, :backend => 'docbook45'
+ output = convert_string_to_embedded input, backend: 'docbook45'
assert_xpath '//orderedlist', output, 1
assert_xpath '(//orderedlist)/listitem', output, 2
assert_xpath '(//orderedlist/listitem)[1][@override = "7"]', output, 1
@@ -1980,7 +1980,7 @@ List
. item 8
EOS
- output = convert_string_to_embedded input, :backend => 'docbook5'
+ output = convert_string_to_embedded input, backend: 'docbook5'
assert_xpath '//orderedlist', output, 1
assert_xpath '(//orderedlist)/listitem', output, 2
assert_xpath '(//orderedlist)[@startingnumber = "7"]', output, 1
@@ -2266,7 +2266,7 @@ description
last::
EOS
- output = convert_string_to_embedded input, :backend => 'docbook'
+ output = convert_string_to_embedded input, backend: 'docbook'
assert_xpath '//varlistentry', output, 2
assert_xpath '(//varlistentry)[1]/term', output, 2
assert_xpath '(//varlistentry)[2]/term', output, 1
@@ -2342,7 +2342,7 @@ The highest peak in the Front Range is <<grays-peak>>, which tops <<mount-evans>
refs = doc.catalog[:refs]
assert refs.key?('mount-evans')
assert refs.key?('grays-peak')
- output = doc.convert :header_footer => false
+ output = doc.convert header_footer: false
assert_xpath '(//p)[1]/a[@href="#grays-peak"][text()="Grays Peak"]', output, 1
assert_xpath '(//p)[1]/a[@href="#mount-evans"][text()="Mount Evans"]', output, 1
assert_xpath '//dl', output, 1
@@ -2938,7 +2938,7 @@ description
last::
EOS
- output = convert_string_to_embedded input, :backend => 'docbook'
+ output = convert_string_to_embedded input, backend: 'docbook'
assert_xpath '/glossentry', output, 2
assert_xpath '(/glossentry)[1]/glossterm', output, 2
assert_xpath '(/glossentry)[2]/glossterm', output, 1
@@ -2995,7 +2995,7 @@ term:: def
term:: def
EOS
- output = convert_string_to_embedded input, :backend => 'docbook'
+ output = convert_string_to_embedded input, backend: 'docbook'
assert_css 'informaltable', output, 1
assert_css 'informaltable > tgroup', output, 1
assert_css 'informaltable > tgroup > colspec', output, 2
@@ -3041,7 +3041,7 @@ description
last::
EOS
- output = convert_string_to_embedded input, :backend => 'docbook'
+ output = convert_string_to_embedded input, backend: 'docbook'
assert_xpath '//row', output, 2
assert_xpath '(//row)[1]/entry', output, 2
assert_xpath '((//row)[1]/entry)[1]/simpara', output, 2
@@ -3059,7 +3059,7 @@ more detail
second term:: description
EOS
- output = convert_string_to_embedded input, :backend => 'docbook'
+ output = convert_string_to_embedded input, backend: 'docbook'
assert_xpath '/table', output, 1
assert_xpath '/table[@tabstyle="horizontal"]', output, 1
assert_xpath '/table[@tabstyle="horizontal"]/title[text()="Terms"]', output, 1
@@ -3103,7 +3103,7 @@ Question 2::
+
NOTE: A note about Answer 2.
EOS
- output = convert_string_to_embedded input, :backend => 'docbook'
+ output = convert_string_to_embedded input, backend: 'docbook'
assert_css 'qandaset', output, 1
assert_css 'qandaset > qandaentry', output, 2
(1..2).each do |idx|
@@ -3126,7 +3126,7 @@ response
last question::
EOS
- output = convert_string_to_embedded input, :backend => 'docbook'
+ output = convert_string_to_embedded input, backend: 'docbook'
assert_xpath '//qandaentry', output, 2
assert_xpath '(//qandaentry)[1]/question', output, 1
assert_xpath '(//qandaentry)[1]/question/simpara', output, 2
@@ -3164,7 +3164,7 @@ last question::
'DocBook - The Definitive Guide'. O'Reilly & Associates. 1999.
ISBN 1-56592-580-7.
EOS
- output = convert_string_to_embedded input, :backend => 'docbook'
+ output = convert_string_to_embedded input, backend: 'docbook'
assert_css 'bibliodiv', output, 1
assert_css 'bibliodiv > bibliomixed', output, 2
assert_css 'bibliodiv > bibliomixed > bibliomisc', output, 2
@@ -3207,7 +3207,7 @@ Addison-Wesley. 1997.
* [[[doc-writer]]] Doc Writer. _Documentation As Code_. Static Times, 54. August 2016.
EOS
doc = document_from_string input
- ulists = doc.find_by :context => :ulist
+ ulists = doc.find_by context: :ulist
assert_equal 2, ulists.size
assert_equal ulists[0].style, 'bibliography'
assert_equal ulists[1].style, 'bibliography'
@@ -3266,11 +3266,11 @@ Please read #{'<<'}Fowler_1997>>.
* [[[Fowler_1997,1]]] Fowler M. _Analysis Patterns: Reusable Object Models_. Addison-Wesley. 1997.
EOS
- doc = document_from_string input, :header_footer => false
+ doc = document_from_string input, header_footer: false
ids = doc.catalog[:ids]
assert ids.key?('Fowler_1997')
assert_equal '[1]', ids['Fowler_1997']
- result = doc.convert :header_footer => false
+ result = doc.convert header_footer: false
assert_xpath '//a[@href="#Fowler_1997"]', result, 1
assert_xpath '//a[@href="#Fowler_1997"][text()="[1]"]', result, 1
assert_xpath '//a[@id="Fowler_1997"]', result, 1
@@ -3284,7 +3284,7 @@ Please read #{'<<'}Fowler_1997>>.
* [[[Fowler_1997,1]]] Fowler M. _Analysis Patterns: Reusable Object Models_. Addison-Wesley. 1997.
EOS
- result = convert_string_to_embedded input, :backend => :docbook
+ result = convert_string_to_embedded input, backend: :docbook
assert_includes result, '<anchor xml:id="Fowler_1997" xreflabel="[1]"/>'
end
end
@@ -4341,7 +4341,7 @@ puts doc.convert # <3>
<2> Describe the second line
<3> Describe the third line
EOS
- output = convert_string input, :attributes => {'backend' => 'docbook45'}
+ output = convert_string input, attributes: { 'backend' => 'docbook45' }
assert_xpath '//programlisting', output, 1
assert_xpath '//programlisting//co', output, 3
assert_xpath '(//programlisting//co)[1][@id = "CO1-1"]', output, 1
@@ -4368,7 +4368,7 @@ Paragraph.
<2> Describe the second line
<3> Describe the third line
EOS
- output = convert_string input, :attributes => {'backend' => 'docbook45'}
+ output = convert_string input, attributes: { 'backend' => 'docbook45' }
assert_xpath '//programlisting', output, 1
assert_xpath '//programlisting//co', output, 3
assert_xpath '(//programlisting//co)[1][@id = "CO1-1"]', output, 1
@@ -4392,7 +4392,7 @@ puts doc.convert # <2>
<1> Import the library
<2> Where the magic happens
EOS
- output = convert_string input, :attributes => {'backend' => 'docbook45'}
+ output = convert_string input, attributes: { 'backend' => 'docbook45' }
assert_xpath '//programlisting', output, 1
assert_xpath '//programlisting//co', output, 3
assert_xpath '(//programlisting//co)[1][@id = "CO1-1"]', output, 1
@@ -4415,7 +4415,7 @@ puts doc.convert # <1>
<2> Describe the second line
<3> Describe the third line
EOS
- output = convert_string input, :attributes => {'backend' => 'docbook45'}
+ output = convert_string input, attributes: { 'backend' => 'docbook45' }
assert_xpath '//programlisting', output, 1
assert_xpath '//programlisting//co', output, 3
assert_xpath '(//programlisting//co)[1][@id = "CO1-1"]', output, 1
@@ -4446,7 +4446,7 @@ puts doc.convert # <3>
<2> Describe the second line
<3> Describe the third line
EOS
- output = convert_string input, :attributes => {'backend' => 'docbook45'}
+ output = convert_string input, attributes: { 'backend' => 'docbook45' }
assert_xpath '//programlisting', output, 2
assert_xpath '(//programlisting)[1]//co', output, 1
assert_xpath '(//programlisting)[1]//co[@id = "CO1-1"]', output, 1
@@ -4476,7 +4476,7 @@ puts doc.convert # <2>
<1> Describe the second line
<2> Describe the third line
EOS
- output = convert_string input, :attributes => {'backend' => 'docbook45'}
+ output = convert_string input, attributes: { 'backend' => 'docbook45' }
assert_xpath '//programlisting', output, 2
assert_xpath '(//programlisting)[1]//co', output, 1
assert_xpath '(//programlisting)[1]//co[@id = "CO1-1"]', output, 1
@@ -4533,7 +4533,7 @@ as a RubyGem
+
You can write this to file rather than printing to stdout.
EOS
- output = convert_string input, :attributes => {'backend' => 'docbook45'}
+ output = convert_string input, attributes: { 'backend' => 'docbook45' }
assert_xpath '//calloutlist', output, 1
assert_xpath '//calloutlist/callout', output, 3
assert_xpath '(//calloutlist/callout)[1]/*', output, 1
@@ -4551,8 +4551,8 @@ require 'asciidoctor' # \\<1>
Asciidoctor.convert 'convert me!' \\<2>
----
EOS
- [{}, {'source-highlighter' => 'coderay'}].each do |attributes|
- output = convert_string_to_embedded input, :attributes => attributes
+ [{}, { 'source-highlighter' => 'coderay' }].each do |attributes|
+ output = convert_string_to_embedded input, attributes: attributes
assert_css 'pre b', output, 0
assert_includes output, ' # &lt;1&gt;'
assert_includes output, ' &lt;2&gt;'
@@ -4723,8 +4723,8 @@ main = putStrLn "Hello, World!" -- <1>
----
<1> Haskell
EOS
- [{}, {'source-highlighter' => 'coderay'}].each do |attributes|
- output = convert_string_to_embedded input, :attributes => attributes
+ [{}, { 'source-highlighter' => 'coderay' }].each do |attributes|
+ output = convert_string_to_embedded input, attributes: attributes
assert_xpath '//b', output, 4
nodes = xmlnodes_at_css 'pre', output
assert_equal %(puts 'Hello, world!' # (1)), nodes[0].text
@@ -4761,8 +4761,8 @@ main = putStrLn "Hello, World!" -- <1>
----
<1> Haskell
EOS
- [{}, {'source-highlighter' => 'coderay'}].each do |attributes|
- output = convert_string_to_embedded input, :attributes => attributes.merge({ 'icons' => 'font' })
+ [{}, { 'source-highlighter' => 'coderay' }].each do |attributes|
+ output = convert_string_to_embedded input, attributes: attributes.merge({ 'icons' => 'font' })
assert_css 'pre b', output, 4
assert_css 'pre i.conum', output, 4
nodes = xmlnodes_at_css 'pre', output
@@ -4798,7 +4798,7 @@ hello_world() -> % <1>
----
<1> Prints a paragraph with the text "Hello"
EOS
- output = convert_string_to_embedded input, :attributes => { 'source-highlighter' => 'coderay' }
+ output = convert_string_to_embedded input, attributes: { 'source-highlighter' => 'coderay' }
assert_xpath '//b', output, 1
nodes = xmlnodes_at_css 'pre', output
assert_equal %(-# (1)\n%p Hello), nodes[0].text
@@ -4815,7 +4815,7 @@ Violets are blue <2>
<1> And so is Ruby
<2> But violet is more like purple
EOS
- output = convert_string input, :attributes => {'backend' => 'docbook45'}
+ output = convert_string input, attributes: { 'backend' => 'docbook45' }
assert_xpath '//literallayout', output, 1
assert_xpath '//literallayout//co', output, 2
assert_xpath '(//literallayout//co)[1][@id = "CO1-1"]', output, 1
@@ -4837,7 +4837,7 @@ puts doc.convert # <3>
<2> Describe the second line
<3> Describe the third line
EOS
- output = convert_string_to_embedded input, :attributes => {'icons' => ''}
+ output = convert_string_to_embedded input, attributes: { 'icons' => '' }
assert_css '.listingblock code > img', output, 3
(1..3).each do |i|
assert_xpath %((/div[@class="listingblock"]//code/img)[#{i}][@src="./images/icons/callouts/#{i}.png"][@alt="#{i}"]), output, 1
@@ -4860,7 +4860,7 @@ puts doc.convert #<3>
<2> Describe the second line
<3> Describe the third line
EOS
- output = convert_string_to_embedded input, :attributes => {'icons' => 'font'}
+ output = convert_string_to_embedded input, attributes: { 'icons' => 'font' }
assert_css '.listingblock code > i', output, 3
(1..3).each do |i|
assert_xpath %((/div[@class="listingblock"]//code/i)[#{i}]), output, 1
@@ -4930,7 +4930,7 @@ context 'Checklists' do
assert checklist.items[1].attr?('checked')
refute checklist.items[4].attr?('checkbox')
- output = doc.convert :header_footer => false
+ output = doc.convert header_footer: false
assert_css '.ulist.checklist', output, 1
assert_xpath %((/*[@class="ulist checklist"]/ul/li)[1]/p[text()="#{decode_char 10063} todo"]), output, 1
assert_xpath %((/*[@class="ulist checklist"]/ul/li)[2]/p[text()="#{decode_char 10003} done"]), output, 1
@@ -4946,7 +4946,7 @@ context 'Checklists' do
- plain
EOS
- output = convert_string_to_embedded input, :attributes => {'icons' => 'font'}
+ output = convert_string_to_embedded input, attributes: { 'icons' => 'font' }
assert_css '.ulist.checklist', output, 1
assert_css '.ulist.checklist li i.fa-check-square-o', output, 1
assert_css '.ulist.checklist li i.fa-square-o', output, 1
@@ -4967,7 +4967,7 @@ context 'Checklists' do
assert checklist.option?('checklist')
assert checklist.option?('interactive')
- output = doc.convert :header_footer => false
+ output = doc.convert header_footer: false
assert_css '.ulist.checklist', output, 1
assert_css '.ulist.checklist li input[type="checkbox"]', output, 2
assert_css '.ulist.checklist li input[type="checkbox"][disabled]', output, 0
@@ -5095,7 +5095,7 @@ listing block in list item 1
EOS
doc = document_from_string input
- list = (doc.find_by :context => :ulist).first
+ list = (doc.find_by context: :ulist).first
assert_equal 3, list.items.size
assert_equal 'one', list.items[0].text
list.items[0].text = 'un'
@@ -5111,7 +5111,7 @@ listing block in list item 1
EOS
doc = document_from_string input
- list = (doc.find_by :context => :ulist).first
+ list = (doc.find_by context: :ulist).first
assert_equal 4, list.items.size
list.items[0].remove_sub :quotes
assert_equal '*one*', list.items[0].text
@@ -5132,13 +5132,13 @@ listing block in list item 1
*** bullet 1.1.1
* bullet 2
EOS
- doc = document_from_string input, :sourcemap => true
- lists = doc.find_by :context => :ulist
+ doc = document_from_string input, sourcemap: true
+ lists = doc.find_by context: :ulist
assert_equal 1, lists[0].lineno
assert_equal 2, lists[1].lineno
assert_equal 3, lists[2].lineno
- list_items = doc.find_by :context => :list_item
+ list_items = doc.find_by context: :list_item
assert_equal 1, list_items[0].lineno
assert_equal 2, list_items[1].lineno
assert_equal 3, list_items[2].lineno
diff --git a/test/logger_test.rb b/test/logger_test.rb
index 73c8a7bc..0081f37e 100644
--- a/test/logger_test.rb
+++ b/test/logger_test.rb
@@ -83,7 +83,7 @@ context 'Logger' do
old_logger = Asciidoctor::LoggerManager.logger
new_logger = MyLogger.new $stdout
begin
- Asciidoctor.load 'contents', :logger => new_logger
+ Asciidoctor.load 'contents', logger: new_logger
assert_same new_logger, Asciidoctor::LoggerManager.logger
ensure
Asciidoctor::LoggerManager.logger = old_logger
@@ -94,7 +94,7 @@ context 'Logger' do
old_logger = Asciidoctor::LoggerManager.logger
new_logger = MyLogger.new $stdout
begin
- Asciidoctor.load_file fixture_path('basic.asciidoc'), :logger => new_logger
+ Asciidoctor.load_file fixture_path('basic.asciidoc'), logger: new_logger
assert_same new_logger, Asciidoctor::LoggerManager.logger
ensure
Asciidoctor::LoggerManager.logger = old_logger
@@ -105,7 +105,7 @@ context 'Logger' do
old_logger = Asciidoctor::LoggerManager.logger
new_logger = MyLogger.new $stdout
begin
- Asciidoctor.convert 'contents', :logger => new_logger
+ Asciidoctor.convert 'contents', logger: new_logger
assert_same new_logger, Asciidoctor::LoggerManager.logger
ensure
Asciidoctor::LoggerManager.logger = old_logger
@@ -116,7 +116,7 @@ context 'Logger' do
old_logger = Asciidoctor::LoggerManager.logger
new_logger = MyLogger.new $stdout
begin
- Asciidoctor.convert_file fixture_path('basic.asciidoc'), :to_file => false, :logger => new_logger
+ Asciidoctor.convert_file fixture_path('basic.asciidoc'), to_file: false, logger: new_logger
assert_same new_logger, Asciidoctor::LoggerManager.logger
ensure
Asciidoctor::LoggerManager.logger = old_logger
@@ -178,7 +178,7 @@ context 'Logger' do
class SampleClassE
include Asciidoctor::Logging
def create_message cursor
- message_with_context 'Asciidoctor was here', :source_location => cursor
+ message_with_context 'Asciidoctor was here', source_location: cursor
end
end
diff --git a/test/manpage_test.rb b/test/manpage_test.rb
index 2dae269c..99e718c0 100644
--- a/test/manpage_test.rb
+++ b/test/manpage_test.rb
@@ -22,7 +22,7 @@ context 'Manpage' do
context 'Configuration' do
test 'should set proper manpage-related attributes' do
input = SAMPLE_MANPAGE_HEADER
- doc = Asciidoctor.load input, :backend => :manpage
+ doc = Asciidoctor.load input, backend: :manpage
assert_equal 'man', doc.attributes['filetype']
assert_equal '', doc.attributes['filetype-man']
assert_equal '1', doc.attributes['manvolnum']
@@ -35,7 +35,7 @@ context 'Manpage' do
test 'should output multiple mannames in NAME section' do
input = SAMPLE_MANPAGE_HEADER.sub(/^command - /, 'command, alt_command - ')
- output = Asciidoctor.convert input, :backend => :manpage, :header_footer => true
+ output = Asciidoctor.convert input, backend: :manpage, header_footer: true
assert_includes output.lines, %(command, alt_command \\- does stuff\n)
end
@@ -57,7 +57,7 @@ When you need to put some foo on the bar.
EOS
attrs = { 'manname' => 'foobar', 'manpurpose' => 'puts some foo on the bar' }
- doc = Asciidoctor.load input, :backend => :manpage, :header_footer => true, :attributes => attrs
+ doc = Asciidoctor.load input, backend: :manpage, header_footer: true, attributes: attrs
assert_equal 'foobar', (doc.attr 'manname')
assert_equal ['foobar'], (doc.attr 'mannames')
assert_equal 'puts some foo on the bar', (doc.attr 'manpurpose')
@@ -89,14 +89,14 @@ foobar - puts some foo
When you need to put some foo on the bar.
EOS
- doc = Asciidoctor.load input, :backend => :manpage, :header_footer => true
+ doc = Asciidoctor.load input, backend: :manpage, header_footer: true
assert_equal 'puts some foo on the bar', (doc.attr 'manpurpose')
end
test 'should parse malformed document with warnings' do
input = 'garbage in'
using_memory_logger do |logger|
- doc = Asciidoctor.load input, :backend => :manpage, :header_footer => true, :attributes => { 'docname' => 'cmd' }
+ doc = Asciidoctor.load input, backend: :manpage, header_footer: true, attributes: { 'docname' => 'cmd' }
assert_equal 'cmd', doc.attr('manname')
assert_equal ['cmd'], doc.attr('mannames')
assert_equal '.1', doc.attr('outfilesuffix')
@@ -117,7 +117,7 @@ command - does stuff
EOS
using_memory_logger do |logger|
- document_from_string input, :backend => :manpage
+ document_from_string input, backend: :manpage
assert_message logger, :ERROR, '<stdin>: line 1: non-conforming manpage title', Hash
end
end
@@ -132,7 +132,7 @@ Does stuff.
EOS
using_memory_logger do |logger|
- doc = document_from_string input, :backend => :manpage
+ doc = document_from_string input, backend: :manpage
assert_message logger, :ERROR, '<stdin>: line 3: non-conforming name section body', Hash
refute_nil doc.sections[0]
assert_equal 'Synopsis', doc.sections[0].title
@@ -141,26 +141,26 @@ Does stuff.
test 'should define default linkstyle' do
input = SAMPLE_MANPAGE_HEADER
- output = Asciidoctor.convert input, :backend => :manpage, :header_footer => true
+ output = Asciidoctor.convert input, backend: :manpage, header_footer: true
assert_includes output.lines, %(. LINKSTYLE blue R < >\n)
end
test 'should use linkstyle defined by man-linkstyle attribute' do
input = SAMPLE_MANPAGE_HEADER
- output = Asciidoctor.convert input, :backend => :manpage, :header_footer => true,
- :attributes => { 'man-linkstyle' => 'cyan B \[fo] \[fc]' }
+ output = Asciidoctor.convert input, backend: :manpage, header_footer: true,
+ attributes: { 'man-linkstyle' => 'cyan B \[fo] \[fc]' }
assert_includes output.lines, %(. LINKSTYLE cyan B \\[fo] \\[fc]\n)
end
test 'should require specialchars in value of man-linkstyle attribute defined in document to be escaped' do
input = %(:man-linkstyle: cyan R < >
#{SAMPLE_MANPAGE_HEADER})
- output = Asciidoctor.convert input, :backend => :manpage, :header_footer => true
+ output = Asciidoctor.convert input, backend: :manpage, header_footer: true
assert_includes output.lines, %(. LINKSTYLE cyan R &lt; &gt;\n)
input = %(:man-linkstyle: pass:[cyan R < >]
#{SAMPLE_MANPAGE_HEADER})
- output = Asciidoctor.convert input, :backend => :manpage, :header_footer => true
+ output = Asciidoctor.convert input, backend: :manpage, header_footer: true
assert_includes output.lines, %(. LINKSTYLE cyan R < >\n)
end
end
@@ -170,7 +170,7 @@ Does stuff.
input = %(#{SAMPLE_MANPAGE_HEADER}
(C) & (R) are translated to character references, but not the &.)
- output = Asciidoctor.convert input, :backend => :manpage
+ output = Asciidoctor.convert input, backend: :manpage
assert_equal '\\(co & \\(rg are translated to character references, but not the &.', output.lines.last.chomp
end
@@ -180,7 +180,7 @@ Does stuff.
go -- to
go--to)
- output = Asciidoctor.convert input, :backend => :manpage
+ output = Asciidoctor.convert input, backend: :manpage
assert_includes output, 'go \\(em to'
assert_includes output, 'go\\(emto'
end
@@ -189,7 +189,7 @@ go--to)
input = %(#{SAMPLE_MANPAGE_HEADER}
.)
- output = Asciidoctor.convert input, :backend => :manpage
+ output = Asciidoctor.convert input, backend: :manpage
assert_equal '\&.', output.lines.last.chomp
end
@@ -200,7 +200,7 @@ AAA this line of text should be show
.if 1 .nx
BBB this line and the one above it should be visible)
- output = Asciidoctor.convert input, :backend => :manpage
+ output = Asciidoctor.convert input, backend: :manpage
assert_equal '\&.if 1 .nx', output.lines[-2].chomp
end
@@ -212,7 +212,7 @@ Oh, here it goes again
should have known,
should have known again)
- output = Asciidoctor.convert input, :backend => :manpage
+ output = Asciidoctor.convert input, backend: :manpage
assert_includes output, %(Oh, here it goes again\nI should have known,\nshould have known,\nshould have known again)
end
@@ -224,7 +224,7 @@ should have known again)
should have known,
should have known again)
- output = Asciidoctor.convert input, :backend => :manpage
+ output = Asciidoctor.convert input, backend: :manpage
assert_includes output, %(Oh, here it goes again\nI should have known,\nshould have known,\nshould have known again)
end
@@ -233,9 +233,9 @@ should have known again)
Describe this thing.)
- output = Asciidoctor.convert input, :backend => :manpage, :header_footer => true, :attributes => {
+ output = Asciidoctor.convert input, backend: :manpage, header_footer: true, attributes: {
'manmanual' => %(General\nCommands\nManual),
- 'mansource' => %(Control\nAll\nThe\nThings\n5.0)
+ 'mansource' => %(Control\nAll\nThe\nThings\n5.0),
}
assert_includes output, 'Manual: General Commands Manual'
assert_includes output, 'Source: Control All The Things 5.0'
@@ -246,7 +246,7 @@ Describe this thing.)
context 'Backslash' do
test 'should not escape spaces for empty manual or source fields' do
input = SAMPLE_MANPAGE_HEADER.lines.select {|l| !l.start_with?(':man ') }
- output = Asciidoctor.convert input, :backend => :manpage, :header_footer => true
+ output = Asciidoctor.convert input, backend: :manpage, header_footer: true
assert_match ' Manual: \ \&', output
assert_match ' Source: \ \&', output
assert_match(/^\.TH "COMMAND" .* "\\ \\&" "\\ \\&"$/, output)
@@ -256,7 +256,7 @@ Describe this thing.)
input = %(#{SAMPLE_MANPAGE_HEADER}
"`hello`" '`goodbye`' *strong* _weak_ `even`)
- output = Asciidoctor.convert input, :backend => :manpage
+ output = Asciidoctor.convert input, backend: :manpage
assert_equal '\(lqhello\(rq \(oqgoodbye\(cq \fBstrong\fP \fIweak\fP \f(CReven\fP', output.lines.last.chomp
end
@@ -265,7 +265,7 @@ Describe this thing.)
\\.foo \\ bar\\
baz)
- output = Asciidoctor.convert input, :backend => :manpage
+ output = Asciidoctor.convert input, backend: :manpage
assert_equal '\(rs.foo \(rs bar\(rs', output.lines[-2].chomp
end
@@ -273,7 +273,7 @@ baz)
input = %(#{SAMPLE_MANPAGE_HEADER}
\\fB makes text bold)
- output = Asciidoctor.convert input, :backend => :manpage
+ output = Asciidoctor.convert input, backend: :manpage
assert_match '\(rsfB makes text bold', output
end
@@ -282,7 +282,7 @@ baz)
Before break. +
After break.)
- output = Asciidoctor.convert input, :backend => :manpage
+ output = Asciidoctor.convert input, backend: :manpage
assert_equal 'Before break.
.br
After break.', output.lines[-3..-1].join
@@ -295,7 +295,7 @@ After break.', output.lines[-3..-1].join
First paragraph.
http://asciidoc.org[AsciiDoc])
- output = Asciidoctor.convert input, :backend => :manpage
+ output = Asciidoctor.convert input, backend: :manpage
assert_equal '.sp
First paragraph.
.sp
@@ -306,7 +306,7 @@ First paragraph.
input = %(#{SAMPLE_MANPAGE_HEADER}
http://asciidoc.org[AsciiDoc] can be used to create man pages.)
- output = Asciidoctor.convert input, :backend => :manpage
+ output = Asciidoctor.convert input, backend: :manpage
assert_equal '.URL "http://asciidoc.org" "AsciiDoc" " "
can be used to create man pages.', output.lines[-2..-1].join
end
@@ -315,7 +315,7 @@ can be used to create man pages.', output.lines[-2..-1].join
input = %(#{SAMPLE_MANPAGE_HEADER}
This is http://asciidoc.org[AsciiDoc].)
- output = Asciidoctor.convert input, :backend => :manpage
+ output = Asciidoctor.convert input, backend: :manpage
assert_equal 'This is \c
.URL "http://asciidoc.org" "AsciiDoc" "."', output.lines[-2..-1].join
end
@@ -324,7 +324,7 @@ This is http://asciidoc.org[AsciiDoc].)
input = %(#{SAMPLE_MANPAGE_HEADER}
This is http://asciidoc.org[AsciiDoc], which can be used to write content.)
- output = Asciidoctor.convert input, :backend => :manpage
+ output = Asciidoctor.convert input, backend: :manpage
assert_equal 'This is \c
.URL "http://asciidoc.org" "AsciiDoc" ","
which can be used to write content.', output.lines[-3..-1].join
@@ -339,7 +339,7 @@ http://ccl.clozure.com[Clozure CL],
http://cmucl.org[CMUCL],
http://ecls.sf.net[ECL],
and http://sbcl.sf.net[SBCL].)
- output = Asciidoctor.convert input, :backend => :manpage
+ output = Asciidoctor.convert input, backend: :manpage
assert_equal '.sp
The corresponding implementations are
.URL "http://clisp.sf.net" "CLISP" ","
@@ -354,7 +354,7 @@ and \c
input = %(#{SAMPLE_MANPAGE_HEADER}
The corresponding implementations are http://clisp.sf.net[CLISP], http://ccl.clozure.com[Clozure CL], http://cmucl.org[CMUCL], http://ecls.sf.net[ECL], and http://sbcl.sf.net[SBCL].)
- output = Asciidoctor.convert input, :backend => :manpage
+ output = Asciidoctor.convert input, backend: :manpage
assert_equal '.sp
The corresponding implementations are \c
.URL "http://clisp.sf.net" "CLISP" ","
@@ -369,7 +369,7 @@ and
input = %(#{SAMPLE_MANPAGE_HEADER}
Please search |link:http://discuss.asciidoctor.org[the forums]| before asking.)
- output = Asciidoctor.convert input, :backend => :manpage
+ output = Asciidoctor.convert input, backend: :manpage
assert_equal '.sp
Please search |\c
.URL "http://discuss.asciidoctor.org" "the forums" "|"
@@ -380,7 +380,7 @@ before asking.', output.lines[-4..-1].join
input = %(#{SAMPLE_MANPAGE_HEADER}
Enter the link:cat[`cat`] command.)
- output = Asciidoctor.convert input, :backend => :manpage
+ output = Asciidoctor.convert input, backend: :manpage
assert_equal '.sp
Enter the \c
.URL "cat" "\f(CRcat\fP" " "
@@ -394,7 +394,7 @@ command.', output.lines[-4..-1].join
First paragraph.
mailto:doc@example.org[Contact the doc])
- output = Asciidoctor.convert input, :backend => :manpage
+ output = Asciidoctor.convert input, backend: :manpage
assert_equal '.sp
First paragraph.
.sp
@@ -404,7 +404,7 @@ First paragraph.
test 'should set text of MTO macro to blank for implicit email' do
input = %(#{SAMPLE_MANPAGE_HEADER}
Bugs fixed daily by doc@example.org.)
- output = Asciidoctor.convert input, :backend => :manpage
+ output = Asciidoctor.convert input, backend: :manpage
assert output.end_with? 'Bugs fixed daily by \\c
.MTO "doc\\(atexample.org" "" "."'
end
@@ -421,7 +421,7 @@ Bugs fixed daily by doc@example.org.)
|Body 2
|Footer
|===)
- output = Asciidoctor.convert input, :backend => :manpage
+ output = Asciidoctor.convert input, backend: :manpage
assert output.end_with? 'allbox tab(:);
lt.
T{
@@ -453,7 +453,7 @@ T}
|*bold* |`mono`
|_italic_ | #mark#
|===)
- output = Asciidoctor.convert input, :backend => :manpage
+ output = Asciidoctor.convert input, backend: :manpage
refute_match(/<\/?BOUNDARY>/, output)
end
@@ -468,7 +468,7 @@ T}
| dimension of the object
| 3
|===)
- output = Asciidoctor.convert input, :backend => :manpage
+ output = Asciidoctor.convert input, backend: :manpage
assert output.end_with? '.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
@@ -509,7 +509,7 @@ T}
c _d_
.
|===)
- output = Asciidoctor.convert input, :backend => :manpage
+ output = Asciidoctor.convert input, backend: :manpage
assert output.end_with? '.TS
allbox tab(:);
lt lt.
@@ -536,7 +536,7 @@ T}
c _d_
.
|===)
- output = Asciidoctor.convert input, :backend => :manpage
+ output = Asciidoctor.convert input, backend: :manpage
assert output.end_with? '.TS
allbox tab(:);
lt lt.
@@ -561,7 +561,7 @@ T}
input = %(#{SAMPLE_MANPAGE_HEADER}
The Magic 8 Ball says image:signs-point-to-yes.jpg[].)
- output = Asciidoctor.convert input, :backend => :manpage
+ output = Asciidoctor.convert input, backend: :manpage
assert_includes output, 'The Magic 8 Ball says [signs point to yes].'
end
@@ -569,7 +569,7 @@ The Magic 8 Ball says image:signs-point-to-yes.jpg[].)
input = %(#{SAMPLE_MANPAGE_HEADER}
The Magic 8 Ball says image:signs-point-to-yes.jpg[link=https://en.wikipedia.org/wiki/Magic_8-Ball].)
- output = Asciidoctor.convert input, :backend => :manpage
+ output = Asciidoctor.convert input, backend: :manpage
assert_includes output, 'The Magic 8 Ball says [signs point to yes] <https://en.wikipedia.org/wiki/Magic_8\-Ball>.'
end
end
@@ -583,7 +583,7 @@ ____
Not everything that is faced can be changed.
But nothing can be changed until it is faced.
____)
- output = Asciidoctor.convert input, :backend => :manpage
+ output = Asciidoctor.convert input, backend: :manpage
assert output.end_with? '.RS 3
.ll -.6i
.sp
@@ -608,7 +608,7 @@ But nothing can be changed until it is faced.
$ gem install asciidoctor # <1>
----
<1> Installs the asciidoctor gem from RubyGems.org)
- output = Asciidoctor.convert input, :backend => :manpage
+ output = Asciidoctor.convert input, backend: :manpage
assert output.end_with? '.TS
tab(:);
r lw(\n(.lu*75u/100u).
@@ -624,7 +624,7 @@ T}
old_source_date_epoch = ENV.delete 'SOURCE_DATE_EPOCH'
begin
ENV['SOURCE_DATE_EPOCH'] = '1234123412'
- output = Asciidoctor.convert SAMPLE_MANPAGE_HEADER, :backend => :manpage, :header_footer => true
+ output = Asciidoctor.convert SAMPLE_MANPAGE_HEADER, backend: :manpage, header_footer: true
assert_match(/Date: 2009-02-08/, output)
assert_match(/^\.TH "COMMAND" "1" "2009-02-08" "Command 1.2.3" "Command Manual"$/, output)
ensure
@@ -640,7 +640,7 @@ T}
old_source_date_epoch = ENV.delete 'SOURCE_DATE_EPOCH'
begin
ENV['SOURCE_DATE_EPOCH'] = 'aaaaaaaa'
- Asciidoctor.convert SAMPLE_MANPAGE_HEADER, :backend => :manpage, :header_footer => true
+ Asciidoctor.convert SAMPLE_MANPAGE_HEADER, backend: :manpage, header_footer: true
assert false
rescue
assert true
diff --git a/test/paragraphs_test.rb b/test/paragraphs_test.rb
index 0a5f1446..01a20d37 100644
--- a/test/paragraphs_test.rb
+++ b/test/paragraphs_test.rb
@@ -150,7 +150,7 @@ Here is an index entry for indexterm2:[Linux].
Note that multi-entry terms generate separate index entries.
EOS
- output = convert_string_to_embedded input, :attributes => {'backend' => 'docbook45'}
+ output = convert_string_to_embedded input, attributes: { 'backend' => 'docbook45' }
assert_xpath '/simpara', output, 1
term1 = xmlnodes_at_xpath '(//indexterm)[1]', output, 1
assert_equal '<indexterm><primary>tigers</primary></indexterm>', term1.to_s
@@ -466,7 +466,7 @@ Wise words from a wise person.
Make it what you want.
EOS
- output = convert_string input, :backend => 'docbook'
+ output = convert_string input, backend: 'docbook'
assert_css 'abstract > simpara', output, 1
assert_css 'partintro > simpara', output, 1
assert_css 'sidebar > simpara', output, 1
@@ -519,7 +519,7 @@ As you can see here.
Wise words from a wise person.
EOS
- output = convert_string input, :backend => 'docbook'
+ output = convert_string input, backend: 'docbook'
assert_css 'abstract > title', output, 1
assert_xpath '//abstract/title[text() = "Abstract title"]', output, 1
assert_css 'abstract > title + simpara', output, 1
@@ -541,14 +541,14 @@ Wise words from a wise person.
context 'Inline doctype' do
test 'should only format and output text in first paragraph when doctype is inline' do
input = "http://asciidoc.org[AsciiDoc] is a _lightweight_ markup language...\n\nignored"
- output = convert_string input, :doctype => 'inline'
+ output = convert_string input, doctype: 'inline'
assert_equal '<a href="http://asciidoc.org">AsciiDoc</a> is a <em>lightweight</em> markup language&#8230;&#8203;', output
end
test 'should output nil and warn if first block is not a paragraph' do
input = '* bullet'
using_memory_logger do |logger|
- output = convert_string input, :doctype => 'inline'
+ output = convert_string input, doctype: 'inline'
assert_nil output
assert_message logger, :WARN, '~no inline candidate'
end
diff --git a/test/parser_test.rb b/test/parser_test.rb
index b21c22c2..c0c3b9c0 100644
--- a/test/parser_test.rb
+++ b/test/parser_test.rb
@@ -57,7 +57,7 @@ context "Parser" do
end
test 'store inaccessible attribute on document with value' do
- doc = empty_document :attributes => { 'foo' => 'baz' }
+ doc = empty_document attributes: { 'foo' => 'baz' }
attrs = {}
attr_name, attr_value = Asciidoctor::Parser.store_attribute 'foo', 'bar', doc, attrs
assert_equal 'foo', attr_name
@@ -83,7 +83,7 @@ context "Parser" do
test 'store inaccessible attribute on document with negated value' do
{ 'foo!' => nil, '!foo' => nil, 'foo' => nil }.each do |name, value|
- doc = empty_document :attributes => { 'foo' => 'baz' }
+ doc = empty_document attributes: { 'foo' => 'baz' }
attrs = {}
attr_name, attr_value = Asciidoctor::Parser.store_attribute name, value, doc, attrs
assert_equal name.sub('!', ''), attr_name
@@ -93,7 +93,7 @@ context "Parser" do
end
test 'parse style attribute with id and role' do
- attributes = {1 => 'style#id.role'}
+ attributes = { 1 => 'style#id.role' }
style = Asciidoctor::Parser.parse_style_attribute(attributes)
assert_equal 'style', style
assert_equal 'style', attributes['style']
@@ -103,7 +103,7 @@ context "Parser" do
end
test 'parse style attribute with style, role, id and option' do
- attributes = {1 => 'style.role#id%fragment'}
+ attributes = { 1 => 'style.role#id%fragment' }
style = Asciidoctor::Parser.parse_style_attribute(attributes)
assert_equal 'style', style
assert_equal 'style', attributes['style']
@@ -115,7 +115,7 @@ context "Parser" do
end
test 'parse style attribute with style, id and multiple roles' do
- attributes = {1 => 'style#id.role1.role2'}
+ attributes = { 1 => 'style#id.role1.role2' }
style = Asciidoctor::Parser.parse_style_attribute(attributes)
assert_equal 'style', style
assert_equal 'style', attributes['style']
@@ -125,7 +125,7 @@ context "Parser" do
end
test 'parse style attribute with style, multiple roles and id' do
- attributes = {1 => 'style.role1.role2#id'}
+ attributes = { 1 => 'style.role1.role2#id' }
style = Asciidoctor::Parser.parse_style_attribute(attributes)
assert_equal 'style', style
assert_equal 'style', attributes['style']
@@ -135,7 +135,7 @@ context "Parser" do
end
test 'parse style attribute with positional and original style' do
- attributes = {1 => 'new_style', 'style' => 'original_style'}
+ attributes = { 1 => 'new_style', 'style' => 'original_style' }
style = Asciidoctor::Parser.parse_style_attribute(attributes)
assert_equal 'new_style', style
assert_equal 'new_style', attributes['style']
@@ -143,7 +143,7 @@ context "Parser" do
end
test 'parse style attribute with id and role only' do
- attributes = {1 => '#id.role'}
+ attributes = { 1 => '#id.role' }
style = Asciidoctor::Parser.parse_style_attribute(attributes)
assert_nil style
assert_equal 'id', attributes['id']
@@ -152,7 +152,7 @@ context "Parser" do
end
test 'parse empty style attribute' do
- attributes = {1 => nil}
+ attributes = { 1 => nil }
style = Asciidoctor::Parser.parse_style_attribute(attributes)
assert_nil style
assert_nil attributes['id']
@@ -161,7 +161,7 @@ context "Parser" do
end
test 'parse style attribute with option should preserve existing options' do
- attributes = {1 => '%header', 'options' => 'footer', 'footer-option' => ''}
+ attributes = { 1 => '%header', 'options' => 'footer', 'footer-option' => '' }
style = Asciidoctor::Parser.parse_style_attribute(attributes)
assert_nil style
assert_equal 'footer,header', attributes['options']
@@ -454,10 +454,10 @@ v{project-version}, {release-date}: {release-summary}
Author Name
{project-version}, {release-date}: {release-summary}
EOS
- doc = document_from_string input, :attributes => {
+ doc = document_from_string input, attributes: {
'project-version' => '1.0.1',
'release-date' => '2018-05-15',
- 'release-summary' => 'The one you can count on!'
+ 'release-summary' => 'The one you can count on!',
}
assert_equal '1.0.1', (doc.attr 'revnumber')
assert_equal '2018-05-15', (doc.attr 'revdate')
diff --git a/test/paths_test.rb b/test/paths_test.rb
index 8dae5696..292c3fb9 100644
--- a/test/paths_test.rb
+++ b/test/paths_test.rb
@@ -145,7 +145,7 @@ context 'Path Resolver' do
test 'throws exception for illegal path access if recover is false' do
begin
- @resolver.system_path('../../../../../css', "#{JAIL}/assets/stylesheets", JAIL, :recover => false)
+ @resolver.system_path('../../../../../css', "#{JAIL}/assets/stylesheets", JAIL, recover: false)
flunk 'Expecting SecurityError to be raised'
rescue SecurityError
end
@@ -244,13 +244,13 @@ context 'Path Resolver' do
test 'raises security error if start is not contained within jail and recover is disabled' do
begin
- @resolver.system_path('images/tiger.png', '/etc', JAIL, :recover => false)
+ @resolver.system_path('images/tiger.png', '/etc', JAIL, recover: false)
flunk 'Expecting SecurityError to be raised'
rescue SecurityError
end
begin
- @resolver.system_path('.', '/etc', JAIL, :recover => false)
+ @resolver.system_path('.', '/etc', JAIL, recover: false)
flunk 'Expecting SecurityError to be raised'
rescue SecurityError
end
@@ -359,7 +359,7 @@ context 'Path Resolver' do
test 'should resolve relative path relative to base dir in unsafe mode' do
base_dir = fixture_path 'base'
- doc = empty_document :base_dir => base_dir, :safe => Asciidoctor::SafeMode::UNSAFE
+ doc = empty_document base_dir: base_dir, safe: Asciidoctor::SafeMode::UNSAFE
expected = ::File.join base_dir, 'images', 'tiger.png'
actual = doc.normalize_system_path 'tiger.png', 'images'
assert_equal expected, actual
@@ -367,7 +367,7 @@ context 'Path Resolver' do
test 'should resolve absolute path as absolute in unsafe mode' do
base_dir = fixture_path 'base'
- doc = empty_document :base_dir => base_dir, :safe => Asciidoctor::SafeMode::UNSAFE
+ doc = empty_document base_dir: base_dir, safe: Asciidoctor::SafeMode::UNSAFE
actual = doc.normalize_system_path 'tiger.png', '/etc/images'
assert_equal '/etc/images/tiger.png', actual
end
diff --git a/test/preamble_test.rb b/test/preamble_test.rb
index b6cd27b3..47c723f4 100644
--- a/test/preamble_test.rb
+++ b/test/preamble_test.rb
@@ -31,7 +31,7 @@ Preface content.
Section content.
EOS
- result = convert_string input, :backend => :docbook
+ result = convert_string input, backend: :docbook
assert_xpath '//preface/title', result, 1
title_node = xmlnodes_at_xpath '//preface/title', result, 1
assert_equal '', title_node.text
@@ -49,7 +49,7 @@ Preface content.
Section content.
EOS
- result = convert_string input, :backend => :docbook
+ result = convert_string input, backend: :docbook
assert_xpath '//preface/title[text()="Preface"]', result, 1
end
diff --git a/test/reader_test.rb b/test/reader_test.rb
index ed03084e..a1419556 100644
--- a/test/reader_test.rb
+++ b/test/reader_test.rb
@@ -24,7 +24,7 @@ third line
test 'should remove UTF-8 BOM from first line of String data' do
['UTF-8', 'ASCII-8BIT'].each do |start_encoding|
data = "\xef\xbb\xbf#{SAMPLE_DATA.join ::Asciidoctor::LF}".force_encoding start_encoding
- reader = Asciidoctor::Reader.new data, nil, :normalize => true
+ reader = Asciidoctor::Reader.new data, nil, normalize: true
assert_equal Encoding::UTF_8, reader.lines[0].encoding
assert_equal 'f', reader.lines[0].chr
assert_equal SAMPLE_DATA, reader.lines
@@ -35,7 +35,7 @@ third line
['UTF-8', 'ASCII-8BIT'].each do |start_encoding|
data = SAMPLE_DATA.dup
data[0] = "\xef\xbb\xbf#{data.first}".force_encoding start_encoding
- reader = Asciidoctor::Reader.new data, nil, :normalize => true
+ reader = Asciidoctor::Reader.new data, nil, normalize: true
assert_equal Encoding::UTF_8, reader.lines[0].encoding
assert_equal 'f', reader.lines[0].chr
assert_equal SAMPLE_DATA, reader.lines
@@ -45,7 +45,7 @@ third line
test 'should encode UTF-16LE string to UTF-8 when BOM is found' do
['UTF-8', 'ASCII-8BIT'].each do |start_encoding|
data = "\ufeff#{SAMPLE_DATA.join ::Asciidoctor::LF}".encode('UTF-16LE').force_encoding(start_encoding)
- reader = Asciidoctor::Reader.new data, nil, :normalize => true
+ reader = Asciidoctor::Reader.new data, nil, normalize: true
assert_equal Encoding::UTF_8, reader.lines[0].encoding
assert_equal 'f', reader.lines[0].chr
assert_equal SAMPLE_DATA, reader.lines
@@ -58,7 +58,7 @@ third line
data = SAMPLE_DATA.dup
data.unshift %(\ufeff#{data.shift})
data.each {|line| (line.encode 'UTF-16LE').force_encoding start_encoding }
- reader = Asciidoctor::Reader.new data, nil, :normalize => true
+ reader = Asciidoctor::Reader.new data, nil, normalize: true
assert_equal Encoding::UTF_8, reader.lines[0].encoding
assert_equal 'f', reader.lines[0].chr
assert_equal SAMPLE_DATA, reader.lines
@@ -68,7 +68,7 @@ third line
test 'should encode UTF-16BE string to UTF-8 when BOM is found' do
['UTF-8', 'ASCII-8BIT'].each do |start_encoding|
data = "\ufeff#{SAMPLE_DATA.join ::Asciidoctor::LF}".encode('UTF-16BE').force_encoding(start_encoding)
- reader = Asciidoctor::Reader.new data, nil, :normalize => true
+ reader = Asciidoctor::Reader.new data, nil, normalize: true
assert_equal Encoding::UTF_8, reader.lines[0].encoding
assert_equal 'f', reader.lines[0].chr
assert_equal SAMPLE_DATA, reader.lines
@@ -80,7 +80,7 @@ third line
data = SAMPLE_DATA.dup
data.unshift %(\ufeff#{data.shift})
data = data.map {|line| (line.encode 'UTF-16BE').force_encoding start_encoding }
- reader = Asciidoctor::Reader.new data, nil, :normalize => true
+ reader = Asciidoctor::Reader.new data, nil, normalize: true
assert_equal Encoding::UTF_8, reader.lines[0].encoding
assert_equal 'f', reader.lines[0].chr
assert_equal SAMPLE_DATA, reader.lines
@@ -223,7 +223,7 @@ third line
end
test 'unshift puts line onto Reader as next line to read' do
- reader = Asciidoctor::Reader.new SAMPLE_DATA, nil, :normalize => true
+ reader = Asciidoctor::Reader.new SAMPLE_DATA, nil, normalize: true
reader.unshift 'line zero'
assert_equal 'line zero', reader.peek_line
assert_equal 'line zero', reader.read_line
@@ -292,7 +292,7 @@ This is one paragraph.
This is another paragraph.
EOS
- reader = Asciidoctor::Reader.new lines, nil, :normalize => true
+ reader = Asciidoctor::Reader.new lines, nil, normalize: true
result = reader.read_lines_until
assert_equal 3, result.size
assert_equal lines.map {|l| l.chomp }, result
@@ -307,8 +307,8 @@ This is one paragraph.
This is another paragraph.
EOS
- reader = Asciidoctor::Reader.new lines, nil, :normalize => true
- result = reader.read_lines_until :break_on_blank_lines => true
+ reader = Asciidoctor::Reader.new lines, nil, normalize: true
+ result = reader.read_lines_until break_on_blank_lines: true
assert_equal 1, result.size
assert_equal lines.first.chomp, result.first
assert_equal lines.last.chomp, reader.peek_line
@@ -322,7 +322,7 @@ This is another paragraph.
EOS
reader = Asciidoctor::Reader.new lines
- result = reader.read_lines_until :break_on_blank_lines => true, :preserve_last_line => true
+ result = reader.read_lines_until break_on_blank_lines: true, preserve_last_line: true
assert_equal 1, result.size
assert_equal lines.first.chomp, result.first
assert reader.next_line_empty?
@@ -360,7 +360,7 @@ This is a paragraph outside the block.
reader = Asciidoctor::Reader.new lines
reader.read_line
- result = reader.read_lines_until(:read_last_line => true) {|line| line == '--' }
+ result = reader.read_lines_until(read_last_line: true) {|line| line == '--' }
assert_equal 4, result.size
assert_equal lines[1, 4], result
assert reader.next_line_empty?
@@ -379,7 +379,7 @@ This is a paragraph outside the block.
reader = Asciidoctor::Reader.new lines
reader.read_line
- result = reader.read_lines_until(:read_last_line => true, :preserve_last_line => true) {|line| line == '--' }
+ result = reader.read_lines_until(read_last_line: true, preserve_last_line: true) {|line| line == '--' }
assert_equal 4, result.size
assert_equal lines[1, 4], result
assert_equal '--', reader.peek_line
@@ -398,10 +398,10 @@ not captured
expected = ['captured', '', 'also captured']
- doc = empty_safe_document :base_dir => DIRNAME
- reader = Asciidoctor::PreprocessorReader.new doc, lines, nil, :normalize => true
+ doc = empty_safe_document base_dir: DIRNAME
+ reader = Asciidoctor::PreprocessorReader.new doc, lines, nil, normalize: true
terminator = reader.read_line
- result = reader.read_lines_until :terminator => terminator, :skip_processing => true
+ result = reader.read_lines_until terminator: terminator, skip_processing: true
assert_equal expected, result
refute reader.unterminated
end
@@ -419,10 +419,10 @@ captured yet again
expected = lines[1..-1].map {|l| l.chomp }
using_memory_logger do |logger|
- doc = empty_safe_document :base_dir => DIRNAME
- reader = Asciidoctor::PreprocessorReader.new doc, lines, nil, :normalize => true
+ doc = empty_safe_document base_dir: DIRNAME
+ reader = Asciidoctor::PreprocessorReader.new doc, lines, nil, normalize: true
terminator = reader.peek_line
- result = reader.read_lines_until :terminator => terminator, :skip_first_line => true, :skip_processing => true
+ result = reader.read_lines_until terminator: terminator, skip_first_line: true, skip_processing: true
assert_equal expected, result
assert reader.unterminated
assert_message logger, :WARN, '<stdin>: line 1: unterminated **** block', Hash
@@ -520,7 +520,7 @@ Author Name
preamble
EOS
- doc = Asciidoctor::Document.new input, :attributes => {'skip-front-matter' => ''}
+ doc = Asciidoctor::Document.new input, attributes: { 'skip-front-matter' => '' }
reader = doc.reader
assert_equal '= Document Title', reader.peek_line
assert_equal front_matter, doc.attributes['front-matter']
@@ -603,7 +603,7 @@ include::include-file.asciidoc[]
include::fixtures/include-file.asciidoc[]
EOS
- doc = document_from_string input, :safe => :safe, :header_footer => false, :base_dir => DIRNAME
+ doc = document_from_string input, safe: :safe, header_footer: false, base_dir: DIRNAME
output = doc.convert
assert_match(/included content/, output)
assert doc.catalog[:includes]['fixtures/include-file']
@@ -616,7 +616,7 @@ include::fixtures/circle.svg[]
----
EOS
- doc = document_from_string input, :safe => :safe, :header_footer => false, :base_dir => DIRNAME
+ doc = document_from_string input, safe: :safe, header_footer: false, base_dir: DIRNAME
assert doc.catalog[:includes].empty?
end
@@ -629,7 +629,7 @@ include::fixtures/include file.asciidoc[]
include_file_with_sp = File.join DIRNAME, 'fixtures', 'include file.asciidoc'
begin
FileUtils.cp include_file, include_file_with_sp
- doc = document_from_string input, :safe => :safe, :header_footer => false, :base_dir => DIRNAME
+ doc = document_from_string input, safe: :safe, header_footer: false, base_dir: DIRNAME
output = doc.convert
assert_match(/included content/, output)
ensure
@@ -646,7 +646,7 @@ include::fixtures/include{sp}file.asciidoc[]
include_file_with_sp = File.join DIRNAME, 'fixtures', 'include file.asciidoc'
begin
FileUtils.cp include_file, include_file_with_sp
- doc = document_from_string input, :safe => :safe, :header_footer => false, :base_dir => DIRNAME
+ doc = document_from_string input, safe: :safe, header_footer: false, base_dir: DIRNAME
output = doc.convert
assert_match(/included content/, output)
ensure
@@ -665,8 +665,8 @@ include::fixtures/parent-include.adoc[]
child_include_docfile = File.join fixtures_dir, 'child-include.adoc'
grandchild_include_docfile = File.join fixtures_dir, 'grandchild-include.adoc'
- doc = empty_safe_document :base_dir => DIRNAME
- reader = Asciidoctor::PreprocessorReader.new doc, input, pseudo_docfile, :normalize => true
+ doc = empty_safe_document base_dir: DIRNAME
+ reader = Asciidoctor::PreprocessorReader.new doc, input, pseudo_docfile, normalize: true
assert_equal pseudo_docfile, reader.file
assert_equal DIRNAME, reader.dir
@@ -724,7 +724,7 @@ trailing content
begin
using_memory_logger do |logger|
- doc = document_from_string input, :safe => :safe, :base_dir => DIRNAME
+ doc = document_from_string input, safe: :safe, base_dir: DIRNAME
assert_equal 1, doc.blocks.size
assert_equal ['trailing content'], doc.blocks[0].lines
assert logger.empty?
@@ -743,7 +743,7 @@ trailing content
begin
using_memory_logger do |logger|
- doc = document_from_string input, :safe => :safe, :base_dir => DIRNAME
+ doc = document_from_string input, safe: :safe, base_dir: DIRNAME
assert_equal 2, doc.blocks.size
assert_equal ['Unresolved directive in <stdin> - include::fixtures/no-such-file.adoc[]'], doc.blocks[0].lines
assert_equal ['trailing content'], doc.blocks[1].lines
@@ -765,7 +765,7 @@ trailing content
begin
using_memory_logger do |logger|
- doc = document_from_string input, :safe => :safe, :base_dir => DIRNAME
+ doc = document_from_string input, safe: :safe, base_dir: DIRNAME
assert_equal 2, doc.blocks.size
assert_equal ['Unresolved directive in <stdin> - include::fixtures/chapter-a.adoc[]'], doc.blocks[0].lines
assert_equal ['trailing content'], doc.blocks[1].lines
@@ -784,10 +784,10 @@ trailing content
input = <<-EOS
include::#{include_path}[]
EOS
- result = document_from_string input, :safe => :safe
+ result = document_from_string input, safe: :safe
assert_equal 'Chapter A', result.doctitle
- result = document_from_string input, :safe => :unsafe, :base_dir => ::Dir.tmpdir
+ result = document_from_string input, safe: :unsafe, base_dir: ::Dir.tmpdir
assert_equal 'Chapter A', result.doctitle
end
@@ -800,7 +800,7 @@ include::#{url}[]
EOS
expect = /\{"name": "asciidoctor"\}/
output = using_test_webserver do
- convert_string_to_embedded input, :safe => :safe, :attributes => {'allow-uri-read' => ''}
+ convert_string_to_embedded input, safe: :safe, attributes: { 'allow-uri-read' => '' }
end
refute_nil output
@@ -814,7 +814,7 @@ include::fixtures/outer-include.adoc[]
....
EOS
- output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME
+ output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
expected = 'first line of outer
first line of middle
@@ -837,7 +837,7 @@ include::#{url}[]
....
EOS
output = using_test_webserver do
- convert_string_to_embedded input, :safe => :safe, :attributes => {'allow-uri-read' => ''}
+ convert_string_to_embedded input, safe: :safe, attributes: { 'allow-uri-read' => '' }
end
expected = 'first line of outer
@@ -865,7 +865,7 @@ include::#{include_url}[]
begin
using_memory_logger do |logger|
result = using_test_webserver do
- convert_string_to_embedded input, :safe => :safe, :attributes => {'allow-uri-read' => ''}
+ convert_string_to_embedded input, safe: :safe, attributes: { 'allow-uri-read' => '' }
end
assert_includes result, %(Unresolved directive in #{include_url} - include::#{nested_include_url}[])
assert_message logger, :ERROR, %(#{include_url}: line 1: include uri not readable: http://#{resolve_localhost}:9876/fixtures/#{nested_include_url}), Hash
@@ -884,7 +884,7 @@ include::#{url}[tag=init,indent=0]
----
EOS
output = using_test_webserver do
- convert_string_to_embedded input, :safe => :safe, :attributes => {'allow-uri-read' => ''}
+ convert_string_to_embedded input, safe: :safe, attributes: { 'allow-uri-read' => '' }
end
expected = '<code class="language-ruby" data-lang="ruby">def initialize breed
@@ -904,7 +904,7 @@ include::#{url}[]
begin
using_memory_logger do |logger|
output = using_test_webserver do
- convert_string_to_embedded input, :safe => :safe, :attributes => {'allow-uri-read' => ''}
+ convert_string_to_embedded input, safe: :safe, attributes: { 'allow-uri-read' => '' }
end
refute_nil output
assert_match(/Unresolved directive/, output)
@@ -920,7 +920,7 @@ include::#{url}[]
include::fixtures/include-file.asciidoc[lines=1;3..4;6..-1]
EOS
- output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME
+ output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
assert_match(/first line/, output)
refute_match(/second line/, output)
assert_match(/third line/, output)
@@ -937,7 +937,7 @@ include::fixtures/include-file.asciidoc[lines=1;3..4;6..-1]
include::fixtures/include-file.asciidoc[lines="1, 3..4 , 6 .. -1"]
EOS
- output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME
+ output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
assert_match(/first line/, output)
refute_match(/second line/, output)
assert_match(/third line/, output)
@@ -954,7 +954,7 @@ include::fixtures/include-file.asciidoc[lines="1, 3..4 , 6 .. -1"]
include::fixtures/include-file.asciidoc[lines=6..]
EOS
- output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME
+ output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
refute_match(/first line/, output)
refute_match(/second line/, output)
refute_match(/third line/, output)
@@ -973,7 +973,7 @@ include::fixtures/include-file.asciidoc[lines=]
++++
EOS
- output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME
+ output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
assert_includes output, 'first line of included content'
assert_includes output, 'last line of included content'
end
@@ -983,7 +983,7 @@ include::fixtures/include-file.asciidoc[lines=]
include::fixtures/include-file.asciidoc[tag=snippetA]
EOS
- output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME
+ output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
assert_match(/snippetA content/, output)
refute_match(/snippetB content/, output)
refute_match(/non-tagged content/, output)
@@ -995,7 +995,7 @@ include::fixtures/include-file.asciidoc[tag=snippetA]
include::fixtures/include-file.asciidoc[tags=snippetA;snippetB]
EOS
- output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME
+ output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
assert_match(/snippetA content/, output)
assert_match(/snippetB content/, output)
refute_match(/non-tagged content/, output)
@@ -1006,7 +1006,7 @@ include::fixtures/include-file.asciidoc[tags=snippetA;snippetB]
{
'include-file.xml' => '<snippet>content</snippet>',
'include-file.ml' => 'let s = SS.empty;;',
- 'include-file.jsx' => '<p>Welcome to the club.</p>'
+ 'include-file.jsx' => '<p>Welcome to the club.</p>',
}.each do |filename, expect|
input = <<-EOS
[source,xml]
@@ -1015,7 +1015,7 @@ include::fixtures/#{filename}[tag=snippet,indent=0]
----
EOS
- doc = document_from_string input, :safe => :safe, :base_dir => DIRNAME
+ doc = document_from_string input, safe: :safe, base_dir: DIRNAME
assert_equal expect, doc.blocks[0].source
end
end
@@ -1029,12 +1029,12 @@ include::fixtures/#{filename}[tag=snippet,indent=0]
input = <<-EOS
include::#{tmp_include_path}[tag=include-me]
EOS
- output = convert_string_to_embedded input, :safe => :safe, :base_dir => tmp_include_dir
+ output = convert_string_to_embedded input, safe: :safe, base_dir: tmp_include_dir
assert_includes output, 'included line'
refute_includes output, 'do not include'
ensure
tmp_include.close!
- end
+ end
end
test 'include directive finds closing tag on last line of file without a trailing newline' do
@@ -1047,14 +1047,14 @@ include::#{tmp_include_path}[tag=include-me]
include::#{tmp_include_path}[tag=include-me]
EOS
using_memory_logger do |logger|
- output = convert_string_to_embedded input, :safe => :safe, :base_dir => tmp_include_dir
+ output = convert_string_to_embedded input, safe: :safe, base_dir: tmp_include_dir
assert_empty logger.messages
assert_includes output, 'line included'
refute_includes output, 'line not included'
end
ensure
tmp_include.close!
- end
+ end
end
test 'include directive does not select lines with tag directives within selected tag region' do
@@ -1064,7 +1064,7 @@ include::fixtures/include-file.asciidoc[tags=snippet]
++++
EOS
- output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME
+ output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
expect = %(snippetA content
non-tagged content
@@ -1080,7 +1080,7 @@ include::fixtures/tagged-class-enclosed.rb[tags=all;!bark]
----
EOS
- output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME
+ output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
expected = %(class Dog
def initialize breed
@breed = breed
@@ -1096,7 +1096,7 @@ include::fixtures/tagged-class.rb[tags=**]
----
EOS
- output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME
+ output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
expected = %(class Dog
def initialize breed
@breed = breed
@@ -1120,7 +1120,7 @@ include::fixtures/tagged-class.rb[tags=**;!bark]
----
EOS
- output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME
+ output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
expected = %(class Dog
def initialize breed
@breed = breed
@@ -1136,7 +1136,7 @@ include::fixtures/tagged-class-enclosed.rb[tags=*]
----
EOS
- output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME
+ output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
expected = %(class Dog
def initialize breed
@breed = breed
@@ -1160,7 +1160,7 @@ include::fixtures/tagged-class-enclosed.rb[tags=*;!init]
----
EOS
- output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME
+ output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
expected = %(class Dog
def bark
@@ -1181,7 +1181,7 @@ include::fixtures/tagged-class.rb[tags=!*]
----
EOS
- output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME
+ output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
expected = %(class Dog
end)
assert_includes output, expected
@@ -1195,7 +1195,7 @@ include::fixtures/tagged-class.rb[tags=bark;!bark-other]
----
EOS
- output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME
+ output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
expected = %(def bark
if @breed == 'beagle'
'woof woof woof woof woof'
@@ -1210,7 +1210,7 @@ include::fixtures/include-file.asciidoc[tag=no-such-tag]
EOS
using_memory_logger do |logger|
- convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME
+ convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
assert_message logger, :WARN, %(~<stdin>: line 1: tag 'no-such-tag' not found in include file), Hash
end
end
@@ -1223,7 +1223,7 @@ include::fixtures/include-file.asciidoc[tags=no-such-tag-b;no-such-tag-a]
EOS
using_memory_logger do |logger|
- convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME
+ convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
expected_tags = 'no-such-tag-b, no-such-tag-a'
assert_message logger, :WARN, %(~<stdin>: line 2: tags '#{expected_tags}' not found in include file), Hash
end
@@ -1237,7 +1237,7 @@ include::fixtures/unclosed-tag.adoc[tag=a]
EOS
using_memory_logger do |logger|
- result = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME
+ result = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
assert_equal 'a', result
assert_message logger, :WARN, %(~<stdin>: line 2: detected unclosed tag 'a' starting at line 2 of include file), Hash
refute_nil logger.messages[0][:message][:include_location]
@@ -1253,7 +1253,7 @@ include::fixtures/mismatched-end-tag.adoc[tags=a;b]
inc_path = File.join DIRNAME, 'fixtures/mismatched-end-tag.adoc'
using_memory_logger do |logger|
- result = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME
+ result = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
assert_equal %(a\nb), result
assert_message logger, :WARN, %(<stdin>: line 2: mismatched end tag (expected 'b' but found 'a') at line 5 of include file: #{inc_path}), Hash
refute_nil logger.messages[0][:message][:include_location]
@@ -1269,7 +1269,7 @@ include::fixtures/unexpected-end-tag.adoc[tags=a]
inc_path = File.join DIRNAME, 'fixtures/unexpected-end-tag.adoc'
using_memory_logger do |logger|
- result = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME
+ result = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
assert_equal 'a', result
assert_message logger, :WARN, %(<stdin>: line 2: unexpected end tag 'a' at line 4 of include file: #{inc_path}), Hash
refute_nil logger.messages[0][:message][:include_location]
@@ -1284,7 +1284,7 @@ include::fixtures/include-file.xml[#{attr_name}=]
++++
EOS
- output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME
+ output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
assert_match(/(?:tag|end)::/, output, 2)
end
end
@@ -1294,7 +1294,7 @@ include::fixtures/include-file.xml[#{attr_name}=]
include::fixtures/include-file.asciidoc[lines=1, tags=snippetA;snippetB]
EOS
- output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME
+ output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
assert_match(/first line of included content/, output)
refute_match(/snippetA content/, output)
refute_match(/snippetB content/, output)
@@ -1308,7 +1308,7 @@ include::fixtures/basic-docinfo.xml[lines=2..3, indent=0]
----
EOS
- output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME
+ output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
result = xmlnodes_at_xpath('//pre', output, 1).text
assert_equal "<year>2013</year>\n<holder>Acme™, Inc.</holder>", result
end
@@ -1319,7 +1319,7 @@ include::fixtures/basic-docinfo.xml[lines=2..3, indent=0]
include::fixtures/include-file.asciidoc[tag={name-of-tag}]
EOS
- output = convert_string_to_embedded input, :safe => :safe, :base_dir => DIRNAME
+ output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
assert_match(/snippetA content/, output)
refute_match(/snippetB content/, output)
refute_match(/non-tagged content/, output)
@@ -1344,8 +1344,8 @@ include::fixtures/include-file.asciidoc[]
end
}
- document = empty_safe_document :base_dir => DIRNAME
- reader = Asciidoctor::PreprocessorReader.new document, input, nil, :normalize => true
+ document = empty_safe_document base_dir: DIRNAME
+ reader = Asciidoctor::PreprocessorReader.new document, input, nil, normalize: true
reader.instance_variable_set '@include_processors', [include_processor.new(document)]
lines = reader.read_lines
source = lines * ::Asciidoctor::LF
@@ -1371,7 +1371,7 @@ content
:leveloffset!:
EOS
- document = Asciidoctor.load input, :safe => :safe, :base_dir => DIRNAME, :parse => false
+ document = Asciidoctor.load input, safe: :safe, base_dir: DIRNAME, parse: false
assert_equal expected, document.reader.read_lines
end
@@ -1383,7 +1383,7 @@ content
include::{fixturesdir}/include-file.{ext}[]
EOS
- doc = document_from_string input, :safe => :safe, :base_dir => DIRNAME
+ doc = document_from_string input, safe: :safe, base_dir: DIRNAME
output = doc.convert
assert_match(/included content/, output)
end
@@ -1394,8 +1394,8 @@ include::{foodir}/include-file.asciidoc[]
EOS
using_memory_logger do |logger|
- doc = empty_safe_document :base_dir => DIRNAME
- reader = Asciidoctor::PreprocessorReader.new doc, input, nil, :normalize => true
+ doc = empty_safe_document base_dir: DIRNAME
+ reader = Asciidoctor::PreprocessorReader.new doc, input, nil, normalize: true
line = reader.read_line
assert_equal 'Unresolved directive in <stdin> - include::{foodir}/include-file.asciidoc[]', line
assert_message logger, :WARN, 'dropping line containing reference to missing attribute: foodir'
@@ -1408,8 +1408,8 @@ include::{foodir}/include-file.asciidoc[]
EOS
using_memory_logger do |logger|
- doc = empty_safe_document :base_dir => DIRNAME, :attributes => {'attribute-missing' => 'drop'}
- reader = Asciidoctor::PreprocessorReader.new doc, input, nil, :normalize => true
+ doc = empty_safe_document base_dir: DIRNAME, attributes: { 'attribute-missing' => 'drop' }
+ reader = Asciidoctor::PreprocessorReader.new doc, input, nil, normalize: true
line = reader.read_line
assert_nil line
assert_message logger, :WARN, 'dropping line containing reference to missing attribute: foodir'
@@ -1423,8 +1423,8 @@ yo
EOS
using_memory_logger do |logger|
- doc = empty_safe_document :base_dir => DIRNAME, :attributes => {'attribute-missing' => 'drop'}
- reader = Asciidoctor::PreprocessorReader.new doc, input, nil, :normalize => true
+ doc = empty_safe_document base_dir: DIRNAME, attributes: { 'attribute-missing' => 'drop' }
+ reader = Asciidoctor::PreprocessorReader.new doc, input, nil, normalize: true
line = reader.read_line
assert_equal 'yo', line
assert_message logger, :WARN, 'dropping line containing reference to missing attribute: foodir'
@@ -1436,8 +1436,8 @@ yo
\\include::fixtures/include-file.asciidoc[]
\\escape preserved here
EOS
- doc = empty_safe_document :base_dir => DIRNAME
- reader = Asciidoctor::PreprocessorReader.new doc, input, nil, :normalize => true
+ doc = empty_safe_document base_dir: DIRNAME
+ reader = Asciidoctor::PreprocessorReader.new doc, input, nil, normalize: true
# we should be able to peek it multiple times and still have the backslash preserved
# this is the test for @unescape_next_line
assert_equal 'include::fixtures/include-file.asciidoc[]', reader.peek_line
@@ -1461,7 +1461,7 @@ yo
input = <<-EOS
include::include-file.asciidoc[]
EOS
- para = block_from_string input, :safe => :safe, :attributes => { 'max-include-depth' => 0 }
+ para = block_from_string input, safe: :safe, attributes: { 'max-include-depth' => 0 }
assert_equal 1, para.lines.size
assert_equal 'include::include-file.asciidoc[]', para.source
end
@@ -1472,7 +1472,7 @@ include::include-file.asciidoc[]
include::include-file.asciidoc[]
EOS
- para = block_from_string input, :safe => :safe, :attributes => { 'max-include-depth' => 0 }
+ para = block_from_string input, safe: :safe, attributes: { 'max-include-depth' => 0 }
assert_equal 1, para.lines.size
assert_equal 'include::include-file.asciidoc[]', para.source
end
@@ -1484,8 +1484,8 @@ include::fixtures/parent-include.adoc[depth=1]
using_memory_logger do |logger|
pseudo_docfile = File.join DIRNAME, 'include-master.adoc'
- doc = empty_safe_document :base_dir => DIRNAME
- reader = Asciidoctor::PreprocessorReader.new doc, input, Asciidoctor::Reader::Cursor.new(pseudo_docfile), :normalize => true
+ doc = empty_safe_document base_dir: DIRNAME
+ reader = Asciidoctor::PreprocessorReader.new doc, input, Asciidoctor::Reader::Cursor.new(pseudo_docfile), normalize: true
lines = reader.readlines
assert_includes lines, 'include::child-include.adoc[]'
assert_message logger, :ERROR, 'fixtures/parent-include.adoc: line 3: maximum include depth of 1 exceeded', Hash
@@ -1499,8 +1499,8 @@ include::fixtures/parent-include-restricted.adoc[depth=3]
using_memory_logger do |logger|
pseudo_docfile = File.join DIRNAME, 'include-master.adoc'
- doc = empty_safe_document :base_dir => DIRNAME
- reader = Asciidoctor::PreprocessorReader.new doc, input, Asciidoctor::Reader::Cursor.new(pseudo_docfile), :normalize => true
+ doc = empty_safe_document base_dir: DIRNAME
+ reader = Asciidoctor::PreprocessorReader.new doc, input, Asciidoctor::Reader::Cursor.new(pseudo_docfile), normalize: true
lines = reader.readlines
assert_includes lines, 'first line of child'
assert_includes lines, 'include::grandchild-include.adoc[]'
@@ -1515,10 +1515,10 @@ include::fixtures/no-such-file.adoc[]
////
EOS
- doc = empty_safe_document :base_dir => DIRNAME
- reader = Asciidoctor::PreprocessorReader.new doc, lines, nil, :normalize => true
+ doc = empty_safe_document base_dir: DIRNAME
+ reader = Asciidoctor::PreprocessorReader.new doc, lines, nil, normalize: true
reader.read_line
- result = reader.read_lines_until(:terminator => '////', :skip_processing => true)
+ result = reader.read_lines_until(terminator: '////', skip_processing: true)
assert_equal lines.map {|l| l.chomp}[1..1], result
end
@@ -1530,8 +1530,8 @@ include::fixtures/no-such-file.adoc[]
EOS
using_memory_logger do |logger|
- doc = empty_safe_document :base_dir => DIRNAME
- reader = Asciidoctor::PreprocessorReader.new doc, lines, nil, :normalize => true
+ doc = empty_safe_document base_dir: DIRNAME
+ reader = Asciidoctor::PreprocessorReader.new doc, lines, nil, normalize: true
reader.skip_comment_lines
assert reader.empty?
assert logger.empty?
@@ -1649,7 +1649,7 @@ There is a holy grail!
endif::holygrail[]
EOS
- doc = Asciidoctor::Document.new input, :attributes => { 'holygrail' => '' }
+ doc = Asciidoctor::Document.new input, attributes: { 'holygrail' => '' }
reader = doc.reader
lines = []
while reader.has_more_lines?
@@ -1665,7 +1665,7 @@ ifdef::holygrail[There is a holy grail!]
There was much rejoicing.
EOS
- doc = Asciidoctor::Document.new input, :attributes => { 'holygrail' => '' }
+ doc = Asciidoctor::Document.new input, attributes: { 'holygrail' => '' }
reader = doc.reader
lines = []
while reader.has_more_lines?
@@ -1679,7 +1679,7 @@ There was much rejoicing.
ifdef::asciidoctor-version[include::fixtures/include-file.asciidoc[tag=snippetA]]
EOS
- doc = Asciidoctor::Document.new input, :safe => :safe, :base_dir => DIRNAME
+ doc = Asciidoctor::Document.new input, safe: :safe, base_dir: DIRNAME
reader = doc.reader
lines = []
while reader.has_more_lines?
@@ -1695,7 +1695,7 @@ The script is shown!
endif::showScript[]
EOS
- doc = Asciidoctor::Document.new input, :attributes => { 'showscript' => '' }
+ doc = Asciidoctor::Document.new input, attributes: { 'showscript' => '' }
result = doc.reader.read
assert_equal 'The script is shown!', result
end
@@ -1707,7 +1707,7 @@ ifndef::hardships[There is a holy grail!]
There was no rejoicing.
EOS
- doc = Asciidoctor::Document.new input, :attributes => { 'hardships' => '' }
+ doc = Asciidoctor::Document.new input, attributes: { 'hardships' => '' }
reader = doc.reader
lines = []
while reader.has_more_lines?
@@ -1727,7 +1727,7 @@ grail
endif::grail[]
EOS
- doc = Asciidoctor::Document.new input, :attributes => { 'grail' => '' }
+ doc = Asciidoctor::Document.new input, attributes: { 'grail' => '' }
reader = doc.reader
lines = []
while reader.has_more_lines?
@@ -1745,7 +1745,7 @@ endif::grail[]
endif::grail[]
EOS
- doc = Asciidoctor::Document.new input, :attributes => { 'grail' => '' }
+ doc = Asciidoctor::Document.new input, attributes: { 'grail' => '' }
reader = doc.reader
lines = []
while reader.has_more_lines?
@@ -1765,7 +1765,7 @@ grail
endif::grail[]
EOS
- doc = Asciidoctor::Document.new input, :attributes => { 'grail' => '' }
+ doc = Asciidoctor::Document.new input, attributes: { 'grail' => '' }
reader = doc.reader
lines = []
while reader.has_more_lines?
@@ -1787,7 +1787,7 @@ endif::swallow[]
gone
EOS
- doc = Asciidoctor::Document.new input, :attributes => { 'grail' => '' }
+ doc = Asciidoctor::Document.new input, attributes: { 'grail' => '' }
reader = doc.reader
lines = []
while reader.has_more_lines?
@@ -1809,7 +1809,7 @@ endif::[]
gone
EOS
- doc = Asciidoctor::Document.new input, :attributes => { 'grail' => '' }
+ doc = Asciidoctor::Document.new input, attributes: { 'grail' => '' }
reader = doc.reader
lines = []
while reader.has_more_lines?
@@ -1825,7 +1825,7 @@ Our quest is complete!
endif::holygrail,swallow[]
EOS
- doc = Asciidoctor::Document.new input, :attributes => { 'swallow' => '' }
+ doc = Asciidoctor::Document.new input, attributes: { 'swallow' => '' }
reader = doc.reader
lines = []
while reader.has_more_lines?
@@ -1857,7 +1857,7 @@ Our quest is complete!
endif::holygrail+swallow[]
EOS
- doc = Asciidoctor::Document.new input, :attributes => { 'holygrail' => '', 'swallow' => '' }
+ doc = Asciidoctor::Document.new input, attributes: { 'holygrail' => '', 'swallow' => '' }
reader = doc.reader
lines = []
while reader.has_more_lines?
@@ -1873,7 +1873,7 @@ Our quest is complete!
endif::holygrail+swallow[]
EOS
- doc = Asciidoctor::Document.new input, :attributes => { 'holygrail' => '' }
+ doc = Asciidoctor::Document.new input, attributes: { 'holygrail' => '' }
reader = doc.reader
lines = []
while reader.has_more_lines?
@@ -1889,14 +1889,14 @@ endif::holygrail+swallow[]
'asciidoctor+' => '',
'+asciidoctor' => '',
'asciidoctor,,asciidoctor-version' => 'content',
- 'asciidoctor++asciidoctor-version' => ''
+ 'asciidoctor++asciidoctor-version' => '',
}.each do |condition, expected|
input = <<-EOS
ifdef::#{condition}[]
content
endif::[]
EOS
- assert_equal expected, (document_from_string input, :parse => false).reader.read
+ assert_equal expected, (document_from_string input, parse: false).reader.read
end
end
@@ -1923,7 +1923,7 @@ Our quest is complete!
endif::holygrail,swallow[]
EOS
- result = (Asciidoctor::Document.new input, :attributes => { 'swallow' => '' }).reader.read
+ result = (Asciidoctor::Document.new input, attributes: { 'swallow' => '' }).reader.read
assert_empty result
end
@@ -1934,7 +1934,7 @@ Our quest is complete!
endif::holygrail,swallow[]
EOS
- result = (Asciidoctor::Document.new input, :attributes => { 'swallow' => '', 'holygrail' => '' }).reader.read
+ result = (Asciidoctor::Document.new input, attributes: { 'swallow' => '', 'holygrail' => '' }).reader.read
assert_empty result
end
@@ -1967,7 +1967,7 @@ Our quest is complete!
endif::holygrail+swallow[]
EOS
- result = (Asciidoctor::Document.new input, :attributes => { 'swallow' => '', 'holygrail' => '' }).reader.read
+ result = (Asciidoctor::Document.new input, attributes: { 'swallow' => '', 'holygrail' => '' }).reader.read
assert_empty result
end
@@ -1978,7 +1978,7 @@ Our quest is complete!
endif::holygrail+swallow[]
EOS
- result = (Asciidoctor::Document.new input, :attributes => { 'swallow' => '' }).reader.read
+ result = (Asciidoctor::Document.new input, attributes: { 'swallow' => '' }).reader.read
assert_equal 'Our quest is complete!', result
end
@@ -2037,7 +2037,7 @@ Asciidoctor it is!
endif::[]
EOS
- doc = Asciidoctor::Document.new input, :attributes => { 'gem' => 'asciidoctor' }
+ doc = Asciidoctor::Document.new input, attributes: { 'gem' => 'asciidoctor' }
reader = doc.reader
lines = []
while reader.has_more_lines?
@@ -2053,7 +2053,7 @@ Asciidoctor it is!
endif::[]
EOS
- doc = Asciidoctor::Document.new input, :attributes => { 'gem' => 'asciidoctor' }
+ doc = Asciidoctor::Document.new input, attributes: { 'gem' => 'asciidoctor' }
reader = doc.reader
lines = []
while reader.has_more_lines?
@@ -2069,7 +2069,7 @@ Asciidoctor it is!
endif::[]
EOS
- doc = Asciidoctor::Document.new input, :attributes => { 'gem' => 'tilt' }
+ doc = Asciidoctor::Document.new input, attributes: { 'gem' => 'tilt' }
reader = doc.reader
lines = []
while reader.has_more_lines?
@@ -2133,7 +2133,7 @@ One ring to rule them all!
endif::[]
EOS
- doc = Asciidoctor::Document.new input, :attributes => { 'rings' => '1' }
+ doc = Asciidoctor::Document.new input, attributes: { 'rings' => '1' }
reader = doc.reader
lines = []
while reader.has_more_lines?
@@ -2149,7 +2149,7 @@ One ring to rule them all!
endif::[]
EOS
- doc = Asciidoctor::Document.new input, :attributes => { 'rings' => '1' }
+ doc = Asciidoctor::Document.new input, attributes: { 'rings' => '1' }
reader = doc.reader
lines = []
while reader.has_more_lines?
diff --git a/test/sections_test.rb b/test/sections_test.rb
index 595fcb95..976e0a94 100644
--- a/test/sections_test.rb
+++ b/test/sections_test.rb
@@ -431,7 +431,7 @@ preamble
end
test 'document title created from leveloffset shift defined in API' do
- assert_xpath "//h1[not(@id)][text() = 'Document Title']", convert_string('== Document Title', :attributes => { 'leveloffset' => '-1@' })
+ assert_xpath "//h1[not(@id)][text() = 'Document Title']", convert_string('== Document Title', attributes: { 'leveloffset' => '-1@' })
end
test 'should assign id on document title to body' do
@@ -705,7 +705,7 @@ content
EOS
using_memory_logger do |logger|
- convert_string_to_embedded input, :attributes => { 'fragment' => '' }
+ convert_string_to_embedded input, attributes: { 'fragment' => '' }
assert logger.empty?
end
end
@@ -720,7 +720,7 @@ content
EOS
using_memory_logger do |logger|
- convert_string_to_embedded input, :attributes => { 'fragment' => '' }
+ convert_string_to_embedded input, attributes: { 'fragment' => '' }
assert_message logger, :WARN, '<stdin>: line 5: section title out of sequence: expected level 3, got level 4', Hash
end
end
@@ -1040,7 +1040,7 @@ not in section
not in section
EOS
- output = convert_string_to_embedded input, :attributes => {'sectids' => nil}
+ output = convert_string_to_embedded input, attributes: { 'sectids' => nil }
assert_xpath '/h3', output, 1
assert_xpath '/h3[@id="_independent_heading"]', output, 0
assert_xpath '/h3[@class="float"]', output, 1
@@ -1403,7 +1403,7 @@ text
using_memory_logger do |logger|
output = convert_string input
assert_xpath '//h1[text()="Part"]', output, 1
- assert_xpath '//h3[text()=".1. Out of Sequence Section"]', output, 1
+ assert_xpath '//h3[text()=".1. Out of Sequence Section"]', output, 1
end
end
@@ -1564,7 +1564,7 @@ paragraph
== Section Three
EOS
- output = convert_string input, :attributes => {'numbered' => ''}
+ output = convert_string input, attributes: { 'numbered' => '' }
assert_xpath '//h1[text()="Document Title"]', output, 1
assert_xpath '//h2[@id="_colophon_section"][text()="Colophon Section"]', output, 1
assert_xpath '//h2[@id="_another_colophon_section"][text()="Another Colophon Section"]', output, 1
@@ -1598,7 +1598,7 @@ paragraph
== Section Three
EOS
- output = convert_string input, :attributes => {'numbered!' => ''}
+ output = convert_string input, attributes: { 'numbered!' => '' }
assert_xpath '//h1[text()="Document Title"]', output, 1
assert_xpath '//h2[@id="_colophon_section"][text()="Colophon Section"]', output, 1
assert_xpath '//h2[@id="_another_colophon_section"][text()="Another Colophon Section"]', output, 1
@@ -1761,12 +1761,12 @@ content
== The End
EOS
- doc = document_from_string input, :attributes => { 'sectnums' => '' }
+ doc = document_from_string input, attributes: { 'sectnums' => '' }
doc.sections.each do |sect|
sect.number += 1
end
- output = doc.convert :header_footer => false
+ output = doc.convert header_footer: false
assert_xpath '//h2[text()="2. Somewhere in the Middle"]', output, 1
assert_xpath '//h2[text()="3. The End"]', output, 1
end
@@ -1784,7 +1784,7 @@ Installation section.
Linux installation instructions.
EOS
- output = convert_string_to_embedded input, :attributes => {'sectanchors' => ''}
+ output = convert_string_to_embedded input, attributes: { 'sectanchors' => '' }
assert_xpath '/*[@class="sect1"]/h2[@id="_installation"]/a', output, 1
assert_xpath '/*[@class="sect1"]/h2[@id="_installation"]/a[@class="anchor"][@href="#_installation"]', output, 1
assert_xpath '/*[@class="sect1"]/h2[@id="_installation"]/a/following-sibling::text()="Installation"', output, true
@@ -1804,7 +1804,7 @@ Installation section.
Linux installation instructions.
EOS
- output = convert_string_to_embedded input, :attributes => {'sectanchors' => 'after'}
+ output = convert_string_to_embedded input, attributes: { 'sectanchors' => 'after' }
assert_xpath '/*[@class="sect1"]/h2[@id="_installation"]/a', output, 1
assert_xpath '/*[@class="sect1"]/h2[@id="_installation"]/a[@class="anchor"][@href="#_installation"]', output, 1
assert_xpath '/*[@class="sect1"]/h2[@id="_installation"]/a/preceding-sibling::text()="Installation"', output, true
@@ -1824,7 +1824,7 @@ Installation section.
Linux installation instructions.
EOS
- output = convert_string_to_embedded input, :attributes => {'sectlinks' => ''}
+ output = convert_string_to_embedded input, attributes: { 'sectlinks' => '' }
assert_xpath '/*[@class="sect1"]/h2[@id="_installation"]/a', output, 1
assert_xpath '/*[@class="sect1"]/h2[@id="_installation"]/a[@class="link"][@href="#_installation"]', output, 1
assert_xpath '/*[@class="sect1"]/h2[@id="_installation"]/a[text()="Installation"]', output, 1
@@ -1850,7 +1850,7 @@ content
content
EOS
- output = convert_string input, :backend => :docbook
+ output = convert_string input, backend: :docbook
assert_xpath '//section', output, 2
assert_xpath '//sect1', output, 0
assert_xpath '//sect2', output, 0
@@ -2426,7 +2426,7 @@ Colophon content
= Index Title
EOS
- output = convert_string_to_embedded input, :backend => 'docbook45'
+ output = convert_string_to_embedded input, backend: 'docbook45'
assert_xpath '/chapter[@id="abstract_title"]', output, 1
assert_xpath '/chapter[@id="abstract_title"]/title[text()="Abstract Title"]', output, 1
assert_xpath '/chapter/following-sibling::dedication[@id="dedication_title"]', output, 1
@@ -2466,7 +2466,7 @@ Colophon content
Abstract content
EOS
- output = convert_string_to_embedded input, :backend => 'docbook45'
+ output = convert_string_to_embedded input, backend: 'docbook45'
assert_xpath '/abstract[@id="abstract_title"]', output, 1
assert_xpath '/abstract[@id="abstract_title"]/title[text()="Abstract Title"]', output, 1
end
@@ -2492,7 +2492,7 @@ A second glossary term::
The corresponding definition.
EOS
- output = convert_string input, :backend => :docbook
+ output = convert_string input, backend: :docbook
assert_xpath '//glossary', output, 1
assert_xpath '//chapter/glossary', output, 1
assert_xpath '//glossary/title[text()="Glossary A"]', output, 1
@@ -2507,7 +2507,7 @@ The corresponding definition.
content
EOS
- output = convert_string_to_embedded input, :backend => :docbook
+ output = convert_string_to_embedded input, backend: :docbook
assert_xpath '/dedication', output, 1
assert_xpath '/dedication/title', output, 0
end
@@ -3242,7 +3242,7 @@ content
content
EOS
- output = convert_string_to_embedded input, :safe => :safe
+ output = convert_string_to_embedded input, safe: :safe
assert_xpath '/*[@id="toc"]', output, 1
toc_links = xmlnodes_at_xpath '/*[@id="toc"]//li', output
assert_equal 3, toc_links.size
@@ -3283,7 +3283,7 @@ While they were returning...
That's all she wrote!
EOS
- output = convert_string input, :backend => 'docbook'
+ output = convert_string input, backend: 'docbook'
assert_xpath '//part', output, 0
assert_xpath '//chapter', output, 0
assert_xpath '/article/section', output, 2
@@ -3407,11 +3407,11 @@ content
doc = document_from_string input
assert_equal 'header', doc.header.sectname
- assert_equal 'part', (doc.find_by :id => 'part-title')[0].sectname
- assert_equal 'chapter', (doc.find_by :id => 'chapter-title')[0].sectname
- assert_equal 'section', (doc.find_by :id => 'section-title')[0].sectname
- assert_equal 'appendix', (doc.find_by :id => 'appendix-title')[0].sectname
- assert_equal 'section', (doc.find_by :id => 'appendix-section-title')[0].sectname
+ assert_equal 'part', (doc.find_by id: 'part-title')[0].sectname
+ assert_equal 'chapter', (doc.find_by id: 'chapter-title')[0].sectname
+ assert_equal 'section', (doc.find_by id: 'section-title')[0].sectname
+ assert_equal 'appendix', (doc.find_by id: 'appendix-title')[0].sectname
+ assert_equal 'section', (doc.find_by id: 'appendix-section-title')[0].sectname
end
test 'should add partintro style to child paragraph of part' do
@@ -3525,7 +3525,7 @@ While they were returning...
That's all she wrote!
EOS
- output = convert_string input, :backend => 'docbook'
+ output = convert_string input, backend: 'docbook'
assert_xpath '//chapter/chapter', output, 0
assert_xpath '/book/part', output, 2
assert_xpath '/book/part[1]/title[text() = "Part 1"]', output, 1
@@ -3572,7 +3572,7 @@ Appendix subsection content
output = nil
using_memory_logger do |logger|
- output = convert_string input, :backend => 'docbook'
+ output = convert_string input, backend: 'docbook'
assert logger.empty?
end
assert_xpath '/book/preface', output, 1
diff --git a/test/substitutions_test.rb b/test/substitutions_test.rb
index 7efee60b..348c0143 100644
--- a/test/substitutions_test.rb
+++ b/test/substitutions_test.rb
@@ -50,21 +50,21 @@ context 'Substitutions' do
context 'Quotes' do
test 'single-line double-quoted string' do
- para = block_from_string(%q{``a few quoted words''}, :attributes => {'compat-mode' => ''})
+ para = block_from_string(%q{``a few quoted words''}, attributes: { 'compat-mode' => '' })
assert_equal '&#8220;a few quoted words&#8221;', para.sub_quotes(para.source)
para = block_from_string(%q{"`a few quoted words`"})
assert_equal '&#8220;a few quoted words&#8221;', para.sub_quotes(para.source)
- para = block_from_string(%q{"`a few quoted words`"}, :backend => 'docbook')
+ para = block_from_string(%q{"`a few quoted words`"}, backend: 'docbook')
assert_equal '<quote>a few quoted words</quote>', para.sub_quotes(para.source)
end
test 'escaped single-line double-quoted string' do
- para = block_from_string %(#{BACKSLASH}``a few quoted words''), :attributes => {'compat-mode' => ''}
+ para = block_from_string %(#{BACKSLASH}``a few quoted words''), attributes: { 'compat-mode' => '' }
assert_equal %q(&#8216;`a few quoted words&#8217;'), para.sub_quotes(para.source)
- para = block_from_string %(#{BACKSLASH * 2}``a few quoted words''), :attributes => {'compat-mode' => ''}
+ para = block_from_string %(#{BACKSLASH * 2}``a few quoted words''), attributes: { 'compat-mode' => '' }
assert_equal %q(``a few quoted words''), para.sub_quotes(para.source)
para = block_from_string(%(#{BACKSLASH}"`a few quoted words`"))
@@ -75,7 +75,7 @@ context 'Substitutions' do
end
test 'multi-line double-quoted string' do
- para = block_from_string(%Q{``a few\nquoted words''}, :attributes => {'compat-mode' => ''})
+ para = block_from_string(%Q{``a few\nquoted words''}, attributes: { 'compat-mode' => '' })
assert_equal "&#8220;a few\nquoted words&#8221;", para.sub_quotes(para.source)
para = block_from_string(%Q{"`a few\nquoted words`"})
@@ -83,7 +83,7 @@ context 'Substitutions' do
end
test 'double-quoted string with inline single quote' do
- para = block_from_string(%q{``Here's Johnny!''}, :attributes => {'compat-mode' => ''})
+ para = block_from_string(%q{``Here's Johnny!''}, attributes: { 'compat-mode' => '' })
assert_equal %q{&#8220;Here's Johnny!&#8221;}, para.sub_quotes(para.source)
para = block_from_string(%q{"`Here's Johnny!`"})
@@ -91,7 +91,7 @@ context 'Substitutions' do
end
test 'double-quoted string with inline backquote' do
- para = block_from_string(%q{``Here`s Johnny!''}, :attributes => {'compat-mode' => ''})
+ para = block_from_string(%q{``Here`s Johnny!''}, attributes: { 'compat-mode' => '' })
assert_equal %q{&#8220;Here`s Johnny!&#8221;}, para.sub_quotes(para.source)
para = block_from_string(%q{"`Here`s Johnny!`"})
@@ -107,18 +107,18 @@ context 'Substitutions' do
end
test 'single-line single-quoted string' do
- para = block_from_string(%q{`a few quoted words'}, :attributes => {'compat-mode' => ''})
+ para = block_from_string(%q{`a few quoted words'}, attributes: { 'compat-mode' => '' })
assert_equal '&#8216;a few quoted words&#8217;', para.sub_quotes(para.source)
para = block_from_string(%q{'`a few quoted words`'})
assert_equal '&#8216;a few quoted words&#8217;', para.sub_quotes(para.source)
- para = block_from_string(%q{'`a few quoted words`'}, :backend => 'docbook')
+ para = block_from_string(%q{'`a few quoted words`'}, backend: 'docbook')
assert_equal '<quote>a few quoted words</quote>', para.sub_quotes(para.source)
end
test 'escaped single-line single-quoted string' do
- para = block_from_string(%(#{BACKSLASH}`a few quoted words'), :attributes => {'compat-mode' => ''})
+ para = block_from_string(%(#{BACKSLASH}`a few quoted words'), attributes: { 'compat-mode' => '' })
assert_equal %(`a few quoted words'), para.sub_quotes(para.source)
para = block_from_string(%(#{BACKSLASH}'`a few quoted words`'))
@@ -126,7 +126,7 @@ context 'Substitutions' do
end
test 'multi-line single-quoted string' do
- para = block_from_string(%Q{`a few\nquoted words'}, :attributes => {'compat-mode' => ''})
+ para = block_from_string(%Q{`a few\nquoted words'}, attributes: { 'compat-mode' => '' })
assert_equal "&#8216;a few\nquoted words&#8217;", para.sub_quotes(para.source)
para = block_from_string(%Q{'`a few\nquoted words`'})
@@ -134,7 +134,7 @@ context 'Substitutions' do
end
test 'single-quoted string with inline single quote' do
- para = block_from_string(%q{`That isn't what I did.'}, :attributes => {'compat-mode' => ''})
+ para = block_from_string(%q{`That isn't what I did.'}, attributes: { 'compat-mode' => '' })
assert_equal %q{&#8216;That isn't what I did.&#8217;}, para.sub_quotes(para.source)
para = block_from_string(%q{'`That isn't what I did.`'})
@@ -142,7 +142,7 @@ context 'Substitutions' do
end
test 'single-quoted string with inline backquote' do
- para = block_from_string(%q{`Here`s Johnny!'}, :attributes => {'compat-mode' => ''})
+ para = block_from_string(%q{`Here`s Johnny!'}, attributes: { 'compat-mode' => '' })
assert_equal %q{&#8216;Here`s Johnny!&#8217;}, para.sub_quotes(para.source)
para = block_from_string(%q{'`Here`s Johnny!`'})
@@ -150,7 +150,7 @@ context 'Substitutions' do
end
test 'single-line constrained marked string' do
- #para = block_from_string(%q{#a few words#}, :attributes => {'compat-mode' => ''})
+ #para = block_from_string(%q{#a few words#}, attributes: { 'compat-mode' => '' })
#assert_equal 'a few words', para.sub_quotes(para.source)
para = block_from_string(%q{#a few words#})
@@ -163,7 +163,7 @@ context 'Substitutions' do
end
test 'multi-line constrained marked string' do
- #para = block_from_string(%Q{#a few\nwords#}, :attributes => {'compat-mode' => ''})
+ #para = block_from_string(%Q{#a few\nwords#}, attributes: { 'compat-mode' => '' })
#assert_equal "a few\nwords", para.sub_quotes(para.source)
para = block_from_string(%Q{#a few\nwords#})
@@ -176,7 +176,7 @@ context 'Substitutions' do
end
test 'single-line unconstrained marked string' do
- #para = block_from_string(%q{##--anything goes ##}, :attributes => {'compat-mode' => ''})
+ #para = block_from_string(%q{##--anything goes ##}, attributes: { 'compat-mode' => '' })
#assert_equal '--anything goes ', para.sub_quotes(para.source)
para = block_from_string(%q{##--anything goes ##})
@@ -189,7 +189,7 @@ context 'Substitutions' do
end
test 'multi-line unconstrained marked string' do
- #para = block_from_string(%Q{##--anything\ngoes ##}, :attributes => {'compat-mode' => ''})
+ #para = block_from_string(%Q{##--anything\ngoes ##}, attributes: { 'compat-mode' => '' })
#assert_equal "--anything\ngoes ", para.sub_quotes(para.source)
para = block_from_string(%Q{##--anything\ngoes ##})
@@ -248,7 +248,7 @@ context 'Substitutions' do
end
test 'single-quoted string containing an emphasized phrase' do
- para = block_from_string(%q{`I told him, 'Just go for it!''}, :attributes => {'compat-mode' => ''})
+ para = block_from_string(%q{`I told him, 'Just go for it!''}, attributes: { 'compat-mode' => '' })
assert_equal '&#8216;I told him, <em>Just go for it!</em>&#8217;', para.sub_quotes(para.source)
para = block_from_string(%q{'`I told him, 'Just go for it!'`'})
@@ -256,7 +256,7 @@ context 'Substitutions' do
end
test 'escaped single-quotes inside emphasized words are restored' do
- para = block_from_string(%('Here#{BACKSLASH}'s Johnny!'), :attributes => {'compat-mode' => ''})
+ para = block_from_string(%('Here#{BACKSLASH}'s Johnny!'), attributes: { 'compat-mode' => '' })
assert_equal %q(<em>Here's Johnny!</em>), para.apply_subs(para.source)
para = block_from_string(%('Here#{BACKSLASH}'s Johnny!'))
@@ -280,25 +280,25 @@ context 'Substitutions' do
# NOTE must use apply_subs because constrained monospaced is handled as a passthrough
test 'single-line constrained monospaced string' do
- para = block_from_string(%(`a few <{monospaced}> words`), :attributes => {'monospaced' => 'monospaced', 'compat-mode' => ''})
+ para = block_from_string(%(`a few <{monospaced}> words`), attributes: { 'monospaced' => 'monospaced', 'compat-mode' => '' })
assert_equal '<code>a few &lt;{monospaced}&gt; words</code>', para.apply_subs(para.source)
- para = block_from_string(%(`a few <{monospaced}> words`), :attributes => {'monospaced' => 'monospaced'})
+ para = block_from_string(%(`a few <{monospaced}> words`), attributes: { 'monospaced' => 'monospaced' })
assert_equal '<code>a few &lt;monospaced&gt; words</code>', para.apply_subs(para.source)
end
# NOTE must use apply_subs because constrained monospaced is handled as a passthrough
test 'single-line constrained monospaced string with role' do
- para = block_from_string(%([input]`a few <{monospaced}> words`), :attributes => {'monospaced' => 'monospaced', 'compat-mode' => ''})
+ para = block_from_string(%([input]`a few <{monospaced}> words`), attributes: { 'monospaced' => 'monospaced', 'compat-mode' => '' })
assert_equal '<code class="input">a few &lt;{monospaced}&gt; words</code>', para.apply_subs(para.source)
- para = block_from_string(%([input]`a few <{monospaced}> words`), :attributes => {'monospaced' => 'monospaced'})
+ para = block_from_string(%([input]`a few <{monospaced}> words`), attributes: { 'monospaced' => 'monospaced' })
assert_equal '<code class="input">a few &lt;monospaced&gt; words</code>', para.apply_subs(para.source)
end
# NOTE must use apply_subs because constrained monospaced is handled as a passthrough
test 'escaped single-line constrained monospaced string' do
- para = block_from_string(%(#{BACKSLASH}`a few <monospaced> words`), :attributes => {'compat-mode' => ''})
+ para = block_from_string(%(#{BACKSLASH}`a few <monospaced> words`), attributes: { 'compat-mode' => '' })
assert_equal '`a few &lt;monospaced&gt; words`', para.apply_subs(para.source)
para = block_from_string(%(#{BACKSLASH}`a few <monospaced> words`))
@@ -307,7 +307,7 @@ context 'Substitutions' do
# NOTE must use apply_subs because constrained monospaced is handled as a passthrough
test 'escaped single-line constrained monospaced string with role' do
- para = block_from_string(%([input]#{BACKSLASH}`a few <monospaced> words`), :attributes => {'compat-mode' => ''})
+ para = block_from_string(%([input]#{BACKSLASH}`a few <monospaced> words`), attributes: { 'compat-mode' => '' })
assert_equal '[input]`a few &lt;monospaced&gt; words`', para.apply_subs(para.source)
para = block_from_string(%([input]#{BACKSLASH}`a few <monospaced> words`))
@@ -316,7 +316,7 @@ context 'Substitutions' do
# NOTE must use apply_subs because constrained monospaced is handled as a passthrough
test 'escaped role on single-line constrained monospaced string' do
- para = block_from_string(%(#{BACKSLASH}[input]`a few <monospaced> words`), :attributes => {'compat-mode' => ''})
+ para = block_from_string(%(#{BACKSLASH}[input]`a few <monospaced> words`), attributes: { 'compat-mode' => '' })
assert_equal '[input]<code>a few &lt;monospaced&gt; words</code>', para.apply_subs(para.source)
para = block_from_string(%(#{BACKSLASH}[input]`a few <monospaced> words`))
@@ -325,7 +325,7 @@ context 'Substitutions' do
# NOTE must use apply_subs because constrained monospaced is handled as a passthrough
test 'escaped role on escaped single-line constrained monospaced string' do
- para = block_from_string(%(#{BACKSLASH}[input]#{BACKSLASH}`a few <monospaced> words`), :attributes => {'compat-mode' => ''})
+ para = block_from_string(%(#{BACKSLASH}[input]#{BACKSLASH}`a few <monospaced> words`), attributes: { 'compat-mode' => '' })
assert_equal %(#{BACKSLASH}[input]`a few &lt;monospaced&gt; words`), para.apply_subs(para.source)
para = block_from_string(%(#{BACKSLASH}[input]#{BACKSLASH}`a few <monospaced> words`))
@@ -334,10 +334,10 @@ context 'Substitutions' do
# NOTE must use apply_subs because constrained monospaced is handled as a passthrough
test 'multi-line constrained monospaced string' do
- para = block_from_string(%(`a few\n<{monospaced}> words`), :attributes => {'monospaced' => 'monospaced', 'compat-mode' => ''})
+ para = block_from_string(%(`a few\n<{monospaced}> words`), attributes: { 'monospaced' => 'monospaced', 'compat-mode' => '' })
assert_equal "<code>a few\n&lt;{monospaced}&gt; words</code>", para.apply_subs(para.source)
- para = block_from_string(%(`a few\n<{monospaced}> words`), :attributes => {'monospaced' => 'monospaced'})
+ para = block_from_string(%(`a few\n<{monospaced}> words`), attributes: { 'monospaced' => 'monospaced' })
assert_equal "<code>a few\n&lt;monospaced&gt; words</code>", para.apply_subs(para.source)
end
@@ -403,7 +403,7 @@ context 'Substitutions' do
end
test 'single-line constrained monospaced chars' do
- para = block_from_string(%q{call +save()+ to persist the changes}, :attributes => {'compat-mode' => ''})
+ para = block_from_string(%q{call +save()+ to persist the changes}, attributes: { 'compat-mode' => '' })
assert_equal 'call <code>save()</code> to persist the changes', para.sub_quotes(para.source)
para = block_from_string(%q{call [x-]+save()+ to persist the changes})
@@ -414,7 +414,7 @@ context 'Substitutions' do
end
test 'single-line constrained monospaced chars with role' do
- para = block_from_string(%q{call [method]+save()+ to persist the changes}, :attributes => {'compat-mode' => ''})
+ para = block_from_string(%q{call [method]+save()+ to persist the changes}, attributes: { 'compat-mode' => '' })
assert_equal 'call <code class="method">save()</code> to persist the changes', para.sub_quotes(para.source)
para = block_from_string(%q{call [method x-]+save()+ to persist the changes})
@@ -425,7 +425,7 @@ context 'Substitutions' do
end
test 'escaped single-line constrained monospaced chars' do
- para = block_from_string(%(call #{BACKSLASH}+save()+ to persist the changes), :attributes => {'compat-mode' => ''})
+ para = block_from_string(%(call #{BACKSLASH}+save()+ to persist the changes), attributes: { 'compat-mode' => '' })
assert_equal 'call +save()+ to persist the changes', para.sub_quotes(para.source)
para = block_from_string(%(call #{BACKSLASH}`save()` to persist the changes))
@@ -433,7 +433,7 @@ context 'Substitutions' do
end
test 'escaped single-line constrained monospaced chars with role' do
- para = block_from_string(%(call [method]#{BACKSLASH}+save()+ to persist the changes), :attributes => {'compat-mode' => ''})
+ para = block_from_string(%(call [method]#{BACKSLASH}+save()+ to persist the changes), attributes: { 'compat-mode' => '' })
assert_equal 'call [method]+save()+ to persist the changes', para.sub_quotes(para.source)
para = block_from_string(%(call [method]#{BACKSLASH}`save()` to persist the changes))
@@ -441,7 +441,7 @@ context 'Substitutions' do
end
test 'escaped role on single-line constrained monospaced chars' do
- para = block_from_string(%(call #{BACKSLASH}[method]+save()+ to persist the changes), :attributes => {'compat-mode' => ''})
+ para = block_from_string(%(call #{BACKSLASH}[method]+save()+ to persist the changes), attributes: { 'compat-mode' => '' })
assert_equal 'call [method]<code>save()</code> to persist the changes', para.sub_quotes(para.source)
para = block_from_string(%(call #{BACKSLASH}[method]`save()` to persist the changes))
@@ -449,7 +449,7 @@ context 'Substitutions' do
end
test 'escaped role on escaped single-line constrained monospaced chars' do
- para = block_from_string(%(call #{BACKSLASH}[method]#{BACKSLASH}+save()+ to persist the changes), :attributes => {'compat-mode' => ''})
+ para = block_from_string(%(call #{BACKSLASH}[method]#{BACKSLASH}+save()+ to persist the changes), attributes: { 'compat-mode' => '' })
assert_equal %(call #{BACKSLASH}[method]+save()+ to persist the changes), para.sub_quotes(para.source)
para = block_from_string(%(call #{BACKSLASH}[method]#{BACKSLASH}`save()` to persist the changes))
@@ -457,7 +457,7 @@ context 'Substitutions' do
end
test 'single-line unconstrained monospaced chars' do
- para = block_from_string(%q{Git++Hub++}, :attributes => {'compat-mode' => ''})
+ para = block_from_string(%q{Git++Hub++}, attributes: { 'compat-mode' => '' })
assert_equal 'Git<code>Hub</code>', para.sub_quotes(para.source)
para = block_from_string(%q{Git[x-]++Hub++})
@@ -468,10 +468,10 @@ context 'Substitutions' do
end
test 'escaped single-line unconstrained monospaced chars' do
- para = block_from_string(%(Git#{BACKSLASH}++Hub++), :attributes => {'compat-mode' => ''})
+ para = block_from_string(%(Git#{BACKSLASH}++Hub++), attributes: { 'compat-mode' => '' })
assert_equal 'Git+<code>Hub</code>+', para.sub_quotes(para.source)
- para = block_from_string(%(Git#{BACKSLASH * 2}++Hub++), :attributes => {'compat-mode' => ''})
+ para = block_from_string(%(Git#{BACKSLASH * 2}++Hub++), attributes: { 'compat-mode' => '' })
assert_equal 'Git++Hub++', para.sub_quotes(para.source)
para = block_from_string(%(Git#{BACKSLASH}``Hub``))
@@ -479,7 +479,7 @@ context 'Substitutions' do
end
test 'multi-line unconstrained monospaced chars' do
- para = block_from_string(%Q{Git++\nH\nu\nb++}, :attributes => {'compat-mode' => ''})
+ para = block_from_string(%Q{Git++\nH\nu\nb++}, attributes: { 'compat-mode' => '' })
assert_equal "Git<code>\nH\nu\nb</code>", para.sub_quotes(para.source)
para = block_from_string(%Q{Git[x-]++\nH\nu\nb++})
@@ -555,7 +555,7 @@ context 'Substitutions' do
end
test 'quoted text with id and role shorthand using docbook backend' do
- para = block_from_string(%q{[#bond.white.red-background]#007#}, :backend => 'docbook45')
+ para = block_from_string(%q{[#bond.white.red-background]#007#}, backend: 'docbook45')
assert_equal '<anchor id="bond" xreflabel="007"/><phrase role="white red-background">007</phrase>', para.sub_quotes(para.source)
end
@@ -573,14 +573,14 @@ context 'Substitutions' do
test 'should assign role attribute when shorthand style contains a role' do
para = block_from_string 'blah'
result = para.parse_quoted_text_attributes '.red#idref'
- expect = {'id' => 'idref', 'role' => 'red'}
+ expect = { 'id' => 'idref', 'role' => 'red' }
assert_equal expect, result
end
test 'should not assign role attribute if shorthand style has no roles' do
para = block_from_string 'blah'
result = para.parse_quoted_text_attributes '#idref'
- expect = {'id' => 'idref'}
+ expect = { 'id' => 'idref' }
assert_equal expect, result
end
end
@@ -656,7 +656,7 @@ context 'Substitutions' do
test 'should not resolve an escaped attribute in link text' do
{
'http://google.com' => "http://google.com[#{BACKSLASH}{google_homepage}]",
- 'http://google.com?q=,' => "link:http://google.com?q=,[#{BACKSLASH}{google_homepage}]"
+ 'http://google.com?q=,' => "link:http://google.com?q=,[#{BACKSLASH}{google_homepage}]",
}.each do |uri, macro|
para = block_from_string macro
para.document.attributes['google_homepage'] = 'Google Homepage'
@@ -702,17 +702,17 @@ context 'Substitutions' do
end
test 'an image macro with an interactive SVG image and alt text should be converted to an object element' do
- para = block_from_string('image:tiger.svg[Tiger,opts=interactive]', :safe => Asciidoctor::SafeMode::SERVER, :attributes => { 'imagesdir' => 'images' })
+ para = block_from_string('image:tiger.svg[Tiger,opts=interactive]', safe: Asciidoctor::SafeMode::SERVER, attributes: { 'imagesdir' => 'images' })
assert_equal %{<span class="image"><object type="image/svg+xml" data="images/tiger.svg"><span class="alt">Tiger</span></object></span>}, para.sub_macros(para.source).gsub(/>\s+</, '><')
end
test 'an image macro with an interactive SVG image, fallback and alt text should be converted to an object element' do
- para = block_from_string('image:tiger.svg[Tiger,fallback=tiger.png,opts=interactive]', :safe => Asciidoctor::SafeMode::SERVER, :attributes => { 'imagesdir' => 'images' })
+ para = block_from_string('image:tiger.svg[Tiger,fallback=tiger.png,opts=interactive]', safe: Asciidoctor::SafeMode::SERVER, attributes: { 'imagesdir' => 'images' })
assert_equal %{<span class="image"><object type="image/svg+xml" data="images/tiger.svg"><img src="images/tiger.png" alt="Tiger"></object></span>}, para.sub_macros(para.source).gsub(/>\s+</, '><')
end
test 'an image macro with an inline SVG image should be converted to an svg element' do
- para = block_from_string('image:circle.svg[Tiger,100,opts=inline]', :safe => Asciidoctor::SafeMode::SERVER, :attributes => { 'imagesdir' => 'fixtures', 'docdir' => testdir })
+ para = block_from_string('image:circle.svg[Tiger,100,opts=inline]', safe: Asciidoctor::SafeMode::SERVER, attributes: { 'imagesdir' => 'fixtures', 'docdir' => testdir })
result = para.sub_macros(para.source).gsub(/>\s+</, '><')
assert_match(/<svg\s[^>]*width="100px"[^>]*>/, result)
refute_match(/<svg\s[^>]*width="500px"[^>]*>/, result)
@@ -721,12 +721,12 @@ context 'Substitutions' do
end
test 'an image macro with an inline SVG image should be converted to an svg element even when data-uri is set' do
- para = block_from_string('image:circle.svg[Tiger,100,opts=inline]', :safe => Asciidoctor::SafeMode::SERVER, :attributes => { 'data-uri' => '', 'imagesdir' => 'fixtures', 'docdir' => testdir })
+ para = block_from_string('image:circle.svg[Tiger,100,opts=inline]', safe: Asciidoctor::SafeMode::SERVER, attributes: { 'data-uri' => '', 'imagesdir' => 'fixtures', 'docdir' => testdir })
assert_match(/<svg\s[^>]*width="100px">/, para.sub_macros(para.source).gsub(/>\s+</, '><'))
end
test 'an image macro with an SVG image should not use an object element when safe mode is secure' do
- para = block_from_string('image:tiger.svg[Tiger,opts=interactive]', :attributes => { 'imagesdir' => 'images' })
+ para = block_from_string('image:tiger.svg[Tiger,opts=interactive]', attributes: { 'imagesdir' => 'images' })
assert_equal %{<span class="image"><img src="images/tiger.svg" alt="Tiger"></span>}, para.sub_macros(para.source).gsub(/>\s+</, '><')
end
@@ -742,7 +742,7 @@ context 'Substitutions' do
end
test 'a single-line image macro with text and dimensions should be interpreted as an image with alt text and dimensions in docbook' do
- para = block_from_string 'image:tiger.png[Tiger, 200, 100]', :backend => 'docbook'
+ para = block_from_string 'image:tiger.png[Tiger, 200, 100]', backend: 'docbook'
assert_equal %{<inlinemediaobject><imageobject><imagedata fileref="tiger.png" contentwidth="200" contentdepth="100"/></imageobject><textobject><phrase>Tiger</phrase></textobject></inlinemediaobject>},
para.sub_macros(para.source).gsub(/>\s+</, '><')
end
@@ -790,19 +790,19 @@ context 'Substitutions' do
end
test 'should prepend value of imagesdir attribute to inline image target if target is relative path' do
- para = block_from_string %(Beware of the image:tiger.png[tiger].), :attributes => {'imagesdir' => './images'}
+ para = block_from_string %(Beware of the image:tiger.png[tiger].), attributes: { 'imagesdir' => './images' }
assert_equal %{Beware of the <span class="image"><img src="./images/tiger.png" alt="tiger"></span>.},
para.sub_macros(para.source).gsub(/>\s+</, '><')
end
test 'should not prepend value of imagesdir attribute to inline image target if target is absolute path' do
- para = block_from_string %(Beware of the image:/tiger.png[tiger].), :attributes => {'imagesdir' => './images'}
+ para = block_from_string %(Beware of the image:/tiger.png[tiger].), attributes: { 'imagesdir' => './images' }
assert_equal %{Beware of the <span class="image"><img src="/tiger.png" alt="tiger"></span>.},
para.sub_macros(para.source).gsub(/>\s+</, '><')
end
test 'should not prepend value of imagesdir attribute to inline image target if target is url' do
- para = block_from_string %(Beware of the image:http://example.com/images/tiger.png[tiger].), :attributes => {'imagesdir' => './images'}
+ para = block_from_string %(Beware of the image:http://example.com/images/tiger.png[tiger].), attributes: { 'imagesdir' => './images' }
assert_equal %{Beware of the <span class="image"><img src="http://example.com/images/tiger.png" alt="tiger"></span>.},
para.sub_macros(para.source).gsub(/>\s+</, '><')
end
@@ -843,7 +843,7 @@ context 'Substitutions' do
EOS
using_memory_logger do |logger|
- sect = block_from_string input, :attributes => { 'data-uri' => '', 'iconsdir' => 'fixtures', 'docdir' => testdir }, :safe => :server, :catalog_assets => true
+ sect = block_from_string input, attributes: { 'data-uri' => '', 'iconsdir' => 'fixtures', 'docdir' => testdir }, safe: :server, catalog_assets: true
assert 1, sect.document.catalog[:images].size
assert_equal 'fixtures/dot.gif', sect.document.catalog[:images][0].to_s
assert_nil sect.document.catalog[:images][0].imagesdir
@@ -852,7 +852,7 @@ context 'Substitutions' do
end
test 'an icon macro should be interpreted as an icon if icons are enabled' do
- para = block_from_string 'icon:github[]', :attributes => {'icons' => ''}
+ para = block_from_string 'icon:github[]', attributes: { 'icons' => '' }
assert_equal %{<span class="icon"><img src="./images/icons/github.png" alt="github"></span>}, para.sub_macros(para.source).gsub(/>\s+</, '><')
end
@@ -867,17 +867,17 @@ context 'Substitutions' do
end
test 'an icon macro should be interpreted as a font-based icon when icons=font' do
- para = block_from_string 'icon:github[]', :attributes => {'icons' => 'font'}
+ para = block_from_string 'icon:github[]', attributes: { 'icons' => 'font' }
assert_equal %{<span class="icon"><i class="fa fa-github"></i></span>}, para.sub_macros(para.source).gsub(/>\s+</, '><')
end
test 'an icon macro with a size should be interpreted as a font-based icon with a size when icons=font' do
- para = block_from_string 'icon:github[4x]', :attributes => {'icons' => 'font'}
+ para = block_from_string 'icon:github[4x]', attributes: { 'icons' => 'font' }
assert_equal %{<span class="icon"><i class="fa fa-github fa-4x"></i></span>}, para.sub_macros(para.source).gsub(/>\s+</, '><')
end
test 'an icon macro with a role and title should be interpreted as a font-based icon with a class and title when icons=font' do
- para = block_from_string 'icon:heart[role="red", title="Heart me"]', :attributes => {'icons' => 'font'}
+ para = block_from_string 'icon:heart[role="red", title="Heart me"]', attributes: { 'icons' => 'font' }
assert_equal %{<span class="icon red"><i class="fa fa-heart" title="Heart me"></i></span>}, para.sub_macros(para.source).gsub(/>\s+</, '><')
end
@@ -956,7 +956,7 @@ context 'Substitutions' do
# specialcharacters escaping is simulated
para = block_from_string('text footnote:[&lt;&lt;_install,install&gt;&gt;]')
doc = para.document
- doc.register :refs, ['_install', (Asciidoctor::Inline.new doc, :anchor, 'Install', :type => :ref, :target => '_install'), 'Install']
+ doc.register :refs, ['_install', (Asciidoctor::Inline.new doc, :anchor, 'Install', type: :ref, target: '_install'), 'Install']
catalog = doc.catalog
assert_equal %(text <sup class="footnote">[<a id="_footnoteref_1" class="footnote" href="#_footnotedef_1" title="View footnote.">1</a>]</sup>), para.sub_macros(para.source)
assert_equal 1, catalog[:footnotes].size
@@ -977,7 +977,7 @@ context 'Substitutions' do
foofootnote:[+http://example.com+]barfootnote:[+http://acme.com+]baz
EOS
- result = convert_string_to_embedded input, :doctype => 'inline', :backend => 'docbook'
+ result = convert_string_to_embedded input, doctype: 'inline', backend: 'docbook'
assert_equal 'foo<footnote><simpara>http://example.com</simpara></footnote>bar<footnote><simpara>http://acme.com</simpara></footnote>baz', result
end
@@ -1137,7 +1137,7 @@ You can download the software from the product page.footnote:1[Option only avail
test 'should escape concealed index term if second bracket is preceded by a backslash' do
input = %[National Institute of Science and Technology (#{BACKSLASH}((NIST)))]
- doc = document_from_string input, :header_footer => false
+ doc = document_from_string input, header_footer: false
output = doc.convert
assert_xpath '//p[text()="National Institute of Science and Technology (((NIST)))"]', output, 1
assert doc.catalog[:indexterms].empty?
@@ -1145,7 +1145,7 @@ You can download the software from the product page.footnote:1[Option only avail
test 'should only escape enclosing brackets if concealed index term is preceded by a backslash' do
input = %[National Institute of Science and Technology #{BACKSLASH}(((NIST)))]
- doc = document_from_string input, :header_footer => false
+ doc = document_from_string input, header_footer: false
output = doc.convert
assert_xpath '//p[text()="National Institute of Science and Technology (NIST)"]', output, 1
term = doc.catalog[:indexterms].first
@@ -1215,7 +1215,7 @@ EOS
input = '(text with ((index term)))'
expected = '(text with <indexterm><primary>index term</primary></indexterm>index term)'
expected_term = ['index term']
- para = block_from_string input, :backend => :docbook
+ para = block_from_string input, backend: :docbook
output = para.sub_macros para.source
indexterms_table = para.document.catalog[:indexterms]
assert_equal 1, indexterms_table.size
@@ -1227,7 +1227,7 @@ EOS
input = '(((index term)) for text)'
expected = '(<indexterm><primary>index term</primary></indexterm>index term for text)'
expected_term = ['index term']
- para = block_from_string input, :backend => :docbook
+ para = block_from_string input, backend: :docbook
output = para.sub_macros para.source
indexterms_table = para.document.catalog[:indexterms]
assert_equal 1, indexterms_table.size
@@ -1309,201 +1309,201 @@ EOS
context 'Button macro' do
test 'btn macro' do
- para = block_from_string('btn:[Save]', :attributes => {'experimental' => ''})
+ para = block_from_string('btn:[Save]', attributes: { 'experimental' => '' })
assert_equal %q{<b class="button">Save</b>}, para.sub_macros(para.source)
end
test 'btn macro that spans multiple lines' do
- para = block_from_string(%(btn:[Rebase and\nmerge]), :attributes => {'experimental' => ''})
+ para = block_from_string(%(btn:[Rebase and\nmerge]), attributes: { 'experimental' => '' })
assert_equal %q{<b class="button">Rebase and merge</b>}, para.sub_macros(para.source)
end
test 'btn macro for docbook backend' do
- para = block_from_string('btn:[Save]', :backend => 'docbook', :attributes => {'experimental' => ''})
+ para = block_from_string('btn:[Save]', backend: 'docbook', attributes: { 'experimental' => '' })
assert_equal %q{<guibutton>Save</guibutton>}, para.sub_macros(para.source)
end
end
context 'Keyboard macro' do
test 'kbd macro with single key' do
- para = block_from_string('kbd:[F3]', :attributes => {'experimental' => ''})
+ para = block_from_string('kbd:[F3]', attributes: { 'experimental' => '' })
assert_equal %q{<kbd>F3</kbd>}, para.sub_macros(para.source)
end
test 'kbd macro with single backslash key' do
- para = block_from_string("kbd:[#{BACKSLASH} ]", :attributes => {'experimental' => ''})
+ para = block_from_string("kbd:[#{BACKSLASH} ]", attributes: { 'experimental' => '' })
assert_equal %q(<kbd>\</kbd>), para.sub_macros(para.source)
end
test 'kbd macro with single key, docbook backend' do
- para = block_from_string('kbd:[F3]', :backend => 'docbook', :attributes => {'experimental' => ''})
+ para = block_from_string('kbd:[F3]', backend: 'docbook', attributes: { 'experimental' => '' })
assert_equal %q{<keycap>F3</keycap>}, para.sub_macros(para.source)
end
test 'kbd macro with key combination' do
- para = block_from_string('kbd:[Ctrl+Shift+T]', :attributes => {'experimental' => ''})
+ para = block_from_string('kbd:[Ctrl+Shift+T]', attributes: { 'experimental' => '' })
assert_equal %q{<span class="keyseq"><kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>T</kbd></span>}, para.sub_macros(para.source)
end
test 'kbd macro with key combination that spans multiple lines' do
- para = block_from_string(%(kbd:[Ctrl +\nT]), :attributes => {'experimental' => ''})
+ para = block_from_string(%(kbd:[Ctrl +\nT]), attributes: { 'experimental' => '' })
assert_equal %q{<span class="keyseq"><kbd>Ctrl</kbd>+<kbd>T</kbd></span>}, para.sub_macros(para.source)
end
test 'kbd macro with key combination, docbook backend' do
- para = block_from_string('kbd:[Ctrl+Shift+T]', :backend => 'docbook', :attributes => {'experimental' => ''})
+ para = block_from_string('kbd:[Ctrl+Shift+T]', backend: 'docbook', attributes: { 'experimental' => '' })
assert_equal %q{<keycombo><keycap>Ctrl</keycap><keycap>Shift</keycap><keycap>T</keycap></keycombo>}, para.sub_macros(para.source)
end
test 'kbd macro with key combination delimited by pluses with spaces' do
- para = block_from_string('kbd:[Ctrl + Shift + T]', :attributes => {'experimental' => ''})
+ para = block_from_string('kbd:[Ctrl + Shift + T]', attributes: { 'experimental' => '' })
assert_equal %q{<span class="keyseq"><kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>T</kbd></span>}, para.sub_macros(para.source)
end
test 'kbd macro with key combination delimited by commas' do
- para = block_from_string('kbd:[Ctrl,Shift,T]', :attributes => {'experimental' => ''})
+ para = block_from_string('kbd:[Ctrl,Shift,T]', attributes: { 'experimental' => '' })
assert_equal %q{<span class="keyseq"><kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>T</kbd></span>}, para.sub_macros(para.source)
end
test 'kbd macro with key combination delimited by commas with spaces' do
- para = block_from_string('kbd:[Ctrl, Shift, T]', :attributes => {'experimental' => ''})
+ para = block_from_string('kbd:[Ctrl, Shift, T]', attributes: { 'experimental' => '' })
assert_equal %q{<span class="keyseq"><kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>T</kbd></span>}, para.sub_macros(para.source)
end
test 'kbd macro with key combination delimited by plus containing a comma key' do
- para = block_from_string('kbd:[Ctrl+,]', :attributes => {'experimental' => ''})
+ para = block_from_string('kbd:[Ctrl+,]', attributes: { 'experimental' => '' })
assert_equal %q{<span class="keyseq"><kbd>Ctrl</kbd>+<kbd>,</kbd></span>}, para.sub_macros(para.source)
end
test 'kbd macro with key combination delimited by commas containing a plus key' do
- para = block_from_string('kbd:[Ctrl, +, Shift]', :attributes => {'experimental' => ''})
+ para = block_from_string('kbd:[Ctrl, +, Shift]', attributes: { 'experimental' => '' })
assert_equal %q{<span class="keyseq"><kbd>Ctrl</kbd>+<kbd>+</kbd>+<kbd>Shift</kbd></span>}, para.sub_macros(para.source)
end
test 'kbd macro with key combination where last key matches plus delimiter' do
- para = block_from_string('kbd:[Ctrl + +]', :attributes => {'experimental' => ''})
+ para = block_from_string('kbd:[Ctrl + +]', attributes: { 'experimental' => '' })
assert_equal %q{<span class="keyseq"><kbd>Ctrl</kbd>+<kbd>+</kbd></span>}, para.sub_macros(para.source)
end
test 'kbd macro with key combination where last key matches comma delimiter' do
- para = block_from_string('kbd:[Ctrl, ,]', :attributes => {'experimental' => ''})
+ para = block_from_string('kbd:[Ctrl, ,]', attributes: { 'experimental' => '' })
assert_equal %q{<span class="keyseq"><kbd>Ctrl</kbd>+<kbd>,</kbd></span>}, para.sub_macros(para.source)
end
test 'kbd macro with key combination containing escaped bracket' do
- para = block_from_string('kbd:[Ctrl + \]]', :attributes => {'experimental' => ''})
+ para = block_from_string('kbd:[Ctrl + \]]', attributes: { 'experimental' => '' })
assert_equal %q{<span class="keyseq"><kbd>Ctrl</kbd>+<kbd>]</kbd></span>}, para.sub_macros(para.source)
end
test 'kbd macro with key combination ending in backslash' do
- para = block_from_string("kbd:[Ctrl + #{BACKSLASH} ]", :attributes => {'experimental' => ''})
+ para = block_from_string("kbd:[Ctrl + #{BACKSLASH} ]", attributes: { 'experimental' => '' })
assert_equal %q(<span class="keyseq"><kbd>Ctrl</kbd>+<kbd>\\</kbd></span>), para.sub_macros(para.source)
end
test 'kbd macro looks for delimiter beyond first character' do
- para = block_from_string('kbd:[,te]', :attributes => {'experimental' => ''})
+ para = block_from_string('kbd:[,te]', attributes: { 'experimental' => '' })
assert_equal %q(<kbd>,te</kbd>), para.sub_macros(para.source)
end
test 'kbd macro restores trailing delimiter as key value' do
- para = block_from_string('kbd:[te,]', :attributes => {'experimental' => ''})
+ para = block_from_string('kbd:[te,]', attributes: { 'experimental' => '' })
assert_equal %q(<kbd>te,</kbd>), para.sub_macros(para.source)
end
end
context 'Menu macro' do
test 'should process menu using macro sytnax' do
- para = block_from_string('menu:File[]', :attributes => {'experimental' => ''})
+ para = block_from_string('menu:File[]', attributes: { 'experimental' => '' })
assert_equal %q{<b class="menuref">File</b>}, para.sub_macros(para.source)
end
test 'should process menu for docbook backend' do
- para = block_from_string('menu:File[]', :backend => 'docbook', :attributes => {'experimental' => ''})
+ para = block_from_string('menu:File[]', backend: 'docbook', attributes: { 'experimental' => '' })
assert_equal %q{<guimenu>File</guimenu>}, para.sub_macros(para.source)
end
test 'should process menu with menu item using macro syntax' do
- para = block_from_string('menu:File[Save As&#8230;]', :attributes => {'experimental' => ''})
+ para = block_from_string('menu:File[Save As&#8230;]', attributes: { 'experimental' => '' })
assert_equal %q{<span class="menuseq"><b class="menu">File</b>&#160;<b class="caret">&#8250;</b> <b class="menuitem">Save As&#8230;</b></span>}, para.sub_macros(para.source)
end
test 'should process menu macro that spans multiple lines' do
input = %(menu:Preferences[Compile\non\nSave])
- para = block_from_string input, :attributes => {'experimental' => ''}
+ para = block_from_string input, attributes: { 'experimental' => '' }
assert_equal %(<span class="menuseq"><b class="menu">Preferences</b>&#160;<b class="caret">&#8250;</b> <b class="menuitem">Compile\non\nSave</b></span>), para.sub_macros(para.source)
end
test 'should unescape escaped closing bracket in menu macro' do
input = 'menu:Preferences[Compile [on\\] Save]'
- para = block_from_string input, :attributes => {'experimental' => ''}
+ para = block_from_string input, attributes: { 'experimental' => '' }
assert_equal %q(<span class="menuseq"><b class="menu">Preferences</b>&#160;<b class="caret">&#8250;</b> <b class="menuitem">Compile [on] Save</b></span>), para.sub_macros(para.source)
end
test 'should process menu with menu item using macro syntax when fonts icons are enabled' do
- para = block_from_string('menu:Tools[More Tools &gt; Extensions]', :attributes => {'experimental' => '', 'icons' => 'font'})
+ para = block_from_string('menu:Tools[More Tools &gt; Extensions]', attributes: { 'experimental' => '', 'icons' => 'font' })
assert_equal %q{<span class="menuseq"><b class="menu">Tools</b>&#160;<i class="fa fa-angle-right caret"></i> <b class="submenu">More Tools</b>&#160;<i class="fa fa-angle-right caret"></i> <b class="menuitem">Extensions</b></span>}, para.sub_macros(para.source)
end
test 'should process menu with menu item for docbook backend' do
- para = block_from_string('menu:File[Save As&#8230;]', :backend => 'docbook', :attributes => {'experimental' => ''})
+ para = block_from_string('menu:File[Save As&#8230;]', backend: 'docbook', attributes: { 'experimental' => '' })
assert_equal %q{<menuchoice><guimenu>File</guimenu> <guimenuitem>Save As&#8230;</guimenuitem></menuchoice>}, para.sub_macros(para.source)
end
test 'should process menu with menu item in submenu using macro syntax' do
- para = block_from_string('menu:Tools[Project &gt; Build]', :attributes => {'experimental' => ''})
+ para = block_from_string('menu:Tools[Project &gt; Build]', attributes: { 'experimental' => '' })
assert_equal %q{<span class="menuseq"><b class="menu">Tools</b>&#160;<b class="caret">&#8250;</b> <b class="submenu">Project</b>&#160;<b class="caret">&#8250;</b> <b class="menuitem">Build</b></span>}, para.sub_macros(para.source)
end
test 'should process menu with menu item in submenu for docbook backend' do
- para = block_from_string('menu:Tools[Project &gt; Build]', :backend => 'docbook', :attributes => {'experimental' => ''})
+ para = block_from_string('menu:Tools[Project &gt; Build]', backend: 'docbook', attributes: { 'experimental' => '' })
assert_equal %q{<menuchoice><guimenu>Tools</guimenu> <guisubmenu>Project</guisubmenu> <guimenuitem>Build</guimenuitem></menuchoice>}, para.sub_macros(para.source)
end
test 'should process menu with menu item in submenu using macro syntax and comma delimiter' do
- para = block_from_string('menu:Tools[Project, Build]', :attributes => {'experimental' => ''})
+ para = block_from_string('menu:Tools[Project, Build]', attributes: { 'experimental' => '' })
assert_equal %q{<span class="menuseq"><b class="menu">Tools</b>&#160;<b class="caret">&#8250;</b> <b class="submenu">Project</b>&#160;<b class="caret">&#8250;</b> <b class="menuitem">Build</b></span>}, para.sub_macros(para.source)
end
test 'should process menu with menu item using inline syntax' do
- para = block_from_string('"File &gt; Save As&#8230;"', :attributes => {'experimental' => ''})
+ para = block_from_string('"File &gt; Save As&#8230;"', attributes: { 'experimental' => '' })
assert_equal %q{<span class="menuseq"><b class="menu">File</b>&#160;<b class="caret">&#8250;</b> <b class="menuitem">Save As&#8230;</b></span>}, para.sub_macros(para.source)
end
test 'should process menu with menu item in submenu using inline syntax' do
- para = block_from_string('"Tools &gt; Project &gt; Build"', :attributes => {'experimental' => ''})
+ para = block_from_string('"Tools &gt; Project &gt; Build"', attributes: { 'experimental' => '' })
assert_equal %q{<span class="menuseq"><b class="menu">Tools</b>&#160;<b class="caret">&#8250;</b> <b class="submenu">Project</b>&#160;<b class="caret">&#8250;</b> <b class="menuitem">Build</b></span>}, para.sub_macros(para.source)
end
test 'inline menu syntax should not match closing quote of XML attribute' do
- para = block_from_string('<span class="xmltag">&lt;node&gt;</span><span class="classname">r</span>', :attributes => {'experimental' => ''})
+ para = block_from_string('<span class="xmltag">&lt;node&gt;</span><span class="classname">r</span>', attributes: { 'experimental' => '' })
assert_equal %q{<span class="xmltag">&lt;node&gt;</span><span class="classname">r</span>}, para.sub_macros(para.source)
end
test 'should process menu macro with items containing multibyte characters' do
- para = block_from_string('menu:视图[放大, 重置]', :attributes => {'experimental' => ''})
+ para = block_from_string('menu:视图[放大, 重置]', attributes: { 'experimental' => '' })
assert_equal %q{<span class="menuseq"><b class="menu">视图</b>&#160;<b class="caret">&#8250;</b> <b class="submenu">放大</b>&#160;<b class="caret">&#8250;</b> <b class="menuitem">重置</b></span>}, para.sub_macros(para.source)
end
test 'should process inline menu with items containing multibyte characters' do
- para = block_from_string('"视图 &gt; 放大 &gt; 重置"', :attributes => {'experimental' => ''})
+ para = block_from_string('"视图 &gt; 放大 &gt; 重置"', attributes: { 'experimental' => '' })
assert_equal %q{<span class="menuseq"><b class="menu">视图</b>&#160;<b class="caret">&#8250;</b> <b class="submenu">放大</b>&#160;<b class="caret">&#8250;</b> <b class="menuitem">重置</b></span>}, para.sub_macros(para.source)
end
test 'should process a menu macro with a target that begins with a character reference' do
- para = block_from_string('menu:&#8942;[More Tools, Extensions]', :attributes => {'experimental' => ''})
+ para = block_from_string('menu:&#8942;[More Tools, Extensions]', attributes: { 'experimental' => '' })
assert_equal %q{<span class="menuseq"><b class="menu">&#8942;</b>&#160;<b class="caret">&#8250;</b> <b class="submenu">More Tools</b>&#160;<b class="caret">&#8250;</b> <b class="menuitem">Extensions</b></span>}, para.sub_macros(para.source)
end
test 'should not process a menu macro with a target that ends with a space' do
input = 'menu:foo [bar] menu:File[Save]'
- para = block_from_string input, :attributes => {'experimental' => ''}
+ para = block_from_string input, attributes: { 'experimental' => '' }
result = para.sub_macros para.source
assert_xpath '/span[@class="menuseq"]', result, 1
assert_xpath '//b[@class="menu"][text()="File"]', result, 1
end
test 'should process an inline menu that begins with a character reference' do
- para = block_from_string('"&#8942; &gt; More Tools &gt; Extensions"', :attributes => {'experimental' => ''})
+ para = block_from_string('"&#8942; &gt; More Tools &gt; Extensions"', attributes: { 'experimental' => '' })
assert_equal %q{<span class="menuseq"><b class="menu">&#8942;</b>&#160;<b class="caret">&#8250;</b> <b class="submenu">More Tools</b>&#160;<b class="caret">&#8250;</b> <b class="menuitem">Extensions</b></span>}, para.sub_macros(para.source)
end
end
@@ -1637,7 +1637,7 @@ EOS
# NOTE placeholder is surrounded by text to prevent reader from stripping trailing boundary char (unique to test scenario)
test 'restore inline passthroughs without subs' do
para = block_from_string("some #{Asciidoctor::Substitutors::PASS_START}" + '0' + "#{Asciidoctor::Substitutors::PASS_END} to study")
- para.passthroughs[0] = {:text => '<code>inline code</code>', :subs => []}
+ para.passthroughs[0] = { text: '<code>inline code</code>', subs: [] }
result = para.restore_passthroughs(para.source)
assert_equal "some <code>inline code</code> to study", result
end
@@ -1645,8 +1645,8 @@ EOS
# NOTE placeholder is surrounded by text to prevent reader from stripping trailing boundary char (unique to test scenario)
test 'restore inline passthroughs with subs' do
para = block_from_string("some #{Asciidoctor::Substitutors::PASS_START}" + '0' + "#{Asciidoctor::Substitutors::PASS_END} to study in the #{Asciidoctor::Substitutors::PASS_START}" + '1' + "#{Asciidoctor::Substitutors::PASS_END} programming language")
- para.passthroughs[0] = {:text => '<code>{code}</code>', :subs => [:specialcharacters]}
- para.passthroughs[1] = {:text => '{language}', :subs => [:specialcharacters]}
+ para.passthroughs[0] = { text: '<code>{code}</code>', subs: [:specialcharacters] }
+ para.passthroughs[1] = { text: '{language}', subs: [:specialcharacters] }
result = para.restore_passthroughs(para.source)
assert_equal 'some &lt;code&gt;{code}&lt;/code&gt; to study in the {language} programming language', result
end
@@ -1704,7 +1704,7 @@ EOS
input = 'asciimath:[a < b]'
expected = '<inlineequation><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML"><mml:mi>a</mml:mi><mml:mo>&lt;</mml:mo><mml:mi>b</mml:mi></mml:math></inlineequation>'
using_memory_logger do |logger|
- para = block_from_string input, :backend => :docbook
+ para = block_from_string input, backend: :docbook
actual = para.content
if asciimath_available
assert_equal expected, actual
@@ -1719,7 +1719,7 @@ EOS
test 'should not perform specialcharacters subs on asciimath macro content in Docbook output if asciimath gem not available' do
asciimath_available = !(Asciidoctor::Helpers.require_library 'asciimath', true, :ignore).nil?
input = 'asciimath:[a < b]'
- para = block_from_string input, :backend => :docbook
+ para = block_from_string input, backend: :docbook
para.document.converter.instance_variable_set :@asciimath, :unavailable
if asciimath_available
old_asciimath = ::AsciiMath
@@ -1731,7 +1731,7 @@ EOS
test 'should honor explicit subslist on asciimath macro' do
input = 'asciimath:attributes[{expr}]'
- para = block_from_string input, :attributes => {'expr' => 'x != 0'}
+ para = block_from_string input, attributes: { 'expr' => 'x != 0' }
assert_equal '\$x != 0\$', para.content
end
@@ -1755,19 +1755,19 @@ EOS
test 'should not perform specialcharacters subs on latexmath macro content in docbook backend by default' do
input = 'latexmath:[a < b]'
- para = block_from_string input, :backend => :docbook
+ para = block_from_string input, backend: :docbook
assert_equal '<inlineequation><alt><![CDATA[a < b]]></alt><mathphrase><![CDATA[a < b]]></mathphrase></inlineequation>', para.content
end
test 'should honor explicit subslist on latexmath macro' do
input = 'latexmath:attributes[{expr}]'
- para = block_from_string input, :attributes => {'expr' => '\sqrt{4} = 2'}
+ para = block_from_string input, attributes: { 'expr' => '\sqrt{4} = 2' }
assert_equal '\(\sqrt{4} = 2\)', para.content
end
test 'should passthrough math macro inside another passthrough' do
input = 'the text `asciimath:[x = y]` should be passed through as +literal+ text'
- para = block_from_string input, :attributes => {'compat-mode' => ''}
+ para = block_from_string input, attributes: { 'compat-mode' => '' }
assert_equal 'the text <code>asciimath:[x = y]</code> should be passed through as <code>literal</code> text', para.content
input = 'the text [x-]`asciimath:[x = y]` should be passed through as `literal` text'
@@ -1806,38 +1806,38 @@ EOS
test 'should passthrough text in stem macro and surround with AsciiMath delimiters if stem attribute is asciimath, empty, or not set' do
[
{},
- {'stem' => ''},
- {'stem' => 'asciimath'},
- {'stem' => 'bogus'}
+ { 'stem' => '' },
+ { 'stem' => 'asciimath' },
+ { 'stem' => 'bogus' },
].each do |attributes|
input = 'stem:[x/x={(1,if x!=0),(text{undefined},if x=0):}]'
- para = block_from_string input, :attributes => attributes
+ para = block_from_string input, attributes: attributes
assert_equal '\$x/x={(1,if x!=0),(text{undefined},if x=0):}\$', para.content
end
end
test 'should passthrough text in stem macro and surround with LaTeX math delimiters if stem attribute is latexmath, latex, or tex' do
[
- {'stem' => 'latexmath'},
- {'stem' => 'latex'},
- {'stem' => 'tex'}
+ { 'stem' => 'latexmath' },
+ { 'stem' => 'latex' },
+ { 'stem' => 'tex' },
].each do |attributes|
input = 'stem:[C = \alpha + \beta Y^{\gamma} + \epsilon]'
- para = block_from_string input, :attributes => attributes
+ para = block_from_string input, attributes: attributes
assert_equal '\(C = \alpha + \beta Y^{\gamma} + \epsilon\)', para.content
end
end
test 'should apply substitutions specified on stem macro' do
input = 'stem:c,a[sqrt(x) <=> {solve-for-x}]'
- para = block_from_string input, :attributes => {'stem' => 'asciimath', 'solve-for-x' => '13'}
+ para = block_from_string input, attributes: { 'stem' => 'asciimath', 'solve-for-x' => '13' }
assert_equal '\$sqrt(x) &lt;=&gt; 13\$', para.content
end
test 'should not recognize stem macro with invalid substitution list' do
[',', '42', 'a,'].each do |subs|
input = %(stem:#{subs}[x^2])
- para = block_from_string input, :attributes => {'stem' => 'asciimath'}
+ para = block_from_string input, attributes: { 'stem' => 'asciimath' }
assert_equal %(stem:#{subs}[x^2]), para.content
end
end
@@ -1939,19 +1939,19 @@ foo&#8201;&#8212;&#8201;'
end
test 'line break inserted after line wrap with hardbreaks enabled' do
- para = block_from_string("First line\nSecond line", :attributes => {'hardbreaks' => ''})
+ para = block_from_string("First line\nSecond line", attributes: { 'hardbreaks' => '' })
result = para.apply_subs para.lines, (para.expand_subs :post_replacements)
assert_equal 'First line<br>', result.first
end
test 'line break character stripped from end of line with hardbreaks enabled' do
- para = block_from_string("First line +\nSecond line", :attributes => {'hardbreaks' => ''})
+ para = block_from_string("First line +\nSecond line", attributes: { 'hardbreaks' => '' })
result = para.apply_subs para.lines, (para.expand_subs :post_replacements)
assert_equal 'First line<br>', result.first
end
test 'line break not inserted for single line with hardbreaks enabled' do
- para = block_from_string('First line', :attributes => {'hardbreaks' => ''})
+ para = block_from_string('First line', attributes: { 'hardbreaks' => '' })
result = para.apply_subs para.lines, (para.expand_subs :post_replacements)
assert_equal 'First line', result.first
end
@@ -1966,8 +1966,8 @@ foo&#8201;&#8212;&#8201;'
end
test 'should resolve specialcharacters sub as highlight for source block when source highlighter is coderay' do
- doc = empty_document :attributes => {'source-highlighter' => 'coderay'}
- block = Asciidoctor::Block.new(doc, :listing, :content_model => :verbatim)
+ doc = empty_document attributes: { 'source-highlighter' => 'coderay' }
+ block = Asciidoctor::Block.new(doc, :listing, content_model: :verbatim)
block.style = 'source'
block.attributes['subs'] = 'specialcharacters'
block.attributes['language'] = 'ruby'
@@ -1976,8 +1976,8 @@ foo&#8201;&#8212;&#8201;'
end
test 'should resolve specialcharacters sub as highlight for source block when source highlighter is pygments' do
- doc = empty_document :attributes => {'source-highlighter' => 'pygments'}
- block = Asciidoctor::Block.new(doc, :listing, :content_model => :verbatim)
+ doc = empty_document attributes: { 'source-highlighter' => 'pygments' }
+ block = Asciidoctor::Block.new(doc, :listing, content_model: :verbatim)
block.style = 'source'
block.attributes['subs'] = 'specialcharacters'
block.attributes['language'] = 'ruby'
@@ -1987,7 +1987,7 @@ foo&#8201;&#8212;&#8201;'
test 'should not resolve specialcharacters sub as highlight for source block when source highlighter is not set' do
doc = empty_document
- block = Asciidoctor::Block.new(doc, :listing, :content_model => :verbatim)
+ block = Asciidoctor::Block.new(doc, :listing, content_model: :verbatim)
block.style = 'source'
block.attributes['subs'] = 'specialcharacters'
block.attributes['language'] = 'ruby'
@@ -1997,7 +1997,7 @@ foo&#8201;&#8212;&#8201;'
test 'should not use subs if subs option passed to block constructor is nil' do
doc = empty_document
- block = Asciidoctor::Block.new doc, :paragraph, :source => '*bold* _italic_', :subs => nil, :attributes => {'subs' => 'quotes'}
+ block = Asciidoctor::Block.new doc, :paragraph, source: '*bold* _italic_', subs: nil, attributes: { 'subs' => 'quotes' }
assert_empty block.subs
block.lock_in_subs
assert_empty block.subs
@@ -2005,7 +2005,7 @@ foo&#8201;&#8212;&#8201;'
test 'should not use subs if subs option passed to block constructor is empty array' do
doc = empty_document
- block = Asciidoctor::Block.new doc, :paragraph, :source => '*bold* _italic_', :subs => [], :attributes => {'subs' => 'quotes'}
+ block = Asciidoctor::Block.new doc, :paragraph, source: '*bold* _italic_', subs: [], attributes: { 'subs' => 'quotes' }
assert_empty block.subs
block.lock_in_subs
assert_empty block.subs
@@ -2013,7 +2013,7 @@ foo&#8201;&#8212;&#8201;'
test 'should use subs from subs option passed to block constructor' do
doc = empty_document
- block = Asciidoctor::Block.new doc, :paragraph, :source => '*bold* _italic_', :subs => [:specialcharacters], :attributes => {'subs' => 'quotes'}
+ block = Asciidoctor::Block.new doc, :paragraph, source: '*bold* _italic_', subs: [:specialcharacters], attributes: { 'subs' => 'quotes' }
assert_equal [:specialcharacters], block.subs
block.lock_in_subs
assert_equal [:specialcharacters], block.subs
@@ -2021,7 +2021,7 @@ foo&#8201;&#8212;&#8201;'
test 'should use subs from subs attribute if subs option is not passed to block constructor' do
doc = empty_document
- block = Asciidoctor::Block.new doc, :paragraph, :source => '*bold* _italic_', :attributes => {'subs' => 'quotes'}
+ block = Asciidoctor::Block.new doc, :paragraph, source: '*bold* _italic_', attributes: { 'subs' => 'quotes' }
assert_empty block.subs
# in this case, we have to call lock_in_subs to resolve the subs
block.lock_in_subs
@@ -2030,7 +2030,7 @@ foo&#8201;&#8212;&#8201;'
test 'should use subs from subs attribute if subs option passed to block constructor is :default' do
doc = empty_document
- block = Asciidoctor::Block.new doc, :paragraph, :source => '*bold* _italic_', :subs => :default, :attributes => {'subs' => 'quotes'}
+ block = Asciidoctor::Block.new doc, :paragraph, source: '*bold* _italic_', subs: :default, attributes: { 'subs' => 'quotes' }
assert_equal [:quotes], block.subs
block.lock_in_subs
assert_equal [:quotes], block.subs
@@ -2038,7 +2038,7 @@ foo&#8201;&#8212;&#8201;'
test 'should use built-in subs if subs option passed to block constructor is :default and subs attribute is absent' do
doc = empty_document
- block = Asciidoctor::Block.new doc, :paragraph, :source => '*bold* _italic_', :subs => :default
+ block = Asciidoctor::Block.new doc, :paragraph, source: '*bold* _italic_', subs: :default
assert_equal [:specialcharacters, :quotes, :attributes, :replacements, :macros, :post_replacements], block.subs
block.lock_in_subs
assert_equal [:specialcharacters, :quotes, :attributes, :replacements, :macros, :post_replacements], block.subs
diff --git a/test/tables_test.rb b/test/tables_test.rb
index c95017c4..cc00dc71 100644
--- a/test/tables_test.rb
+++ b/test/tables_test.rb
@@ -12,7 +12,7 @@ context 'Tables' do
|=======
EOS
cells = [%w(A B C), %w(a b c), %w(1 2 3)]
- doc = document_from_string input, :header_footer => false
+ doc = document_from_string input, header_footer: false
table = doc.blocks[0]
assert 100, table.columns.map {|col| col.attributes['colpcwidth'] }.reduce(:+)
output = doc.convert
@@ -336,7 +336,7 @@ three
assert_equal expected_pcwidths[i], table_row0[i].attributes['colpcwidth']
assert_equal '', table_row0[i].attributes['autowidth-option']
end
- output = doc.convert :header_footer => false
+ output = doc.convert header_footer: false
assert_css 'table', output, 1
assert_css 'table colgroup col', output, 4
assert_css 'table colgroup col[style]', output, 1
@@ -359,7 +359,7 @@ three
assert_equal 25, table_row0[i].attributes['colpcwidth']
assert_equal '', table_row0[i].attributes['autowidth-option']
end
- output = doc.convert :header_footer => false
+ output = doc.convert header_footer: false
assert_css 'table', output, 1
assert_css 'table[style*="width: 50%;"]', output, 1
assert_css 'table colgroup col', output, 4
@@ -375,7 +375,7 @@ three
|1 |2 |3 |4
|=======
EOS
- output = convert_string_to_embedded input, :backend => 'docbook5'
+ output = convert_string_to_embedded input, backend: 'docbook5'
assert_css 'tgroup[cols="4"]', output, 1
assert_css 'tgroup colspec', output, 4
assert_css 'tgroup colspec[colwidth]', output, 4
@@ -569,7 +569,7 @@ three
|Total |6
|===
EOS
- output = convert_string_to_embedded input, :backend => 'docbook'
+ output = convert_string_to_embedded input, backend: 'docbook'
assert_css 'table', output, 1
assert_css 'table[frame="topbot"]', output, 1
assert_css 'table > title', output, 1
@@ -599,7 +599,7 @@ three
|A |B |C
|===
EOS
- output = convert_string_to_embedded input, :backend => 'docbook'
+ output = convert_string_to_embedded input, backend: 'docbook'
assert_css 'informaltable[frame="topbot"]', output, 1
end
@@ -612,7 +612,7 @@ three
|===
EOS
- output = convert_string_to_embedded input, :backend => 'docbook'
+ output = convert_string_to_embedded input, backend: 'docbook'
assert_css 'informaltable', output, 1
assert_css 'informaltable[orient="land"]', output, 1
end
@@ -982,7 +982,7 @@ d|9 2+>|10
|===
EOS
- output = convert_string_to_embedded input, :backend => 'docbook'
+ output = convert_string_to_embedded input, backend: 'docbook'
assert_xpath '//colspec', output, 2
assert_xpath '(//colspec)[1][@colname="col_1"]', output, 1
assert_xpath '(//colspec)[2][@colname="col_2"]', output, 1
@@ -999,7 +999,7 @@ d|9 2+>|10
|===
EOS
- output = convert_string_to_embedded input, :backend => 'docbook'
+ output = convert_string_to_embedded input, backend: 'docbook'
assert_xpath '//colspec', output, 3
assert_xpath '(//colspec)[1][@colname="col_1"]', output, 1
assert_xpath '(//colspec)[2][@colname="col_2"]', output, 1
@@ -1021,7 +1021,7 @@ d|9 2+>|10
|===
EOS
- output = convert_string_to_embedded input, :backend => 'docbook'
+ output = convert_string_to_embedded input, backend: 'docbook'
assert_xpath '//colspec', output, 5
(1..5).each do |n|
assert_xpath %((//colspec)[#{n}][@colname="col_#{n}"]), output, 1
@@ -1184,7 +1184,7 @@ doctype={doctype}
|===
EOS
- result = convert_string_to_embedded input, :attributes => { 'attribute-missing' => 'skip' }
+ result = convert_string_to_embedded input, attributes: { 'attribute-missing' => 'skip' }
assert_includes result, 'doctype=article'
refute_includes result, '{backend-html5-doctype-article}'
assert_includes result, '{backend-html5-doctype-book}'
@@ -1208,7 +1208,7 @@ doctype={doctype}
|===
EOS
- result = convert_string_to_embedded input, :attributes => { 'attribute-missing' => 'skip' }
+ result = convert_string_to_embedded input, attributes: { 'attribute-missing' => 'skip' }
assert_includes result, 'doctype=book'
refute_includes result, '{backend-html5-doctype-book}'
assert_includes result, '{backend-html5-doctype-article}'
@@ -1242,7 +1242,7 @@ DocBook outputs. If the input file is the standard input then the
output file name is used.
|===
EOS
- doc = document_from_string input, :sourcemap => true
+ doc = document_from_string input, sourcemap: true
table = doc.blocks.first
refute_nil table
tbody = table.rows.body
@@ -1256,9 +1256,9 @@ output file name is used.
assert_equal doc.converter, body_cell_1_3.inner_document.converter
assert_equal 5, body_cell_1_3.lineno
assert_equal 6, body_cell_1_3.inner_document.lineno
- note = (body_cell_1_3.inner_document.find_by :context => :admonition)[0]
+ note = (body_cell_1_3.inner_document.find_by context: :admonition)[0]
assert_equal 9, note.lineno
- output = doc.convert :header_footer => false
+ output = doc.convert header_footer: false
assert_css 'table > tbody > tr', output, 2
assert_css 'table > tbody > tr:nth-child(1) > td:nth-child(3) div.admonitionblock', output, 1
@@ -1273,14 +1273,14 @@ a|
a| paragraph
|===
EOS
- doc = document_from_string input, :sourcemap => true
+ doc = document_from_string input, sourcemap: true
table = doc.blocks[0]
tbody = table.rows.body
assert_equal 1, table.lineno
assert_equal 2, tbody[0][0].lineno
assert_equal 3, tbody[0][0].inner_document.lineno
assert_equal 4, tbody[1][0].lineno
- output = doc.convert :header_footer => false
+ output = doc.convert header_footer: false
assert_css 'td', output, 2
assert_xpath '(//td)[1]//*[@class="literalblock"]', output, 1
assert_xpath '(//td)[2]//*[@class="paragraph"]', output, 1
@@ -1295,7 +1295,7 @@ a|include::fixtures/include-file.asciidoc[]
|===
EOS
- output = convert_string_to_embedded input, :safe => :safe, :base_dir => testdir
+ output = convert_string_to_embedded input, safe: :safe, base_dir: testdir
assert_match(/included content/, output)
end
@@ -1335,7 +1335,7 @@ Grays Peak
refs = doc.catalog[:refs]
assert refs.key?('mount-evans')
assert refs.key?('grays-peak')
- output = doc.convert :header_footer => false
+ output = doc.convert header_footer: false
assert_xpath '(//p)[1]/a[@href="#grays-peak"][text()="Grays Peak"]', output, 1
assert_xpath '(//p)[1]/a[@href="#mount-evans"][text()="Mount Evans"]', output, 1
assert_xpath '(//table/tbody/tr)[1]//td//a[@id="mount-evans"]', output, 1
@@ -1388,7 +1388,7 @@ key: value <1>
<1> Third callout
EOS
- result = convert_string input, :backend => 'docbook'
+ result = convert_string input, backend: 'docbook'
conums = xmlnodes_at_xpath '//co', result
assert_equal 3, conums.size
['CO1-1', 'CO2-1', 'CO3-1'].each_with_index do |conum, idx|
@@ -1679,7 +1679,7 @@ asciidoctor -o - -s test.adoc | view -
|Item 1 |1
|===
EOS
- output = convert_string_to_embedded input, :backend => 'docbook45'
+ output = convert_string_to_embedded input, backend: 'docbook45'
assert_includes output, '<?dbfo keep-together="auto"?>'
end
@@ -1692,7 +1692,7 @@ asciidoctor -o - -s test.adoc | view -
|Item 1 |1
|===
EOS
- output = convert_string_to_embedded input, :backend => 'docbook5'
+ output = convert_string_to_embedded input, backend: 'docbook5'
assert_includes output, '<?dbfo keep-together="auto"?>'
end
@@ -1705,7 +1705,7 @@ asciidoctor -o - -s test.adoc | view -
|Item 1 |1
|===
EOS
- output = convert_string_to_embedded input, :backend => 'docbook5'
+ output = convert_string_to_embedded input, backend: 'docbook5'
assert_includes output, '<?dbfo keep-together="always"?>'
end
@@ -1718,7 +1718,7 @@ asciidoctor -o - -s test.adoc | view -
|Item 1 |1
|===
EOS
- output = convert_string_to_embedded input, :backend => 'docbook45'
+ output = convert_string_to_embedded input, backend: 'docbook45'
assert_includes output, '<?dbfo keep-together="always"?>'
end
@@ -1756,7 +1756,7 @@ sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
|===
EOS
- doc = document_from_string input, :header_footer => false
+ doc = document_from_string input, header_footer: false
table = doc.blocks[0]
assert 100, table.columns.map {|col| col.attributes['colpcwidth'] }.reduce(:+)
output = doc.convert
diff --git a/test/text_test.rb b/test/text_test.rb
index 0b38a821..0a515ac3 100644
--- a/test/text_test.rb
+++ b/test/text_test.rb
@@ -8,19 +8,19 @@ context "Text" do
end
test "proper encoding to handle utf8 characters in embedded document using html backend" do
- output = example_document(:encoding, :header_footer => false).convert
+ output = example_document(:encoding, header_footer: false).convert
assert_xpath '//p', output, 4
assert_xpath '//a', output, 1
end
test "proper encoding to handle utf8 characters in document using docbook45 backend" do
- output = example_document(:encoding, :attributes => {'backend' => 'docbook45', 'xmlns' => ''}).convert
+ output = example_document(:encoding, attributes: { 'backend' => 'docbook45', 'xmlns' => '' }).convert
assert_xpath '//xmlns:simpara', output, 4
assert_xpath '//xmlns:ulink', output, 1
end
test "proper encoding to handle utf8 characters in embedded document using docbook45 backend" do
- output = example_document(:encoding, :header_footer => false, :attributes => {'backend' => 'docbook45'}).convert
+ output = example_document(:encoding, header_footer: false, attributes: { 'backend' => 'docbook45' }).convert
assert_xpath '//simpara', output, 4
assert_xpath '//ulink', output, 1
end
@@ -31,7 +31,7 @@ context "Text" do
input << "[verse]\n"
input.concat(File.readlines(sample_doc_path(:encoding)))
doc = empty_document
- reader = Asciidoctor::PreprocessorReader.new doc, input, nil, :normalize => true
+ reader = Asciidoctor::PreprocessorReader.new doc, input, nil, normalize: true
block = Asciidoctor::Parser.next_block(reader, doc)
assert_xpath '//pre', block.convert.gsub(/^\s*\n/, ''), 1
end
@@ -40,8 +40,8 @@ context "Text" do
input = <<-EOS
include::fixtures/encoding.asciidoc[tags=romé]
EOS
- doc = empty_safe_document :base_dir => testdir
- reader = Asciidoctor::PreprocessorReader.new doc, input, nil, :normalize => true
+ doc = empty_safe_document base_dir: testdir
+ reader = Asciidoctor::PreprocessorReader.new doc, input, nil, normalize: true
block = Asciidoctor::Parser.next_block(reader, doc)
output = block.convert
assert_css '.paragraph', output, 1
@@ -57,7 +57,7 @@ include::fixtures/encoding.asciidoc[tags=romé]
end
test 'single- and double-quoted text' do
- output = convert_string_to_embedded(%q(``Where?,'' she said, flipping through her copy of `The New Yorker.'), :attributes => {'compat-mode' => ''})
+ output = convert_string_to_embedded(%q(``Where?,'' she said, flipping through her copy of `The New Yorker.'), attributes: { 'compat-mode' => '' })
assert_match(/&#8220;Where\?,&#8221;/, output)
assert_match(/&#8216;The New Yorker.&#8217;/, output)
@@ -68,7 +68,7 @@ include::fixtures/encoding.asciidoc[tags=romé]
test 'multiple double-quoted text on a single line' do
assert_equal '&#8220;Our business is constantly changing&#8221; or &#8220;We need faster time to market.&#8221;',
- convert_inline_string(%q(``Our business is constantly changing'' or ``We need faster time to market.''), :attributes => {'compat-mode' => ''})
+ convert_inline_string(%q(``Our business is constantly changing'' or ``We need faster time to market.''), attributes: { 'compat-mode' => '' })
assert_equal '&#8220;Our business is constantly changing&#8221; or &#8220;We need faster time to market.&#8221;',
convert_inline_string(%q("`Our business is constantly changing`" or "`We need faster time to market.`"))
end
@@ -184,12 +184,12 @@ This line is separated by something that is not a horizontal rule...
test 'emphasized text with single quote using apostrophe characters' do
rsquo = decode_char 8217
- assert_xpath %(//em[text()="Johnny#{rsquo}s"]), convert_string(%q(It's 'Johnny's' phone), :attributes => {'compat-mode' => ''})
+ assert_xpath %(//em[text()="Johnny#{rsquo}s"]), convert_string(%q(It's 'Johnny's' phone), attributes: { 'compat-mode' => '' })
assert_xpath %(//p[text()="It#{rsquo}s 'Johnny#{rsquo}s' phone"]), convert_string(%q(It's 'Johnny's' phone))
end
test 'emphasized text with escaped single quote using apostrophe characters' do
- assert_xpath %(//em[text()="Johnny's"]), convert_string(%q(It's 'Johnny\\'s' phone), :attributes => {'compat-mode' => ''})
+ assert_xpath %(//em[text()="Johnny's"]), convert_string(%q(It's 'Johnny\\'s' phone), attributes: { 'compat-mode' => '' })
assert_xpath %(//p[text()="It's 'Johnny's' phone"]), convert_string(%q(It\\'s 'Johnny\\'s' phone))
end
@@ -198,8 +198,8 @@ This line is separated by something that is not a horizontal rule...
end
test 'unescape escaped single quote emphasis in compat mode only' do
- assert_xpath %(//p[text()="A 'single quoted string' example"]), convert_string_to_embedded(%(A \\'single quoted string' example), :attributes => {'compat-mode' => ''})
- assert_xpath %(//p[text()="'single quoted string'"]), convert_string_to_embedded(%(\\'single quoted string'), :attributes => {'compat-mode' => ''})
+ assert_xpath %(//p[text()="A 'single quoted string' example"]), convert_string_to_embedded(%(A \\'single quoted string' example), attributes: { 'compat-mode' => '' })
+ assert_xpath %(//p[text()="'single quoted string'"]), convert_string_to_embedded(%(\\'single quoted string'), attributes: { 'compat-mode' => '' })
assert_xpath %(//p[text()="A \\'single quoted string' example"]), convert_string_to_embedded(%(A \\'single quoted string' example))
assert_xpath %(//p[text()="\\'single quoted string'"]), convert_string_to_embedded(%(\\'single quoted string'))
@@ -223,7 +223,7 @@ This line is separated by something that is not a horizontal rule...
test 'backticks and straight quotes in text' do
backslash = '\\'
- assert_equal %q(run <code>foo</code> <em>dog</em>), convert_inline_string(%q(run `foo` 'dog'), :attributes => {'compat-mode' => ''})
+ assert_equal %q(run <code>foo</code> <em>dog</em>), convert_inline_string(%q(run `foo` 'dog'), attributes: { 'compat-mode' => '' })
assert_equal %q(run <code>foo</code> 'dog'), convert_inline_string(%q(run `foo` 'dog'))
assert_equal %q(run `foo` 'dog'), convert_inline_string(%(run #{backslash}`foo` 'dog'))
assert_equal %q(run &#8216;foo` 'dog&#8217;), convert_inline_string(%q(run '`foo` 'dog`'))
@@ -267,11 +267,11 @@ This line is separated by something that is not a horizontal rule...
test "passthrough" do
assert_xpath "//code", convert_string("This is +passed through+."), 0
- assert_xpath "//code", convert_string("This is +passed through and monospaced+.", :attributes => {'compat-mode' => ''}), 1
+ assert_xpath "//code", convert_string("This is +passed through and monospaced+.", attributes: { 'compat-mode' => '' }), 1
end
test "nested styles" do
- output = convert_string("Winning *big _time_* in the +city *boyeeee*+.", :attributes => {'compat-mode' => ''})
+ output = convert_string("Winning *big _time_* in the +city *boyeeee*+.", attributes: { 'compat-mode' => '' })
assert_xpath "//strong/em", output
assert_xpath "//code/strong", output
@@ -283,7 +283,7 @@ This line is separated by something that is not a horizontal rule...
end
test 'unconstrained quotes' do
- output = convert_string('**B**__I__++M++[role]++M++', :attributes => {'compat-mode' => ''})
+ output = convert_string('**B**__I__++M++[role]++M++', attributes: { 'compat-mode' => '' })
assert_xpath '//strong', output, 1
assert_xpath '//em', output, 1
assert_xpath '//code[not(@class)]', output, 1