From 6718d12fae455b915eb003c75599a5a57c3113f3 Mon Sep 17 00:00:00 2001 From: Pawel Veselov Date: Sun, 27 Jun 2021 19:24:31 +0200 Subject: [PATCH 1/4] Fixes #13 --- lib/asciidoctor-multipage.rb | 2 +- test/black-box-docs/list-in-table/_oops.html | 45 +++++++++++++++++++ .../black-box-docs/list-in-table/_second.html | 19 ++++++++ .../list-in-table/list-in-table.adoc | 16 +++++++ .../list-in-table/list-in-table.attr.yaml | 1 + .../list-in-table/list-in-table.html | 17 +++++++ test/test_asciidoctor-multipage.rb | 10 ++++- 7 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 test/black-box-docs/list-in-table/_oops.html create mode 100644 test/black-box-docs/list-in-table/_second.html create mode 100644 test/black-box-docs/list-in-table/list-in-table.adoc create mode 100644 test/black-box-docs/list-in-table/list-in-table.attr.yaml create mode 100644 test/black-box-docs/list-in-table/list-in-table.html diff --git a/lib/asciidoctor-multipage.rb b/lib/asciidoctor-multipage.rb index 3b59c72..929fd99 100644 --- a/lib/asciidoctor-multipage.rb +++ b/lib/asciidoctor-multipage.rb @@ -245,7 +245,7 @@ def generate_nav_links(doc) # Html5Converter convert_outline(). def generate_outline(node, opts = {}) # Do the same as Html5Converter convert_outline() here - return unless node.sections? + return unless node.sections? && node.sections.length > 0 sectnumlevels = opts[:sectnumlevels] || (node.document.attributes['sectnumlevels'] || 3).to_i toclevels = opts[:toclevels] || (node.document.attributes['toclevels'] || 2).to_i sections = node.sections diff --git a/test/black-box-docs/list-in-table/_oops.html b/test/black-box-docs/list-in-table/_oops.html new file mode 100644 index 0000000..a00270b --- /dev/null +++ b/test/black-box-docs/list-in-table/_oops.html @@ -0,0 +1,45 @@ +
+
Table of Contents
+

TOP

+
+
+

OOPS

+
+

DANGER

+ ++++ + + + + + + +

abc.${ext}

+
    +
  • +

    item

    +
  • +
+
+
+
    +
+
+
+
+
+ \ No newline at end of file diff --git a/test/black-box-docs/list-in-table/_second.html b/test/black-box-docs/list-in-table/_second.html new file mode 100644 index 0000000..cd93659 --- /dev/null +++ b/test/black-box-docs/list-in-table/_second.html @@ -0,0 +1,19 @@ +
+
Table of Contents
+

TOP

+
+
+

SECOND

+
+
+ +
+
+
+ \ No newline at end of file diff --git a/test/black-box-docs/list-in-table/list-in-table.adoc b/test/black-box-docs/list-in-table/list-in-table.adoc new file mode 100644 index 0000000..8bb655a --- /dev/null +++ b/test/black-box-docs/list-in-table/list-in-table.adoc @@ -0,0 +1,16 @@ += TOP + +:toc: + +== SECOND + +=== OOPS + +==== DANGER + +[cols=","] +|=== +|abc.$\{ext} a| +* item + +|=== diff --git a/test/black-box-docs/list-in-table/list-in-table.attr.yaml b/test/black-box-docs/list-in-table/list-in-table.attr.yaml new file mode 100644 index 0000000..58f4735 --- /dev/null +++ b/test/black-box-docs/list-in-table/list-in-table.attr.yaml @@ -0,0 +1 @@ +multipage-level: 2 diff --git a/test/black-box-docs/list-in-table/list-in-table.html b/test/black-box-docs/list-in-table/list-in-table.html new file mode 100644 index 0000000..fd6631d --- /dev/null +++ b/test/black-box-docs/list-in-table/list-in-table.html @@ -0,0 +1,17 @@ +
+
Table of Contents
+

TOP

+
+
+ +
+ \ No newline at end of file diff --git a/test/test_asciidoctor-multipage.rb b/test/test_asciidoctor-multipage.rb index 2792c22..5968219 100644 --- a/test/test_asciidoctor-multipage.rb +++ b/test/test_asciidoctor-multipage.rb @@ -1,5 +1,6 @@ require 'minitest/autorun' require 'asciidoctor' +require 'yaml' require 'asciidoctor-multipage' class AsciidoctorMultipageTest < Minitest::Test @@ -8,12 +9,19 @@ def test_black_box_docs Dir.foreach(dir) do |filename| next if filename == '.' or filename == '..' doc_path = File.join(dir, filename) - next if !File.directory?(doc_path) + next unless File.directory?(doc_path) adoc_path = File.join(doc_path, filename + '.adoc') + attr_path = File.join(doc_path, filename + '.attr.yaml') + if File.exist?(attr_path) + attr = YAML.load_file(attr_path) + else + attr = {} + end doc = Asciidoctor.convert_file(adoc_path, :to_dir => 'test/out', :to_file => true, :header_footer => false, + :attributes => attr, :backend => 'multipage_html5') pages = [doc] + doc.converter.pages pages.each do |page| From 9d6d65c19d54338838504b6568ee4e8d6e1444b7 Mon Sep 17 00:00:00 2001 From: "Owen T. Heisler" Date: Mon, 28 Jun 2021 02:59:37 +0000 Subject: [PATCH 2/4] Set multipage-level attr in doc header instead This avoids the additional dependency on YAML parsing. --- test/black-box-docs/list-in-table/list-in-table.adoc | 2 +- test/black-box-docs/list-in-table/list-in-table.attr.yaml | 1 - test/test_asciidoctor-multipage.rb | 8 -------- 3 files changed, 1 insertion(+), 10 deletions(-) delete mode 100644 test/black-box-docs/list-in-table/list-in-table.attr.yaml diff --git a/test/black-box-docs/list-in-table/list-in-table.adoc b/test/black-box-docs/list-in-table/list-in-table.adoc index 8bb655a..2ca41fb 100644 --- a/test/black-box-docs/list-in-table/list-in-table.adoc +++ b/test/black-box-docs/list-in-table/list-in-table.adoc @@ -1,6 +1,6 @@ = TOP - :toc: +:multipage-level: 2 == SECOND diff --git a/test/black-box-docs/list-in-table/list-in-table.attr.yaml b/test/black-box-docs/list-in-table/list-in-table.attr.yaml deleted file mode 100644 index 58f4735..0000000 --- a/test/black-box-docs/list-in-table/list-in-table.attr.yaml +++ /dev/null @@ -1 +0,0 @@ -multipage-level: 2 diff --git a/test/test_asciidoctor-multipage.rb b/test/test_asciidoctor-multipage.rb index 5968219..ab038f3 100644 --- a/test/test_asciidoctor-multipage.rb +++ b/test/test_asciidoctor-multipage.rb @@ -1,6 +1,5 @@ require 'minitest/autorun' require 'asciidoctor' -require 'yaml' require 'asciidoctor-multipage' class AsciidoctorMultipageTest < Minitest::Test @@ -11,17 +10,10 @@ def test_black_box_docs doc_path = File.join(dir, filename) next unless File.directory?(doc_path) adoc_path = File.join(doc_path, filename + '.adoc') - attr_path = File.join(doc_path, filename + '.attr.yaml') - if File.exist?(attr_path) - attr = YAML.load_file(attr_path) - else - attr = {} - end doc = Asciidoctor.convert_file(adoc_path, :to_dir => 'test/out', :to_file => true, :header_footer => false, - :attributes => attr, :backend => 'multipage_html5') pages = [doc] + doc.converter.pages pages.each do |page| From 168b3ae754f1ddd552c4a6e214d118c3e52d5b37 Mon Sep 17 00:00:00 2001 From: "Owen T. Heisler" Date: Mon, 28 Jun 2021 03:14:07 +0000 Subject: [PATCH 3/4] Rename list-in-table test to table-block-operator Putting a list in a table cell requires using the AsciiDoc "a" column operator which enables block-level styling (by nesting a separate document). Support for a nested documents like this is the underlying problem being fixed here. So this commit renames the test to make that more clear. --- .../{list-in-table => table-block-operator}/_oops.html | 4 ++-- .../{list-in-table => table-block-operator}/_second.html | 4 ++-- .../table-block-operator.adoc} | 0 .../table-block-operator.html} | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) rename test/black-box-docs/{list-in-table => table-block-operator}/_oops.html (85%) rename test/black-box-docs/{list-in-table => table-block-operator}/_second.html (59%) rename test/black-box-docs/{list-in-table/list-in-table.adoc => table-block-operator/table-block-operator.adoc} (100%) rename test/black-box-docs/{list-in-table/list-in-table.html => table-block-operator/table-block-operator.html} (71%) diff --git a/test/black-box-docs/list-in-table/_oops.html b/test/black-box-docs/table-block-operator/_oops.html similarity index 85% rename from test/black-box-docs/list-in-table/_oops.html rename to test/black-box-docs/table-block-operator/_oops.html index a00270b..39f5c65 100644 --- a/test/black-box-docs/list-in-table/_oops.html +++ b/test/black-box-docs/table-block-operator/_oops.html @@ -1,6 +1,6 @@
Table of Contents
-

TOP

\ No newline at end of file diff --git a/test/black-box-docs/list-in-table/_second.html b/test/black-box-docs/table-block-operator/_second.html similarity index 59% rename from test/black-box-docs/list-in-table/_second.html rename to test/black-box-docs/table-block-operator/_second.html index cd93659..3459dd3 100644 --- a/test/black-box-docs/list-in-table/_second.html +++ b/test/black-box-docs/table-block-operator/_second.html @@ -1,6 +1,6 @@
Table of Contents
-

TOP

+

TOP

SECOND

@@ -15,5 +15,5 @@

SECOND

\ No newline at end of file diff --git a/test/black-box-docs/list-in-table/list-in-table.adoc b/test/black-box-docs/table-block-operator/table-block-operator.adoc similarity index 100% rename from test/black-box-docs/list-in-table/list-in-table.adoc rename to test/black-box-docs/table-block-operator/table-block-operator.adoc diff --git a/test/black-box-docs/list-in-table/list-in-table.html b/test/black-box-docs/table-block-operator/table-block-operator.html similarity index 71% rename from test/black-box-docs/list-in-table/list-in-table.html rename to test/black-box-docs/table-block-operator/table-block-operator.html index fd6631d..42152ad 100644 --- a/test/black-box-docs/list-in-table/list-in-table.html +++ b/test/black-box-docs/table-block-operator/table-block-operator.html @@ -1,6 +1,6 @@
Table of Contents
-

TOP

    +

    TOP

    From fc133aedfc643061940dfba82ea5b0b7e20bbec4 Mon Sep 17 00:00:00 2001 From: "Owen T. Heisler" Date: Mon, 28 Jun 2021 03:48:34 +0000 Subject: [PATCH 4/4] Add table & comments to table-block-operator test --- .../table-block-operator/_oops.html | 67 +++++++++++++++++++ .../table-block-operator.adoc | 33 +++++++++ 2 files changed, 100 insertions(+) diff --git a/test/black-box-docs/table-block-operator/_oops.html b/test/black-box-docs/table-block-operator/_oops.html index 39f5c65..c84c994 100644 --- a/test/black-box-docs/table-block-operator/_oops.html +++ b/test/black-box-docs/table-block-operator/_oops.html @@ -13,6 +13,9 @@

    OOPS

    DANGER

    +
    +

    This tests the use of the AsciiDoc "a" block-level styling for a single cell.

    +
    @@ -38,6 +41,70 @@

    DANGER

    +
    +

    The following table from the +AsciiDoc +Language Documentation uses the "a" operator for the entire first column.

    +
    + ++++ + + + + + + + + + + + + + + + + +
    Column with the a style operator applied to its specifierColumn using the default style
    +
      +
    • +

      List item 1

      +
    • +
    • +

      List item 2

      +
    • +
    • +

      List item 3

      +
    • +
    +
    +
    +
      +
    +
    +

    * List item 1 +* List item 2 +* List item 3

    +
    +
    import os
    +print "%s" %(os.uname())
    +
    +
    +
    +
      +
    +
    +

    [source,python] +---- +import os +print ("%s" %(os.uname())) +----