asciidoctor 1.5.6.2 → 1.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of asciidoctor might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +330 -143
- data/README-fr.adoc +441 -0
- data/README-jp.adoc +418 -0
- data/README-zh_CN.adoc +430 -0
- data/README.adoc +454 -0
- data/Rakefile +57 -0
- data/asciidoctor.gemspec +7 -1
- data/data/locale/attributes-ar.adoc +22 -0
- data/data/locale/attributes-bg.adoc +22 -0
- data/data/locale/attributes-ca.adoc +22 -0
- data/data/locale/attributes-cs.adoc +22 -0
- data/data/locale/attributes-da.adoc +22 -0
- data/data/locale/attributes-de.adoc +22 -0
- data/data/locale/attributes-en.adoc +23 -0
- data/data/locale/attributes-es.adoc +22 -0
- data/data/locale/attributes-fa.adoc +22 -0
- data/data/locale/attributes-fi.adoc +22 -0
- data/data/locale/attributes-fr.adoc +22 -0
- data/data/locale/attributes-hu.adoc +22 -0
- data/data/locale/attributes-id.adoc +22 -0
- data/data/locale/attributes-it.adoc +22 -0
- data/data/locale/attributes-ja.adoc +22 -0
- data/data/locale/attributes-kr.adoc +22 -0
- data/data/locale/attributes-nb.adoc +22 -0
- data/data/locale/attributes-nl.adoc +22 -0
- data/data/locale/attributes-nn.adoc +22 -0
- data/data/locale/attributes-pl.adoc +22 -0
- data/data/locale/attributes-pt.adoc +22 -0
- data/data/locale/attributes-pt_BR.adoc +22 -0
- data/data/locale/attributes-ro.adoc +22 -0
- data/data/locale/attributes-ru.adoc +22 -0
- data/data/locale/attributes-sr.adoc +22 -0
- data/data/locale/attributes-sr_Latn.adoc +22 -0
- data/data/locale/attributes-tr.adoc +22 -0
- data/data/locale/attributes-uk.adoc +22 -0
- data/data/locale/attributes-zh_CN.adoc +22 -0
- data/data/locale/attributes-zh_TW.adoc +22 -0
- data/data/locale/attributes.adoc +8 -649
- data/data/stylesheets/asciidoctor-default.css +77 -72
- data/features/xref.feature +366 -7
- data/lib/asciidoctor.rb +107 -93
- data/lib/asciidoctor/abstract_block.rb +247 -239
- data/lib/asciidoctor/abstract_node.rb +56 -58
- data/lib/asciidoctor/block.rb +3 -3
- data/lib/asciidoctor/callouts.rb +1 -1
- data/lib/asciidoctor/cli/invoker.rb +36 -9
- data/lib/asciidoctor/cli/options.rb +63 -25
- data/lib/asciidoctor/converter.rb +23 -13
- data/lib/asciidoctor/converter/base.rb +4 -0
- data/lib/asciidoctor/converter/docbook45.rb +16 -9
- data/lib/asciidoctor/converter/docbook5.rb +115 -97
- data/lib/asciidoctor/converter/factory.rb +29 -31
- data/lib/asciidoctor/converter/html5.rb +229 -192
- data/lib/asciidoctor/converter/manpage.rb +72 -50
- data/lib/asciidoctor/converter/template.rb +12 -12
- data/lib/asciidoctor/core_ext.rb +5 -1
- data/lib/asciidoctor/core_ext/1.8.7/base64/strict_encode64.rb +6 -0
- data/lib/asciidoctor/document.rb +168 -77
- data/lib/asciidoctor/extensions.rb +79 -47
- data/lib/asciidoctor/helpers.rb +33 -11
- data/lib/asciidoctor/inline.rb +3 -2
- data/lib/asciidoctor/list.rb +2 -1
- data/lib/asciidoctor/logging.rb +122 -0
- data/lib/asciidoctor/parser.rb +406 -382
- data/lib/asciidoctor/path_resolver.rb +169 -162
- data/lib/asciidoctor/reader.rb +166 -121
- data/lib/asciidoctor/section.rb +45 -28
- data/lib/asciidoctor/stylesheets.rb +13 -5
- data/lib/asciidoctor/substitutors.rb +328 -254
- data/lib/asciidoctor/table.rb +105 -48
- data/lib/asciidoctor/timings.rb +34 -6
- data/lib/asciidoctor/version.rb +1 -1
- data/man/asciidoctor.1 +41 -23
- data/man/asciidoctor.adoc +14 -8
- data/test/api_test.rb +1004 -0
- data/test/attributes_test.rb +241 -50
- data/test/blocks_test.rb +549 -124
- data/test/converter_test.rb +170 -78
- data/test/document_test.rb +208 -767
- data/test/extensions_test.rb +188 -53
- data/test/fixtures/custom-backends/slim/html5/block_paragraph.html.slim +1 -1
- data/test/fixtures/custom-backends/slim/html5/block_sidebar.html.slim +1 -1
- data/test/fixtures/file-with-missing-include.adoc +1 -0
- data/test/fixtures/include-file.jsx +8 -0
- data/test/fixtures/lists.adoc +96 -0
- data/test/fixtures/other-chapters.adoc +11 -0
- data/test/fixtures/outer-include.adoc +5 -0
- data/test/fixtures/sample.asciidoc +5 -1
- data/test/fixtures/subdir/index.adoc +3 -0
- data/test/fixtures/subdir/inner-include.adoc +3 -0
- data/test/fixtures/subdir/middle-include.adoc +5 -0
- data/test/fixtures/tagged-class-enclosed.rb +0 -1
- data/test/fixtures/unclosed-tag.adoc +3 -0
- data/test/fixtures/unexpected-end-tag.adoc +4 -0
- data/test/invoker_test.rb +101 -40
- data/test/links_test.rb +266 -72
- data/test/lists_test.rb +243 -45
- data/test/logger_test.rb +211 -0
- data/test/manpage_test.rb +124 -6
- data/test/options_test.rb +46 -1
- data/test/paragraphs_test.rb +23 -10
- data/test/parser_test.rb +30 -1
- data/test/paths_test.rb +115 -33
- data/test/preamble_test.rb +1 -1
- data/test/reader_test.rb +337 -81
- data/test/sections_test.rb +656 -72
- data/test/substitutions_test.rb +182 -57
- data/test/tables_test.rb +324 -57
- data/test/test_helper.rb +77 -32
- data/test/text_test.rb +7 -7
- metadata +67 -3
    
        data/lib/asciidoctor/table.rb
    CHANGED
    
    | @@ -3,6 +3,8 @@ module Asciidoctor | |
| 3 3 | 
             
            # Public: Methods and constants for managing AsciiDoc table content in a document.
         | 
| 4 4 | 
             
            # It supports all three of AsciiDoc's table formats: psv, dsv and csv.
         | 
| 5 5 | 
             
            class Table < AbstractBlock
         | 
| 6 | 
            +
              # multipler / divisor for tuning precision of calculated result
         | 
| 7 | 
            +
              DEFAULT_PRECISION_FACTOR = 10000.0
         | 
| 6 8 |  | 
| 7 9 | 
             
              # Public: A data object that encapsulates the collection of rows (head, foot, body) for a table
         | 
| 8 10 | 
             
              class Rows
         | 
| @@ -24,7 +26,7 @@ class Table < AbstractBlock | |
| 24 26 | 
             
                #
         | 
| 25 27 | 
             
                # Returns a 2-dimentional Array of rows grouped by section.
         | 
| 26 28 | 
             
                def by_section
         | 
| 27 | 
            -
                  [[:head, @head], [: | 
| 29 | 
            +
                  [[:head, @head], [:body, @body], [:foot, @foot]]
         | 
| 28 30 | 
             
                end
         | 
| 29 31 | 
             
              end
         | 
| 30 32 |  | 
| @@ -48,7 +50,7 @@ class Table < AbstractBlock | |
| 48 50 |  | 
| 49 51 | 
             
                @has_header_option = attributes.key? 'header-option'
         | 
| 50 52 |  | 
| 51 | 
            -
                #  | 
| 53 | 
            +
                # smells like we need a utility method here
         | 
| 52 54 | 
             
                # to resolve an integer width from potential bogus input
         | 
| 53 55 | 
             
                if (pcwidth = attributes['width'])
         | 
| 54 56 | 
             
                  if (pcwidth_intval = pcwidth.to_i) > 100 || pcwidth_intval < 1
         | 
| @@ -79,14 +81,21 @@ class Table < AbstractBlock | |
| 79 81 | 
             
              # returns nothing
         | 
| 80 82 | 
             
              def create_columns colspecs
         | 
| 81 83 | 
             
                cols = []
         | 
| 84 | 
            +
                autowidth_cols = nil
         | 
| 82 85 | 
             
                width_base = 0
         | 
| 83 86 | 
             
                colspecs.each do |colspec|
         | 
| 84 | 
            -
                   | 
| 87 | 
            +
                  colwidth = colspec['width']
         | 
| 85 88 | 
             
                  cols << (Column.new self, cols.size, colspec)
         | 
| 89 | 
            +
                  if colwidth < 0
         | 
| 90 | 
            +
                    (autowidth_cols ||= []) << cols[-1]
         | 
| 91 | 
            +
                  else
         | 
| 92 | 
            +
                    width_base += colwidth
         | 
| 93 | 
            +
                  end
         | 
| 86 94 | 
             
                end
         | 
| 87 | 
            -
                 | 
| 88 | 
            -
                  @attributes['colcount'] =  | 
| 89 | 
            -
                   | 
| 95 | 
            +
                if (num_cols = (@columns = cols).size) > 0
         | 
| 96 | 
            +
                  @attributes['colcount'] = num_cols
         | 
| 97 | 
            +
                  width_base = nil unless width_base > 0 || autowidth_cols
         | 
| 98 | 
            +
                  assign_column_widths width_base, autowidth_cols
         | 
| 90 99 | 
             
                end
         | 
| 91 100 | 
             
                nil
         | 
| 92 101 | 
             
              end
         | 
| @@ -101,11 +110,23 @@ class Table < AbstractBlock | |
| 101 110 | 
             
              # width_base - the total of the relative column values used for calculating percentage widths (default: nil)
         | 
| 102 111 | 
             
              #
         | 
| 103 112 | 
             
              # returns nothing
         | 
| 104 | 
            -
              def assign_column_widths width_base = nil
         | 
| 105 | 
            -
                pf =  | 
| 113 | 
            +
              def assign_column_widths width_base = nil, autowidth_cols = nil
         | 
| 114 | 
            +
                pf = DEFAULT_PRECISION_FACTOR
         | 
| 106 115 | 
             
                total_width = col_pcwidth = 0
         | 
| 107 116 |  | 
| 108 117 | 
             
                if width_base
         | 
| 118 | 
            +
                  if autowidth_cols
         | 
| 119 | 
            +
                    if width_base > 100
         | 
| 120 | 
            +
                      autowidth = 0
         | 
| 121 | 
            +
                      logger.warn %(total column width must not exceed 100% when using autowidth columns; got #{width_base}%)
         | 
| 122 | 
            +
                    else
         | 
| 123 | 
            +
                      autowidth = ((100.0 - width_base) / autowidth_cols.size * pf).to_i / pf
         | 
| 124 | 
            +
                      autowidth = autowidth.to_i if autowidth.to_i == autowidth
         | 
| 125 | 
            +
                      width_base = 100
         | 
| 126 | 
            +
                    end
         | 
| 127 | 
            +
                    autowidth_attrs = { 'width' => autowidth, 'autowidth-option' => '' }
         | 
| 128 | 
            +
                    autowidth_cols.each {|col| col.update_attributes autowidth_attrs }
         | 
| 129 | 
            +
                  end
         | 
| 109 130 | 
             
                  @columns.each {|col| total_width += (col_pcwidth = col.assign_width nil, width_base, pf) }
         | 
| 110 131 | 
             
                else
         | 
| 111 132 | 
             
                  col_pcwidth = ((100 * pf / @columns.size).to_i) / pf
         | 
| @@ -198,9 +219,15 @@ end | |
| 198 219 |  | 
| 199 220 | 
             
            # Public: Methods for managing the a cell in an AsciiDoc table.
         | 
| 200 221 | 
             
            class Table::Cell < AbstractNode
         | 
| 222 | 
            +
              # Public: Gets/Sets the location in the AsciiDoc source where this cell begins
         | 
| 223 | 
            +
              attr_reader :source_location
         | 
| 224 | 
            +
             | 
| 201 225 | 
             
              # Public: Get/Set the Symbol style for this cell (default: nil)
         | 
| 202 226 | 
             
              attr_accessor :style
         | 
| 203 227 |  | 
| 228 | 
            +
              # Public: Substitutions to be applied to content in this cell
         | 
| 229 | 
            +
              attr_accessor :subs
         | 
| 230 | 
            +
             | 
| 204 231 | 
             
              # Public: An Integer of the number of columns this cell will span (default: nil)
         | 
| 205 232 | 
             
              attr_accessor :colspan
         | 
| 206 233 |  | 
| @@ -215,34 +242,47 @@ class Table::Cell < AbstractNode | |
| 215 242 |  | 
| 216 243 | 
             
              def initialize column, cell_text, attributes = {}, opts = {}
         | 
| 217 244 | 
             
                super column, :cell
         | 
| 245 | 
            +
                @source_location = opts[:cursor].dup if @document.sourcemap
         | 
| 218 246 | 
             
                if column
         | 
| 219 | 
            -
                  cell_style = (in_header_row = column.table.header_row?) | 
| 247 | 
            +
                  cell_style = column.attributes['style'] unless (in_header_row = column.table.header_row?)
         | 
| 220 248 | 
             
                  # REVIEW feels hacky to inherit all attributes from column
         | 
| 221 249 | 
             
                  update_attributes column.attributes
         | 
| 222 | 
            -
                else
         | 
| 223 | 
            -
                  in_header_row = cell_style = nil
         | 
| 224 250 | 
             
                end
         | 
| 251 | 
            +
                # NOTE if attributes is defined, we know this is a psv cell; implies text should be stripped
         | 
| 225 252 | 
             
                if attributes
         | 
| 226 | 
            -
                   | 
| 227 | 
            -
             | 
| 228 | 
            -
                   | 
| 229 | 
            -
             | 
| 230 | 
            -
             | 
| 231 | 
            -
             | 
| 232 | 
            -
                     | 
| 233 | 
            -
             | 
| 234 | 
            -
             | 
| 253 | 
            +
                  if attributes.empty?
         | 
| 254 | 
            +
                    @colspan = @rowspan = nil
         | 
| 255 | 
            +
                  else
         | 
| 256 | 
            +
                    @colspan, @rowspan = (attributes.delete 'colspan'), (attributes.delete 'rowspan')
         | 
| 257 | 
            +
                    # TODO delete style attribute from @attributes if set
         | 
| 258 | 
            +
                    cell_style = attributes['style'] || cell_style unless in_header_row
         | 
| 259 | 
            +
                    update_attributes attributes
         | 
| 260 | 
            +
                  end
         | 
| 261 | 
            +
                  if cell_style == :asciidoc
         | 
| 262 | 
            +
                    asciidoc = true
         | 
| 263 | 
            +
                    inner_document_cursor = opts[:cursor]
         | 
| 264 | 
            +
                    if (cell_text = cell_text.rstrip).start_with? LF
         | 
| 265 | 
            +
                      lines_advanced = 1
         | 
| 266 | 
            +
                      lines_advanced += 1 while (cell_text = cell_text.slice 1, cell_text.length).start_with? LF
         | 
| 267 | 
            +
                      # NOTE this only works if we remain in the same file
         | 
| 268 | 
            +
                      inner_document_cursor.advance lines_advanced
         | 
| 235 269 | 
             
                    else
         | 
| 236 | 
            -
                      cell_text = cell_text. | 
| 270 | 
            +
                      cell_text = cell_text.lstrip
         | 
| 237 271 | 
             
                    end
         | 
| 272 | 
            +
                  elsif (literal = cell_style == :literal) || cell_style == :verse
         | 
| 273 | 
            +
                    cell_text = cell_text.rstrip
         | 
| 274 | 
            +
                    # QUESTION should we use same logic as :asciidoc cell? strip leading space if text doesn't start with newline?
         | 
| 275 | 
            +
                    cell_text = cell_text.slice 1, cell_text.length while cell_text.start_with? LF
         | 
| 276 | 
            +
                  else
         | 
| 277 | 
            +
                    normal_psv = true
         | 
| 278 | 
            +
                    # NOTE AsciidoctorJ uses nil cell_text to create an empty cell
         | 
| 279 | 
            +
                    cell_text = cell_text ? cell_text.strip : ''
         | 
| 238 280 | 
             
                  end
         | 
| 239 | 
            -
                  update_attributes attributes
         | 
| 240 281 | 
             
                else
         | 
| 241 | 
            -
                  @colspan = nil
         | 
| 242 | 
            -
                  @rowspan = nil
         | 
| 282 | 
            +
                  @colspan = @rowspan = nil
         | 
| 243 283 | 
             
                end
         | 
| 244 284 | 
             
                # NOTE only true for non-header rows
         | 
| 245 | 
            -
                if  | 
| 285 | 
            +
                if asciidoc
         | 
| 246 286 | 
             
                  # FIXME hide doctitle from nested document; temporary workaround to fix
         | 
| 247 287 | 
             
                  # nested document seeing doctitle and assuming it has its own document title
         | 
| 248 288 | 
             
                  parent_doctitle = @document.attributes.delete('doctitle')
         | 
| @@ -259,8 +299,16 @@ class Table::Cell < AbstractNode | |
| 259 299 | 
             
                      inner_document_lines.unshift(*preprocessed_lines) unless preprocessed_lines.empty?
         | 
| 260 300 | 
             
                    end
         | 
| 261 301 | 
             
                  end unless inner_document_lines.empty?
         | 
| 262 | 
            -
                  @inner_document = Document.new(inner_document_lines, :header_footer => false, :parent => @document, :cursor =>  | 
| 302 | 
            +
                  @inner_document = Document.new(inner_document_lines, :header_footer => false, :parent => @document, :cursor => inner_document_cursor)
         | 
| 263 303 | 
             
                  @document.attributes['doctitle'] = parent_doctitle unless parent_doctitle.nil?
         | 
| 304 | 
            +
                  @subs = nil
         | 
| 305 | 
            +
                elsif literal
         | 
| 306 | 
            +
                  @subs = BASIC_SUBS
         | 
| 307 | 
            +
                else
         | 
| 308 | 
            +
                  if normal_psv && (cell_text.start_with? '[[') && LeadingInlineAnchorRx =~ cell_text
         | 
| 309 | 
            +
                    Parser.catalog_inline_anchor $1, $2, self, opts[:cursor], @document
         | 
| 310 | 
            +
                  end
         | 
| 311 | 
            +
                  @subs = NORMAL_SUBS
         | 
| 264 312 | 
             
                end
         | 
| 265 313 | 
             
                @text = cell_text
         | 
| 266 314 | 
             
                @style = cell_style
         | 
| @@ -275,7 +323,7 @@ class Table::Cell < AbstractNode | |
| 275 323 | 
             
              #
         | 
| 276 324 | 
             
              # Returns the converted String text for this Cell
         | 
| 277 325 | 
             
              def text
         | 
| 278 | 
            -
                apply_subs @text,  | 
| 326 | 
            +
                apply_subs @text, @subs
         | 
| 279 327 | 
             
              end
         | 
| 280 328 |  | 
| 281 329 | 
             
              # Public: Set the String text.
         | 
| @@ -302,6 +350,16 @@ class Table::Cell < AbstractNode | |
| 302 350 | 
             
                end
         | 
| 303 351 | 
             
              end
         | 
| 304 352 |  | 
| 353 | 
            +
              # Public: Get the source file where this block started
         | 
| 354 | 
            +
              def file
         | 
| 355 | 
            +
                @source_location && @source_location.file
         | 
| 356 | 
            +
              end
         | 
| 357 | 
            +
             | 
| 358 | 
            +
              # Public: Get the source line number where this block started
         | 
| 359 | 
            +
              def lineno
         | 
| 360 | 
            +
                @source_location && @source_location.lineno
         | 
| 361 | 
            +
              end
         | 
| 362 | 
            +
             | 
| 305 363 | 
             
              def to_s
         | 
| 306 364 | 
             
                "#{super.to_s} - [text: #@text, colspan: #{@colspan || 1}, rowspan: #{@rowspan || 1}, attributes: #@attributes]"
         | 
| 307 365 | 
             
              end
         | 
| @@ -314,6 +372,8 @@ end | |
| 314 372 | 
             
            # instantiated, the row is closed if the cell satisifies the column count and,
         | 
| 315 373 | 
             
            # finally, a new buffer is allocated to track the next cell.
         | 
| 316 374 | 
             
            class Table::ParserContext
         | 
| 375 | 
            +
              include Logging
         | 
| 376 | 
            +
             | 
| 317 377 | 
             
              # Public: An Array of String keys that represent the table formats in AsciiDoc
         | 
| 318 378 | 
             
              #--
         | 
| 319 379 | 
             
              # QUESTION should we recognize !sv as a valid format value?
         | 
| @@ -351,10 +411,8 @@ class Table::ParserContext | |
| 351 411 | 
             
              attr_reader :delimiter_re
         | 
| 352 412 |  | 
| 353 413 | 
             
              def initialize reader, table, attributes = {}
         | 
| 354 | 
            -
                @reader = reader
         | 
| 414 | 
            +
                @start_cursor_data = (@reader = reader).mark
         | 
| 355 415 | 
             
                @table = table
         | 
| 356 | 
            -
                # IMPORTANT if reader.cursor becomes a reference, this assignment would require .dup
         | 
| 357 | 
            -
                @last_cursor = reader.cursor
         | 
| 358 416 |  | 
| 359 417 | 
             
                if attributes.key? 'format'
         | 
| 360 418 | 
             
                  if FORMATS.include?(xsv = attributes['format'])
         | 
| @@ -365,7 +423,7 @@ class Table::ParserContext | |
| 365 423 | 
             
                      xsv = '!sv'
         | 
| 366 424 | 
             
                    end
         | 
| 367 425 | 
             
                  else
         | 
| 368 | 
            -
                     | 
| 426 | 
            +
                    logger.error message_with_context %(illegal table format: #{xsv}), :source_location => reader.cursor_at_prev_line
         | 
| 369 427 | 
             
                    @format, xsv = 'psv', (table.document.nested? ? '!sv' : 'psv')
         | 
| 370 428 | 
             
                  end
         | 
| 371 429 | 
             
                else
         | 
| @@ -413,18 +471,18 @@ class Table::ParserContext | |
| 413 471 |  | 
| 414 472 | 
             
              # Public: Skip past the matched delimiter because it's inside quoted text.
         | 
| 415 473 | 
             
              #
         | 
| 416 | 
            -
              #  | 
| 417 | 
            -
              def skip_past_delimiter( | 
| 418 | 
            -
                @buffer = %(#{@buffer}#{ | 
| 419 | 
            -
                 | 
| 474 | 
            +
              # Returns nothing
         | 
| 475 | 
            +
              def skip_past_delimiter(pre)
         | 
| 476 | 
            +
                @buffer = %(#{@buffer}#{pre}#{@delimiter})
         | 
| 477 | 
            +
                nil
         | 
| 420 478 | 
             
              end
         | 
| 421 479 |  | 
| 422 480 | 
             
              # Public: Skip past the matched delimiter because it's escaped.
         | 
| 423 481 | 
             
              #
         | 
| 424 | 
            -
              #  | 
| 425 | 
            -
              def skip_past_escaped_delimiter( | 
| 426 | 
            -
                @buffer = %(#{@buffer}#{ | 
| 427 | 
            -
                 | 
| 482 | 
            +
              # Returns nothing
         | 
| 483 | 
            +
              def skip_past_escaped_delimiter(pre)
         | 
| 484 | 
            +
                @buffer = %(#{@buffer}#{pre.chop}#{@delimiter})
         | 
| 485 | 
            +
                nil
         | 
| 428 486 | 
             
              end
         | 
| 429 487 |  | 
| 430 488 | 
             
              # Public: Determines whether the buffer has unclosed quotes. Used for CSV data.
         | 
| @@ -432,7 +490,9 @@ class Table::ParserContext | |
| 432 490 | 
             
              # returns true if the buffer has unclosed quotes, false if it doesn't or it
         | 
| 433 491 | 
             
              # isn't quoted data
         | 
| 434 492 | 
             
              def buffer_has_unclosed_quotes? append = nil
         | 
| 435 | 
            -
                if (record = append ? (buffer + append).strip : buffer.strip) | 
| 493 | 
            +
                if (record = append ? (@buffer + append).strip : @buffer.strip) == '"'
         | 
| 494 | 
            +
                  true
         | 
| 495 | 
            +
                elsif record.start_with? '"'
         | 
| 436 496 | 
             
                  if ((trailing_quote = record.end_with? '"') && (record.end_with? '""')) || (record.start_with? '""')
         | 
| 437 497 | 
             
                    ((record = record.gsub '""', '').start_with? '"') && !(record.end_with? '"')
         | 
| 438 498 | 
             
                  else
         | 
| @@ -513,18 +573,16 @@ class Table::ParserContext | |
| 513 573 | 
             
              # returns nothing
         | 
| 514 574 | 
             
              def close_cell(eol = false)
         | 
| 515 575 | 
             
                if @format == 'psv'
         | 
| 516 | 
            -
                  strip_text = true
         | 
| 517 576 | 
             
                  cell_text = @buffer
         | 
| 518 577 | 
             
                  @buffer = ''
         | 
| 519 578 | 
             
                  if (cellspec = take_cellspec)
         | 
| 520 579 | 
             
                    repeat = cellspec.delete('repeatcol') || 1
         | 
| 521 580 | 
             
                  else
         | 
| 522 | 
            -
                     | 
| 581 | 
            +
                    logger.error message_with_context 'table missing leading separator; recovering automatically', :source_location => Reader::Cursor.new(*@start_cursor_data)
         | 
| 523 582 | 
             
                    cellspec = {}
         | 
| 524 583 | 
             
                    repeat = 1
         | 
| 525 584 | 
             
                  end
         | 
| 526 585 | 
             
                else
         | 
| 527 | 
            -
                  strip_text = false
         | 
| 528 586 | 
             
                  cell_text = @buffer.strip
         | 
| 529 587 | 
             
                  @buffer = ''
         | 
| 530 588 | 
             
                  cellspec = nil
         | 
| @@ -534,7 +592,7 @@ class Table::ParserContext | |
| 534 592 | 
             
                      # this may not be perfect logic, but it hits the 99%
         | 
| 535 593 | 
             
                      if cell_text.start_with?('"') && cell_text.end_with?('"')
         | 
| 536 594 | 
             
                        # unquote
         | 
| 537 | 
            -
                        cell_text = cell_text | 
| 595 | 
            +
                        cell_text = cell_text.slice(1, cell_text.length - 2).strip
         | 
| 538 596 | 
             
                      end
         | 
| 539 597 |  | 
| 540 598 | 
             
                      # collapse escaped quotes
         | 
| @@ -556,13 +614,13 @@ class Table::ParserContext | |
| 556 614 | 
             
                  else
         | 
| 557 615 | 
             
                    # QUESTION is this right for cells that span columns?
         | 
| 558 616 | 
             
                    unless (column = @table.columns[@current_row.size])
         | 
| 559 | 
            -
                       | 
| 617 | 
            +
                      logger.error message_with_context 'dropping cell because it exceeds specified number of columns', :source_location => @reader.cursor_before_mark
         | 
| 560 618 | 
             
                      return
         | 
| 561 619 | 
             
                    end
         | 
| 562 620 | 
             
                  end
         | 
| 563 621 |  | 
| 564 | 
            -
                  cell = Table::Cell.new(column, cell_text, cellspec, :cursor => @ | 
| 565 | 
            -
                  @ | 
| 622 | 
            +
                  cell = Table::Cell.new(column, cell_text, cellspec, :cursor => @reader.cursor_before_mark)
         | 
| 623 | 
            +
                  @reader.mark
         | 
| 566 624 | 
             
                  unless !cell.rowspan || cell.rowspan == 1
         | 
| 567 625 | 
             
                    activate_rowspan(cell.rowspan, (cell.colspan || 1))
         | 
| 568 626 | 
             
                  end
         | 
| @@ -620,6 +678,5 @@ class Table::ParserContext | |
| 620 678 | 
             
              def advance
         | 
| 621 679 | 
             
                @linenum += 1
         | 
| 622 680 | 
             
              end
         | 
| 623 | 
            -
             | 
| 624 681 | 
             
            end
         | 
| 625 682 | 
             
            end
         | 
    
        data/lib/asciidoctor/timings.rb
    CHANGED
    
    | @@ -7,27 +7,44 @@ module Asciidoctor | |
| 7 7 | 
             
                end
         | 
| 8 8 |  | 
| 9 9 | 
             
                def start key
         | 
| 10 | 
            -
                  @timers[key] =  | 
| 10 | 
            +
                  @timers[key] = now
         | 
| 11 11 | 
             
                end
         | 
| 12 12 |  | 
| 13 13 | 
             
                def record key
         | 
| 14 | 
            -
                  @log[key] = ( | 
| 14 | 
            +
                  @log[key] = (now - (@timers.delete key))
         | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                def time *keys
         | 
| 18 | 
            +
                  time = keys.reduce(0) {|sum, key| sum + (@log[key] || 0) }
         | 
| 19 | 
            +
                  time > 0 ? time : nil
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                def read
         | 
| 23 | 
            +
                  time :read
         | 
| 24 | 
            +
                end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                def parse
         | 
| 27 | 
            +
                  time :parse
         | 
| 15 28 | 
             
                end
         | 
| 16 29 |  | 
| 17 30 | 
             
                def read_parse
         | 
| 18 | 
            -
                   | 
| 31 | 
            +
                  time :read, :parse
         | 
| 19 32 | 
             
                end
         | 
| 20 33 |  | 
| 21 34 | 
             
                def convert
         | 
| 22 | 
            -
                   | 
| 35 | 
            +
                  time :convert
         | 
| 23 36 | 
             
                end
         | 
| 24 37 |  | 
| 25 38 | 
             
                def read_parse_convert
         | 
| 26 | 
            -
                   | 
| 39 | 
            +
                  time :read, :parse, :convert
         | 
| 40 | 
            +
                end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                def write
         | 
| 43 | 
            +
                  time :write
         | 
| 27 44 | 
             
                end
         | 
| 28 45 |  | 
| 29 46 | 
             
                def total
         | 
| 30 | 
            -
                   | 
| 47 | 
            +
                  time :read, :parse, :convert, :write
         | 
| 31 48 | 
             
                end
         | 
| 32 49 |  | 
| 33 50 | 
             
                def print_report to = $stdout, subject = nil
         | 
| @@ -36,5 +53,16 @@ module Asciidoctor | |
| 36 53 | 
             
                  to.puts %(  Time to convert document: #{'%05.5f' % convert.to_f})
         | 
| 37 54 | 
             
                  to.puts %(  Total time (read, parse and convert): #{'%05.5f' % read_parse_convert.to_f})
         | 
| 38 55 | 
             
                end
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                if (::Process.const_defined? :CLOCK_MONOTONIC) && (::Process.respond_to? :clock_gettime)
         | 
| 58 | 
            +
                  CLOCK_ID = ::Process::CLOCK_MONOTONIC
         | 
| 59 | 
            +
                  def now
         | 
| 60 | 
            +
                    ::Process.clock_gettime CLOCK_ID
         | 
| 61 | 
            +
                  end
         | 
| 62 | 
            +
                else
         | 
| 63 | 
            +
                  def now
         | 
| 64 | 
            +
                    ::Time.now
         | 
| 65 | 
            +
                  end
         | 
| 66 | 
            +
                end
         | 
| 39 67 | 
             
              end
         | 
| 40 68 | 
             
            end
         | 
    
        data/lib/asciidoctor/version.rb
    CHANGED
    
    
    
        data/man/asciidoctor.1
    CHANGED
    
    | @@ -1,23 +1,32 @@ | |
| 1 1 | 
             
            '\" t
         | 
| 2 2 | 
             
            .\"     Title: asciidoctor
         | 
| 3 3 | 
             
            .\"    Author: Dan Allen, Sarah White, Ryan Waldron
         | 
| 4 | 
            -
            .\" Generator: Asciidoctor 1.5. | 
| 5 | 
            -
            .\"      Date: 2018- | 
| 4 | 
            +
            .\" Generator: Asciidoctor 1.5.7
         | 
| 5 | 
            +
            .\"      Date: 2018-05-02
         | 
| 6 6 | 
             
            .\"    Manual: Asciidoctor Manual
         | 
| 7 | 
            -
            .\"    Source: Asciidoctor 1.5. | 
| 7 | 
            +
            .\"    Source: Asciidoctor 1.5.7
         | 
| 8 8 | 
             
            .\"  Language: English
         | 
| 9 9 | 
             
            .\"
         | 
| 10 | 
            -
            .TH "ASCIIDOCTOR" "1" "2018- | 
| 10 | 
            +
            .TH "ASCIIDOCTOR" "1" "2018-05-02" "Asciidoctor 1.5.7" "Asciidoctor Manual"
         | 
| 11 11 | 
             
            .ie \n(.g .ds Aq \(aq
         | 
| 12 12 | 
             
            .el       .ds Aq '
         | 
| 13 13 | 
             
            .ss \n[.ss] 0
         | 
| 14 14 | 
             
            .nh
         | 
| 15 15 | 
             
            .ad l
         | 
| 16 16 | 
             
            .de URL
         | 
| 17 | 
            -
            \\$2 | 
| 17 | 
            +
            \fI\\$2\fP <\\$1>\\$3
         | 
| 18 18 | 
             
            ..
         | 
| 19 | 
            -
            . | 
| 20 | 
            -
            . | 
| 19 | 
            +
            .als MTO URL
         | 
| 20 | 
            +
            .if \n[.g] \{\
         | 
| 21 | 
            +
            .  mso www.tmac
         | 
| 22 | 
            +
            .  am URL
         | 
| 23 | 
            +
            .    ad l
         | 
| 24 | 
            +
            .  .
         | 
| 25 | 
            +
            .  am MTO
         | 
| 26 | 
            +
            .    ad l
         | 
| 27 | 
            +
            .  .
         | 
| 28 | 
            +
            .  LINKSTYLE blue R < >
         | 
| 29 | 
            +
            .\}
         | 
| 21 30 | 
             
            .SH "NAME"
         | 
| 22 31 | 
             
            asciidoctor \- converts AsciiDoc source files to HTML, DocBook and other formats
         | 
| 23 32 | 
             
            .SH "SYNOPSIS"
         | 
| @@ -41,7 +50,7 @@ When combined with the safe mode setting, can be used to chroot the execution of | |
| 41 50 | 
             
            \fB\-S, \-\-safe\-mode\fP=\fISAFE_MODE\fP
         | 
| 42 51 | 
             
            .RS 4
         | 
| 43 52 | 
             
            Set safe mode level: \fIunsafe\fP, \fIsafe\fP, \fIserver\fP or \fIsecure\fP.
         | 
| 44 | 
            -
            Disables potentially dangerous macros in source files, such as \f | 
| 53 | 
            +
            Disables potentially dangerous macros in source files, such as \f(CRinclude::[]\fP.
         | 
| 45 54 | 
             
            If not set, the safe mode level defaults to \fIunsafe\fP when Asciidoctor is invoked using this script.
         | 
| 46 55 | 
             
            .RE
         | 
| 47 56 | 
             
            .sp
         | 
| @@ -83,13 +92,7 @@ The \fImanpage\fP document type enables parsing of metadata necessary to produce | |
| 83 92 | 
             
            The \fIinline\fP document type allows the content of a single paragraph to be formatted and returned without wrapping it in a containing element.
         | 
| 84 93 | 
             
            Defaults to \fIarticle\fP.
         | 
| 85 94 | 
             
            .RE
         | 
| 86 | 
            -
            .SS " | 
| 87 | 
            -
            .sp
         | 
| 88 | 
            -
            \fB\-C, \-\-compact\fP
         | 
| 89 | 
            -
            .RS 4
         | 
| 90 | 
            -
            Compact the output by removing blank lines.
         | 
| 91 | 
            -
            (No longer in use).
         | 
| 92 | 
            -
            .RE
         | 
| 95 | 
            +
            .SS "Document Conversion"
         | 
| 93 96 | 
             
            .sp
         | 
| 94 97 | 
             
            \fB\-D, \-\-destination\-dir\fP=\fIDIR\fP
         | 
| 95 98 | 
             
            .RS 4
         | 
| @@ -122,7 +125,7 @@ This option may be specified more than once. | |
| 122 125 | 
             
            \fB\-n, \-\-section\-numbers\fP
         | 
| 123 126 | 
             
            .RS 4
         | 
| 124 127 | 
             
            Auto\-number section titles.
         | 
| 125 | 
            -
            Synonym for \fB\-\-attribute  | 
| 128 | 
            +
            Synonym for \fB\-\-attribute sectnums\fP.
         | 
| 126 129 | 
             
            .RE
         | 
| 127 130 | 
             
            .sp
         | 
| 128 131 | 
             
            \fB\-o, \-\-out\-file\fP=\fIOUT_FILE\fP
         | 
| @@ -134,6 +137,14 @@ If the input is read from standard input or a named pipe (fifo), then the output | |
| 134 137 | 
             
            If \fIOUT_FILE\fP is \fI\-\fP, then the output file is written to standard output.
         | 
| 135 138 | 
             
            .RE
         | 
| 136 139 | 
             
            .sp
         | 
| 140 | 
            +
            \fB\-R, \-\-source\-dir\fP=\fIDIR\fP
         | 
| 141 | 
            +
            .RS 4
         | 
| 142 | 
            +
            Source directory.
         | 
| 143 | 
            +
            Currently only used if the destination directory is also specified.
         | 
| 144 | 
            +
            Used to preserve the directory structure of files converted within this directory in the destination directory.
         | 
| 145 | 
            +
            If specified, the directory is resolved relative to the working directory.
         | 
| 146 | 
            +
            .RE
         | 
| 147 | 
            +
            .sp
         | 
| 137 148 | 
             
            \fB\-r, \-\-require\fP=\fILIBRARY\fP
         | 
| 138 149 | 
             
            .RS 4
         | 
| 139 150 | 
             
            Require the specified library before executing the processor, using the standard Ruby require.
         | 
| @@ -158,6 +169,12 @@ Matching templates found in subsequent directories override ones previously disc | |
| 158 169 | 
             
            .RE
         | 
| 159 170 | 
             
            .SS "Processing Information"
         | 
| 160 171 | 
             
            .sp
         | 
| 172 | 
            +
            \fB\-\-failure\-level\fP=\fILEVEL\fP
         | 
| 173 | 
            +
            .RS 4
         | 
| 174 | 
            +
            The minimum logging level that triggers a non\-zero exit code (failure).
         | 
| 175 | 
            +
            If this option is not set (default: FATAL), the program exits with a status code zero even if warnings or errors have been logged.
         | 
| 176 | 
            +
            .RE
         | 
| 177 | 
            +
            .sp
         | 
| 161 178 | 
             
            \fB\-q, \-\-quiet\fP
         | 
| 162 179 | 
             
            .RS 4
         | 
| 163 180 | 
             
            Silence warnings.
         | 
| @@ -191,7 +208,7 @@ Dump the Asciidoctor man page (in troff/groff format) if \fITOPIC\fP is \fImanpa | |
| 191 208 | 
             
            .RS 4
         | 
| 192 209 | 
             
            Print program version number.
         | 
| 193 210 | 
             
            .sp
         | 
| 194 | 
            -
            \f | 
| 211 | 
            +
            \f(CR\-v\fP can also be used if no other flags or arguments are present.
         | 
| 195 212 | 
             
            .RE
         | 
| 196 213 | 
             
            .SH "ENVIRONMENT"
         | 
| 197 214 | 
             
            .sp
         | 
| @@ -223,7 +240,7 @@ Refer to the \fBAsciidoctor\fP issue tracker at \c | |
| 223 240 | 
             
            .SH "RESOURCES"
         | 
| 224 241 | 
             
            .sp
         | 
| 225 242 | 
             
            \fBProject web site:\fP \c
         | 
| 226 | 
            -
            .URL " | 
| 243 | 
            +
            .URL "https://asciidoctor.org" "" ""
         | 
| 227 244 | 
             
            .sp
         | 
| 228 245 | 
             
            \fBGit source repository on GitHub:\fP \c
         | 
| 229 246 | 
             
            .URL "https://github.com/asciidoctor/asciidoctor" "" ""
         | 
| @@ -237,9 +254,10 @@ Refer to the \fBAsciidoctor\fP issue tracker at \c | |
| 237 254 | 
             
            .sp
         | 
| 238 255 | 
             
            Copyright (C) 2012\-2018 Dan Allen, Ryan Waldron and the Asciidoctor Project.
         | 
| 239 256 | 
             
            Free use of this software is granted under the terms of the MIT License.
         | 
| 240 | 
            -
            .SH " | 
| 257 | 
            +
            .SH "AUTHORS"
         | 
| 241 258 | 
             
            .sp
         | 
| 242 | 
            -
             | 
| 243 | 
            -
            . | 
| 244 | 
            -
             | 
| 245 | 
            -
            . | 
| 259 | 
            +
            Dan Allen
         | 
| 260 | 
            +
            .sp
         | 
| 261 | 
            +
            Sarah White
         | 
| 262 | 
            +
            .sp
         | 
| 263 | 
            +
            Ryan Waldron
         |