Skip to content

Commit

Permalink
Use a new way to extract list text to avoid ghost footnotes (fix #69)
Browse files Browse the repository at this point in the history
  • Loading branch information
ProgramFan committed Jul 4, 2020
1 parent cbf8e28 commit 884e444
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/asciidoctor-bibtex/extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def process(document)

# Fild bibtex file automatically if not supplied.
if bibtex_file.empty?
bibtex_file = AsciidoctorBibtex::PathUtils.find_bibfile document.basedir
bibtex_file = AsciidoctorBibtex::PathUtils.find_bibfile document.base_dir
end
if bibtex_file.empty?
bibtex_file = AsciidoctorBibtex::PathUtils.find_bibfile '.'
Expand Down Expand Up @@ -100,7 +100,10 @@ def process(document)
# First pass: extract all citations.
prose_blocks.each do |block|
if block.context == :list_item || block.context == :table_cell
line = block.text
# NOTE: we access the instance variable @text for raw text.
# Otherwise the footnotes in the text will be pre-processed and
# ghost footnotes will be inserted (as of asciidoctor 2.0.10).
line = block.instance_variable_get(:@text)
unless line.nil? || line.empty?
processor.process_citation_macros line
end
Expand All @@ -109,7 +112,7 @@ def process(document)
processor.process_citation_macros line
end
else
line = block.title
line = block.instance_variable_get(:@title)
processor.process_citation_macros line
end
end
Expand All @@ -136,7 +139,7 @@ def process(document)
# NOTE: we access the instance variable @text for raw text.
line = block.instance_variable_get(:@title)
line = processor.replace_citation_macros(line)
# line = processor.replace_bibitem_macros(line)
line = processor.replace_bibitem_macros(line)
block.title = line
end
end
Expand Down
10 changes: 10 additions & 0 deletions samples/dup-of-footnotes/test.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
= Test File

== Heading 1

Some text with footnote footnote:[words0]

Some text with footnote footnote:[words1]

* Some list text with footnote footnote:[list0]
* Some list text with footnote footnote:[list1]
Empty file.

0 comments on commit 884e444

Please sign in to comment.