Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve rendering of the bibliography #76

Open
odrotbohm opened this issue Mar 19, 2021 · 11 comments · May be fixed by #84
Open

Improve rendering of the bibliography #76

odrotbohm opened this issue Mar 19, 2021 · 11 comments · May be fixed by #84

Comments

@odrotbohm
Copy link

According to this ticket, apparently Bibtex doesn't generate idiomatic text structures for Asciidoctor to eventually render PDFs properly. To quote the most relevant section from the original ticket:

This is a problem that needs to be dealt with in asciidoctor-bibtex. It really shouldn't be creating multiple paragraphs. Instead, it should be constructing an unordered list with the bibliography role and letting the converter handle the formatting. It's important that extensions work in a way that is compatible with converters. Otherwise, the converters cannot properly format the document.

@odrotbohm odrotbohm changed the title Improve rendering of the biibliography Improve rendering of the bibliography Mar 19, 2021
@mojavelinux
Copy link
Member

To the maintainers, please @ me if you need help creating the idiomatic / semantic structure that the converters rely on for formatting this document element.

@ProgramFan
Copy link
Contributor

I see. This behavior inherits from the orginal asciidoc-bib. I am looking into this issue.

@odrotbohm
Copy link
Author

I am completely blank on the Ruby side of things but am happy to help testing changes.

@ProgramFan
Copy link
Contributor

The problem here is that in numerical styles such as IEEE, we need to customize the list item header to be exactly [1]. This does not quite fit in the bibliography syntax in asciidoc. How can we resolve this?

@odrotbohm
Copy link
Author

odrotbohm commented Mar 22, 2021

Shouldn't it be a matter of literally replacing the paragraphs with unordered list items and marking the entire list as [bibliography]? /cc @mojavelinux

@mojavelinux
Copy link
Member

That's essentially it. Since this extension comes after block parsing, the unordered list does not have to use the bibliography syntax in AsciiDoc. It just needs to be an unordered list with the correct block style. I'll share some code that shows how this would be done.

@ProgramFan
Copy link
Contributor

Thanks, Dan. My major concern is how to represent the bibliography list. Eventually, there are two cases:

  1. For numerical csl styles like IEEE, the list is an ordered list with labels as [1].
  2. For non-numerical csl styles like APA, the list is an unordered list without labels.

How can I represent case 1 in asciidoctor?

@odrotbohm
Copy link
Author

I am of course lacking the insight into the implementation but as I understand it, the code currently renders something equivalent to <p>[1] …</p> and Dan is suggesting to change that to <ul>[1] …</ul>, right? I.e. the IEEE "label" currently is just plain text currently, not a semantic label of some sorts either?

@mojavelinux
Copy link
Member

Currently, the bibliography list in AsciiDoc has to be an unordered list that uses a square marker. And all the converters recognize this requirement. If we need to be able to customize how a bibliography list is displayed using one of the other list types or styles, then that is something that needs to be addressed in AsciiDoc. It's not something an extension should be changing because then we'll have lost the integrity of the document semantics. I'd be happy to prototype support for a secondary list style on a bibliography list in Asciidoctor PDF.

@mojavelinux
Copy link
Member

mojavelinux commented Mar 23, 2021

Here's an example of how to create a bibliography list from an extension:

require 'asciidoctor/pdf'

input = <<~EOS
= Document Title

[bibliography]
== Bibliography
EOS

Asciidoctor::Extensions.register do
  tree_processor do
    process do |doc|
      bibsect = doc.sections.last
      biblist = create_list bibsect, :ulist
      biblist.style = 'bibliography'
      biblist << (create_list_item biblist, 'text of bibliography item')
      bibsect << biblist
      nil
    end
  end
end

Asciidoctor.convert input, safe: :safe, backend: :pdf, to_file: 'out.pdf'

@mojavelinux
Copy link
Member

mojavelinux commented Mar 23, 2021

In the interim of having support for customizing the list marker on an bibliography list (at least from the API), I could understand needing to implement the items as paragraphs as you do today. But at the very least, you should be passing attributes (namely the role) defined on the macro to those paragraphs so that the styling can be controlled. In other words:

[.text-left]
bibliography::references.bib[ieee]

The text-left role should be passed to the paragraphs the extension adds.

odrotbohm added a commit to odrotbohm/asciidoctor-bibtex that referenced this issue Apr 27, 2022
Previously, the bibliography entries have been rendered as individual paragraphs. This commit tweaks the rendering to rather use an unstyled, left-aligned, unordered list.

This essentially fixes asciidoctor#76 and relates to asciidoctor/asciidoctor-pdf#1889.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants