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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
50 changes: 50 additions & 0 deletions lib/asciidoctor/converter/semantic_html5.rb
Expand Up @@ -92,6 +92,56 @@ def convert_listing node
</figure>)
end

def convert_quote node
attributes = common_html_attributes node.id, node.role
title = node.title ? %(<header><strong class="title">#{node.title}</strong></header>) : nil
attribution = (node.attr? 'attribution') ? (node.attr 'attribution') : nil
citation = (node.attr? 'citetitle') ? (node.attr 'citetitle') : nil
ret = []
ret << "<blockquote>"
if title
ret << title
end
ret << (node.content_model == :simple ? %(<p>#{node.content}</p>) : node.content)
if attribution or citation
ret << "<footer>"
if attribution
ret << %(<span class="blockquote-attribution">#{attribution}</span>)
end
if citation
ret << %(<cite class="blockquote-citation">#{citation}</cite>)
end
ret << "<footer>"
end
ret << "</blockquote>"
ret.join LF
end

def convert_verse node
attributes = common_html_attributes node.id, node.role
title = node.title ? %(<header><strong class="title">#{node.title}</strong></header>) : nil
attribution = (node.attr? 'attribution') ? (node.attr 'attribution') : nil
citation = (node.attr? 'citetitle') ? (node.attr 'citetitle') : nil
ret = []
ret << "<blockquote class=\"verse\">"
if title
ret << title
end
ret << %(<pre class="verse">#{node.content}</pre>)
if attribution or citation
ret << "<footer>"
if attribution
ret << %(<span class="verse-attribution">#{attribution}</span>)
end
if citation
ret << %(<cite class="verse-citation">#{citation}</cite>)
end
ret << "<footer>"
end
ret << "</blockquote>"
ret.join LF
end

def convert_thematic_break node
'<hr>'
end
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/semantic-html5-scenarios/blockquote-1.adoc
@@ -0,0 +1,4 @@
The blockquote example 1 from https://docs.asciidoctor.org/asciidoc/latest/blocks/blockquotes/[here].

[quote,attribution,citation title and information]
Quote or excerpt text
10 changes: 10 additions & 0 deletions test/fixtures/semantic-html5-scenarios/blockquote-1.html
@@ -0,0 +1,10 @@
<p>
The blockquote example 1 from <a href="https://docs.asciidoctor.org/asciidoc/latest/blocks/blockquotes/">here</a>.
</p>
<blockquote>
<p>Quote or excerpt text</p>
<footer>
<span class="blockquote-attribution">attribution</span>
<cite class="blockquote-citation">citation title and information</cite>
<footer>
</blockquote>
5 changes: 5 additions & 0 deletions test/fixtures/semantic-html5-scenarios/blockquote-2.adoc
@@ -0,0 +1,5 @@
The blockquote example 2 from https://docs.asciidoctor.org/asciidoc/latest/blocks/blockquotes/[here].

.After landing the cloaked Klingon bird of prey in Golden Gate park:
[quote,Captain James T. Kirk,Star Trek IV: The Voyage Home]
Everybody remember where we parked.
11 changes: 11 additions & 0 deletions test/fixtures/semantic-html5-scenarios/blockquote-2.html
@@ -0,0 +1,11 @@
<p>
The blockquote example 2 from <a href="https://docs.asciidoctor.org/asciidoc/latest/blocks/blockquotes/">here</a>.
</p>
<blockquote>
<header><strong class="title">After landing the cloaked Klingon bird of prey in Golden Gate park:</strong></header>
<p>Everybody remember where we parked.</p>
<footer>
<span class="blockquote-attribution">Captain James T. Kirk</span>
<cite class="blockquote-citation">Star Trek IV: The Voyage Home</cite>
<footer>
</blockquote>
10 changes: 10 additions & 0 deletions test/fixtures/semantic-html5-scenarios/blockquote-3.adoc
@@ -0,0 +1,10 @@
The blockquote example 3 from https://docs.asciidoctor.org/asciidoc/latest/blocks/blockquotes/[here].

[quote,Monty Python and the Holy Grail]
____
Dennis: Come and see the violence inherent in the system. Help! Help! I'm being repressed!

King Arthur: Bloody peasant!

Dennis: Oh, what a giveaway! Did you hear that? Did you hear that, eh? That's what I'm on about! Did you see him repressing me? You saw him, Didn't you?
____
17 changes: 17 additions & 0 deletions test/fixtures/semantic-html5-scenarios/blockquote-3.html
@@ -0,0 +1,17 @@
<p>
The blockquote example 3 from <a href="https://docs.asciidoctor.org/asciidoc/latest/blocks/blockquotes/">here</a>.
</p>
<blockquote>
<p>
Dennis: Come and see the violence inherent in the system. Help! Help! I&#8217;m being repressed!
</p>
<p>
King Arthur: Bloody peasant!
</p>
<p>
Dennis: Oh, what a giveaway! Did you hear that? Did you hear that, eh? That&#8217;s what I&#8217;m on about! Did you see him repressing me? You saw him, Didn&#8217;t you?
</p>
<footer>
<span class="blockquote-attribution">Monty Python and the Holy Grail</span>
<footer>
</blockquote>
5 changes: 5 additions & 0 deletions test/fixtures/semantic-html5-scenarios/blockquote-4.adoc
@@ -0,0 +1,5 @@
The blockquote example 4 from https://docs.asciidoctor.org/asciidoc/latest/blocks/blockquotes/[here].

"I hold it that a little rebellion now and then is a good thing,
and as necessary in the political world as storms in the physical."
-- Thomas Jefferson, Papers of Thomas Jefferson: Volume 11
11 changes: 11 additions & 0 deletions test/fixtures/semantic-html5-scenarios/blockquote-4.html
@@ -0,0 +1,11 @@
<p>
The blockquote example 4 from <a href="https://docs.asciidoctor.org/asciidoc/latest/blocks/blockquotes/">here</a>.
</p>
<blockquote>
<p>I hold it that a little rebellion now and then is a good thing,
and as necessary in the political world as storms in the physical.</p>
<footer>
<span class="blockquote-attribution">Thomas Jefferson</span>
<cite class="blockquote-citation">Papers of Thomas Jefferson: Volume 11</cite>
<footer>
</blockquote>
5 changes: 5 additions & 0 deletions test/fixtures/semantic-html5-scenarios/blockquote-5.adoc
@@ -0,0 +1,5 @@
The blockquote example 6 from https://docs.asciidoctor.org/asciidoc/latest/blocks/blockquotes/[here].

> I hold it that a little rebellion now and then is a good thing,
> and as necessary in the political world as storms in the physical.
> -- Thomas Jefferson, Papers of Thomas Jefferson: Volume 11
13 changes: 13 additions & 0 deletions test/fixtures/semantic-html5-scenarios/blockquote-5.html
@@ -0,0 +1,13 @@
<p>
The blockquote example 6 from <a href="https://docs.asciidoctor.org/asciidoc/latest/blocks/blockquotes/">here</a>.
</p>
<blockquote>
<p>
I hold it that a little rebellion now and then is a good thing,
and as necessary in the political world as storms in the physical.
</p>
<footer>
<span class="blockquote-attribution">Thomas Jefferson</span>
<cite class="blockquote-citation">Papers of Thomas Jefferson: Volume 11</cite>
<footer>
</blockquote>
15 changes: 15 additions & 0 deletions test/fixtures/semantic-html5-scenarios/blockquote-6.adoc
@@ -0,0 +1,15 @@
The blockquote example 6 from https://docs.asciidoctor.org/asciidoc/latest/blocks/blockquotes/[here].

> > What's new?
>
> I've got Markdown in my AsciiDoc!
>
> > Like what?
>
> * Blockquotes
> * Headings
> * Fenced code blocks
>
> > Is there more?
>
> Yep. AsciiDoc and Markdown share a lot of common syntax already.
14 changes: 14 additions & 0 deletions test/fixtures/semantic-html5-scenarios/blockquote-lt-tags.adoc
@@ -0,0 +1,14 @@
This tests the blockquotes for occasions where a quote might begin with a leading `<`.

[quote, redbow-kimee, AsciiDoctor Test Suite]
<A single line quote may start with a `<`.

[quote, redbow-kimee, AsciiDoctor Test Suite]
<A single line quote> may start with a `<`, and have a `>` within it.

[quote, redbow-kimee, AsciiDoctor Test Suite]
____
<A multi paragraph quote may start with `<` and contain a `>`.

This is the second paragraph
____
29 changes: 29 additions & 0 deletions test/fixtures/semantic-html5-scenarios/blockquote-lt-tags.html
@@ -0,0 +1,29 @@
<p>
This tests the blockquotes for occasions where a quote might begin with a leading <code>&lt;</code>.
</p>
<blockquote>
<p>&lt;A single line quote may start with a <code>&lt;</code>.</p>
<footer>
<span class="blockquote-attribution">redbow-kimee</span>
<cite class="blockquote-citation">AsciiDoctor Test Suite</cite>
<footer>
</blockquote>
<blockquote>
<p>&lt;A single line quote&gt; may start with a <code>&lt;</code>, and have a <code>&gt;</code> within it.</p>
<footer>
<span class="blockquote-attribution">redbow-kimee</span>
<cite class="blockquote-citation">AsciiDoctor Test Suite</cite>
<footer>
</blockquote>
<blockquote>
<p>
&lt;A multi paragraph quote may start with <code>&lt;</code> and contain a <code>&gt;</code>.
</p>
<p>
This is the second paragraph
</p>
<footer>
<span class="blockquote-attribution">redbow-kimee</span>
<cite class="blockquote-citation">AsciiDoctor Test Suite</cite>
<footer>
</blockquote>
5 changes: 5 additions & 0 deletions test/fixtures/semantic-html5-scenarios/verse-1.adoc
@@ -0,0 +1,5 @@
The verse example 1 from https://docs.asciidoctor.org/asciidoc/latest/blocks/verses/[here].

[verse,Carl Sandburg, two lines from the poem Fog]
The fog comes
on little cat feet.
11 changes: 11 additions & 0 deletions test/fixtures/semantic-html5-scenarios/verse-1.html
@@ -0,0 +1,11 @@
<p>
The verse example 1 from <a href="https://docs.asciidoctor.org/asciidoc/latest/blocks/verses/">here</a>.
</p>
<blockquote class="verse">
<pre class="verse">The fog comes
on little cat feet.</pre>
<footer>
<span class="verse-attribution">Carl Sandburg</span>
<cite class="verse-citation">two lines from the poem Fog</cite>
<footer>
</blockquote>
12 changes: 12 additions & 0 deletions test/fixtures/semantic-html5-scenarios/verse-2.adoc
@@ -0,0 +1,12 @@
The verse example 2 from https://docs.asciidoctor.org/asciidoc/latest/blocks/verses/[here].

[verse,Carl Sandburg,Fog]
____
The fog comes
on little cat feet.

It sits looking
over harbor and city
on silent haunches
and then moves on.
____
16 changes: 16 additions & 0 deletions test/fixtures/semantic-html5-scenarios/verse-2.html
@@ -0,0 +1,16 @@
<p>
The verse example 2 from <a href="https://docs.asciidoctor.org/asciidoc/latest/blocks/verses/">here</a>.
</p>
<blockquote class="verse">
<pre class="verse">The fog comes
on little cat feet.

It sits looking
over harbor and city
on silent haunches
and then moves on.</pre>
<footer>
<span class="verse-attribution">Carl Sandburg</span>
<cite class="verse-citation">Fog</cite>
<footer>
</blockquote>