summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2019-02-05 00:58:59 -0700
committerGitHub <noreply@github.com>2019-02-05 00:58:59 -0700
commit21f67d35e9f85e6acf1ea99039a5b6ccc146546e (patch)
treeed5f566e4bc67f288d646e8ac5f79f51ac188609
parent98a1d0123647eb85a1dc460d0103f624b0367cc5 (diff)
resolves #3005 remove the converter for the docbook45 backend (PR #3040)
- remove the DocBook45Converter class - remove accomodations in DocBook5Converter for DocBook 4.5 - don't register the docbook45 backend name in the converter registry - drop docbook45 from the backend CLI option values - don't mention DocBook 4.5 in the man page - don't mention DocBook 4.5 in the CLI usage statement - update tests to use DocBook 5 instead of DocBook 4.5
-rw-r--r--.travis.yml2
-rw-r--r--CHANGELOG.adoc3
-rw-r--r--README-de.adoc10
-rw-r--r--README-fr.adoc10
-rw-r--r--README-jp.adoc10
-rw-r--r--README-zh_CN.adoc10
-rw-r--r--asciidoctor.gemspec4
-rw-r--r--lib/asciidoctor.rb2
-rw-r--r--lib/asciidoctor/cli/options.rb2
-rw-r--r--lib/asciidoctor/converter.rb3
-rw-r--r--lib/asciidoctor/converter/docbook45.rb92
-rw-r--r--lib/asciidoctor/converter/docbook5.rb83
-rw-r--r--man/asciidoctor.110
-rw-r--r--man/asciidoctor.adoc4
-rw-r--r--test/attributes_test.rb28
-rw-r--r--test/blocks_test.rb117
-rw-r--r--test/converter_test.rb12
-rw-r--r--test/document_test.rb351
-rw-r--r--test/fixtures/custom-backends/haml/docbook45/block_paragraph.xml.haml6
-rw-r--r--test/fixtures/custom-backends/haml/docbook5/block_paragraph.xml.haml6
-rw-r--r--test/fixtures/custom-backends/haml/html5/block_paragraph.html.haml2
-rw-r--r--test/fixtures/custom-backends/haml/html5/block_sidebar.html.haml2
-rw-r--r--test/fixtures/custom-backends/slim/docbook45/block_paragraph.xml.slim6
-rw-r--r--test/fixtures/custom-backends/slim/docbook5/block_paragraph.xml.slim6
-rw-r--r--test/fixtures/docinfo-footer.xml2
-rw-r--r--test/invoker_test.rb6
-rw-r--r--test/links_test.rb8
-rw-r--r--test/lists_test.rb71
-rw-r--r--test/paragraphs_test.rb2
-rw-r--r--test/sections_test.rb60
-rw-r--r--test/substitutions_test.rb4
-rw-r--r--test/tables_test.rb26
-rw-r--r--test/text_test.rb12
33 files changed, 318 insertions, 654 deletions
diff --git a/.travis.yml b/.travis.yml
index 90bad48f..5399f3e6 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -10,7 +10,7 @@ rvm:
- 2.3.8
- jruby-9.2.5.0
- jruby-9.1.17.0
-- truffleruby-rc10
+#- truffleruby-rc10
env:
global:
# use system libraries to speed up installation of nokogiri
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc
index 2717516f..7299f8ed 100644
--- a/CHANGELOG.adoc
+++ b/CHANGELOG.adoc
@@ -8,7 +8,7 @@ ifndef::icons[]
:star: &#9733;
endif::[]
-{uri-asciidoctor}[Asciidoctor] is a _fast_, open source text processor and publishing toolchain for converting {uri-asciidoc}[AsciiDoc] content into HTML5, DocBook 5 (or 4.5) and other formats.
+{uri-asciidoctor}[Asciidoctor] is a _fast_, open source text processor and publishing toolchain for converting {uri-asciidoc}[AsciiDoc] content into HTML 5, DocBook 5, and other formats.
This document provides a high-level view of the changes introduced in Asciidoctor by release.
For a detailed view of what has changed, refer to the {uri-repo}/commits/master[commit history] on GitHub.
@@ -19,6 +19,7 @@ Enhancements::
* drop support for Ruby < 2.3 and JRuby < 9.1 and remove workarounds (#2764)
* drop support for Slim < 3 (#2998)
+ * drop the converter for the docbook45 backend (#3005)
* make syntax highlighter pluggable; extract all logic into adapter classes (#2106)
* add syntax highlighter adapter for Rouge (#1040)
* redesign Converter API based on SyntaxHighlighter API; remap deprecated API to new API to ensure compatibility (#2891)
diff --git a/README-de.adoc b/README-de.adoc
index 6f5117ac..ed025d61 100644
--- a/README-de.adoc
+++ b/README-de.adoc
@@ -59,7 +59,7 @@ endif::[]
// images:
:image-uri-screenshot: https://raw.githubusercontent.com/asciidoctor/asciidoctor/master/screenshot.png
-{uri-project}[Asciidoctor] ist ein _schneller_, {uri-license}[Open Source] Textverarbeitungs- und Publishing-Toolchain für die Konvertierung von {uri-what-is-asciidoc}[AsciiDoc]-Inhalten in HTML5, DocBook, PDF und andere Formate.
+{uri-project}[Asciidoctor] ist ein _schneller_, {uri-license}[Open Source] Textverarbeitungs- und Publishing-Toolchain für die Konvertierung von {uri-what-is-asciidoc}[AsciiDoc]-Inhalten in HTML 5, DocBook 5, PDF und andere Formate.
Asciidoctor ist in Ruby geschrieben und läuft auf allen gängigen Betriebsystemen.
Um die Installation zu vereinfachen wird Asciidoctor als Gem auf {uri-rubygem}[RubyGems.org] verpackt und ist als Paket für gängige Linux-Distributionen und MacOS erhältlich.
Asciidoctor kann auch in einer JVM mit {uri-asciidoctorj}[AsciidoctorJ] oder einer beliebigen Javascript-Umgebung mit {uri-asciidoctorjs}[Asciidoctor.js] ausgeführt werden.
@@ -108,21 +108,21 @@ Sie können dieses Projekt unterstützen, indem Sie Sponsor bei https://opencoll
== Das große Ganze
-Asciidoctor liest Inhalte, die im Klartext geschrieben wurden, wie im Feld links im Bild unten gezeigt, und wandelt Sie in HTML5 um, wie im rechten Feld dargestellt.
-Asciidoctor wendet ein Standard-Stylesheet auf das HTML5-Dokument an, um ein angenehmes Out-of-the-Box-Erlebnis zu bieten.
+Asciidoctor liest Inhalte, die im Klartext geschrieben wurden, wie im Feld links im Bild unten gezeigt, und wandelt Sie in HTML 5 um, wie im rechten Feld dargestellt.
+Asciidoctor wendet ein Standard-Stylesheet auf das HTML 5-Dokument an, um ein angenehmes Out-of-the-Box-Erlebnis zu bieten.
image::{image-uri-screenshot}[Preview of AsciiDoc source and corresponding rendered HTML]
== AsciiDoc Verarbeitung
-Asciidoctor liest und analysiert Text, der in der AsciiDoc-Syntax geschrieben wurde, und leitet dann den Parse-Tree durch eine Reihe von eingebauten Konvertern, um HTML5, DocBook 5 und man-pages zu erzeugen.
+Asciidoctor liest und analysiert Text, der in der AsciiDoc-Syntax geschrieben wurde, und leitet dann den Parse-Tree durch eine Reihe von eingebauten Konvertern, um HTML 5, DocBook 5 und man-pages zu erzeugen.
Sie haben die Möglichkeit, eigene Konverter zu verwenden oder {uri-tilt}[Tilt]-gestützte Vorlagen zu laden, um die generierte Ausgabe anzupassen oder zusätzliche Formate zu erzeugen.
Asciidoctor ist ein Ersatz für den Original AsciiDoc Python Prozessor (`asciidoc.py`).
Die Asciidoctor-Testsuite verfügt über {uri-tests}[mehr als 2,000 Tests], um die Kompatibilität mit der AsciiDoc-Syntax sicherzustellen.
Neben der klassischen AsciiDoc-Syntax erkennt Asciidoctor zusätzliche Markup- und Formatierungsoptionen, wie z.B. fontbasierte Icons (z.B. `+icon:fire[]+`) und UI-Elemente (z.B. `+button:[Save]+`).
-Asciidoctor bietet auch ein modernes, __responsive Theme__, das auf {uri-foundation}[Foundation] basiert, um die HTML5-Ausgabe zu gestalten.
+Asciidoctor bietet auch ein modernes, __responsive Theme__, das auf {uri-foundation}[Foundation] basiert, um die HTML 5-Ausgabe zu gestalten.
== Wo Ruby hingeht, folgt Asciidoctor
diff --git a/README-fr.adoc b/README-fr.adoc
index a4d2878e..3b6c0a8b 100644
--- a/README-fr.adoc
+++ b/README-fr.adoc
@@ -58,7 +58,7 @@ endif::[]
// images:
:image-uri-screenshot: https://raw.githubusercontent.com/asciidoctor/asciidoctor/master/screenshot.png
-{uri-project}/[Asciidoctor] est un processeur de texte et une chaîne de publication _rapide_ et {uri-license}[open source] permettant de convertir du contenu {uri-what-is-asciidoc}[AsciiDoc] en HTML5, DocBook, PDF et d'autres formats.
+{uri-project}/[Asciidoctor] est un processeur de texte et une chaîne de publication _rapide_ et {uri-license}[open source] permettant de convertir du contenu {uri-what-is-asciidoc}[AsciiDoc] en HTML 5, DocBook 5, PDF et d'autres formats.
Asciidoctor est écrit en Ruby et fonctionne sur les principaux systèmes d'exploitation.
Pour simplifier l'installation, Asciidoctor est publié au format gem sur {uri-rubygem}[RubyGems.org], et il est également disponible en tant que paquet système sur les principales distributions Linux ainsi que sur macOS.
Asciidoctor fonctionne aussi sur la JVM avec {uri-asciidoctorj}[AsciidoctorJ] et dans n'importe quel environnement JavaScript avec {uri-asciidoctorjs}[Asciidoctor.js].
@@ -105,14 +105,14 @@ Vous pouvez aider ce projet en devant un sponsor sur https://opencollective.com/
== En un mot
-Asciidoctor lit du contenu écrit en texte brut, comme présenté dans la partie gauche de l'image ci-dessous, et le convertit en HTML5, comme présenté dans la partie droite.
-Asciidoctor applique une feuille de style par défaut au document HTML5 afin de fournir une expérience de lecture agréable, clé en main.
+Asciidoctor lit du contenu écrit en texte brut, comme présenté dans la partie gauche de l'image ci-dessous, et le convertit en HTML 5, comme présenté dans la partie droite.
+Asciidoctor applique une feuille de style par défaut au document HTML 5 afin de fournir une expérience de lecture agréable, clé en main.
image::{image-uri-screenshot}[Prévisualisation d'une source AsciiDoc et le rendu HTML correspondant]
== Le traitement d'AsciiDoc
-Asciidoctor lit et analyse la syntaxe du texte écrit en AsciiDoc afin de créer une représentation, sous forme d'arbre, à partir de laquelle des templates sont appliqués pour produire de l'HTML5, du DocBook 5 et des pages de man(uel).
+Asciidoctor lit et analyse la syntaxe du texte écrit en AsciiDoc afin de créer une représentation, sous forme d'arbre, à partir de laquelle des templates sont appliqués pour produire de l'HTML 5, du DocBook 5 et des pages de man(uel).
Vous avez la possibilité d'écrire votre propre convertisseur ou de fournir des templates supportant {uri-tilt}[Tilt] pour personnaliser le résultat généré ou pour produire des formats alternatifs.
@@ -120,7 +120,7 @@ Asciidoctor remplace le processeur AsciiDoc original écrit en Python (`asciidoc
La suite de tests Asciidoctor possède {uri-tests}[plus de 2,000 tests] afin de garantir la compatibilité avec la syntaxe AsciiDoc.
En plus de la syntaxe AsciiDoc standard, Asciidoctor reconnaît des balises additionnelles ainsi que des options de formatage, comme les polices d'icônes (par exemple `+icon:fire[]+`) et des éléments d'interface (par exemple `+button:[Enregistrer]+`).
-Asciidoctor offre aussi un thème moderne et « responsive » basé sur {uri-foundation}[Foundation] pour styliser le document HTML5 généré.
+Asciidoctor offre aussi un thème moderne et « responsive » basé sur {uri-foundation}[Foundation] pour styliser le document HTML 5 généré.
== Asciidoctor est disponible partout où Ruby est disponible
diff --git a/README-jp.adoc b/README-jp.adoc
index ce1e612d..de87b88f 100644
--- a/README-jp.adoc
+++ b/README-jp.adoc
@@ -59,7 +59,7 @@ endif::[]
// images:
:image-uri-screenshot: https://raw.githubusercontent.com/asciidoctor/asciidoctor/master/screenshot.png
-{uri-project}/[Asciidoctor]は _高速な_ テキストプロセッサで {uri-what-is-asciidoc}[AsciiDoc] をHTML5, DocBook 5(4.5)や他のフォーマットに変換するツールチェインを配布しています.
+{uri-project}/[Asciidoctor]は _高速な_ テキストプロセッサで {uri-what-is-asciidoc}[AsciiDoc] をHTML 5, DocBook 5や他のフォーマットに変換するツールチェインを配布しています.
AsciidoctorはRubyで書かれており, RubyGemとしてパッケージされ, {uri-rubygem}[RubyGems.org] で配布されています.
gemはいくつかのLinuxディストリビューション, Fedora, Debian, Ubuntuにも含まれています.
Asciidoctorはオープンソース {uri-repo}[hosted on GitHub] で {uri-license}[the MIT licence]のもとに配布されます.
@@ -101,20 +101,20 @@ endif::[]
== The Big Picture
-Asciidoctorは下図の左側のパネルに示されるように, 平文で書かれた内容を読み, 右のパネルに描かれるようにHTML5に変換します.
-Asciidoctorは枠にとらわれない快適なエクスペリエンスのためにデフォルトスタイルシートをHTML5ドキュメントに適用します.
+Asciidoctorは下図の左側のパネルに示されるように, 平文で書かれた内容を読み, 右のパネルに描かれるようにHTML 5に変換します.
+Asciidoctorは枠にとらわれない快適なエクスペリエンスのためにデフォルトスタイルシートをHTML 5ドキュメントに適用します.
image::{image-uri-screenshot}[Preview of AsciiDoc source and corresponding rendered HTML]
== AsciiDoc Processing
-AsciidoctorはAsciiDoc文法で書かれたテキストを読み込み解釈し, それからHTML5, DocBook5(4.5)やman(ual)を出力するために内蔵コンバータセットにパースツリーを渡します.
+AsciidoctorはAsciiDoc文法で書かれたテキストを読み込み解釈し, それからHTML 5, DocBook 5やman(ual)を出力するために内蔵コンバータセットにパースツリーを渡します.
生成された出力をカスタマイズ, あるいは追加のフォーマットをつくるためにあなた自身のコンバータを使うことや {uri-tilt}[Tilt]-supported テンプレートを読み込むオプションがあります.
NOTE: AsciidoctorはオリジナルのAsciiDoc Pythonプロセッサ(`asciidoc.py`)の完全互換です.
Asciidoctorテストスイートは {uri-tests}[> 1,600 tests] をAsciiDoc文法との互換性を保証するために有しています.
クラシックなAsciiDoc文法に加えて, Asciidoctorは追加のマークアップとフォントベースのicons(例えば, `+icon:fire[]+`)などのフォーマッティングオプションとUIエレメント(`+button:[Save]+`)を 受け付けます.
-AsciidoctorはHTML5出力をスタイルするため, モダンで, {uri-foundation}[Foundation] に基づいたレスポンシブテーマをも提供します.
+AsciidoctorはHTML 5出力をスタイルするため, モダンで, {uri-foundation}[Foundation] に基づいたレスポンシブテーマをも提供します.
== Requirements
diff --git a/README-zh_CN.adoc b/README-zh_CN.adoc
index 4bc0827d..0d562fb0 100644
--- a/README-zh_CN.adoc
+++ b/README-zh_CN.adoc
@@ -59,7 +59,7 @@ endif::[]
// images:
:image-uri-screenshot: https://raw.githubusercontent.com/asciidoctor/asciidoctor/master/screenshot.png
-{uri-project}/[Asciidoctor] 是一个 _快速_ 文本处理器和发布工具链,它可以将 {uri-what-is-asciidoc}[AsciiDoc] 文档转化成 HTML5、 DocBook 5 (或 4.5) 以及其他格式。
+{uri-project}/[Asciidoctor] 是一个 _快速_ 文本处理器和发布工具链,它可以将 {uri-what-is-asciidoc}[AsciiDoc] 文档转化成 HTML 5、 DocBook 5 以及其他格式。
Asciidoctor 由 Ruby 编写,打包成 RubyGem,然后发布到 {uri-rubygem}[RubyGems.org] 上。
这个 gem 还被包含道几个 Linux 发行版中,其中包括 Fedora、Debian 和 Ubuntu。
Asciidoctor 是开源的,{uri-repo}[代码]托管在 GitHub,遵从 {uri-license}[MIT] 协议。
@@ -100,22 +100,22 @@ endif::[]
[#the-big-picture]
== 整体概况
-Asciidoctor 以纯文本格式读取内容,见下图左边的面板,并将它转换成 HTML5 呈现在右侧面板中。
-Asciidoctor 将默认的样式表应用到 HTML5 文档上,提供一个愉快的开箱即用的体验。
+Asciidoctor 以纯文本格式读取内容,见下图左边的面板,并将它转换成 HTML 5 呈现在右侧面板中。
+Asciidoctor 将默认的样式表应用到 HTML 5 文档上,提供一个愉快的开箱即用的体验。
image::{image-uri-screenshot}[AsciiDoc 源文预览和相应的 HTML 渲染]
[#asciidoc-processing]
== AsciiDoc Processing
-Asciidoctor 会读取并处理用 AsciiDoc 语法写的文件,然后将解析出来的解析树参数交给内置的转化器去生成 HTML5,DocBook 5 (或 4.5) 或帮助手册页面输出。
+Asciidoctor 会读取并处理用 AsciiDoc 语法写的文件,然后将解析出来的解析树参数交给内置的转化器去生成 HTML 5,DocBook 5 或帮助手册页面输出。
你可以选择使用你自己的转化器或者加载 {uri-tilt}[Tilt] - 支持通过模板来自定义输出或产生附加的格式。
NOTE: Asciidoctor是为了直接替换原 AsciiDoc Python 处理器(`asciidoc.py`)。
Asciidoctor 测试套件含有 {uri-tests}[> 1,600 测试示例] 来确保和 AsciiDoc 语法的兼容性。
除了传统的 AsciiDoc 语法,Asciidoctor 还添加额外的标记和格式设置选项,例如 font-based 图标(例如: `+icon:fire[]+`)和 UI 元素(例如: `+button:[Save]+`)。
-Asciidoctor 还提供了一个基于 {uri-foundation}[Foundation] 的现代化的、响应式主题来美化 HTML5 输出。
+Asciidoctor 还提供了一个基于 {uri-foundation}[Foundation] 的现代化的、响应式主题来美化 HTML 5 输出。
[#requirements]
== 要求
diff --git a/asciidoctor.gemspec b/asciidoctor.gemspec
index bfa11491..5d14a5d8 100644
--- a/asciidoctor.gemspec
+++ b/asciidoctor.gemspec
@@ -9,8 +9,8 @@ require 'open3' unless defined? Open3.popen3
Gem::Specification.new do |s|
s.name = 'asciidoctor'
s.version = Asciidoctor::VERSION
- s.summary = 'An implementation of the AsciiDoc text processor and publishing toolchain in Ruby'
- s.description = 'A fast, open source text processor and publishing toolchain, written in Ruby, for converting AsciiDoc content to HTML5, DocBook 5 (or 4.5) and other formats.'
+ s.summary = 'An implementation of the AsciiDoc text processor and publishing toolchain'
+ s.description = 'A fast, open source text processor and publishing toolchain for converting AsciiDoc content to HTML 5, DocBook 5, and other formats.'
s.authors = ['Dan Allen', 'Sarah White', 'Ryan Waldron', 'Jason Porter', 'Nick Hengeveld', 'Jeremy McAnally']
s.email = ['dan.j.allen@gmail.com']
s.homepage = 'http://asciidoctor.org'
diff --git a/lib/asciidoctor.rb b/lib/asciidoctor.rb
index 9fc353cc..45abbf67 100644
--- a/lib/asciidoctor.rb
+++ b/lib/asciidoctor.rb
@@ -1064,7 +1064,7 @@ module Asciidoctor
#
# Examples
#
- # docbook45
+ # docbook5
# html5
#
TrailingDigitsRx = /\d+$/
diff --git a/lib/asciidoctor/cli/options.rb b/lib/asciidoctor/cli/options.rb
index af76d758..e2158137 100644
--- a/lib/asciidoctor/cli/options.rb
+++ b/lib/asciidoctor/cli/options.rb
@@ -46,7 +46,7 @@ module Asciidoctor
EOS
- opts.on('-b', '--backend BACKEND', 'set output format backend: [html5, xhtml5, docbook5, docbook45, manpage] (default: html5)',
+ opts.on('-b', '--backend BACKEND', 'set output format backend: [html5, xhtml5, docbook5, manpage] (default: html5)',
'additional backends are supported via extensions (e.g., pdf, latex)') do |backend|
self[:attributes]['backend'] = backend
end
diff --git a/lib/asciidoctor/converter.rb b/lib/asciidoctor/converter.rb
index 5915be9c..db00e8aa 100644
--- a/lib/asciidoctor/converter.rb
+++ b/lib/asciidoctor/converter.rb
@@ -254,7 +254,7 @@ module Converter
# Mixed into the {Converter} module to provide the global registry of converters that are registered statically.
#
# This registry includes built-in converters for {Html5Converter HTML 5}, {DocBook5Converter DocBook 5} and
- # {DocBook45Converter DocBook 4.5}, as well as any custom converters that have been discovered or explicitly
+ # {ManPageConverter man(ual) page}, as well as any custom converters that have been discovered or explicitly
# registered. Converter registration is synchronized (where applicable) and is thus guaranteed to be thread safe.
module DefaultFactory
include Factory
@@ -296,7 +296,6 @@ module Converter
end
PROVIDED = {
- 'docbook45' => %(#{__dir__}/converter/docbook45),
'docbook5' => %(#{__dir__}/converter/docbook5),
'html5' => %(#{__dir__}/converter/html5),
'manpage' => %(#{__dir__}/converter/manpage),
diff --git a/lib/asciidoctor/converter/docbook45.rb b/lib/asciidoctor/converter/docbook45.rb
deleted file mode 100644
index 0c639497..00000000
--- a/lib/asciidoctor/converter/docbook45.rb
+++ /dev/null
@@ -1,92 +0,0 @@
-require_relative 'docbook5'
-
-module Asciidoctor
-# A built-in {Converter} implementation that generates DocBook 4.5 output
-# consistent with the docbook45 backend from AsciiDoc Python.
-class Converter::DocBook45Converter < Converter::DocBook5Converter
- register_for 'docbook45'
-
- def admonition node
- # address a bug in the DocBook 4.5 DTD
- if node.parent.context == :example
- %(<para>
-#{super}
-</para>)
- else
- super
- end
- end
-
- def olist node
- result = []
- num_attribute = node.style ? %( numeration="#{node.style}") : ''
- start_attribute = (node.attr? 'start') ? %( override="#{node.attr 'start'}") : ''
- result << %(<orderedlist#{_common_attributes node.id, node.role, node.reftext}#{num_attribute}>)
- result << %(<title>#{node.title}</title>) if node.title?
- node.items.each_with_index do |item, idx|
- result << (idx == 0 ? %(<listitem#{start_attribute}>) : '<listitem>')
- result << %(<simpara>#{item.text}</simpara>)
- result << item.content if item.blocks?
- result << '</listitem>'
- end
- result << %(</orderedlist>)
- result.join LF
- end
-
- def inline_anchor node
- case node.type
- when :ref
- %(<anchor#{_common_attributes node.target, nil, node.text}/>)
- when :xref
- if (path = node.attributes['path'])
- # QUESTION should we use refid as fallback text instead? (like the html5 backend?)
- %(<ulink url="#{node.target}">#{node.text || path}</ulink>)
- else
- linkend = node.attributes['fragment'] || node.target
- (text = node.text) ? %(<link linkend="#{linkend}">#{text}</link>) : %(<xref linkend="#{linkend}"/>)
- end
- when :link
- %(<ulink url="#{node.target}">#{node.text}</ulink>)
- when :bibref
- target = node.target
- %(<anchor#{_common_attributes target, nil, "[#{target}]"}/>[#{target}])
- end
- end
-
- private
-
- def _author_tag author
- result = []
- result << '<author>'
- result << %(<firstname>#{author.firstname}</firstname>) if author.firstname
- result << %(<othername>#{author.middlename}</othername>) if author.middlename
- result << %(<surname>#{author.lastname}</surname>) if author.lastname
- result << %(<email>#{author.email}</email>) if author.email
- result << '</author>'
- result.join LF
- end
-
- def _common_attributes id, role = nil, reftext = nil
- res = id ? %( id="#{id}") : ''
- res = %(#{res} role="#{role}") if role
- res = %(#{res} xreflabel="#{reftext}") if reftext
- res
- end
-
- def _doctype_declaration root_tag_name
- %(<!DOCTYPE #{root_tag_name} PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">)
- end
-
- def _document_info_tag doc, info_tag_prefix
- super doc, info_tag_prefix, true
- end
-
- def _lang_attribute_name
- 'lang'
- end
-
- def _document_ns_attributes doc
- (ns = doc.attr 'xmlns') ? (ns.empty? ? ' xmlns="http://docbook.org/ns/docbook"' : %( xmlns="#{ns}")) : ''
- end
-end
-end
diff --git a/lib/asciidoctor/converter/docbook5.rb b/lib/asciidoctor/converter/docbook5.rb
index 41591cc4..80743a31 100644
--- a/lib/asciidoctor/converter/docbook5.rb
+++ b/lib/asciidoctor/converter/docbook5.rb
@@ -1,7 +1,6 @@
module Asciidoctor
-# A built-in {Converter} implementation that generates DocBook 5 output
-# similar to the docbook45 backend from AsciiDoc Python, but migrated to the
-# DocBook 5 specification.
+# A built-in {Converter} implementation that generates DocBook 5 output. The output is inspired by the output produced
+# by the docbook45 backend from AsciiDoc Python, except it has been migrated to the DocBook 5 specification.
class Converter::DocBook5Converter < Converter::Base
register_for 'docbook5'
@@ -19,9 +18,6 @@ class Converter::DocBook5Converter < Converter::Base
root_tag_name = 'refentry'
end
result << '<?xml version="1.0" encoding="UTF-8"?>'
- if (doctype_line = _doctype_declaration root_tag_name)
- result << doctype_line
- end
if node.attr? 'toc'
if node.attr? 'toclevels'
result << %(<?asciidoc-toc maxdepth="#{node.attr 'toclevels'}"?>)
@@ -36,9 +32,9 @@ class Converter::DocBook5Converter < Converter::Base
result << '<?asciidoc-numbered?>'
end
end
- lang_attribute = (node.attr? 'nolang') ? '' : %( #{_lang_attribute_name}="#{node.attr 'lang', 'en'}")
- result << %(<#{root_tag_name}#{_document_ns_attributes node}#{lang_attribute}#{_common_attributes node.id}>)
- result << (_document_info_tag node, root_tag_name) unless node.noheader
+ lang_attribute = (node.attr? 'nolang') ? '' : %( xml:lang="#{node.attr 'lang', 'en'}")
+ result << %(<#{root_tag_name} xmlns="http://docbook.org/ns/docbook" xmlns:xl="http://www.w3.org/1999/xlink" version="5.0"#{lang_attribute}#{_common_attributes node.id}>)
+ result << (_document_info_tag node) unless node.noheader
result << node.content if node.blocks?
unless (footer_docinfo = node.docinfo :footer).empty?
result << footer_docinfo
@@ -65,7 +61,7 @@ class Converter::DocBook5Converter < Converter::Base
def admonition node
%(<#{tag_name = node.attr 'name'}#{_common_attributes node.id, node.role, node.reftext}>
-#{_title_tag node}#{_resolve_content node}
+#{_title_tag node}#{_enclose_content node}
</#{tag_name}>)
end
@@ -172,11 +168,11 @@ class Converter::DocBook5Converter < Converter::Base
if node.title?
%(<example#{_common_attributes node.id, node.role, node.reftext}>
<title>#{node.title}</title>
-#{_resolve_content node}
+#{_enclose_content node}
</example>)
else
%(<informalexample#{_common_attributes node.id, node.role, node.reftext}>
-#{_resolve_content node}
+#{_enclose_content node}
</informalexample>)
end
end
@@ -316,7 +312,7 @@ class Converter::DocBook5Converter < Converter::Base
''
else
%(<abstract>
-#{_title_tag node}#{_resolve_content node}
+#{_title_tag node}#{_enclose_content node}
</abstract>)
end
when 'partintro'
@@ -325,7 +321,7 @@ class Converter::DocBook5Converter < Converter::Base
''
else
%(<partintro#{_common_attributes node.id, node.role, node.reftext}>
-#{_title_tag node}#{_resolve_content node}
+#{_title_tag node}#{_enclose_content node}
</partintro>)
end
else
@@ -345,7 +341,7 @@ class Converter::DocBook5Converter < Converter::Base
%(<simpara#{_common_attributes id, role, reftext}>#{node.content}</simpara>)
end
else
- _resolve_content node
+ _enclose_content node
end
end
end
@@ -376,7 +372,7 @@ class Converter::DocBook5Converter < Converter::Base
end
def quote node
- _blockquote_tag(node, (node.has_role? 'epigraph') && 'epigraph') { _resolve_content node }
+ _blockquote_tag(node, (node.has_role? 'epigraph') && 'epigraph') { _enclose_content node }
end
def thematic_break node
@@ -385,7 +381,7 @@ class Converter::DocBook5Converter < Converter::Base
def sidebar node
%(<sidebar#{_common_attributes node.id, node.role, node.reftext}>
-#{_title_tag node}#{_resolve_content node}
+#{_title_tag node}#{_enclose_content node}
</sidebar>)
end
@@ -492,7 +488,6 @@ class Converter::DocBook5Converter < Converter::Base
end
result << '</itemizedlist>'
end
-
result.join LF
end
@@ -650,8 +645,6 @@ class Converter::DocBook5Converter < Converter::Base
attrs
end
- def _doctype_declaration root_tag_name; end
-
def _author_tag author
result = []
result << '<author>'
@@ -665,11 +658,16 @@ class Converter::DocBook5Converter < Converter::Base
result.join LF
end
- def _document_info_tag doc, info_tag_prefix, use_info_tag_prefix = false
- info_tag_prefix = '' unless use_info_tag_prefix
- result = []
- result << %(<#{info_tag_prefix}info>)
- result << _document_title_tags(doc.doctitle partition: true, use_fallback: true) unless doc.notitle
+ def _document_info_tag doc
+ result = ['<info>']
+ unless doc.notitle
+ if (title = doc.doctitle partition: true, use_fallback: true).subtitle?
+ result << %(<title>#{title.main}</title>
+<subtitle>#{title.subtitle}</subtitle>)
+ else
+ result << %(<title>#{title}</title>)
+ end
+ end
if (date = (doc.attr? 'revdate') ? (doc.attr 'revdate') : ((doc.attr? 'reproducible') ? nil : (doc.attr 'docdate')))
result << %(<date>#{date}</date>)
end
@@ -701,14 +699,12 @@ class Converter::DocBook5Converter < Converter::Base
result << %(</revision>
</revhistory>)
end
- unless use_info_tag_prefix
- if (doc.attr? 'front-cover-image') || (doc.attr? 'back-cover-image')
- if (back_cover_tag = _cover_tag doc, 'back')
- result << (_cover_tag doc, 'front', true)
- result << back_cover_tag
- elsif (front_cover_tag = _cover_tag doc, 'front')
- result << front_cover_tag
- end
+ if (doc.attr? 'front-cover-image') || (doc.attr? 'back-cover-image')
+ if (back_cover_tag = _cover_tag doc, 'back')
+ result << (_cover_tag doc, 'front', true)
+ result << back_cover_tag
+ elsif (front_cover_tag = _cover_tag doc, 'front')
+ result << front_cover_tag
end
end
unless (head_docinfo = doc.docinfo).empty?
@@ -716,7 +712,7 @@ class Converter::DocBook5Converter < Converter::Base
end
result << %(<orgname>#{doc.attr 'orgname'}</orgname>) if doc.attr? 'orgname'
end
- result << %(</#{info_tag_prefix}info>)
+ result << '</info>'
if doc.doctype == 'manpage'
result << '<refmeta>'
@@ -734,25 +730,8 @@ class Converter::DocBook5Converter < Converter::Base
result.join LF
end
- def _document_ns_attributes doc
- ' xmlns="http://docbook.org/ns/docbook" xmlns:xl="http://www.w3.org/1999/xlink" version="5.0"'
- end
-
- def _lang_attribute_name
- 'xml:lang'
- end
-
- def _document_title_tags title
- if title.subtitle?
- %(<title>#{title.main}</title>
-<subtitle>#{title.subtitle}</subtitle>)
- else
- %(<title>#{title}</title>)
- end
- end
-
# FIXME this should be handled through a template mechanism
- def _resolve_content node
+ def _enclose_content node
node.content_model == :compound ? node.content : %(<simpara>#{node.content}</simpara>)
end
diff --git a/man/asciidoctor.1 b/man/asciidoctor.1
index 64ef63c6..40a932e5 100644
--- a/man/asciidoctor.1
+++ b/man/asciidoctor.1
@@ -1,13 +1,13 @@
'\" t
.\" Title: asciidoctor
.\" Author: Dan Allen, Sarah White, Ryan Waldron
-.\" Generator: Asciidoctor 1.5.8
-.\" Date: 2018-10-28
+.\" Generator: Asciidoctor 2.0.0.dev
+.\" Date: 2019-02-04
.\" Manual: Asciidoctor Manual
-.\" Source: Asciidoctor 1.5.8
+.\" Source: Asciidoctor 2.0.0.dev
.\" Language: English
.\"
-.TH "ASCIIDOCTOR" "1" "2018-10-28" "Asciidoctor 1.5.8" "Asciidoctor Manual"
+.TH "ASCIIDOCTOR" "1" "2019-02-04" "Asciidoctor 2.0.0.dev" "Asciidoctor Manual"
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.ss \n[.ss] 0
@@ -34,7 +34,7 @@ asciidoctor \- converts AsciiDoc source files to HTML, DocBook and other formats
\fBasciidoctor\fP [\fIOPTION\fP]... \fIFILE\fP...
.SH "DESCRIPTION"
.sp
-The asciidoctor(1) command converts the AsciiDoc source file(s) \fIFILE\fP to HTML5, DocBook 5, DocBook 4.5, man(ual) page and other custom output formats.
+The asciidoctor(1) command converts the AsciiDoc source file(s) \fIFILE\fP to HTML5, DocBook 5, man(ual) page and other custom output formats.
.sp
If \fIFILE\fP is \fI\-\fP then the AsciiDoc source is read from standard input.
.SH "OPTIONS"
diff --git a/man/asciidoctor.adoc b/man/asciidoctor.adoc
index 8cef6504..7319ac70 100644
--- a/man/asciidoctor.adoc
+++ b/man/asciidoctor.adoc
@@ -2,7 +2,7 @@
Dan Allen; Sarah White; Ryan Waldron
:doctype: manpage
:man manual: Asciidoctor Manual
-:man source: Asciidoctor 1.5.8
+:man source: Asciidoctor 2.0.0.dev
:page-layout: base
== NAME
@@ -15,7 +15,7 @@ asciidoctor - converts AsciiDoc source files to HTML, DocBook and other formats
== DESCRIPTION
-The asciidoctor(1) command converts the AsciiDoc source file(s) _FILE_ to HTML5, DocBook 5, DocBook 4.5, man(ual) page and other custom output formats.
+The asciidoctor(1) command converts the AsciiDoc source file(s) _FILE_ to HTML5, DocBook 5, man(ual) page and other custom output formats.
If _FILE_ is _-_ then the AsciiDoc source is read from standard input.
diff --git a/test/attributes_test.rb b/test/attributes_test.rb
index f0a19498..253f5df8 100644
--- a/test/attributes_test.rb
+++ b/test/attributes_test.rb
@@ -457,7 +457,7 @@ context 'Attributes' do
end
test 'backend attributes defined in document options overrides backend attribute in document' do
- doc = document_from_string(':backend: docbook45', safe: Asciidoctor::SafeMode::SAFE, attributes: { 'backend' => 'html5' })
+ doc = document_from_string(':backend: docbook5', safe: Asciidoctor::SafeMode::SAFE, attributes: { 'backend' => 'html5' })
assert_equal 'html5', doc.attributes['backend']
assert doc.attributes.has_key? 'backend-html5'
assert_equal 'html', doc.attributes['basebackend']
@@ -572,8 +572,7 @@ context 'Attributes' do
test "convert properly with simple names" do
html = convert_string(":frog: Tanglefoot\n:my_super-hero: Spiderman\n\nYo, {frog}!\nBeat {my_super-hero}!")
- result = Nokogiri::HTML(html)
- assert_equal "Yo, Tanglefoot!\nBeat Spiderman!", result.css("p").first.content.strip
+ assert_xpath %(//p[text()="Yo, Tanglefoot!\nBeat Spiderman!"]), html, 1
end
test 'attribute lookup is not case sensitive' do
@@ -591,8 +590,7 @@ context 'Attributes' do
test "convert properly with single character name" do
html = convert_string(":r: Ruby\n\nR is for {r}!")
- result = Nokogiri::HTML(html)
- assert_equal 'R is for Ruby!', result.css("p").first.content.strip
+ assert_xpath %(//p[text()="R is for Ruby!"]), html, 1
end
test "collapses spaces in attribute names" do
@@ -706,15 +704,13 @@ context 'Attributes' do
test "substitutes inside unordered list items" do
html = convert_string(":foo: bar\n* snort at the {foo}\n* yawn")
- result = Nokogiri::HTML(html)
- assert_match(/snort at the bar/, result.css("li").first.content.strip)
+ assert_xpath %(//li/p[text()="snort at the bar"]), html, 1
end
test 'substitutes inside section title' do
output = convert_string(":prefix: Cool\n\n== {prefix} Title\n\ncontent")
- result = Nokogiri::HTML(output)
- assert_match(/Cool Title/, result.css('h2').first.content)
- assert_match(/_cool_title/, result.css('h2').first.attr('id'))
+ assert_xpath '//h2[text()="Cool Title"]', output, 1
+ assert_css 'h2#_cool_title', output, 1
end
test 'interpolates attribute defined in header inside attribute entry in header' do
@@ -855,14 +851,12 @@ context 'Attributes' do
test 'does not disturb attribute-looking things escaped with backslash' do
html = convert_string(":foo: bar\nThis is a \\{foo} day.")
- result = Nokogiri::HTML(html)
- assert_equal 'This is a {foo} day.', result.css('p').first.content.strip
+ assert_xpath '//p[text()="This is a {foo} day."]', html, 1
end
test 'does not disturb attribute-looking things escaped with literals' do
html = convert_string(":foo: bar\nThis is a +++{foo}+++ day.")
- result = Nokogiri::HTML(html)
- assert_equal 'This is a {foo} day.', result.css('p').first.content.strip
+ assert_xpath '//p[text()="This is a {foo} day."]', html, 1
end
test 'does not substitute attributes inside listing blocks' do
@@ -1524,14 +1518,14 @@ context 'Attributes' do
content
EOS
- doc = document_from_string input, backend: 'docbook45'
+ doc = document_from_string input, backend: 'docbook'
section = doc.blocks[0]
refute_nil section
assert_equal :section, section.context
refute section.special
output = doc.convert
- assert_css 'section', output, 1
- assert_css 'section#idname', output, 1
+ assert_css 'article:root > section', output, 1
+ assert_css 'article:root > section[xml|id="idname"]', output, 1
end
test "Block attributes are additive" do
diff --git a/test/blocks_test.rb b/test/blocks_test.rb
index dbfbe9ff..7d08b4c2 100644
--- a/test/blocks_test.rb
+++ b/test/blocks_test.rb
@@ -169,7 +169,7 @@ line should be shown
EOS
output = convert_string_to_embedded input
- assert_xpath '//p[text() = "line should be shown"]', output, 1
+ assert_xpath '//p[text()="line should be shown"]', output, 1
end
test 'preprocessor directives should not be processed within comment block' do
@@ -184,7 +184,7 @@ line should be shown
EOS
output = convert_string_to_embedded input
- assert_xpath '//p[text() = "line should be shown"]', output, 1
+ assert_xpath '//p[text()="line should be shown"]', output, 1
end
test 'should warn if unterminated comment block is detected in body' do
@@ -246,7 +246,7 @@ this line should be shown
EOS
output = convert_string_to_embedded input
- assert_xpath '//p[text() = "this line should be shown"]', output, 1
+ assert_xpath '//p[text()="this line should be shown"]', output, 1
end
test 'comment style on open block should only skip block' do
@@ -337,7 +337,7 @@ ____
assert_css '.quoteblock > blockquote', output, 1
assert_css '.quoteblock > blockquote > .paragraph > p', output, 1
assert_css '.quoteblock > .attribution', output, 0
- assert_xpath '//*[@class = "quoteblock"]//p[text() = "A famous quote."]', output, 1
+ assert_xpath '//*[@class="quoteblock"]//p[text()="A famous quote."]', output, 1
end
test 'quote block with attribution' do
@@ -354,8 +354,8 @@ ____
assert_css '.quoteblock > .attribution', output, 1
assert_css '.quoteblock > .attribution > cite', output, 1
assert_css '.quoteblock > .attribution > br + cite', output, 1
- assert_xpath '//*[@class = "quoteblock"]/*[@class = "attribution"]/cite[text() = "Famous Book (1999)"]', output, 1
- attribution = xmlnodes_at_xpath '//*[@class = "quoteblock"]/*[@class = "attribution"]', output, 1
+ assert_xpath '//*[@class="quoteblock"]/*[@class="attribution"]/cite[text()="Famous Book (1999)"]', output, 1
+ attribution = xmlnodes_at_xpath '//*[@class="quoteblock"]/*[@class="attribution"]', output, 1
author = attribution.children.first
assert_equal "#{decode_char 8212} Famous Person", author.text.strip
end
@@ -416,7 +416,7 @@ ____
assert_css 'blockquote > simpara', output, 1
assert_css 'blockquote > attribution', output, 1
assert_css 'blockquote > attribution > citetitle', output, 1
- assert_xpath '//blockquote/attribution/citetitle[text() = "Famous Book (1999)"]', output, 1
+ assert_xpath '//blockquote/attribution/citetitle[text()="Famous Book (1999)"]', output, 1
attribution = xmlnodes_at_xpath '//blockquote/attribution', output, 1
author = attribution.children.first
assert_equal 'Famous Person', author.text.strip
@@ -434,7 +434,7 @@ ____
assert_css 'epigraph > simpara', output, 1
assert_css 'epigraph > attribution', output, 1
assert_css 'epigraph > attribution > citetitle', output, 1
- assert_xpath '//epigraph/attribution/citetitle[text() = "Famous Book (1999)"]', output, 1
+ assert_xpath '//epigraph/attribution/citetitle[text()="Famous Book (1999)"]', output, 1
attribution = xmlnodes_at_xpath '//epigraph/attribution', output, 1
author = attribution.children.first
assert_equal 'Famous Person', author.text.strip
@@ -451,7 +451,7 @@ A famous quote.
assert_css '.quoteblock > blockquote', output, 1
assert_css '.quoteblock > blockquote > .paragraph > p', output, 1
assert_css '.quoteblock > .attribution', output, 0
- assert_xpath '//*[@class = "quoteblock"]//p[text() = "A famous quote."]', output, 1
+ assert_xpath '//*[@class="quoteblock"]//p[text()="A famous quote."]', output, 1
end
test 'markdown-style quote block with single paragraph and no attribution' do
@@ -464,7 +464,7 @@ A famous quote.
assert_css '.quoteblock > blockquote', output, 1
assert_css '.quoteblock > blockquote > .paragraph > p', output, 1
assert_css '.quoteblock > .attribution', output, 0
- assert_xpath %(//*[@class = "quoteblock"]//p[text() = "A famous quote.\nSome more inspiring words."]), output, 1
+ assert_xpath %(//*[@class="quoteblock"]//p[text()="A famous quote.\nSome more inspiring words."]), output, 1
end
test 'lazy markdown-style quote block with single paragraph and no attribution' do
@@ -477,7 +477,7 @@ Some more inspiring words.
assert_css '.quoteblock > blockquote', output, 1
assert_css '.quoteblock > blockquote > .paragraph > p', output, 1
assert_css '.quoteblock > .attribution', output, 0
- assert_xpath %(//*[@class = "quoteblock"]//p[text() = "A famous quote.\nSome more inspiring words."]), output, 1
+ assert_xpath %(//*[@class="quoteblock"]//p[text()="A famous quote.\nSome more inspiring words."]), output, 1
end
test 'markdown-style quote block with multiple paragraphs and no attribution' do
@@ -491,8 +491,8 @@ Some more inspiring words.
assert_css '.quoteblock > blockquote', output, 1
assert_css '.quoteblock > blockquote > .paragraph > p', output, 2
assert_css '.quoteblock > .attribution', output, 0
- assert_xpath %((//*[@class = "quoteblock"]//p)[1][text() = "A famous quote."]), output, 1
- assert_xpath %((//*[@class = "quoteblock"]//p)[2][text() = "Some more inspiring words."]), output, 1
+ assert_xpath %((//*[@class="quoteblock"]//p)[1][text()="A famous quote."]), output, 1
+ assert_xpath %((//*[@class="quoteblock"]//p)[2][text()="Some more inspiring words."]), output, 1
end
test 'markdown-style quote block with multiple blocks and no attribution' do
@@ -507,8 +507,8 @@ Some more inspiring words.
assert_css '.quoteblock > blockquote > .paragraph > p', output, 1
assert_css '.quoteblock > blockquote > .admonitionblock', output, 1
assert_css '.quoteblock > .attribution', output, 0
- assert_xpath %((//*[@class = "quoteblock"]//p)[1][text() = "A famous quote."]), output, 1
- assert_xpath %((//*[@class = "quoteblock"]//*[@class = "admonitionblock note"]//*[@class="content"])[1][normalize-space(text()) = "Some more inspiring words."]), output, 1
+ assert_xpath %((//*[@class="quoteblock"]//p)[1][text()="A famous quote."]), output, 1
+ assert_xpath %((//*[@class="quoteblock"]//*[@class="admonitionblock note"]//*[@class="content"])[1][normalize-space(text())="Some more inspiring words."]), output, 1
end
test 'markdown-style quote block with single paragraph and attribution' do
@@ -521,12 +521,12 @@ Some more inspiring words.
assert_css '.quoteblock', output, 1
assert_css '.quoteblock > blockquote', output, 1
assert_css '.quoteblock > blockquote > .paragraph > p', output, 1
- assert_xpath %(//*[@class = "quoteblock"]//p[text() = "A famous quote.\nSome more inspiring words."]), output, 1
+ assert_xpath %(//*[@class="quoteblock"]//p[text()="A famous quote.\nSome more inspiring words."]), output, 1
assert_css '.quoteblock > .attribution', output, 1
assert_css '.quoteblock > .attribution > cite', output, 1
assert_css '.quoteblock > .attribution > br + cite', output, 1
- assert_xpath '//*[@class = "quoteblock"]/*[@class = "attribution"]/cite[text() = "Famous Source, Volume 1 (1999)"]', output, 1
- attribution = xmlnodes_at_xpath '//*[@class = "quoteblock"]/*[@class = "attribution"]', output, 1
+ assert_xpath '//*[@class="quoteblock"]/*[@class="attribution"]/cite[text()="Famous Source, Volume 1 (1999)"]', output, 1
+ attribution = xmlnodes_at_xpath '//*[@class="quoteblock"]/*[@class="attribution"]', output, 1
author = attribution.children.first
assert_equal "#{decode_char 8212} Famous Person", author.text.strip
end
@@ -564,12 +564,12 @@ Some more inspiring words."
output = convert_string input
assert_css '.quoteblock', output, 1
assert_css '.quoteblock > blockquote', output, 1
- assert_xpath %(//*[@class = "quoteblock"]/blockquote[normalize-space(text()) = "A famous quote. Some more inspiring words."]), output, 1
+ assert_xpath %(//*[@class="quoteblock"]/blockquote[normalize-space(text())="A famous quote. Some more inspiring words."]), output, 1
assert_css '.quoteblock > .attribution', output, 1
assert_css '.quoteblock > .attribution > cite', output, 1
assert_css '.quoteblock > .attribution > br + cite', output, 1
- assert_xpath '//*[@class = "quoteblock"]/*[@class = "attribution"]/cite[text() = "Famous Source, Volume 1 (1999)"]', output, 1
- attribution = xmlnodes_at_xpath '//*[@class = "quoteblock"]/*[@class = "attribution"]', output, 1
+ assert_xpath '//*[@class="quoteblock"]/*[@class="attribution"]/cite[text()="Famous Source, Volume 1 (1999)"]', output, 1
+ attribution = xmlnodes_at_xpath '//*[@class="quoteblock"]/*[@class="attribution"]', output, 1
author = attribution.children.first
assert_equal "#{decode_char 8212} Famous Person", author.text.strip
end
@@ -598,7 +598,7 @@ ____
assert_css '.verseblock > pre', output, 1
assert_css '.verseblock > .attribution', output, 0
assert_css '.verseblock p', output, 0
- assert_xpath '//*[@class = "verseblock"]/pre[normalize-space(text()) = "A famous verse."]', output, 1
+ assert_xpath '//*[@class="verseblock"]/pre[normalize-space(text())="A famous verse."]', output, 1
end
test 'single-line verse block with attribution' do
@@ -615,8 +615,8 @@ ____
assert_css '.verseblock > .attribution', output, 1
assert_css '.verseblock > .attribution > cite', output, 1
assert_css '.verseblock > .attribution > br + cite', output, 1
- assert_xpath '//*[@class = "verseblock"]/*[@class = "attribution"]/cite[text() = "Famous Poem"]', output, 1
- attribution = xmlnodes_at_xpath '//*[@class = "verseblock"]/*[@class = "attribution"]', output, 1
+ assert_xpath '//*[@class="verseblock"]/*[@class="attribution"]/cite[text()="Famous Poem"]', output, 1
+ attribution = xmlnodes_at_xpath '//*[@class="verseblock"]/*[@class="attribution"]', output, 1
author = attribution.children.first
assert_equal "#{decode_char 8212} Famous Poet", author.text.strip
end
@@ -634,7 +634,7 @@ ____
assert_css 'blockquote > literallayout', output, 1
assert_css 'blockquote > attribution', output, 1
assert_css 'blockquote > attribution > citetitle', output, 1
- assert_xpath '//blockquote/attribution/citetitle[text() = "Famous Poem"]', output, 1
+ assert_xpath '//blockquote/attribution/citetitle[text()="Famous Poem"]', output, 1
attribution = xmlnodes_at_xpath '//blockquote/attribution', output, 1
author = attribution.children.first
assert_equal 'Famous Poet', author.text.strip
@@ -653,7 +653,7 @@ ____
assert_css 'epigraph > literallayout', output, 1
assert_css 'epigraph > attribution', output, 1
assert_css 'epigraph > attribution > citetitle', output, 1
- assert_xpath '//epigraph/attribution/citetitle[text() = "Famous Poem"]', output, 1
+ assert_xpath '//epigraph/attribution/citetitle[text()="Famous Poem"]', output, 1
attribution = xmlnodes_at_xpath '//epigraph/attribution', output, 1
author = attribution.children.first
assert_equal 'Famous Poet', author.text.strip
@@ -669,11 +669,11 @@ Stanza two.
____
EOS
output = convert_string input
- assert_xpath '//*[@class = "verseblock"]', output, 1
- assert_xpath '//*[@class = "verseblock"]/pre', output, 1
- assert_xpath '//*[@class = "verseblock"]//p', output, 0
- assert_xpath '//*[@class = "verseblock"]/pre[contains(text(), "A famous verse.")]', output, 1
- assert_xpath '//*[@class = "verseblock"]/pre[contains(text(), "Stanza two.")]', output, 1
+ assert_xpath '//*[@class="verseblock"]', output, 1
+ assert_xpath '//*[@class="verseblock"]/pre', output, 1
+ assert_xpath '//*[@class="verseblock"]//p', output, 0
+ assert_xpath '//*[@class="verseblock"]/pre[contains(text(), "A famous verse.")]', output, 1
+ assert_xpath '//*[@class="verseblock"]/pre[contains(text(), "Stanza two.")]', output, 1
end
test 'verse block does not contain block elements' do
@@ -1401,18 +1401,12 @@ Back to our regularly scheduled programming.
EOS
output = convert_string input, backend: :docbook, keep_namespaces: true
- assert_css 'article > simpara', output, 2
- assert_css 'article > para', output, 1
- assert_css 'article > para > simpara', output, 1
- assert_css 'article > para > tip', output, 1
- open = xmlnodes_at_xpath '/xmlns:article/xmlns:para', output, 1
- # nokogiri can't make up its mind
- id = open.attribute('id') || open.attribute('xml:id')
- refute_nil id
- assert_equal 'open', id.value
- xreflabel = open.attribute('xreflabel')
- refute_nil xreflabel
- assert_equal 'Open Block', xreflabel.value
+ assert_css 'article:root > para[xml|id="open"]', output, 1
+ assert_css 'article:root > para[xreflabel="Open Block"]', output, 1
+ assert_css 'article:root > simpara', output, 2
+ assert_css 'article:root > para', output, 1
+ assert_css 'article:root > para > simpara', output, 1
+ assert_css 'article:root > para > tip', output, 1
end
test 'should transfer id and reftext on open paragraph to DocBook output' do
@@ -1422,16 +1416,9 @@ This is an open paragraph.
EOS
output = convert_string input, backend: :docbook, keep_namespaces: true
- assert_css 'article > simpara', output, 1
- open = xmlnodes_at_xpath '/xmlns:article/xmlns:simpara', output, 1
- open = xmlnodes_at_xpath '/xmlns:article/xmlns:simpara[text()="This is an open paragraph."]', output, 1
- # nokogiri can't make up its mind
- id = open.attribute('id') || open.attribute('xml:id')
- refute_nil id
- assert_equal 'openpara', id.value
- xreflabel = open.attribute('xreflabel')
- refute_nil xreflabel
- assert_equal 'Open Paragraph', xreflabel.value
+ assert_css 'article:root > simpara', output, 1
+ assert_css 'article:root > simpara[xml|id="openpara"]', output, 1
+ assert_css 'article:root > simpara[xreflabel="Open Paragraph"]', output, 1
end
test 'should transfer title on open block to DocBook output' do
@@ -1874,8 +1861,8 @@ paragraph
EOS
output = convert_string input
assert_xpath '//*[@class="paragraph"]', output, 1
- assert_xpath '//*[@class="paragraph"]/*[@class="title"][text() = "Title"]', output, 1
- assert_xpath '//*[@class="paragraph"]/p[text() = "paragraph"]', output, 1
+ assert_xpath '//*[@class="paragraph"]/*[@class="title"][text()="Title"]', output, 1
+ assert_xpath '//*[@class="paragraph"]/p[text()="paragraph"]', output, 1
end
test 'block title above document title demotes document title to a section title' do
@@ -1908,7 +1895,7 @@ paragraph
# NOTE block title demotes document title to level-0 section
refute doc.header?
output = doc.convert
- assert_xpath '//*[@class="sect1"]//*[@class="paragraph"]/*[@class="title"][text() = "Block title"]', output, 1
+ assert_xpath '//*[@class="sect1"]//*[@class="paragraph"]/*[@class="title"][text()="Block title"]', output, 1
end
test 'empty attribute list should not appear in output' do
@@ -2245,7 +2232,7 @@ image::images/tiger.png[Tiger]
assert_equal 1, doc.blocks[0].numeral
output = doc.convert
assert_xpath '//*[@class="imageblock"]//img[@src="images/tiger.png"][@alt="Tiger"]', output, 1
- assert_xpath '//*[@class="imageblock"]/*[@class="title"][text() = "Figure 1. The AsciiDoc Tiger"]', output, 1
+ assert_xpath '//*[@class="imageblock"]/*[@class="title"][text()="Figure 1. The AsciiDoc Tiger"]', output, 1
assert_equal 1, doc.attributes['figure-number']
end
@@ -2260,7 +2247,7 @@ image::images/tiger.png[Tiger]
assert_nil doc.blocks[0].numeral
output = doc.convert
assert_xpath '//*[@class="imageblock"]//img[@src="images/tiger.png"][@alt="Tiger"]', output, 1
- assert_xpath '//*[@class="imageblock"]/*[@class="title"][text() = "Voila! The AsciiDoc Tiger"]', output, 1
+ assert_xpath '//*[@class="imageblock"]/*[@class="title"][text()="Voila! The AsciiDoc Tiger"]', output, 1
refute doc.attributes.has_key?('figure-number')
end
@@ -3238,7 +3225,7 @@ content
assert_css '.openblock .title', output, 1
assert_css '.openblock .content', output, 1
assert_xpath %(//h1[@id="_part_1"]/following-sibling::*[#{contains_class(:openblock)}]), output, 1
- assert_xpath %(//*[#{contains_class(:openblock)}]/*[@class="title"][text() = "Intro title"]), output, 1
+ assert_xpath %(//*[#{contains_class(:openblock)}]/*[@class="title"][text()="Intro title"]), output, 1
assert_xpath %(//*[#{contains_class(:openblock)}]/*[@class="content"]/*[@class="paragraph"]), output, 1
end
@@ -3286,9 +3273,9 @@ It can have multiple paragraphs.
content
EOS
- output = convert_string input, backend: 'docbook45'
+ output = convert_string input, backend: 'docbook'
assert_css 'partintro', output, 1
- assert_css 'part#_part_1 > partintro', output, 1
+ assert_css 'part[xml|id="_part_1"] > partintro', output, 1
assert_css 'partintro > simpara', output, 2
end
@@ -3310,9 +3297,9 @@ This is a part intro with a title.
content
EOS
- output = convert_string input, backend: 'docbook45'
+ output = convert_string input, backend: 'docbook'
assert_css 'partintro', output, 1
- assert_css 'part#_part_1 > partintro', output, 1
+ assert_css 'part[xml|id="_part_1"] > partintro', output, 1
assert_css 'partintro > title', output, 1
assert_css 'partintro > title + simpara', output, 1
end
@@ -3455,7 +3442,7 @@ see how they run
output = convert_string_to_embedded input
assert_includes output, '[[3-blind-mice]]'
- assert_xpath '/*[@id = ":3-blind-mice"]', output, 0
+ assert_xpath '/*[@id=":3-blind-mice"]', output, 0
end
test 'should recognize block anchor that starts with colon' do
@@ -3467,7 +3454,7 @@ content
EOS
output = convert_string_to_embedded input
- assert_xpath '/*[@id = ":idname"]', output, 1
+ assert_xpath '/*[@id=":idname"]', output, 1
end
test 'should use specified id and reftext when registering block reference' do
diff --git a/test/converter_test.rb b/test/converter_test.rb
index c5353245..f5cfb246 100644
--- a/test/converter_test.rb
+++ b/test/converter_test.rb
@@ -13,7 +13,7 @@ context 'Converter' do
end
test 'should set Haml format to xhtml for docbook backend' do
- doc = Asciidoctor::Document.new [], backend: 'docbook45', template_dir: (fixture_path 'custom-backends/haml'), template_cache: false
+ doc = Asciidoctor::Document.new [], backend: 'docbook5', template_dir: (fixture_path 'custom-backends/haml'), template_cache: false
assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter
selected = doc.converter.find_converter('paragraph')
assert_kind_of Asciidoctor::Converter::TemplateConverter, selected
@@ -50,7 +50,7 @@ context 'Converter' do
end
test 'should set Slim format to nil for docbook backend' do
- doc = Asciidoctor::Document.new [], backend: 'docbook45', template_dir: (fixture_path 'custom-backends/slim'), template_cache: false
+ doc = Asciidoctor::Document.new [], backend: 'docbook5', template_dir: (fixture_path 'custom-backends/slim'), template_cache: false
assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter
selected = doc.converter.find_converter('paragraph')
assert_kind_of Asciidoctor::Converter::TemplateConverter, selected
@@ -119,8 +119,8 @@ context 'Converter' do
assert_equal '.foo', doc.attributes['outfilesuffix']
end
- test 'should load Haml templates for docbook45 backend' do
- doc = Asciidoctor::Document.new [], backend: 'docbook45', template_dir: (fixture_path 'custom-backends/haml'), template_cache: false
+ test 'should load Haml templates for docbook5 backend' do
+ doc = Asciidoctor::Document.new [], backend: 'docbook5', template_dir: (fixture_path 'custom-backends/haml'), template_cache: false
assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter
%w(paragraph).each do |node_name|
selected = doc.converter.find_converter node_name
@@ -266,8 +266,8 @@ context 'Converter' do
end
end
- test 'should load Slim templates for docbook45 backend' do
- doc = Asciidoctor::Document.new [], backend: 'docbook45', template_dir: (fixture_path 'custom-backends/slim'), template_cache: false
+ test 'should load Slim templates for docbook5 backend' do
+ doc = Asciidoctor::Document.new [], backend: 'docbook5', template_dir: (fixture_path 'custom-backends/slim'), template_cache: false
assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter
%w(paragraph).each do |node_name|
selected = doc.converter.find_converter node_name
diff --git a/test/document_test.rb b/test/document_test.rb
index 3f72a81d..94f4d539 100644
--- a/test/document_test.rb
+++ b/test/document_test.rb
@@ -76,7 +76,7 @@ context 'Document' do
end
end
- test 'toc and sectnums should be enabled by default for DocBook backend' do
+ test 'toc and sectnums should be enabled by default in DocBook backend' do
doc = document_from_string 'content', backend: 'docbook', parse: true
assert doc.attr?('toc')
assert doc.attr?('sectnums')
@@ -94,7 +94,7 @@ context 'Document' do
assert_match('<?asciidoc-numbered maxdepth="1"?>', result)
end
- test 'should be able to disable toc and sectnums in document header for DocBook backend' do
+ test 'should be able to disable toc and sectnums in document header in DocBook backend' do
input = <<-EOS
= Document Title
:toc!:
@@ -117,7 +117,7 @@ content
assert_xpath '/article/info', result, 0
end
- test 'should be able to disable section numbering using numbered attribute in document header for DocBook backend' do
+ test 'should be able to disable section numbering using numbered attribute in document header in DocBook backend' do
input = <<-EOS
= Document Title
:numbered!:
@@ -204,7 +204,7 @@ content
assert_css 'meta[name="robots"]', output, 0
end
- test 'should include docinfo files for docbook backend' do
+ test 'should include docinfo files in docbook backend' do
sample_input_path = fixture_path('basic.adoc')
output = Asciidoctor.convert_file sample_input_path, to_file: false,
@@ -254,7 +254,7 @@ content
assert_css 'a#top', output, 1
end
- test 'should include docinfo footer files for docbook backend' do
+ test 'should include docinfo footer files in DocBook backend' do
sample_input_path = fixture_path('basic.adoc')
output = Asciidoctor.convert_file sample_input_path, to_file: false,
@@ -262,20 +262,20 @@ content
refute_empty output
assert_css 'article > revhistory', output, 1
assert_xpath '/xmlns:article/xmlns:revhistory/xmlns:revision/xmlns:revnumber[text()="1.0"]', output, 1 # verifies substitutions are performed
- assert_css 'glossary#_glossary', output, 0
+ assert_css 'glossary', output, 0
output = Asciidoctor.convert_file sample_input_path, to_file: false,
header_footer: true, backend: 'docbook', safe: Asciidoctor::SafeMode::SERVER, attributes: { 'docinfo1' => '' }
refute_empty output
assert_css 'article > revhistory', output, 0
- assert_css 'glossary#_glossary', output, 1
+ assert_css 'glossary[xml|id="_glossary"]', output, 1
output = Asciidoctor.convert_file sample_input_path, to_file: false,
header_footer: true, backend: 'docbook', safe: Asciidoctor::SafeMode::SERVER, attributes: { 'docinfo2' => '' }
refute_empty output
assert_css 'article > revhistory', output, 1
assert_xpath '/xmlns:article/xmlns:revhistory/xmlns:revision/xmlns:revnumber[text()="1.0"]', output, 1 # verifies substitutions are performed
- assert_css 'glossary#_glossary', output, 1
+ assert_css 'glossary[xml|id="_glossary"]', output, 1
end
# WARNING this test manipulates runtime settings; should probably be run in forked process
@@ -373,7 +373,7 @@ content
end
context 'Converter' do
- test 'built-in HTML5 views are registered by default' do
+ test 'convert methos on built-in converter are registered by default' do
doc = document_from_string ''
assert_equal 'html5', doc.attributes['backend']
assert doc.attributes.has_key? 'backend-html5'
@@ -386,21 +386,7 @@ content
end
end
- test 'built-in DocBook45 views are registered when backend is docbook45' do
- doc = document_from_string '', attributes: { 'backend' => 'docbook45' }
- converter = doc.converter
- assert_equal 'docbook45', doc.attributes['backend']
- assert doc.attributes.has_key? 'backend-docbook45'
- assert_equal 'docbook', doc.attributes['basebackend']
- assert doc.attributes.has_key? 'basebackend-docbook'
- converter = doc.converter
- assert_kind_of Asciidoctor::Converter::DocBook45Converter, converter
- BUILT_IN_ELEMENTS.each do |element|
- assert_respond_to converter, element
- end
- end
-
- test 'built-in DocBook5 views are registered when backend is docbook5' do
+ test 'convert methods on built-in converter are registered when backend is docbook5' do
doc = document_from_string '', attributes: { 'backend' => 'docbook5' }
converter = doc.converter
assert_equal 'docbook5', doc.attributes['backend']
@@ -738,11 +724,11 @@ more info...
assert_xpath '//meta[@name="description"][@content="AsciiDoc user guide"]', output, 1
assert_xpath '//meta[@name="keywords"][@content="asciidoc,documentation"]', output, 1
assert_xpath '//meta[@name="copyright"][@content="Stuart Rackham"]', output, 1
- assert_xpath '//*[@id="header"]/*[@class="details"]/span[@id="author"][text() = "Stuart Rackham"]', output, 1
- assert_xpath '//*[@id="header"]/*[@class="details"]/span[@id="email"]/a[@href="mailto:founder@asciidoc.org"][text() = "founder@asciidoc.org"]', output, 1
- assert_xpath '//*[@id="header"]/*[@class="details"]/span[@id="revnumber"][text() = "version 8.6.8,"]', output, 1
- assert_xpath '//*[@id="header"]/*[@class="details"]/span[@id="revdate"][text() = "2012-07-12"]', output, 1
- assert_xpath '//*[@id="header"]/*[@class="details"]/span[@id="revremark"][text() = "See changelog."]', output, 1
+ assert_xpath '//*[@id="header"]/*[@class="details"]/span[@id="author"][text()="Stuart Rackham"]', output, 1
+ assert_xpath '//*[@id="header"]/*[@class="details"]/span[@id="email"]/a[@href="mailto:founder@asciidoc.org"][text()="founder@asciidoc.org"]', output, 1
+ assert_xpath '//*[@id="header"]/*[@class="details"]/span[@id="revnumber"][text()="version 8.6.8,"]', output, 1
+ assert_xpath '//*[@id="header"]/*[@class="details"]/span[@id="revdate"][text()="2012-07-12"]', output, 1
+ assert_xpath '//*[@id="header"]/*[@class="details"]/span[@id="revremark"][text()="See changelog."]', output, 1
end
test 'should parse revision line if date is empty' do
@@ -760,7 +746,7 @@ content
assert_equal 'remark', doc.attributes['revremark']
end
- test 'should include revision history if revdate and revnumber is set' do
+ test 'should include revision history in DocBook output if revdate and revnumber is set' do
input = <<-EOS
= Document Title
Author Name
@@ -777,7 +763,7 @@ content
assert_css 'revhistory > revision > revnumber', output, 1
end
- test 'should include revision history if revdate and revremark is set' do
+ test 'should include revision history in DocBook output if revdate and revremark is set' do
input = <<-EOS
= Document Title
Author Name
@@ -794,7 +780,7 @@ content
assert_css 'revhistory > revision > revremark', output, 1
end
- test 'should not include revision history if revdate is not set' do
+ test 'should not include revision history in DocBook output if revdate is not set' do
input = <<-EOS
= Document Title
Author Name
@@ -807,36 +793,7 @@ content
assert_css 'revhistory', output, 0
end
- test 'with metadata to DocBook45' do
- input = <<-EOS
-= AsciiDoc
-Stuart Rackham <founder@asciidoc.org>
-v8.6.8, 2012-07-12: See changelog.
-
-== Version 8.6.8
-
-more info...
- EOS
- output = convert_string input, backend: 'docbook45'
- assert_xpath '/article/articleinfo', output, 1
- assert_xpath '/article/articleinfo/title[text() = "AsciiDoc"]', output, 1
- assert_xpath '/article/articleinfo/date[text() = "2012-07-12"]', output, 1
- assert_xpath '/article/articleinfo/author/firstname[text() = "Stuart"]', output, 1
- assert_xpath '/article/articleinfo/author/surname[text() = "Rackham"]', output, 1
- assert_xpath '/article/articleinfo/author/email[text() = "founder@asciidoc.org"]', output, 1
- assert_xpath '/article/articleinfo/revhistory', output, 1
- assert_xpath '/article/articleinfo/revhistory/revision', output, 1
- assert_xpath '/article/articleinfo/revhistory/revision/revnumber[text() = "8.6.8"]', output, 1
- assert_xpath '/article/articleinfo/revhistory/revision/date[text() = "2012-07-12"]', output, 1
- assert_xpath '/article/articleinfo/revhistory/revision/authorinitials[text() = "SR"]', output, 1
- assert_xpath '/article/articleinfo/revhistory/revision/revremark[text() = "See changelog."]', output, 1
- article = xmlnodes_at_xpath '/article', output, 1
- # nokogiri can't make up its mind
- id_attr = article.attribute('id') || article.attribute('xml:id')
- assert_nil id_attr
- end
-
- test 'with metadata to DocBook5' do
+ test 'with metadata to DocBook 5' do
input = <<-EOS
= AsciiDoc
Stuart Rackham <founder@asciidoc.org>
@@ -847,30 +804,13 @@ more info...
EOS
output = convert_string input, backend: 'docbook5'
assert_xpath '/article/info', output, 1
- assert_xpath '/article/info/title[text() = "AsciiDoc"]', output, 1
+ assert_xpath '/article/info/title[text()="AsciiDoc"]', output, 1
assert_xpath '/article/info/author/personname', output, 1
- assert_xpath '/article/info/author/personname/firstname[text() = "Stuart"]', output, 1
- assert_xpath '/article/info/author/personname/surname[text() = "Rackham"]', output, 1
- assert_xpath '/article/info/author/email[text() = "founder@asciidoc.org"]', output, 1
- article = xmlnodes_at_xpath '/article', output, 1
- # nokogiri can't make up its mind
- id_attr = article.attribute('id') || article.attribute('xml:id')
- assert_nil id_attr
- end
-
- test 'with document ID to Docbook 4.5' do
- input = <<-EOS
-[[document-id]]
-= Document Title
-
-more info...
- EOS
- output = convert_string input, backend: 'docbook45'
- article = xmlnodes_at_xpath '/article', output, 1
- # nokogiri can't make up its mind
- id_attr = article.attribute('id') || article.attribute('xml:id')
- refute_nil id_attr
- assert_equal 'document-id', id_attr.value
+ assert_xpath '/article/info/author/personname/firstname[text()="Stuart"]', output, 1
+ assert_xpath '/article/info/author/personname/surname[text()="Rackham"]', output, 1
+ assert_xpath '/article/info/author/email[text()="founder@asciidoc.org"]', output, 1
+ assert_css 'article:root:not([xml|id])', output, 1
+ assert_css 'article:root[xml|lang="en"]', output, 1
end
test 'with document ID to Docbook 5' do
@@ -881,14 +821,10 @@ more info...
more info...
EOS
output = convert_string input, backend: 'docbook', keep_namespaces: true
- article = xmlnodes_at_xpath '/xmlns:article', output, 1
- # nokogiri can't make up its mind
- id_attr = article.attribute('id') || article.attribute('xml:id')
- refute_nil id_attr
- assert_equal 'document-id', id_attr.value
+ assert_css 'article:root[xml|id="document-id"]', output, 1
end
- test 'with author defined using attribute entry to DocBook 4.5' do
+ test 'with author defined using attribute entry to DocBook' do
input = <<-EOS
= Document Title
:author: Doc Writer
@@ -897,12 +833,12 @@ more info...
content
EOS
- output = convert_string input, backend: 'docbook45'
- assert_xpath '//articleinfo/author', output, 1
- assert_xpath '//articleinfo/author/firstname[text() = "Doc"]', output, 1
- assert_xpath '//articleinfo/author/surname[text() = "Writer"]', output, 1
- assert_xpath '//articleinfo/author/email[text() = "thedoctor@asciidoc.org"]', output, 1
- assert_xpath '//articleinfo/authorinitials[text() = "DW"]', output, 1
+ output = convert_string input, backend: 'docbook'
+ assert_xpath '/article/info/author', output, 1
+ assert_xpath '/article/info/author/personname/firstname[text()="Doc"]', output, 1
+ assert_xpath '/article/info/author/personname/surname[text()="Writer"]', output, 1
+ assert_xpath '/article/info/author/email[text()="thedoctor@asciidoc.org"]', output, 1
+ assert_xpath '/article/info/authorinitials[text()="DW"]', output, 1
end
test 'should sanitize content of HTML meta authors tag' do
@@ -958,12 +894,12 @@ Doc Writer <thedoctor@asciidoc.org>; Junior Writer <junior@asciidoctor.org>
content
EOS
- output = convert_string input, backend: 'docbook45'
- assert_xpath '//articleinfo/author', output, 0
- assert_xpath '//articleinfo/authorgroup', output, 1
- assert_xpath '//articleinfo/authorgroup/author', output, 2
- assert_xpath '//articleinfo/authorgroup/author[1]/firstname[text() = "Doc"]', output, 1
- assert_xpath '//articleinfo/authorgroup/author[2]/firstname[text() = "Junior"]', output, 1
+ output = convert_string input, backend: 'docbook'
+ assert_xpath '/article/info/author', output, 0
+ assert_xpath '/article/info/authorgroup', output, 1
+ assert_xpath '/article/info/authorgroup/author', output, 2
+ assert_xpath '(/article/info/authorgroup/author)[1]/personname/firstname[text()="Doc"]', output, 1
+ assert_xpath '(/article/info/authorgroup/author)[2]/personname/firstname[text()="Junior"]', output, 1
end
test 'with author defined by indexed attribute name' do
@@ -989,14 +925,14 @@ content
content
EOS
- output = convert_string input, backend: 'docbook45'
- assert_xpath '//articleinfo/author', output, 0
- assert_xpath '//articleinfo/authorgroup', output, 1
- assert_xpath '//articleinfo/authorgroup/author', output, 2
- assert_xpath '(//articleinfo/authorgroup/author)[1]/firstname[text() = "Doc"]', output, 1
- assert_xpath '(//articleinfo/authorgroup/author)[1]/email[text() = "thedoctor@asciidoc.org"]', output, 1
- assert_xpath '(//articleinfo/authorgroup/author)[2]/firstname[text() = "Junior"]', output, 1
- assert_xpath '(//articleinfo/authorgroup/author)[2]/email[text() = "junior@asciidoc.org"]', output, 1
+ output = convert_string input, backend: 'docbook'
+ assert_xpath '/article/info/author', output, 0
+ assert_xpath '/article/info/authorgroup', output, 1
+ assert_xpath '/article/info/authorgroup/author', output, 2
+ assert_xpath '(/article/info/authorgroup/author)[1]/personname/firstname[text()="Doc"]', output, 1
+ assert_xpath '(/article/info/authorgroup/author)[1]/email[text()="thedoctor@asciidoc.org"]', output, 1
+ assert_xpath '(/article/info/authorgroup/author)[2]/personname/firstname[text()="Junior"]', output, 1
+ assert_xpath '(/article/info/authorgroup/author)[2]/email[text()="junior@asciidoc.org"]', output, 1
end
test 'should populate copyright element in DocBook output if copyright attribute is defined' do
@@ -1220,16 +1156,16 @@ image::inner.png[]
result = convert_string("= Title\n\nparagraph", attributes: { 'backend' => 'html5' })
assert_xpath '/html', result, 1
assert_xpath '/html/body[@class="article"]', result, 1
- assert_xpath '/html//*[@id="header"]/h1[text() = "Title"]', result, 1
- assert_xpath '/html//*[@id="content"]//p[text() = "paragraph"]', result, 1
+ assert_xpath '/html//*[@id="header"]/h1[text()="Title"]', result, 1
+ assert_xpath '/html//*[@id="content"]//p[text()="paragraph"]', result, 1
end
test 'html5 backend doctype book' do
result = convert_string("= Title\n\nparagraph", attributes: { 'backend' => 'html5', 'doctype' => 'book' })
assert_xpath '/html', result, 1
assert_xpath '/html/body[@class="book"]', result, 1
- assert_xpath '/html//*[@id="header"]/h1[text() = "Title"]', result, 1
- assert_xpath '/html//*[@id="content"]//p[text() = "paragraph"]', result, 1
+ assert_xpath '/html//*[@id="header"]/h1[text()="Title"]', result, 1
+ assert_xpath '/html//*[@id="content"]//p[text()="paragraph"]', result, 1
end
test 'xhtml5 backend should map to html5 and set htmlsyntax to xml' do
@@ -1348,116 +1284,23 @@ two
content
EOS
result = convert_string input, safe: :safe, backend: :xhtml, keep_namespaces: true
- assert_xpath '//*[not(namespace-uri() = "http://www.w3.org/1999/xhtml")]', result, 0
+ assert_xpath '//*[not(namespace-uri()="http://www.w3.org/1999/xhtml")]', result, 0
end
- test 'docbook45 backend doctype article' do
- input = <<-EOS
-= Title
-
-preamble
-
-== First Section
-
-section body
- EOS
- result = convert_string(input, attributes: { 'backend' => 'docbook45' })
- assert_xpath '/article', result, 1
- assert_xpath '/article/articleinfo/title[text() = "Title"]', result, 1
- assert_xpath '/article/simpara[text() = "preamble"]', result, 1
- assert_xpath '/article/section', result, 1
- assert_xpath '/article/section[@id = "_first_section"]/title[text() = "First Section"]', result, 1
- assert_xpath '/article/section[@id = "_first_section"]/simpara[text() = "section body"]', result, 1
- end
-
- test 'docbook45 backend doctype article no title' do
- result = convert_string('text', attributes: { 'backend' => 'docbook45' })
- assert_xpath '/article', result, 1
- assert_xpath '/article/articleinfo/date', result, 1
- assert_xpath '/article/simpara[text() = "text"]', result, 1
- end
-
- test 'docbook45 backend doctype article no xmlns' do
- result = convert_string('text', keep_namespaces: true, attributes: { 'backend' => 'docbook45', 'doctype' => 'article' })
- refute_match(RE_XMLNS_ATTRIBUTE, result)
- end
-
- test 'docbook45 backend doctype manpage' do
- input = <<-EOS
-= asciidoctor(1)
-
-== NAME
-
-asciidoctor - Process text
-
-== SYNOPSIS
-
-some text
-
-== First Section
-
-section body
- EOS
- result = convert_string(input, attributes: { 'backend' => 'docbook45', 'doctype' => 'manpage' })
- assert_xpath '/refentry', result, 1
- assert_xpath '/refentry/refentryinfo/title[text() = "asciidoctor(1)"]', result, 1
- assert_xpath '/refentry/refmeta/refentrytitle[text() = "asciidoctor"]', result, 1
- assert_xpath '/refentry/refmeta/manvolnum[text() = "1"]', result, 1
- assert_xpath '/refentry/refnamediv/refname[text() = "asciidoctor"]', result, 1
- assert_xpath '/refentry/refnamediv/refpurpose[text() = "Process text"]', result, 1
- assert_xpath '/refentry/refsynopsisdiv', result, 1
- assert_xpath '/refentry/refsynopsisdiv/simpara[text() = "some text"]', result, 1
- assert_xpath '/refentry/refsection', result, 1
- assert_xpath '/refentry/refsection[@id = "_first_section"]/title[text() = "First Section"]', result, 1
- assert_xpath '/refentry/refsection[@id = "_first_section"]/simpara[text() = "section body"]', result, 1
- end
-
- test 'docbook45 backend doctype book' do
- input = <<-EOS
-= Title
-
-preamble
-
-== First Chapter
-
-chapter body
- EOS
- result = convert_string(input, attributes: { 'backend' => 'docbook45', 'doctype' => 'book' })
- assert_xpath '/book', result, 1
- assert_xpath '/book/bookinfo/title[text() = "Title"]', result, 1
- assert_xpath '/book/preface/simpara[text() = "preamble"]', result, 1
- assert_xpath '/book/chapter', result, 1
- assert_xpath '/book/chapter[@id = "_first_chapter"]/title[text() = "First Chapter"]', result, 1
- assert_xpath '/book/chapter[@id = "_first_chapter"]/simpara[text() = "chapter body"]', result, 1
- end
-
- test 'docbook45 backend doctype book no title' do
- result = convert_string('text', attributes: { 'backend' => 'docbook45', 'doctype' => 'book' })
- assert_xpath '/book', result, 1
- assert_xpath '/book/bookinfo/date', result, 1
- # NOTE simpara cannot be a direct child of book, so content must be treated as a preface
- assert_xpath '/book/preface/simpara[text() = "text"]', result, 1
- end
-
- test 'docbook45 backend doctype book no xmlns' do
- result = convert_string('text', keep_namespaces: true, attributes: { 'backend' => 'docbook45', 'doctype' => 'book' })
- refute_match(RE_XMLNS_ATTRIBUTE, result)
- end
-
- test 'docbook45 backend parses out subtitle' do
+ test 'should parse out subtitle when backend is DocBook' do
input = <<-EOS
= Document Title: Subtitle
:doctype: book
text
EOS
- result = convert_string input, backend: 'docbook45'
+ result = convert_string input, backend: 'docbook5'
assert_xpath '/book', result, 1
- assert_xpath '/book/bookinfo/title[text() = "Document Title"]', result, 1
- assert_xpath '/book/bookinfo/subtitle[text() = "Subtitle"]', result, 1
+ assert_xpath '/book/info/title[text()="Document Title"]', result, 1
+ assert_xpath '/book/info/subtitle[text()="Subtitle"]', result, 1
end
- test 'docbook5 backend doctype article' do
+ test 'should be able to set doctype to article when converting to DocBoook' do
input = <<-EOS
= Title
Author Name
@@ -1474,19 +1317,21 @@ section body
assert_equal 'http://docbook.org/ns/docbook', doc.namespaces['xmlns']
assert_equal 'http://www.w3.org/1999/xlink', doc.namespaces['xmlns:xl']
assert_xpath '/xmlns:article[@version="5.0"]', result, 1
- assert_xpath '/xmlns:article/xmlns:info/xmlns:title[text() = "Title"]', result, 1
- assert_xpath '/xmlns:article/xmlns:simpara[text() = "preamble"]', result, 1
+ assert_xpath '/xmlns:article/xmlns:info/xmlns:title[text()="Title"]', result, 1
+ assert_xpath '/xmlns:article/xmlns:simpara[text()="preamble"]', result, 1
assert_xpath '/xmlns:article/xmlns:section', result, 1
- section = xmlnodes_at_xpath('/xmlns:article/xmlns:section', result, 1)
- # nokogiri can't make up its mind
- id_attr = section.attribute('id') || section.attribute('xml:id')
- refute_nil id_attr
- refute_nil id_attr.namespace
- assert_equal 'xml', id_attr.namespace.prefix
- assert_equal '_first_section', id_attr.value
+ assert_css 'article:root > section[xml|id="_first_section"]', result, 1
end
- test 'docbook5 backend doctype manpage' do
+ test 'should set doctype to article by default for document with no title when converting to DocBoook' do
+ result = convert_string('text', attributes: { 'backend' => 'docbook' })
+ assert_xpath '/article', result, 1
+ assert_xpath '/article/info/title', result, 1
+ assert_xpath '/article/info/title[text()="Untitled"]', result, 1
+ assert_xpath '/article/info/date', result, 1
+ end
+
+ test 'should be able to convert DocBook manpage output when backend is DocBook and doctype is manpage' do
input = <<-EOS
= asciidoctor(1)
:mansource: Asciidoctor
@@ -1510,26 +1355,20 @@ section body
assert_equal 'http://docbook.org/ns/docbook', doc.namespaces['xmlns']
assert_equal 'http://www.w3.org/1999/xlink', doc.namespaces['xmlns:xl']
assert_xpath '/xmlns:refentry[@version="5.0"]', result, 1
- assert_xpath '/xmlns:refentry/xmlns:info/xmlns:title[text() = "asciidoctor(1)"]', result, 1
- assert_xpath '/xmlns:refentry/xmlns:refmeta/xmlns:refentrytitle[text() = "asciidoctor"]', result, 1
- assert_xpath '/xmlns:refentry/xmlns:refmeta/xmlns:manvolnum[text() = "1"]', result, 1
- assert_xpath '/xmlns:refentry/xmlns:refmeta/xmlns:refmiscinfo[@class="source"][text() = "Asciidoctor"]', result, 1
- assert_xpath '/xmlns:refentry/xmlns:refmeta/xmlns:refmiscinfo[@class="manual"][text() = "Asciidoctor Manual"]', result, 1
- assert_xpath '/xmlns:refentry/xmlns:refnamediv/xmlns:refname[text() = "asciidoctor"]', result, 1
- assert_xpath '/xmlns:refentry/xmlns:refnamediv/xmlns:refpurpose[text() = "Process text"]', result, 1
+ assert_xpath '/xmlns:refentry/xmlns:info/xmlns:title[text()="asciidoctor(1)"]', result, 1
+ assert_xpath '/xmlns:refentry/xmlns:refmeta/xmlns:refentrytitle[text()="asciidoctor"]', result, 1
+ assert_xpath '/xmlns:refentry/xmlns:refmeta/xmlns:manvolnum[text()="1"]', result, 1
+ assert_xpath '/xmlns:refentry/xmlns:refmeta/xmlns:refmiscinfo[@class="source"][text()="Asciidoctor"]', result, 1
+ assert_xpath '/xmlns:refentry/xmlns:refmeta/xmlns:refmiscinfo[@class="manual"][text()="Asciidoctor Manual"]', result, 1
+ assert_xpath '/xmlns:refentry/xmlns:refnamediv/xmlns:refname[text()="asciidoctor"]', result, 1
+ assert_xpath '/xmlns:refentry/xmlns:refnamediv/xmlns:refpurpose[text()="Process text"]', result, 1
assert_xpath '/xmlns:refentry/xmlns:refsynopsisdiv', result, 1
- assert_xpath '/xmlns:refentry/xmlns:refsynopsisdiv/xmlns:simpara[text() = "some text"]', result, 1
+ assert_xpath '/xmlns:refentry/xmlns:refsynopsisdiv/xmlns:simpara[text()="some text"]', result, 1
assert_xpath '/xmlns:refentry/xmlns:refsection', result, 1
- section = xmlnodes_at_xpath('/xmlns:refentry/xmlns:refsection', result, 1)
- # nokogiri can't make up its mind
- id_attr = section.attribute('id') || section.attribute('xml:id')
- refute_nil id_attr
- refute_nil id_attr.namespace
- assert_equal 'xml', id_attr.namespace.prefix
- assert_equal '_first_section', id_attr.value
+ assert_css 'refentry:root > refsection[xml|id="_first_section"]', result, 1
end
- test 'should output non-breaking space for source and manual in docbook5 manpage output if absent from source' do
+ test 'should output non-breaking space for source and manual in docbook manpage output if absent from source' do
input = <<-EOS
= asciidoctor(1)
@@ -1542,11 +1381,11 @@ asciidoctor - Process text
some text
EOS
result = convert_string(input, keep_namespaces: true, attributes: { 'backend' => 'docbook5', 'doctype' => 'manpage' })
- assert_xpath %(/xmlns:refentry/xmlns:refmeta/xmlns:refmiscinfo[@class="source"][text() = "#{decode_char 160}"]), result, 1
- assert_xpath %(/xmlns:refentry/xmlns:refmeta/xmlns:refmiscinfo[@class="manual"][text() = "#{decode_char 160}"]), result, 1
+ assert_xpath %(/xmlns:refentry/xmlns:refmeta/xmlns:refmiscinfo[@class="source"][text()="#{decode_char 160}"]), result, 1
+ assert_xpath %(/xmlns:refentry/xmlns:refmeta/xmlns:refmiscinfo[@class="manual"][text()="#{decode_char 160}"]), result, 1
end
- test 'docbook5 backend doctype book' do
+ test 'should be able to set doctype to book when converting to DocBoook' do
input = <<-EOS
= Title
Author Name
@@ -1563,16 +1402,18 @@ chapter body
assert_equal 'http://docbook.org/ns/docbook', doc.namespaces['xmlns']
assert_equal 'http://www.w3.org/1999/xlink', doc.namespaces['xmlns:xl']
assert_xpath '/xmlns:book[@version="5.0"]', result, 1
- assert_xpath '/xmlns:book/xmlns:info/xmlns:title[text() = "Title"]', result, 1
- assert_xpath '/xmlns:book/xmlns:preface/xmlns:simpara[text() = "preamble"]', result, 1
+ assert_xpath '/xmlns:book/xmlns:info/xmlns:title[text()="Title"]', result, 1
+ assert_xpath '/xmlns:book/xmlns:preface/xmlns:simpara[text()="preamble"]', result, 1
assert_xpath '/xmlns:book/xmlns:chapter', result, 1
- chapter = xmlnodes_at_xpath('/xmlns:book/xmlns:chapter', result, 1)
- # nokogiri can't make up its mind
- id_attr = chapter.attribute('id') || chapter.attribute('xml:id')
- refute_nil id_attr
- refute_nil id_attr.namespace
- assert_equal 'xml', id_attr.namespace.prefix
- assert_equal '_first_chapter', id_attr.value
+ assert_css 'book:root > chapter[xml|id="_first_chapter"]', result, 1
+ end
+
+ test 'should be able to set doctype to book for document with no title when converting to DocBoook' do
+ result = convert_string('text', attributes: { 'backend' => 'docbook5', 'doctype' => 'book' })
+ assert_xpath '/book', result, 1
+ assert_xpath '/book/info/date', result, 1
+ # NOTE simpara cannot be a direct child of book, so content must be treated as a preface
+ assert_xpath '/book/preface/simpara[text()="text"]', result, 1
end
test 'adds refname to DocBook output for each name defined in NAME section of manpage' do
@@ -1627,7 +1468,7 @@ chapter body
end
test ':backend option should override backend attribute' do
- doc = empty_document backend: 'html5', attributes: { 'backend' => 'docbook45' }
+ doc = empty_document backend: 'html5', attributes: { 'backend' => 'docbook5' }
assert_equal 'html5', doc.attributes['backend']
end
@@ -1649,8 +1490,8 @@ Stuart Rackham <founder@asciidoc.org>
more info...
EOS
- output = convert_string input, attributes: { 'backend' => 'docbook45' }
- assert_xpath '/article/articleinfo/authorinitials[text()="SJR"]', output, 1
+ output = convert_string input, attributes: { 'backend' => 'docbook5' }
+ assert_xpath '/article/info/authorinitials[text()="SJR"]', output, 1
end
test 'attribute entry can appear immediately after document title' do
diff --git a/test/fixtures/custom-backends/haml/docbook45/block_paragraph.xml.haml b/test/fixtures/custom-backends/haml/docbook45/block_paragraph.xml.haml
deleted file mode 100644
index bd1cc356..00000000
--- a/test/fixtures/custom-backends/haml/docbook45/block_paragraph.xml.haml
+++ /dev/null
@@ -1,6 +0,0 @@
-- if title?
- %formalpara{:id=>@id, :role=>(attr :role), :xreflabel=>(attr :reftext)}
- %title=title
- %para=content
-- else
- %para{:id=>@id, :role=>(attr :role), :xreflabel=>(attr :reftext)}=content
diff --git a/test/fixtures/custom-backends/haml/docbook5/block_paragraph.xml.haml b/test/fixtures/custom-backends/haml/docbook5/block_paragraph.xml.haml
new file mode 100644
index 00000000..68c788ae
--- /dev/null
+++ b/test/fixtures/custom-backends/haml/docbook5/block_paragraph.xml.haml
@@ -0,0 +1,6 @@
+- if title?
+ %formalpara{'xml:id'=>@id, role: (attr :role), xreflabel: (attr :reftext)}
+ %title=title
+ %para=content
+- else
+ %para{'xml:id'=>@id, role: (attr :role), xreflabel: (attr :reftext)}=content
diff --git a/test/fixtures/custom-backends/haml/html5/block_paragraph.html.haml b/test/fixtures/custom-backends/haml/html5/block_paragraph.html.haml
index 854f5856..893feef3 100644
--- a/test/fixtures/custom-backends/haml/html5/block_paragraph.html.haml
+++ b/test/fixtures/custom-backends/haml/html5/block_paragraph.html.haml
@@ -1,3 +1,3 @@
- if title?
.title=title
-%p{:id=>@id, :class=>(attr 'role')}=content
+%p{id: @id, class: (attr 'role')}=content
diff --git a/test/fixtures/custom-backends/haml/html5/block_sidebar.html.haml b/test/fixtures/custom-backends/haml/html5/block_sidebar.html.haml
index ae3f00dd..4a0f087e 100644
--- a/test/fixtures/custom-backends/haml/html5/block_sidebar.html.haml
+++ b/test/fixtures/custom-backends/haml/html5/block_sidebar.html.haml
@@ -1,4 +1,4 @@
-%aside{:id=>@id, :class=>(attr 'role')}
+%aside{id: @id, class: (attr 'role')}
- if title?
%header
%h1=title
diff --git a/test/fixtures/custom-backends/slim/docbook45/block_paragraph.xml.slim b/test/fixtures/custom-backends/slim/docbook45/block_paragraph.xml.slim
deleted file mode 100644
index 96ddb558..00000000
--- a/test/fixtures/custom-backends/slim/docbook45/block_paragraph.xml.slim
+++ /dev/null
@@ -1,6 +0,0 @@
-- if title?
- formalpara id=@id role=(attr :role) xreflabel=(attr :reftext)
- title=title
- para=content
-- else
- para id=@id role=(attr :role) xreflabel=(attr :reftext) =content
diff --git a/test/fixtures/custom-backends/slim/docbook5/block_paragraph.xml.slim b/test/fixtures/custom-backends/slim/docbook5/block_paragraph.xml.slim
new file mode 100644
index 00000000..ddab195b
--- /dev/null
+++ b/test/fixtures/custom-backends/slim/docbook5/block_paragraph.xml.slim
@@ -0,0 +1,6 @@
+- if title?
+ formalpara xml:id=@id role=(attr :role) xreflabel=(attr :reftext)
+ title=title
+ para=content
+- else
+ para xml:id=@id role=(attr :role) xreflabel=(attr :reftext) =content
diff --git a/test/fixtures/docinfo-footer.xml b/test/fixtures/docinfo-footer.xml
index da2f4923..cbe0acba 100644
--- a/test/fixtures/docinfo-footer.xml
+++ b/test/fixtures/docinfo-footer.xml
@@ -1,4 +1,4 @@
-<glossary id="_glossary">
+<glossary xml:id="_glossary">
<title>Glossary</title>
<glossentry>
<glossterm>term</glossterm>
diff --git a/test/invoker_test.rb b/test/invoker_test.rb
index 9db5b5ed..ae282194 100644
--- a/test/invoker_test.rb
+++ b/test/invoker_test.rb
@@ -486,10 +486,10 @@ context 'Invoker' do
assert_xpath '/html', output, 1
end
- test 'should set backend to docbook45 if specified' do
- invoker = invoke_cli_to_buffer %w(-b docbook45 -a xmlns -o -)
+ test 'should set backend to docbook5 if specified' do
+ invoker = invoke_cli_to_buffer %w(-b docbook5 -a xmlns -o -)
doc = invoker.document
- assert_equal 'docbook45', doc.attr('backend')
+ assert_equal 'docbook5', doc.attr('backend')
assert_equal '.xml', doc.attr('outfilesuffix')
output = invoker.read_output
assert_xpath '/xmlns:article', output, 1
diff --git a/test/links_test.rb b/test/links_test.rb
index d30ca341..8f2c3b17 100644
--- a/test/links_test.rb
+++ b/test/links_test.rb
@@ -61,8 +61,6 @@ context 'Links' do
assert_match '<a href="http://example.com">[bracket1]</a>', doc.convert, 1
doc = document_from_string str, header_footer: false, backend: 'docbook', doctype: 'inline'
assert_match '<link xl:href="http://example.com">[bracket1]</link>', doc.convert, 1
- doc = document_from_string str, header_footer: false, backend: 'docbook45', doctype: 'inline'
- assert_match '<ulink url="http://example.com">[bracket1]</ulink>', doc.convert, 1
end
test 'link macro with empty target' do
@@ -337,12 +335,12 @@ context 'Links' do
test 'inline ref with reftext converted to DocBook' do
%w([[tigers,<Tigers>]] anchor:tigers[<Tigers>]).each do |anchor|
- doc = document_from_string %(Here you can read about tigers.#{anchor}), backend: :docbook45
+ doc = document_from_string %(Here you can read about tigers.#{anchor}), backend: :docbook
output = doc.convert header_footer: false
assert_kind_of Asciidoctor::Inline, doc.catalog[:refs]['tigers']
assert_equal '<Tigers>', doc.catalog[:refs]['tigers'].text
assert_equal '<Tigers>', doc.references[:ids]['tigers']
- assert_includes output, '<anchor id="tigers" xreflabel="&lt;Tigers&gt;"/>'
+ assert_includes output, '<anchor xml:id="tigers" xreflabel="&lt;Tigers&gt;"/>'
end
end
@@ -446,8 +444,6 @@ anchor:foo[b[a\]r]text'
test 'xref using angled bracket syntax with path sans extension using docbook backend' do
doc = document_from_string '<<tigers#>>', header_footer: false, backend: 'docbook'
assert_match '<link xl:href="tigers.xml">tigers.xml</link>', doc.convert, 1
- doc = document_from_string '<<tigers#>>', header_footer: false, backend: 'docbook45'
- assert_match '<ulink url="tigers.xml">tigers.xml</ulink>', doc.convert, 1
end
test 'xref using angled bracket syntax with ancestor path sans extension' do
diff --git a/test/lists_test.rb b/test/lists_test.rb
index c1f798b0..38d0b83e 100644
--- a/test/lists_test.rb
+++ b/test/lists_test.rb
@@ -1956,21 +1956,6 @@ List
assert_xpath '(//ol)[2]/li', output, 1
end
- test 'should use start number in docbook4.5 backend' do
- input = <<-EOS
-== List
-
-[start=7]
-. item 7
-. item 8
- EOS
-
- output = convert_string_to_embedded input, backend: 'docbook45'
- assert_xpath '//orderedlist', output, 1
- assert_xpath '(//orderedlist)/listitem', output, 2
- assert_xpath '(//orderedlist/listitem)[1][@override = "7"]', output, 1
- end
-
test 'should use start number in docbook5 backend' do
input = <<-EOS
== List
@@ -4343,12 +4328,12 @@ puts doc.convert # <3>
<2> Describe the second line
<3> Describe the third line
EOS
- output = convert_string input, attributes: { 'backend' => 'docbook45' }
+ output = convert_string input, attributes: { 'backend' => 'docbook' }
assert_xpath '//programlisting', output, 1
assert_xpath '//programlisting//co', output, 3
- assert_xpath '(//programlisting//co)[1][@id = "CO1-1"]', output, 1
- assert_xpath '(//programlisting//co)[2][@id = "CO1-2"]', output, 1
- assert_xpath '(//programlisting//co)[3][@id = "CO1-3"]', output, 1
+ assert_xpath '(//programlisting//co)[1][@xml:id="CO1-1"]', output, 1
+ assert_xpath '(//programlisting//co)[2][@xml:id="CO1-2"]', output, 1
+ assert_xpath '(//programlisting//co)[3][@xml:id="CO1-3"]', output, 1
assert_xpath '//programlisting/following-sibling::calloutlist/callout', output, 3
assert_xpath '(//programlisting/following-sibling::calloutlist/callout)[1][@arearefs = "CO1-1"]', output, 1
assert_xpath '(//programlisting/following-sibling::calloutlist/callout)[2][@arearefs = "CO1-2"]', output, 1
@@ -4370,12 +4355,12 @@ Paragraph.
<2> Describe the second line
<3> Describe the third line
EOS
- output = convert_string input, attributes: { 'backend' => 'docbook45' }
+ output = convert_string input, attributes: { 'backend' => 'docbook' }
assert_xpath '//programlisting', output, 1
assert_xpath '//programlisting//co', output, 3
- assert_xpath '(//programlisting//co)[1][@id = "CO1-1"]', output, 1
- assert_xpath '(//programlisting//co)[2][@id = "CO1-2"]', output, 1
- assert_xpath '(//programlisting//co)[3][@id = "CO1-3"]', output, 1
+ assert_xpath '(//programlisting//co)[1][@xml:id="CO1-1"]', output, 1
+ assert_xpath '(//programlisting//co)[2][@xml:id="CO1-2"]', output, 1
+ assert_xpath '(//programlisting//co)[3][@xml:id="CO1-3"]', output, 1
assert_xpath '//programlisting/following-sibling::*[1][self::simpara]', output, 1
assert_xpath '//programlisting/following-sibling::calloutlist/callout', output, 3
assert_xpath '(//programlisting/following-sibling::calloutlist/callout)[1][@arearefs = "CO1-1"]', output, 1
@@ -4394,12 +4379,12 @@ puts doc.convert # <2>
<1> Import the library
<2> Where the magic happens
EOS
- output = convert_string input, attributes: { 'backend' => 'docbook45' }
+ output = convert_string input, attributes: { 'backend' => 'docbook' }
assert_xpath '//programlisting', output, 1
assert_xpath '//programlisting//co', output, 3
- assert_xpath '(//programlisting//co)[1][@id = "CO1-1"]', output, 1
- assert_xpath '(//programlisting//co)[2][@id = "CO1-2"]', output, 1
- assert_xpath '(//programlisting//co)[3][@id = "CO1-3"]', output, 1
+ assert_xpath '(//programlisting//co)[1][@xml:id="CO1-1"]', output, 1
+ assert_xpath '(//programlisting//co)[2][@xml:id="CO1-2"]', output, 1
+ assert_xpath '(//programlisting//co)[3][@xml:id="CO1-3"]', output, 1
assert_xpath '//programlisting/following-sibling::calloutlist/callout', output, 2
assert_xpath '(//programlisting/following-sibling::calloutlist/callout)[1][@arearefs = "CO1-1"]', output, 1
assert_xpath '(//programlisting/following-sibling::calloutlist/callout)[2][@arearefs = "CO1-2 CO1-3"]', output, 1
@@ -4417,12 +4402,12 @@ puts doc.convert # <1>
<2> Describe the second line
<3> Describe the third line
EOS
- output = convert_string input, attributes: { 'backend' => 'docbook45' }
+ output = convert_string input, attributes: { 'backend' => 'docbook' }
assert_xpath '//programlisting', output, 1
assert_xpath '//programlisting//co', output, 3
- assert_xpath '(//programlisting//co)[1][@id = "CO1-1"]', output, 1
- assert_xpath '(//programlisting//co)[2][@id = "CO1-2"]', output, 1
- assert_xpath '(//programlisting//co)[3][@id = "CO1-3"]', output, 1
+ assert_xpath '(//programlisting//co)[1][@xml:id="CO1-1"]', output, 1
+ assert_xpath '(//programlisting//co)[2][@xml:id="CO1-2"]', output, 1
+ assert_xpath '(//programlisting//co)[3][@xml:id="CO1-3"]', output, 1
assert_xpath '//programlisting/following-sibling::calloutlist/callout', output, 3
assert_xpath '(//programlisting/following-sibling::calloutlist/callout)[1][@arearefs = "CO1-3"]', output, 1
assert_xpath '(//programlisting/following-sibling::calloutlist/callout)[2][@arearefs = "CO1-1"]', output, 1
@@ -4448,13 +4433,13 @@ puts doc.convert # <3>
<2> Describe the second line
<3> Describe the third line
EOS
- output = convert_string input, attributes: { 'backend' => 'docbook45' }
+ output = convert_string input, attributes: { 'backend' => 'docbook' }
assert_xpath '//programlisting', output, 2
assert_xpath '(//programlisting)[1]//co', output, 1
- assert_xpath '(//programlisting)[1]//co[@id = "CO1-1"]', output, 1
+ assert_xpath '(//programlisting)[1]//co[@xml:id="CO1-1"]', output, 1
assert_xpath '(//programlisting)[2]//co', output, 2
- assert_xpath '((//programlisting)[2]//co)[1][@id = "CO1-2"]', output, 1
- assert_xpath '((//programlisting)[2]//co)[2][@id = "CO1-3"]', output, 1
+ assert_xpath '((//programlisting)[2]//co)[1][@xml:id="CO1-2"]', output, 1
+ assert_xpath '((//programlisting)[2]//co)[2][@xml:id="CO1-3"]', output, 1
assert_xpath '(//calloutlist/callout)[1][@arearefs = "CO1-1"]', output, 1
assert_xpath '(//calloutlist/callout)[2][@arearefs = "CO1-2"]', output, 1
assert_xpath '(//calloutlist/callout)[3][@arearefs = "CO1-3"]', output, 1
@@ -4478,13 +4463,13 @@ puts doc.convert # <2>
<1> Describe the second line
<2> Describe the third line
EOS
- output = convert_string input, attributes: { 'backend' => 'docbook45' }
+ output = convert_string input, attributes: { 'backend' => 'docbook' }
assert_xpath '//programlisting', output, 2
assert_xpath '(//programlisting)[1]//co', output, 1
- assert_xpath '(//programlisting)[1]//co[@id = "CO1-1"]', output, 1
+ assert_xpath '(//programlisting)[1]//co[@xml:id="CO1-1"]', output, 1
assert_xpath '(//programlisting)[2]//co', output, 2
- assert_xpath '((//programlisting)[2]//co)[1][@id = "CO2-1"]', output, 1
- assert_xpath '((//programlisting)[2]//co)[2][@id = "CO2-2"]', output, 1
+ assert_xpath '((//programlisting)[2]//co)[1][@xml:id="CO2-1"]', output, 1
+ assert_xpath '((//programlisting)[2]//co)[2][@xml:id="CO2-2"]', output, 1
assert_xpath '//calloutlist', output, 2
assert_xpath '(//calloutlist)[1]/callout', output, 1
assert_xpath '((//calloutlist)[1]/callout)[1][@arearefs = "CO1-1"]', output, 1
@@ -4535,7 +4520,7 @@ as a RubyGem
+
You can write this to file rather than printing to stdout.
EOS
- output = convert_string input, attributes: { 'backend' => 'docbook45' }
+ output = convert_string input, attributes: { 'backend' => 'docbook' }
assert_xpath '//calloutlist', output, 1
assert_xpath '//calloutlist/callout', output, 3
assert_xpath '(//calloutlist/callout)[1]/*', output, 1
@@ -4817,11 +4802,11 @@ Violets are blue <2>
<1> And so is Ruby
<2> But violet is more like purple
EOS
- output = convert_string input, attributes: { 'backend' => 'docbook45' }
+ output = convert_string input, attributes: { 'backend' => 'docbook' }
assert_xpath '//literallayout', output, 1
assert_xpath '//literallayout//co', output, 2
- assert_xpath '(//literallayout//co)[1][@id = "CO1-1"]', output, 1
- assert_xpath '(//literallayout//co)[2][@id = "CO1-2"]', output, 1
+ assert_xpath '(//literallayout//co)[1][@xml:id="CO1-1"]', output, 1
+ assert_xpath '(//literallayout//co)[2][@xml:id="CO1-2"]', output, 1
assert_xpath '//literallayout/following-sibling::*[1][self::calloutlist]/callout', output, 2
assert_xpath '(//literallayout/following-sibling::*[1][self::calloutlist]/callout)[1][@arearefs = "CO1-1"]', output, 1
assert_xpath '(//literallayout/following-sibling::*[1][self::calloutlist]/callout)[2][@arearefs = "CO1-2"]', output, 1
diff --git a/test/paragraphs_test.rb b/test/paragraphs_test.rb
index d0a31a93..a58eb16c 100644
--- a/test/paragraphs_test.rb
+++ b/test/paragraphs_test.rb
@@ -151,7 +151,7 @@ context 'Paragraphs' do
Note that multi-entry terms generate separate index entries.
EOS
- output = convert_string_to_embedded input, attributes: { 'backend' => 'docbook45' }
+ output = convert_string_to_embedded input, attributes: { 'backend' => 'docbook' }
assert_xpath '/simpara', output, 1
term1 = xmlnodes_at_xpath '(//indexterm)[1]', output, 1
assert_equal '<indexterm><primary>tigers</primary></indexterm>', term1.to_s
diff --git a/test/sections_test.rb b/test/sections_test.rb
index 976e0a94..fa7b9eaa 100644
--- a/test/sections_test.rb
+++ b/test/sections_test.rb
@@ -2426,33 +2426,33 @@ Colophon content
= Index Title
EOS
- output = convert_string_to_embedded input, backend: 'docbook45'
- assert_xpath '/chapter[@id="abstract_title"]', output, 1
- assert_xpath '/chapter[@id="abstract_title"]/title[text()="Abstract Title"]', output, 1
- assert_xpath '/chapter/following-sibling::dedication[@id="dedication_title"]', output, 1
- assert_xpath '/chapter/following-sibling::dedication[@id="dedication_title"]/title[text()="Dedication Title"]', output, 1
- assert_xpath '/dedication/following-sibling::preface[@id="preface_title"]', output, 1
- assert_xpath '/dedication/following-sibling::preface[@id="preface_title"]/title[text()="Preface Title"]', output, 1
- assert_xpath '/preface/section[@id="preface_sub_section"]', output, 1
- assert_xpath '/preface/section[@id="preface_sub_section"]/title[text()="Preface sub-section"]', output, 1
- assert_xpath '/preface/following-sibling::part[@id="part_1"]', output, 1
- assert_xpath '/preface/following-sibling::part[@id="part_1"]/title[text()="Part 1"]', output, 1
- assert_xpath '/part[@id="part_1"]/partintro', output, 1
- assert_xpath '/part[@id="part_1"]/partintro/title[text()="Part intro title"]', output, 1
- assert_xpath '/part[@id="part_1"]/partintro/following-sibling::chapter[@id="chapter_1"]', output, 1
- assert_xpath '/part[@id="part_1"]/partintro/following-sibling::chapter[@id="chapter_1"]/title[text()="Chapter 1"]', output, 1
- assert_xpath '(/part)[2]/following-sibling::appendix[@id="appendix_title"]', output, 1
- assert_xpath '(/part)[2]/following-sibling::appendix[@id="appendix_title"]/title[text()="Appendix Title"]', output, 1
- assert_xpath '/appendix/section[@id="appendix_sub_section"]', output, 1
- assert_xpath '/appendix/section[@id="appendix_sub_section"]/title[text()="Appendix sub-section"]', output, 1
- assert_xpath '/appendix/following-sibling::bibliography[@id="bibliography_title"]', output, 1
- assert_xpath '/appendix/following-sibling::bibliography[@id="bibliography_title"]/title[text()="Bibliography Title"]', output, 1
- assert_xpath '/bibliography/following-sibling::glossary[@id="glossary_title"]', output, 1
- assert_xpath '/bibliography/following-sibling::glossary[@id="glossary_title"]/title[text()="Glossary Title"]', output, 1
- assert_xpath '/glossary/following-sibling::colophon[@id="colophon_title"]', output, 1
- assert_xpath '/glossary/following-sibling::colophon[@id="colophon_title"]/title[text()="Colophon Title"]', output, 1
- assert_xpath '/colophon/following-sibling::index[@id="index_title"]', output, 1
- assert_xpath '/colophon/following-sibling::index[@id="index_title"]/title[text()="Index Title"]', output, 1
+ output = convert_string input, backend: 'docbook'
+ assert_xpath '/book/chapter[@xml:id="abstract_title"]', output, 1
+ assert_xpath '/book/chapter[@xml:id="abstract_title"]/title[text()="Abstract Title"]', output, 1
+ assert_xpath '/book/chapter/following-sibling::dedication[@xml:id="dedication_title"]', output, 1
+ assert_xpath '/book/chapter/following-sibling::dedication[@xml:id="dedication_title"]/title[text()="Dedication Title"]', output, 1
+ assert_xpath '/book/dedication/following-sibling::preface[@xml:id="preface_title"]', output, 1
+ assert_xpath '/book/dedication/following-sibling::preface[@xml:id="preface_title"]/title[text()="Preface Title"]', output, 1
+ assert_xpath '/book/preface/section[@xml:id="preface_sub_section"]', output, 1
+ assert_xpath '/book/preface/section[@xml:id="preface_sub_section"]/title[text()="Preface sub-section"]', output, 1
+ assert_xpath '/book/preface/following-sibling::part[@xml:id="part_1"]', output, 1
+ assert_xpath '/book/preface/following-sibling::part[@xml:id="part_1"]/title[text()="Part 1"]', output, 1
+ assert_xpath '/book/part[@xml:id="part_1"]/partintro', output, 1
+ assert_xpath '/book/part[@xml:id="part_1"]/partintro/title[text()="Part intro title"]', output, 1
+ assert_xpath '/book/part[@xml:id="part_1"]/partintro/following-sibling::chapter[@xml:id="chapter_1"]', output, 1
+ assert_xpath '/book/part[@xml:id="part_1"]/partintro/following-sibling::chapter[@xml:id="chapter_1"]/title[text()="Chapter 1"]', output, 1
+ assert_xpath '(/book/part)[2]/following-sibling::appendix[@xml:id="appendix_title"]', output, 1
+ assert_xpath '(/book/part)[2]/following-sibling::appendix[@xml:id="appendix_title"]/title[text()="Appendix Title"]', output, 1
+ assert_xpath '/book/appendix/section[@xml:id="appendix_sub_section"]', output, 1
+ assert_xpath '/book/appendix/section[@xml:id="appendix_sub_section"]/title[text()="Appendix sub-section"]', output, 1
+ assert_xpath '/book/appendix/following-sibling::bibliography[@xml:id="bibliography_title"]', output, 1
+ assert_xpath '/book/appendix/following-sibling::bibliography[@xml:id="bibliography_title"]/title[text()="Bibliography Title"]', output, 1
+ assert_xpath '/book/bibliography/following-sibling::glossary[@xml:id="glossary_title"]', output, 1
+ assert_xpath '/book/bibliography/following-sibling::glossary[@xml:id="glossary_title"]/title[text()="Glossary Title"]', output, 1
+ assert_xpath '/book/glossary/following-sibling::colophon[@xml:id="colophon_title"]', output, 1
+ assert_xpath '/book/glossary/following-sibling::colophon[@xml:id="colophon_title"]/title[text()="Colophon Title"]', output, 1
+ assert_xpath '/book/colophon/following-sibling::index[@xml:id="index_title"]', output, 1
+ assert_xpath '/book/colophon/following-sibling::index[@xml:id="index_title"]/title[text()="Index Title"]', output, 1
end
test 'abstract section maps to abstract element in docbook for article doctype' do
@@ -2466,9 +2466,9 @@ Colophon content
Abstract content
EOS
- output = convert_string_to_embedded input, backend: 'docbook45'
- assert_xpath '/abstract[@id="abstract_title"]', output, 1
- assert_xpath '/abstract[@id="abstract_title"]/title[text()="Abstract Title"]', output, 1
+ output = convert_string_to_embedded input, backend: 'docbook'
+ assert_xpath '/abstract[@xml:id="abstract_title"]', output, 1
+ assert_xpath '/abstract[@xml:id="abstract_title"]/title[text()="Abstract Title"]', output, 1
end
test 'should allow a special section to be nested at arbitrary depth in DocBook output' do
diff --git a/test/substitutions_test.rb b/test/substitutions_test.rb
index b7c85cbd..c1e0a86c 100644
--- a/test/substitutions_test.rb
+++ b/test/substitutions_test.rb
@@ -555,8 +555,8 @@ context 'Substitutions' do
end
test 'quoted text with id and role shorthand using docbook backend' do
- para = block_from_string(%q{[#bond.white.red-background]#007#}, backend: 'docbook45')
- assert_equal '<anchor id="bond" xreflabel="007"/><phrase role="white red-background">007</phrase>', para.sub_quotes(para.source)
+ para = block_from_string(%q{[#bond.white.red-background]#007#}, backend: 'docbook')
+ assert_equal '<anchor xml:id="bond" xreflabel="007"/><phrase role="white red-background">007</phrase>', para.sub_quotes(para.source)
end
test 'should ignore attributes after comma' do
diff --git a/test/tables_test.rb b/test/tables_test.rb
index b1bb0c27..6bc39ddd 100644
--- a/test/tables_test.rb
+++ b/test/tables_test.rb
@@ -1673,19 +1673,6 @@ context 'Tables' do
assert_css 'table > tbody > tr:nth-child(1) > td:nth-child(2) .listingblock', output, 1
end
- test 'table with breakable option docbook 4.5' do
- input = <<~'EOS'
- .Table with breakable
- [%breakable]
- |===
- |Item |Quantity
- |Item 1 |1
- |===
- EOS
- output = convert_string_to_embedded input, backend: 'docbook45'
- assert_includes output, '<?dbfo keep-together="auto"?>'
- end
-
test 'table with breakable option docbook 5' do
input = <<~'EOS'
.Table with breakable
@@ -1712,19 +1699,6 @@ context 'Tables' do
assert_includes output, '<?dbfo keep-together="always"?>'
end
- test 'table with unbreakable option docbook 4.5' do
- input = <<~'EOS'
- .Table with unbreakable
- [%unbreakable]
- |===
- |Item |Quantity
- |Item 1 |1
- |===
- EOS
- output = convert_string_to_embedded input, backend: 'docbook45'
- assert_includes output, '<?dbfo keep-together="always"?>'
- end
-
test 'no implicit header row if cell in first line is quoted and spans multiple lines' do
input = <<~'EOS'
[cols=2*l]
diff --git a/test/text_test.rb b/test/text_test.rb
index b8bf24b6..daa4a172 100644
--- a/test/text_test.rb
+++ b/test/text_test.rb
@@ -13,16 +13,16 @@ context "Text" do
assert_xpath '//a', output, 1
end
- test "proper encoding to handle utf8 characters in document using docbook45 backend" do
- output = example_document(:encoding, attributes: { 'backend' => 'docbook45', 'xmlns' => '' }).convert
+ test 'proper encoding to handle utf8 characters in document using docbook backend' do
+ output = example_document(:encoding, attributes: { 'backend' => 'docbook', 'xmlns' => '' }).convert
assert_xpath '//xmlns:simpara', output, 4
- assert_xpath '//xmlns:ulink', output, 1
+ assert_xpath '//xmlns:link', output, 1
end
- test "proper encoding to handle utf8 characters in embedded document using docbook45 backend" do
- output = example_document(:encoding, header_footer: false, attributes: { 'backend' => 'docbook45' }).convert
+ test 'proper encoding to handle utf8 characters in embedded document using docbook backend' do
+ output = example_document(:encoding, header_footer: false, attributes: { 'backend' => 'docbook' }).convert
assert_xpath '//simpara', output, 4
- assert_xpath '//ulink', output, 1
+ assert_xpath '//link', output, 1
end
# NOTE this test ensures we have the encoding line on block templates too