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

Block quotes for the semantic HTML 5 Converter #4549

Open
wants to merge 5 commits into
base: feature/html-converter-next
Choose a base branch
from

Conversation

redbow-kimee
Copy link

This MR adds functionality to convert block-quotes in AsciiDoctor for the semantic-html5 converter/backend. I've added the examples from the asciidoctor manual as tests. The blockquotes-6 test requires unordered lists, which is blocked by MR #4321.

This is an example of the old and new output.

OLD:

<div class="quoteblock">
<div class="title">After landing the cloaked Klingon bird of prey in Golden Gate park:</div>
<blockquote>
Everybody remember where we parked.
</blockquote>
<div class="attribution">
&#8212; Captain James T. Kirk<br>
<cite>Star Trek IV: The Voyage Home</cite>
</div>
</div>

NEW:

<blockquote>
<header><strong class="title">After landing the cloaked Klingon bird of prey in Golden Gate park:</strong></header>
Everybody remember where we parked.
<footer>
<span class="blockquote-attribution">Captain James T. Kirk</span>
<cite class="blockquote-citation">Star Trek IV: The Voyage Home</cite>
<footer>
</blockquote>

The use of <header> for the title matches my latest [suggestions for admonitions]. The use of <footer> matches MDNs examples https://developer.mozilla.org/en-US/docs/Web/HTML/Element/blockquote.

@redbow-kimee
Copy link
Author

I added convert_verse too, because it's basically the same as block quote.

@mojavelinux
Copy link
Member

Glad to see this taking shape.

The paragraph content needs to be wrapped in a paragraph. We should never end up with text adjacent to a block-oriented element. It's simply too difficult to style it using CSS. For a styled paragraph, it should be implicitly wrapped in <p> tag. We see this used in Asciidoctor EPUB3. See https://github.com/asciidoctor/asciidoctor-epub3/blob/main/lib/asciidoctor-epub3/converter.rb#L1326-L1328

@redbow-kimee
Copy link
Author

I've added a condition so that content that does not start with a < will be surrounded by a <p>, to avoid situations where multi-paragraph quotes would be doubly surrounded by <p>, although, unless non-html < symbols are always replaced with &lt; then there may be edge-cases where this is performed incorrectly.

@redbow-kimee
Copy link
Author

Okay. I've tested this a bit. I can imagine someone might start with a leading pass:[<], but I think if they're doing that, then they're on their own.

@mojavelinux
Copy link
Member

I've added a condition so that content that does not start with a < will be surrounded by a

, to avoid situations where multi-paragraph quotes would be doubly surrounded by

, although, unless non-html < symbols are always replaced with < then there may be edge-cases where this is performed incorrectly.

This is not the correct approach. A converter should never do analysis on the generated HTML itself. The information needed here is already available by consulting the content model of the node. If the content model is simple, there will be no <p> tag in the generated HTML. Otherwise, there will be a block tag. That's why I pointed to this helper: https://github.com/asciidoctor/asciidoctor-epub3/blob/main/lib/asciidoctor-epub3/converter.rb#L1326-L1328

…nsead of starts_with(<), add missing test body
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 this pull request may close these issues.

None yet

2 participants