summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2017-09-01 23:30:13 -0600
committerGitHub <noreply@github.com>2017-09-01 23:30:13 -0600
commit59617dab4401350efcd4e50403555fa34926ed46 (patch)
treeddc5feaccb2217834180a326d28470ea19ac8ed6
parent1a85aec79b3642c14f8aa21fe9d785466f540a3e (diff)
move callouts into document catalog (PR #2394)
- add callouts as key to document catalog - add callouts method that resolves to this location
-rw-r--r--lib/asciidoctor/document.rb12
-rw-r--r--test/document_test.rb2
2 files changed, 7 insertions, 7 deletions
diff --git a/lib/asciidoctor/document.rb b/lib/asciidoctor/document.rb
index 06333922..715a1bdd 100644
--- a/lib/asciidoctor/document.rb
+++ b/lib/asciidoctor/document.rb
@@ -134,9 +134,6 @@ class Document < AbstractBlock
# Public: Get the Hash of document counters
attr_reader :counters
- # Public: Get the Hash of callouts
- attr_reader :callouts
-
# Public: Get the level-0 Section
attr_reader :header
@@ -187,7 +184,6 @@ class Document < AbstractBlock
accum[key] = (key == :footnotes ? [] : table)
accum
end
- @callouts = parent_doc.callouts
# QUESTION should we support setting attribute in parent document from nested document?
# NOTE we must dup or else all the assignments to the overrides clobbers the real attributes
@attribute_overrides = attr_overrides = parent_doc.attributes.dup
@@ -211,9 +207,9 @@ class Document < AbstractBlock
:links => [],
:images => [],
:indexterms => [],
+ :callouts => Callouts.new,
:includes => ::Set.new,
}
- @callouts = Callouts.new
# copy attributes map and normalize keys
# attribute overrides are attributes that can only be set from the commandline
# a direct assignment effectively makes the attribute a constant
@@ -587,6 +583,10 @@ class Document < AbstractBlock
@catalog[:footnotes]
end
+ def callouts
+ @catalog[:callouts]
+ end
+
def nested?
@parent_document ? true : false
end
@@ -804,7 +804,7 @@ class Document < AbstractBlock
# Internal: Restore the attributes to the previously saved state (attributes in header)
def restore_attributes
- @callouts.rewind unless @parent_document
+ @catalog[:callouts].rewind unless @parent_document
# QUESTION shouldn't this be a dup in case we convert again?
@attributes = @header_attributes
end
diff --git a/test/document_test.rb b/test/document_test.rb
index 843b7b2f..3668620b 100644
--- a/test/document_test.rb
+++ b/test/document_test.rb
@@ -1064,7 +1064,7 @@ content{blank}footnote:[commentary]
doc = document_from_string input
refute_nil doc.catalog
- assert_equal [:footnotes, :ids, :images, :includes, :indexterms, :links, :refs].to_set, doc.catalog.keys.to_set
+ assert_equal [:footnotes, :ids, :images, :includes, :indexterms, :links, :refs, :callouts].to_set, doc.catalog.keys.to_set
assert_same doc.catalog, doc.references
assert_same doc.catalog[:footnotes], doc.references[:footnotes]
assert_same doc.catalog[:ids], doc.references[:ids]