diff options
| author | Dan Allen <dallen@redhat.com> | 2013-05-01 12:10:28 -0600 |
|---|---|---|
| committer | Dan Allen <dallen@redhat.com> | 2013-05-02 03:41:13 -0600 |
| commit | 96c3fa94129eab8d4b38e43c8580ccfc6941bcd7 (patch) | |
| tree | e0dc43e72057da9094c55415a184666437e04284 | |
| parent | b7ca67ce2615bf414817f5f4f46b53edcd46825b (diff) | |
resolves #297 support for abstract and partintro
- support for abstract and partinfo style on open block
- support for abstract and partinfo style on paragraph
- wrap text in paragraph with complex block style in simpara
- fix missing @ on field reference
- fix missing endlines for blocks output by result methods
- add text support to open block
- backend optimizations
| -rwxr-xr-x | lib/asciidoctor.rb | 4 | ||||
| -rw-r--r-- | lib/asciidoctor/abstract_block.rb | 2 | ||||
| -rw-r--r-- | lib/asciidoctor/backends/docbook45.rb | 149 | ||||
| -rw-r--r-- | lib/asciidoctor/backends/html5.rb | 27 | ||||
| -rw-r--r-- | lib/asciidoctor/block.rb | 4 | ||||
| -rw-r--r-- | lib/asciidoctor/lexer.rb | 7 | ||||
| -rw-r--r-- | test/blocks_test.rb | 163 | ||||
| -rw-r--r-- | test/paragraphs_test.rb | 85 |
8 files changed, 345 insertions, 96 deletions
diff --git a/lib/asciidoctor.rb b/lib/asciidoctor.rb index e0f3bfca..e7850272 100755 --- a/lib/asciidoctor.rb +++ b/lib/asciidoctor.rb @@ -142,13 +142,13 @@ module Asciidoctor ADMONITION_STYLES = ['NOTE', 'TIP', 'IMPORTANT', 'WARNING', 'CAUTION'].to_set # NOTE: AsciiDoc doesn't support pass style for paragraph - PARAGRAPH_STYLES = ['comment', 'example', 'literal', 'listing', 'normal', 'pass', 'quote', 'sidebar', 'source', 'verse'].to_set + PARAGRAPH_STYLES = ['comment', 'example', 'literal', 'listing', 'normal', 'pass', 'quote', 'sidebar', 'source', 'verse', 'abstract', 'partintro'].to_set VERBATIM_STYLES = ['literal', 'listing', 'source', 'verse'].to_set DELIMITED_BLOCKS = { # NOTE: AsciiDoc doesn't support pass style for open block - '--' => [:open, ['comment', 'example', 'literal', 'listing', 'pass', 'quote', 'sidebar', 'source', 'verse', 'admonition'].to_set], + '--' => [:open, ['comment', 'example', 'literal', 'listing', 'pass', 'quote', 'sidebar', 'source', 'verse', 'admonition', 'abstract', 'partintro'].to_set], '----' => [:listing, ['literal', 'source'].to_set], '....' => [:literal, ['listing', 'source'].to_set], '====' => [:example, ['admonition'].to_set], diff --git a/lib/asciidoctor/abstract_block.rb b/lib/asciidoctor/abstract_block.rb index 2a6ddd00..2c8d6aa6 100644 --- a/lib/asciidoctor/abstract_block.rb +++ b/lib/asciidoctor/abstract_block.rb @@ -63,7 +63,7 @@ class AbstractBlock < AbstractNode # whether this Block *can* have block content # that should be the option 'sectionbody' def blocks? - !blocks.empty? + !@blocks.empty? end # Public: Get the element at i in the array of blocks. diff --git a/lib/asciidoctor/backends/docbook45.rb b/lib/asciidoctor/backends/docbook45.rb index 96348ccc..46d5ae91 100644 --- a/lib/asciidoctor/backends/docbook45.rb +++ b/lib/asciidoctor/backends/docbook45.rb @@ -15,9 +15,9 @@ module Asciidoctor def title_tag(optional = true) if optional - %q{<%= title? ? "<title>#{title}</title>" : '' %>} + %(<%= title? ? "\n<title>\#{title}</title>" : nil %>) else - %q{<title><%= title %></title>} + %(\n<title><%= title %></title>) end end @@ -26,7 +26,15 @@ module Asciidoctor end def common_attrs_erb - %q{<%= template.common_attrs(@id, (attr 'role'), (attr 'reftext')) %>} + %q(<%= template.common_attrs(@id, (attr 'role'), (attr 'reftext')) %>) + end + + def content(node) + node.blocks? ? node.content.chomp : "<simpara>#{node.content.chomp}</simpara>" + end + + def content_erb + %q(<%= blocks? ? content.chomp : "<simpara>#{content.chomp}</simpara>" %>) end end @@ -102,14 +110,14 @@ class DocumentTemplate < BaseTemplate <bookinfo> #{docinfo} </bookinfo> -<%= content %> +<%= content.chomp %> </book> <% else %> <article<% unless attr? :nolang %> lang="<%= attr :lang, 'en' %>"<% end %>> <articleinfo> #{docinfo} </articleinfo> -<%= content %> +<%= content.chomp %> </article> <% end %> EOF @@ -135,14 +143,13 @@ end class BlockPreambleTemplate < BaseTemplate def template @template ||= @eruby.new <<-EOF -<%#encoding:UTF-8%><% if @document.doctype == 'book' %> -<preface#{common_attrs_erb}> - #{title_tag false} -<%= content %> -</preface> -<% else %> -<%= content %> -<% end %> +<%#encoding:UTF-8%><% +if @document.doctype == 'book' %><preface#{common_attrs_erb}>#{title_tag false} +<%= content.chomp %> +</preface><% +else %> +<%= content.chomp %><% +end %> EOF end end @@ -155,9 +162,9 @@ class SectionTemplate < BaseTemplate tag = sec.document.doctype == 'book' && sec.level <= 1 ? (sec.level == 0 ? 'part' : 'chapter') : 'section' end %(<#{tag}#{common_attrs(sec.id, (sec.attr 'role'), (sec.attr 'reftext'))}> - #{sec.title? ? "<title>#{sec.title}</title>" : nil} - #{sec.content} -</#{tag}>) +#{sec.title? ? "<title>#{sec.title}</title>" : nil} +#{sec.content.chomp} +</#{tag}>\n) end def template @@ -175,27 +182,13 @@ end class BlockParagraphTemplate < BaseTemplate def paragraph(id, style, role, reftext, title, content) - # FIXME temporary hack until I can generalize this feature - if style == 'partintro' - if title - %(<partintro#{common_attrs(id, role, reftext)}> - <title>#{title}</title> - <simpara>#{content}</simpara> -</partintro>) - else - %(<partintro#{common_attrs(id, role, reftext)}> - <simpara>#{content}</simpara> -</partintro>) - end + if !title.nil? + %(<formalpara#{common_attrs(id, role, reftext)}> +<title>#{title}</title> +<para>#{content}</para> +</formalpara>\n) else - if title - %(<formalpara#{common_attrs(id, role, reftext)}> - <title>#{title}</title> - <para>#{content}</para> -</formalpara>) - else - %(<simpara#{common_attrs(id, role, reftext)}>#{content}</simpara>) - end + %(<simpara#{common_attrs(id, role, reftext)}>#{content}</simpara>\n) end end @@ -211,13 +204,8 @@ end class BlockAdmonitionTemplate < BaseTemplate def template @template ||= @eruby.new <<-EOF -<%#encoding:UTF-8%><<%= attr :name %>#{common_attrs_erb}> - #{title_tag} - <% if blocks? %> -<%= content %> - <% else %> - <simpara><%= content.chomp %></simpara> - <% end %> +<%#encoding:UTF-8%><<%= attr :name %>#{common_attrs_erb}>#{title_tag} +#{content_erb} </<%= attr :name %>> EOF end @@ -227,8 +215,7 @@ class BlockUlistTemplate < BaseTemplate def template @template ||= @eruby.new <<-EOF <%#encoding:UTF-8%><% if attr? :style, 'bibliography' %> -<bibliodiv#{common_attrs_erb}> - #{title_tag} +<bibliodiv#{common_attrs_erb}>#{title_tag} <% content.each do |li| %> <bibliomixed> <bibliomisc><%= li.text %></bibliomisc> @@ -239,8 +226,7 @@ class BlockUlistTemplate < BaseTemplate <% end %> </bibliodiv> <% else %> -<itemizedlist#{common_attrs_erb}> - #{title_tag} +<itemizedlist#{common_attrs_erb}>#{title_tag} <% content.each do |li| %> <listitem> <simpara><%= li.text %></simpara> @@ -258,8 +244,7 @@ end class BlockOlistTemplate < BaseTemplate def template @template ||= @eruby.new <<-EOF -<%#encoding:UTF-8%><orderedlist#{common_attrs_erb}#{attribute('numeration', :style)}> - #{title_tag} +<%#encoding:UTF-8%><orderedlist#{common_attrs_erb}#{attribute('numeration', :style)}>#{title_tag} <% content.each do |li| %> <listitem> <simpara><%= li.text %></simpara> @@ -276,8 +261,7 @@ end class BlockColistTemplate < BaseTemplate def template @template ||= @eruby.new <<-EOF -<%#encoding:UTF-8%><calloutlist#{common_attrs_erb}> - #{title_tag} +<%#encoding:UTF-8%><calloutlist#{common_attrs_erb}>#{title_tag} <% content.each do |li| %> <callout arearefs="<%= li.attr :coids %>"> <para><%= li.text %></para> @@ -317,8 +301,7 @@ class BlockDlistTemplate < BaseTemplate def template @template ||= @eruby.new <<-EOF <%#encoding:UTF-8%><% tags = (template.class::LIST_TAGS[attr :style] || template.class::LIST_TAGS['labeled']) %> -<% if tags[:list] %><<%= tags[:list] %>#{common_attrs_erb}><% end %> - #{title_tag} +<% if tags[:list] %><<%= tags[:list] %>#{common_attrs_erb}><% end %>#{title_tag} <% content.each do |dt, dd| %> <<%= tags[:entry] %>> <% if tags.has_key?(:label) %> @@ -350,8 +333,26 @@ class BlockDlistTemplate < BaseTemplate end class BlockOpenTemplate < BaseTemplate + + def result(node) + case node.attr('style') + when 'abstract' + %(<abstract>#{node.title? ? " +<title>#{node.title}</title>" : nil} +#{content node} +</abstract>\n) + when 'partintro' + %(<partintro#{common_attrs node.id, node.attr('role'), node.attr('reftext')}>#{node.title? ? " +<title>#{node.title}</title>" : nil} +#{content node} +</partintro>\n) + else + node.content + end + end + def template - :content + :invoke_result end end @@ -365,8 +366,7 @@ class BlockListingTemplate < BaseTemplate <screen#{common_attrs_erb}><%= template.preserve_endlines(content, self) %></screen> <% end %> <% else %> -<formalpara#{common_attrs_erb}> - #{title_tag false} +<formalpara#{common_attrs_erb}>#{title_tag false} <para> <% if attr :style, 'source' %> <programlisting language="<%= attr :language %>" linenumbering="<%= (attr? :linenums) ? 'numbered' : 'unnumbered' %>"><%= template.preserve_endlines(content, self) %></programlisting> @@ -386,8 +386,7 @@ class BlockLiteralTemplate < BaseTemplate <%#encoding:UTF-8%><% if !title? %> <literallayout#{common_attrs_erb} class="monospaced"><%= template.preserve_endlines(content, self) %></literallayout> <% else %> -<formalpara#{common_attrs_erb}> - #{title_tag false} +<formalpara#{common_attrs_erb}>#{title_tag false} <para> <literallayout class="monospaced"><%= template.preserve_endlines(content, self) %></literallayout> </para> @@ -400,10 +399,9 @@ end class BlockExampleTemplate < BaseTemplate def template @template ||= @eruby.new <<-EOF -<%#encoding:UTF-8%><example#{common_attrs_erb}> - #{title_tag} -<%= content %> -</example> +<%#encoding:UTF-8%><<%= (tag_name = title? ? 'example' : 'informalexample') %>#{common_attrs_erb}>#{title_tag} +#{content_erb} +</<%= tag_name %>> EOF end end @@ -411,9 +409,8 @@ end class BlockSidebarTemplate < BaseTemplate def template @template ||= @eruby.new <<-EOF -<%#encoding:UTF-8%><sidebar#{common_attrs_erb}> - #{title_tag} -<%= content %> +<%#encoding:UTF-8%><sidebar#{common_attrs_erb}>#{title_tag} +#{content_erb} </sidebar> EOF end @@ -422,8 +419,7 @@ end class BlockQuoteTemplate < BaseTemplate def template @template ||= @eruby.new <<-EOF -<%#encoding:UTF-8%><blockquote#{common_attrs_erb}> - #{title_tag} +<%#encoding:UTF-8%><blockquote#{common_attrs_erb}>#{title_tag} <% if (attr? :attribution) || (attr? :citetitle) %> <attribution> <% if attr? :attribution %> @@ -432,11 +428,7 @@ class BlockQuoteTemplate < BaseTemplate #{tag 'citetitle', :citetitle} </attribution> <% end %> -<% if !@buffer.nil? %> -<simpara><%= content %></simpara> -<% else %> -<%= content %> -<% end %> +#{content_erb} </blockquote> EOF end @@ -445,8 +437,7 @@ end class BlockVerseTemplate < BaseTemplate def template @template ||= @eruby.new <<-EOF -<%#encoding:UTF-8%><blockquote#{common_attrs_erb}> - #{title_tag} +<%#encoding:UTF-8%><blockquote#{common_attrs_erb}>#{title_tag} <% if (attr? :attribution) || (attr? :citetitle) %> <attribution> <% if attr? :attribution %> @@ -470,9 +461,8 @@ end class BlockTableTemplate < BaseTemplate def template @template ||= @eruby.new <<-EOS -<%#encoding:UTF-8%><<%= title? ? 'table' : 'informaltable'%>#{common_attrs_erb} frame="<%= attr :frame, 'all'%>" - rowsep="<%= ['none', 'cols'].include?(attr :grid) ? 0 : 1 %>" colsep="<%= ['none', 'rows'].include?(attr :grid) ? 0 : 1 %>"> - #{title_tag} +<%#encoding:UTF-8%><<%= (tag_name = title? ? 'table' : 'informaltable') %>#{common_attrs_erb} frame="<%= attr :frame, 'all'%>" + rowsep="<%= ['none', 'cols'].include?(attr :grid) ? 0 : 1 %>" colsep="<%= ['none', 'rows'].include?(attr :grid) ? 0 : 1 %>">#{title_tag} <% if attr? :width %> <?dbhtml table-width="<%= attr :width %>"?> <?dbfo table-width="<%= attr :width %>"?> @@ -505,7 +495,7 @@ class BlockTableTemplate < BaseTemplate </t<%= tblsec %>> <% end %> </tgroup> -</<%= title? ? 'table' : 'informaltable'%>> +</<%= tag_name %>> EOS end end @@ -513,8 +503,7 @@ end class BlockImageTemplate < BaseTemplate def template @template ||= @eruby.new <<-EOF -<%#encoding:UTF-8%><%#encoding:UTF-8%><figure#{common_attrs_erb}> - #{title_tag} +<%#encoding:UTF-8%><%#encoding:UTF-8%><figure#{common_attrs_erb}>#{title_tag} <mediaobject> <imageobject> <imagedata fileref="<%= image_uri(attr :target) %>"#{attribute('contentwidth', :width)}#{attribute('contentdepth', :height)}/> diff --git a/lib/asciidoctor/backends/html5.rb b/lib/asciidoctor/backends/html5.rb index 1475561c..f86feb2d 100644 --- a/lib/asciidoctor/backends/html5.rb +++ b/lib/asciidoctor/backends/html5.rb @@ -12,7 +12,11 @@ class BaseTemplate end def title_div(opts = {}) - %(<% if title? %><div class="title">#{opts.has_key?(:caption) ? '<%= @caption %>' : ''}<%= title %></div><% end %>) + if opts.has_key? :caption + %q(<% if title? %><div class="title"><%= @caption %><%= title %></div><% end %>) + else + %q(<% if title? %><div class="title"><%= title %></div><% end %>) + end end end @@ -184,10 +188,10 @@ class BlockTocTemplate < BaseTemplate levels = node.attr?('levels') ? node.attr('levels').to_i : doc.attr('toclevels', 2).to_i role = node.attr?('role') ? node.attr('role') : doc.attr('toc-class', 'toc') - %(\n<div#{id_attr} class="#{role}"> + %(<div#{id_attr} class="#{role}"> <div#{title_id_attr} class="title">#{title}</div> #{DocumentTemplate.outline(doc, levels)} -</div>) +</div>\n) end def template @@ -250,7 +254,7 @@ class SectionTemplate < BaseTemplate %(<div class="sect#{slevel}#{role}"> <#{htag}#{id}>#{sectnum}#{sec.attr 'caption'}#{sec.title}</#{htag}> #{content} -</div>) +</div>\n) end end @@ -397,7 +401,7 @@ class BlockParagraphTemplate < BaseTemplate %(<div#{id && " id=\"#{id}\""} class=\"paragraph#{role && " #{role}"}\">#{title && " <div class=\"title\">#{title}</div>"} <p>#{content}</p> -</div>) +</div>\n) end def result(node) @@ -438,12 +442,17 @@ end class BlockOpenTemplate < BaseTemplate def template @template ||= @eruby.new <<-EOS -<%#encoding:UTF-8%><div#{id} class="openblock#{role_class}"> +<%#encoding:UTF-8%><% if attr? :style, 'abstract' %><div#{id} class="quoteblock#{role_class}"> + #{title_div} + <blockquote> +<%= content %> + </blockquote> +</div><% else %><div#{id} class="openblock#{role_class}"> #{title_div} <div class="content"> <%= content %> </div> -</div> +</div><% end %> EOS end end @@ -676,7 +685,7 @@ end class BlockPageBreakTemplate < BaseTemplate def result(node) - '<div style="page-break-after: always;"></div>' + %(<div style="page-break-after: always;"></div>\n) end def template @@ -686,7 +695,7 @@ end class InlineBreakTemplate < BaseTemplate def result(node) - "#{node.text}<br>" + %(#{node.text}<br>\n) end def template diff --git a/lib/asciidoctor/block.rb b/lib/asciidoctor/block.rb index 9c44d02f..def6d2df 100644 --- a/lib/asciidoctor/block.rb +++ b/lib/asciidoctor/block.rb @@ -96,7 +96,7 @@ class Block < AbstractBlock # => ["<em>This</em> is what happens when you <meet> a stranger in the <alps>!"] def content case @context - when :preamble, :open + when :preamble @blocks.map {|b| b.render }.join # lists get iterated in the template (for now) # list items recurse into this block when their text and content methods are called @@ -106,7 +106,7 @@ class Block < AbstractBlock apply_literal_subs(@buffer) when :pass apply_passthrough_subs(@buffer) - when :admonition, :example, :sidebar, :quote, :verse + when :admonition, :example, :sidebar, :quote, :verse, :open if !@buffer.nil? apply_para_subs(@buffer) else diff --git a/lib/asciidoctor/lexer.rb b/lib/asciidoctor/lexer.rb index 65852b70..9bd01672 100644 --- a/lib/asciidoctor/lexer.rb +++ b/lib/asciidoctor/lexer.rb @@ -461,8 +461,7 @@ class Lexer break # FIXME create another set for "passthrough" styles - # though partintro should likely be a dedicated block - elsif !style.nil? && style != 'normal' && style != 'partintro' + elsif !style.nil? && style != 'normal' if PARAGRAPH_STYLES.include?(style) block_context = style.to_sym reader.unshift_line this_line @@ -565,6 +564,10 @@ class Lexer # either delimited block or styled paragraph if block.nil? && !block_context.nil? + # abstract and partintro should be handled by open block + # FIXME kind of hackish...need to sort out how to generalize this + block_context = :open if block_context == :abstract || block_context == :partintro + case block_context when :admonition attributes['name'] = admonition_name = style.downcase diff --git a/test/blocks_test.rb b/test/blocks_test.rb index 2407c8ff..7dd48052 100644 --- a/test/blocks_test.rb +++ b/test/blocks_test.rb @@ -1219,4 +1219,167 @@ html = CodeRay.scan("puts 'Hello, world!'", :ruby).div(:line_numbers => :table) end end + context 'Abstract and Part Intro' do + test 'should make abstract on open block without title a quote block' do + input = <<-EOS += Article + +[abstract] +-- +This article is about stuff. + +And other stuff. +-- + EOS + + output = render_string input + assert_css '.quoteblock', output, 1 + assert_css '#preamble .quoteblock', output, 1 + assert_css '.quoteblock > blockquote', output, 1 + assert_css '.quoteblock > blockquote > .paragraph', output, 2 + end + + test 'should make abstract on open block with title a quote block with title' do + input = <<-EOS += Article + +.My abstract +[abstract] +-- +This article is about stuff. +-- + EOS + + output = render_string input + assert_css '.quoteblock', output, 1 + assert_css '#preamble .quoteblock', output, 1 + assert_css '.quoteblock > .title', output, 1 + assert_css '.quoteblock > .title + blockquote', output, 1 + assert_css '.quoteblock > .title + blockquote > .paragraph', output, 1 + end + + test 'should make abstract on open block without title rendered to DocBook' do + input = <<-EOS += Article + +[abstract] +-- +This article is about stuff. + +And other stuff. +-- + EOS + + output = render_string input, :backend => 'docbook' + assert_css 'abstract', output, 1 + assert_css 'abstract > simpara', output, 2 + end + + test 'should make abstract on open block with title rendered to DocBook' do + input = <<-EOS += Article + +.My abstract +[abstract] +-- +This article is about stuff. +-- + EOS + + output = render_string input, :backend => 'docbook' + assert_css 'abstract', output, 1 + assert_css 'abstract > title', output, 1 + assert_css 'abstract > title + simpara', output, 1 + end + + # TODO partintro shouldn't be recognized if doctype is not book, should be in proper place + test 'should accept partintro on open block without title' do + input = <<-EOS += Book +:doctype: book + += Part 1 + +[partintro] +-- +This is a part intro. + +It can have multiple paragraphs. +-- + EOS + + output = render_string input + assert_css '.openblock', output, 1 + assert_css '.openblock .title', output, 0 + assert_css '.openblock .content', output, 1 + assert_xpath '//h1[@id="_part_1"]/following-sibling::*[@class="openblock"]', output, 1 + assert_xpath '//*[@class="openblock"]/*[@class="content"]/*[@class="paragraph"]', output, 2 + end + + test 'should accept partintro on open block with title' do + input = <<-EOS += Book +:doctype: book + += Part 1 + +.Intro title +[partintro] +-- +This is a part intro with a title. +-- + EOS + + output = render_string input + assert_css '.openblock', output, 1 + assert_css '.openblock .title', output, 1 + assert_css '.openblock .content', output, 1 + assert_xpath '//h1[@id="_part_1"]/following-sibling::*[@class="openblock"]', output, 1 + assert_xpath '//*[@class="openblock"]/*[@class="title"][text() = "Intro title"]', output, 1 + assert_xpath '//*[@class="openblock"]/*[@class="content"]/*[@class="paragraph"]', output, 1 + end + + test 'should accept partintro on open block without title rendered to DocBook' do + input = <<-EOS += Book +:doctype: book + += Part 1 + +[partintro] +-- +This is a part intro. + +It can have multiple paragraphs. +-- + EOS + + output = render_string input, :backend => 'docbook' + assert_css 'partintro', output, 1 + assert_css 'part#_part_1 > partintro', output, 1 + assert_css 'partintro > simpara', output, 2 + end + + test 'should accept partintro on open block with title rendered to DocBook' do + input = <<-EOS += Book +:doctype: book + += Part 1 + +.Intro title +[partintro] +-- +This is a part intro with a title. +-- + EOS + + output = render_string input, :backend => 'docbook' + assert_css 'partintro', output, 1 + assert_css 'part#_part_1 > partintro', output, 1 + assert_css 'partintro > title', output, 1 + assert_css 'partintro > title + simpara', output, 1 + end + end + end diff --git a/test/paragraphs_test.rb b/test/paragraphs_test.rb index 1de9bf68..74d4a759 100644 --- a/test/paragraphs_test.rb +++ b/test/paragraphs_test.rb @@ -366,5 +366,90 @@ Content goes here result = render_string(input) assert_xpath "//*[@class='sidebarblock']//p", result, 1 end + + context 'Styled Paragraphs' do + test 'should wrap text in simpara for styled paragraphs when rendered to DocBook' do + input = <<-EOS += Book +:doctype: book + +[preface] += About this book + +[abstract] +An abstract for the book. + += Part 1 + +[partintro] +An intro to this part. + +[sidebar] +Just a side note. + +[example] +As you can see here. + +[quote] +Wise words from a wise person. + EOS + + output = render_string input, :backend => 'docbook' + assert_css 'abstract > simpara', output, 1 + assert_css 'partintro > simpara', output, 1 + assert_css 'sidebar > simpara', output, 1 + assert_css 'informalexample > simpara', output, 1 + assert_css 'blockquote > simpara', output, 1 + end + + test 'wip should wrap text in simpara for styled paragraphs with title when rendered to DocBook' do + input = <<-EOS += Book +:doctype: book + +[preface] += About this book + +[abstract] +.Abstract title +An abstract for the book. + += Part 1 + +[partintro] +.Part intro title +An intro to this part. + +[sidebar] +.Sidebar title +Just a side note. + +[example] +.Example title +As you can see here. + +[quote] +.Quote title +Wise words from a wise person. + EOS + + output = render_string input, :backend => 'docbook' + assert_css 'abstract > title', output, 1 + assert_xpath '//abstract/title[text() = "Abstract title"]', output, 1 + assert_css 'abstract > title + simpara', output, 1 + assert_css 'partintro > title', output, 1 + assert_xpath '//partintro/title[text() = "Part intro title"]', output, 1 + assert_css 'partintro > title + simpara', output, 1 + assert_css 'sidebar > title', output, 1 + assert_xpath '//sidebar/title[text() = "Sidebar title"]', output, 1 + assert_css 'sidebar > title + simpara', output, 1 + assert_css 'example > title', output, 1 + assert_xpath '//example/title[text() = "Example title"]', output, 1 + assert_css 'example > title + simpara', output, 1 + assert_css 'blockquote > title', output, 1 + assert_xpath '//blockquote/title[text() = "Quote title"]', output, 1 + assert_css 'blockquote > title + simpara', output, 1 + end + end end end |
