metanorma-standoc 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitattributes +4 -0
- data/.gitignore +11 -0
- data/.hound.yml +3 -0
- data/.oss-guides.rubocop.yml +1077 -0
- data/.rubocop.ribose.yml +66 -0
- data/.rubocop.tb.yml +650 -0
- data/.rubocop.yml +15 -0
- data/.travis.yml +21 -0
- data/CODE_OF_CONDUCT.md +46 -0
- data/Gemfile +7 -0
- data/LICENSE +25 -0
- data/Makefile +39 -0
- data/README.adoc +9 -0
- data/Rakefile +6 -0
- data/bin/rspec +18 -0
- data/docs/customisation.adoc +178 -0
- data/docs/guidance.adoc +436 -0
- data/docs/htmloutput.adoc +115 -0
- data/docs/quickstart.adoc +375 -0
- data/lib/asciidoctor/standoc/base.rb +198 -0
- data/lib/asciidoctor/standoc/biblio.rng +836 -0
- data/lib/asciidoctor/standoc/blocks.rb +190 -0
- data/lib/asciidoctor/standoc/cleanup.rb +247 -0
- data/lib/asciidoctor/standoc/cleanup_block.rb +193 -0
- data/lib/asciidoctor/standoc/cleanup_footnotes.rb +78 -0
- data/lib/asciidoctor/standoc/cleanup_ref.rb +125 -0
- data/lib/asciidoctor/standoc/converter.rb +55 -0
- data/lib/asciidoctor/standoc/front.rb +121 -0
- data/lib/asciidoctor/standoc/inline.rb +134 -0
- data/lib/asciidoctor/standoc/isodoc.rng +1059 -0
- data/lib/asciidoctor/standoc/lists.rb +87 -0
- data/lib/asciidoctor/standoc/macros.rb +95 -0
- data/lib/asciidoctor/standoc/ref.rb +187 -0
- data/lib/asciidoctor/standoc/section.rb +159 -0
- data/lib/asciidoctor/standoc/table.rb +61 -0
- data/lib/asciidoctor/standoc/utils.rb +121 -0
- data/lib/asciidoctor/standoc/validate.rb +65 -0
- data/lib/asciidoctor/standoc/validate_section.rb +42 -0
- data/lib/asciidoctor/standoc/version.rb +5 -0
- data/lib/metanorma-standoc.rb +9 -0
- data/lib/metanorma/standoc.rb +7 -0
- data/lib/metanorma/standoc/processor.rb +40 -0
- data/metanorma-standoc.gemspec +47 -0
- data/spec/asciidoctor-standoc/base_spec.rb +271 -0
- data/spec/asciidoctor-standoc/blocks_spec.rb +469 -0
- data/spec/asciidoctor-standoc/cleanup_spec.rb +760 -0
- data/spec/asciidoctor-standoc/inline_spec.rb +162 -0
- data/spec/asciidoctor-standoc/isobib_cache_spec.rb +332 -0
- data/spec/asciidoctor-standoc/lists_spec.rb +190 -0
- data/spec/asciidoctor-standoc/macros_spec.rb +111 -0
- data/spec/asciidoctor-standoc/refs_spec.rb +606 -0
- data/spec/asciidoctor-standoc/section_spec.rb +310 -0
- data/spec/asciidoctor-standoc/table_spec.rb +307 -0
- data/spec/asciidoctor-standoc/validate_spec.rb +133 -0
- data/spec/assets/header.html +7 -0
- data/spec/assets/html.css +2 -0
- data/spec/assets/htmlcover.html +4 -0
- data/spec/assets/htmlintro.html +5 -0
- data/spec/assets/i18n.yaml +2 -0
- data/spec/assets/iso.headless.html +33 -0
- data/spec/assets/iso.xml +8 -0
- data/spec/assets/rice_image1.png +0 -0
- data/spec/assets/scripts.html +3 -0
- data/spec/assets/std.css +2 -0
- data/spec/assets/word.css +2 -0
- data/spec/assets/wordcover.html +3 -0
- data/spec/assets/wordintro.html +4 -0
- data/spec/examples/103_01_02.html +247 -0
- data/spec/examples/english.yaml +69 -0
- data/spec/examples/iso_123_.xml +45 -0
- data/spec/examples/iso_123_all_parts.xml +45 -0
- data/spec/examples/iso_123_no_year_note.xml +46 -0
- data/spec/examples/iso_124_.xml +41 -0
- data/spec/examples/iso_216_.xml +47 -0
- data/spec/examples/iso_iec_12382_.xml +48 -0
- data/spec/examples/rice.adoc +715 -0
- data/spec/examples/rice.preview.html +1877 -0
- data/spec/examples/rice.sh +4 -0
- data/spec/examples/rice_images/rice_image1.png +0 -0
- data/spec/examples/rice_images/rice_image2.png +0 -0
- data/spec/examples/rice_images/rice_image3_1.png +0 -0
- data/spec/examples/rice_images/rice_image3_2.png +0 -0
- data/spec/examples/rice_images/rice_image3_3.png +0 -0
- data/spec/metanorma/processor_spec.rb +70 -0
- data/spec/spec_helper.rb +198 -0
- metadata +370 -0
@@ -0,0 +1,61 @@
|
|
1
|
+
module Asciidoctor
|
2
|
+
module Standoc
|
3
|
+
module Table
|
4
|
+
def table_attrs(node)
|
5
|
+
{ id: Utils::anchor_or_uuid(node),
|
6
|
+
headerrows: node.attr("headerrows") }
|
7
|
+
end
|
8
|
+
|
9
|
+
def table(node)
|
10
|
+
@table_fn_number = "a"
|
11
|
+
noko do |xml|
|
12
|
+
xml.table **attr_code(table_attrs(node)) do |xml_table|
|
13
|
+
table_name(node, xml_table)
|
14
|
+
%i(head body foot).reject do |tblsec|
|
15
|
+
node.rows[tblsec].empty?
|
16
|
+
end
|
17
|
+
table_head_body_and_foot node, xml_table
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def table_name(node, xml_table)
|
25
|
+
if node.title?
|
26
|
+
xml_table.name node.title
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def table_cell1(cell, thd)
|
31
|
+
if cell.style == :asciidoc
|
32
|
+
thd << cell.content
|
33
|
+
else
|
34
|
+
thd << cell.text
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def table_cell(c, xml_tr, tblsec)
|
39
|
+
cell_attributes = { id: c.id, colspan: c.colspan,
|
40
|
+
rowspan: c.rowspan, align: c.attr("halign") }
|
41
|
+
cell_tag = "td"
|
42
|
+
cell_tag = "th" if tblsec == :head || c.style == :header
|
43
|
+
xml_tr.send cell_tag, **attr_code(cell_attributes) do |thd|
|
44
|
+
table_cell1(c, thd)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def table_head_body_and_foot(node, xml)
|
49
|
+
%i(head body foot).reject { |s| node.rows[s].empty? }.each do |s|
|
50
|
+
xml.send "t#{s}" do |xml_tblsec|
|
51
|
+
node.rows[s].each do |row|
|
52
|
+
xml_tblsec.tr do |xml_tr|
|
53
|
+
row.each { |cell| table_cell(cell, xml_tr, s) }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
require "date"
|
2
|
+
require "nokogiri"
|
3
|
+
require "htmlentities"
|
4
|
+
require "json"
|
5
|
+
require "pathname"
|
6
|
+
require "open-uri"
|
7
|
+
require "uuidtools"
|
8
|
+
require "pp"
|
9
|
+
|
10
|
+
module Asciidoctor
|
11
|
+
module Standoc
|
12
|
+
module Utils
|
13
|
+
class << self
|
14
|
+
def anchor_or_uuid(node = nil)
|
15
|
+
uuid = UUIDTools::UUID.random_create
|
16
|
+
node.nil? || node.id.nil? || node.id.empty? ? "_" + uuid : node.id
|
17
|
+
end
|
18
|
+
|
19
|
+
def current_location(n)
|
20
|
+
return "Line #{n.lineno}" if n.respond_to?(:lineno) &&
|
21
|
+
!n.lineno.nil? && !n.lineno.empty?
|
22
|
+
return "Line #{n.line}" if n.respond_to?(:line) &&
|
23
|
+
!n.line.nil?
|
24
|
+
return "ID #{n.id}" if n.respond_to?(:id) && !n.id.nil?
|
25
|
+
while !n.nil? &&
|
26
|
+
(!n.respond_to?(:level) || n.level.positive?) &&
|
27
|
+
(!n.respond_to?(:context) || n.context != :section)
|
28
|
+
n = n.parent
|
29
|
+
return "Section: #{n.title}" if n&.respond_to?(:context) &&
|
30
|
+
n&.context == :section
|
31
|
+
end
|
32
|
+
"??"
|
33
|
+
end
|
34
|
+
|
35
|
+
def warning(node, msg, text)
|
36
|
+
return if @novalid
|
37
|
+
warntext = "asciidoctor: WARNING"\
|
38
|
+
"(#{current_location(node)}): #{msg}"
|
39
|
+
warntext += ": #{text}" if text
|
40
|
+
warn warntext
|
41
|
+
end
|
42
|
+
|
43
|
+
def flatten_rawtext_lines(node, result)
|
44
|
+
node.lines.each do |x|
|
45
|
+
if node.respond_to?(:context) && (node.context == :literal ||
|
46
|
+
node.context == :listing)
|
47
|
+
result << x.gsub(/</, "<").gsub(/>/, ">")
|
48
|
+
else
|
49
|
+
# strip not only HTML <tag>, and Asciidoc xrefs <<xref>>
|
50
|
+
result << x.gsub(/<[^>]*>+/, "")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
result
|
54
|
+
end
|
55
|
+
|
56
|
+
# if node contains blocks, flatten them into a single line;
|
57
|
+
# and extract only raw text
|
58
|
+
def flatten_rawtext(node)
|
59
|
+
result = []
|
60
|
+
if node.respond_to?(:blocks) && node.blocks?
|
61
|
+
node.blocks.each { |b| result << flatten_rawtext(b) }
|
62
|
+
elsif node.respond_to?(:lines)
|
63
|
+
result = flatten_rawtext_lines(node, result)
|
64
|
+
elsif node.respond_to?(:text)
|
65
|
+
result << node.text.gsub(/<[^>]*>+/, "")
|
66
|
+
else
|
67
|
+
result << node.content.gsub(/<[^>]*>+/, "")
|
68
|
+
end
|
69
|
+
result.reject(&:empty?)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def convert(node, transform = nil, opts = {})
|
74
|
+
transform ||= node.node_name
|
75
|
+
opts.empty? ? (send transform, node) : (send transform, node, opts)
|
76
|
+
end
|
77
|
+
|
78
|
+
def document_ns_attributes(_doc)
|
79
|
+
nil
|
80
|
+
end
|
81
|
+
|
82
|
+
NOKOHEAD = <<~HERE.freeze
|
83
|
+
<!DOCTYPE html SYSTEM
|
84
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
85
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
86
|
+
<head> <title></title> <meta charset="UTF-8" /> </head>
|
87
|
+
<body> </body> </html>
|
88
|
+
HERE
|
89
|
+
|
90
|
+
# block for processing XML document fragments as XHTML,
|
91
|
+
# to allow for HTMLentities
|
92
|
+
def noko(&block)
|
93
|
+
doc = ::Nokogiri::XML.parse(NOKOHEAD)
|
94
|
+
fragment = doc.fragment("")
|
95
|
+
::Nokogiri::XML::Builder.with fragment, &block
|
96
|
+
fragment.to_xml(encoding: "US-ASCII").lines.map do |l|
|
97
|
+
l.gsub(/\s*\n/, "")
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def attr_code(attributes)
|
102
|
+
attributes = attributes.reject { |_, val| val.nil? }.map
|
103
|
+
attributes.map do |k, v|
|
104
|
+
[k, (v.is_a? String) ? HTMLEntities.new.decode(v) : v]
|
105
|
+
end.to_h
|
106
|
+
end
|
107
|
+
|
108
|
+
# if the contents of node are blocks, output them to out;
|
109
|
+
# else, wrap them in <p>
|
110
|
+
def wrap_in_para(node, out)
|
111
|
+
if node.blocks? then out << node.content
|
112
|
+
else
|
113
|
+
out.p { |p| p << node.content }
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
SUBCLAUSE_XPATH = "//clause[ancestor::clause or ancestor::annex or "\
|
118
|
+
"ancestor::introduction]".freeze
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require "asciidoctor/standoc/utils"
|
2
|
+
require_relative "./validate_section.rb"
|
3
|
+
require "nokogiri"
|
4
|
+
require "jing"
|
5
|
+
require "pp"
|
6
|
+
require "iev"
|
7
|
+
|
8
|
+
module Asciidoctor
|
9
|
+
module Standoc
|
10
|
+
module Validate
|
11
|
+
|
12
|
+
SOURCELOCALITY = ".//locality[@type = 'clause']/referenceFrom".freeze
|
13
|
+
|
14
|
+
def iev_validate(xmldoc)
|
15
|
+
xmldoc.xpath("//term").each do |t|
|
16
|
+
/^IEV($|\s|:)/.match(t&.at(".//origin/@citeas")&.text) or next
|
17
|
+
pref = t.xpath("./preferred").inject([]) { |m, x| m << x&.text&.downcase }
|
18
|
+
locality = t.xpath(SOURCELOCALITY)&.text or next
|
19
|
+
iev = @iev.fetch(locality, xmldoc&.at("//language")&.text || "en") or next
|
20
|
+
pref.include?(iev.downcase) or
|
21
|
+
warn %(Term "#{pref[0]}" does not match IEV #{locality} "#{iev}")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def content_validate(doc)
|
26
|
+
section_validate(doc)
|
27
|
+
iev_validate(doc.root)
|
28
|
+
end
|
29
|
+
|
30
|
+
def schema_validate(doc, filename)
|
31
|
+
File.open(".tmp.xml", "w:UTF-8") { |f| f.write(doc.to_xml) }
|
32
|
+
begin
|
33
|
+
errors = Jing.new(filename).validate(".tmp.xml")
|
34
|
+
rescue Jing::Error => e
|
35
|
+
abort "what what what #{e}"
|
36
|
+
end
|
37
|
+
warn "Valid!" if errors.none?
|
38
|
+
errors.each do |error|
|
39
|
+
warn "#{error[:message]} @ #{error[:line]}:#{error[:column]}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# RelaxNG cannot cope well with wildcard attributes. So we strip
|
44
|
+
# any attributes from FormattedString instances (which can contain
|
45
|
+
# xs:any markup, and are signalled with @format) before validation.
|
46
|
+
def formattedstr_strip(doc)
|
47
|
+
doc.xpath("//*[@format]").each do |n|
|
48
|
+
n.elements.each do |e|
|
49
|
+
e.traverse do |e1|
|
50
|
+
next unless e1.element?
|
51
|
+
e1.each { |k, _v| e.delete(k) }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
doc
|
56
|
+
end
|
57
|
+
|
58
|
+
def validate(doc)
|
59
|
+
content_validate(doc)
|
60
|
+
schema_validate(formattedstr_strip(doc.dup),
|
61
|
+
File.join(File.dirname(__FILE__), "isodoc.rng"))
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require "nokogiri"
|
2
|
+
|
3
|
+
module Asciidoctor
|
4
|
+
module Standoc
|
5
|
+
module Validate
|
6
|
+
def section_validate(doc)
|
7
|
+
sourcecode_style(doc.root)
|
8
|
+
asset_style(doc.root)
|
9
|
+
end
|
10
|
+
|
11
|
+
def sourcecode_style(root)
|
12
|
+
root.xpath("//sourcecode").each do |x|
|
13
|
+
callouts = x.elements.select { |e| e.name == "callout" }
|
14
|
+
annotations = x.elements.select { |e| e.name == "annotation" }
|
15
|
+
if callouts.size != annotations.size
|
16
|
+
warn "#{x['id']}: mismatch of callouts and annotations"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def style_warning(node, msg, text)
|
22
|
+
return if @novalid
|
23
|
+
w = "ISO style: WARNING (#{Utils::current_location(node)}): #{msg}"
|
24
|
+
w += ": #{text}" if text
|
25
|
+
warn w
|
26
|
+
end
|
27
|
+
|
28
|
+
def asset_title_style(root)
|
29
|
+
root.xpath("//figure[image][not(title)]").each do |node|
|
30
|
+
style_warning(node, "Figure should have title", nil)
|
31
|
+
end
|
32
|
+
root.xpath("//table[not(title)]").each do |node|
|
33
|
+
style_warning(node, "Table should have title", nil)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def asset_style(root)
|
38
|
+
asset_title_style(root)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require "asciidoctor" unless defined? Asciidoctor::Converter
|
2
|
+
require_relative "asciidoctor/standoc/converter"
|
3
|
+
require_relative "asciidoctor/standoc/version"
|
4
|
+
require "asciidoctor/extensions"
|
5
|
+
|
6
|
+
if defined? Metanorma
|
7
|
+
require_relative "metanorma/standoc"
|
8
|
+
Metanorma::Registry.instance.register(Metanorma::Standoc::Processor)
|
9
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "metanorma/processor"
|
2
|
+
|
3
|
+
module Metanorma
|
4
|
+
module Standoc
|
5
|
+
class Processor < Metanorma::Processor
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@short = :standoc
|
9
|
+
@input_format = :asciidoc
|
10
|
+
@asciidoctor_backend = :standoc
|
11
|
+
end
|
12
|
+
|
13
|
+
def output_formats
|
14
|
+
super.merge(
|
15
|
+
html: "html",
|
16
|
+
doc: "doc"
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
def version
|
21
|
+
"Asciidoctor::Standoc #{Metanorma::Standoc::VERSION}/IsoDoc #{IsoDoc::VERSION}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def input_to_isodoc(file)
|
25
|
+
Metanorma::Input::Asciidoc.new.process(file, @asciidoctor_backend)
|
26
|
+
end
|
27
|
+
|
28
|
+
def output(isodoc_node, outname, format, options={})
|
29
|
+
case format
|
30
|
+
when :html
|
31
|
+
IsoDoc::HtmlConvert.new(options).convert(outname, isodoc_node)
|
32
|
+
when :doc
|
33
|
+
IsoDoc::WordConvert.new(options).convert(outname, isodoc_node)
|
34
|
+
else
|
35
|
+
super
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
lib = File.expand_path("../lib", __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require "asciidoctor/standoc/version"
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "metanorma-standoc"
|
9
|
+
spec.version = Metanorma::Standoc::VERSION
|
10
|
+
spec.authors = ["Ribose Inc."]
|
11
|
+
spec.email = ["open.source@ribose.com"]
|
12
|
+
|
13
|
+
spec.summary = "metanorma-standoc realises standards following the Metanorma standoc model"
|
14
|
+
spec.description = <<~DESCRIPTION
|
15
|
+
metanorma-standoc realises standards following the Metanorma standoc model
|
16
|
+
|
17
|
+
This gem is in active development.
|
18
|
+
DESCRIPTION
|
19
|
+
|
20
|
+
spec.homepage = "https://github.com/riboseinc/metanorma-standoc"
|
21
|
+
spec.license = "BSD-2-Clause"
|
22
|
+
|
23
|
+
spec.bindir = "bin"
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
spec.files = `git ls-files`.split("\n")
|
26
|
+
spec.test_files = `git ls-files -- {spec}/*`.split("\n")
|
27
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
28
|
+
|
29
|
+
spec.add_dependency "asciidoctor", "~> 1.5.7"
|
30
|
+
spec.add_dependency "ruby-jing"
|
31
|
+
spec.add_dependency "isodoc", ">= 0.8"
|
32
|
+
spec.add_dependency "iev", "~> 0.2.0"
|
33
|
+
spec.add_dependency "relaton", "~> 0.1.3"
|
34
|
+
|
35
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
36
|
+
spec.add_development_dependency "byebug"
|
37
|
+
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
38
|
+
spec.add_development_dependency "guard", "~> 2.14"
|
39
|
+
spec.add_development_dependency "guard-rspec", "~> 4.7"
|
40
|
+
spec.add_development_dependency "rake", "~> 12.0"
|
41
|
+
spec.add_development_dependency "rspec", "~> 3.6"
|
42
|
+
spec.add_development_dependency "rubocop", "~> 0.50"
|
43
|
+
spec.add_development_dependency "simplecov", "~> 0.15"
|
44
|
+
spec.add_development_dependency "timecop", "~> 0.9"
|
45
|
+
spec.add_development_dependency "metanorma", "~> 0.2.6"
|
46
|
+
spec.add_development_dependency "isobib", "~> 0.2.0"
|
47
|
+
end
|
@@ -0,0 +1,271 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Asciidoctor::Standoc do
|
4
|
+
it "has a version number" do
|
5
|
+
expect(Metanorma::Standoc::VERSION).not_to be nil
|
6
|
+
end
|
7
|
+
|
8
|
+
it "processes a blank document" do
|
9
|
+
expect(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)).to be_equivalent_to <<~"OUTPUT"
|
10
|
+
#{ASCIIDOC_BLANK_HDR}
|
11
|
+
INPUT
|
12
|
+
#{BLANK_HDR}
|
13
|
+
<sections/>
|
14
|
+
</standard-document>
|
15
|
+
OUTPUT
|
16
|
+
end
|
17
|
+
|
18
|
+
it "converts a blank document" do
|
19
|
+
system "rm -f test.doc"
|
20
|
+
expect(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)).to be_equivalent_to <<~"OUTPUT"
|
21
|
+
= Document title
|
22
|
+
Author
|
23
|
+
:docfile: test.adoc
|
24
|
+
:novalid:
|
25
|
+
INPUT
|
26
|
+
#{BLANK_HDR}
|
27
|
+
<sections/>
|
28
|
+
</standard-document>
|
29
|
+
OUTPUT
|
30
|
+
expect(File.exist?("test.doc")).to be true
|
31
|
+
expect(File.exist?("htmlstyle.css")).to be false
|
32
|
+
end
|
33
|
+
|
34
|
+
it "processes default metadata" do
|
35
|
+
expect(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)).to be_equivalent_to <<~'OUTPUT'
|
36
|
+
= Document title
|
37
|
+
Author
|
38
|
+
:docfile: test.adoc
|
39
|
+
:nodoc:
|
40
|
+
:novalid:
|
41
|
+
:docnumber: 1000
|
42
|
+
:partnumber: 1
|
43
|
+
:edition: 2
|
44
|
+
:revdate: 2000-01-01
|
45
|
+
:draft: 3.4
|
46
|
+
:technical-committee: TC
|
47
|
+
:technical-committee-number: 1
|
48
|
+
:technical-committee-type: A
|
49
|
+
:subcommittee: SC
|
50
|
+
:subcommittee-number: 2
|
51
|
+
:subcommittee-type: B
|
52
|
+
:workgroup: WG
|
53
|
+
:workgroup-number: 3
|
54
|
+
:workgroup-type: C
|
55
|
+
:secretariat: SECRETARIAT
|
56
|
+
:copyright-year: 2001
|
57
|
+
:docstage: 10
|
58
|
+
:docsubstage: 20
|
59
|
+
:iteration: 3
|
60
|
+
:language: en
|
61
|
+
:title-intro-en: Introduction
|
62
|
+
:title-main-en: Main Title -- Title
|
63
|
+
:title-part-en: Title Part
|
64
|
+
:title-intro-fr: Introduction Française
|
65
|
+
:title-main-fr: Titre Principal
|
66
|
+
:title-part-fr: Part du Titre
|
67
|
+
:library-ics: 1,2,3
|
68
|
+
INPUT
|
69
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
70
|
+
<standard-document xmlns="http://riboseinc.com/isoxml">
|
71
|
+
<bibdata type="article">
|
72
|
+
|
73
|
+
<docidentifier>
|
74
|
+
<project-number part="1"> 1000</project-number>
|
75
|
+
</docidentifier>
|
76
|
+
<language>en</language>
|
77
|
+
<script>Latn</script>
|
78
|
+
<status format="plain">published</status>
|
79
|
+
<copyright>
|
80
|
+
<from>2001</from>
|
81
|
+
</copyright>
|
82
|
+
<editorialgroup>
|
83
|
+
<technical-committee number="1" type="A">TC</technical-committee>
|
84
|
+
</editorialgroup>
|
85
|
+
<ics>
|
86
|
+
<code>1</code>
|
87
|
+
</ics>
|
88
|
+
<ics>
|
89
|
+
<code>2</code>
|
90
|
+
</ics>
|
91
|
+
<ics>
|
92
|
+
<code>3</code>
|
93
|
+
</ics>
|
94
|
+
</bibdata><version>
|
95
|
+
<edition>2</edition>
|
96
|
+
<revision-date>2000-01-01</revision-date>
|
97
|
+
<draft>3.4</draft>
|
98
|
+
</version>
|
99
|
+
<sections/>
|
100
|
+
</standard-document>
|
101
|
+
OUTPUT
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
it "processes complex metadata" do
|
106
|
+
expect(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)).to be_equivalent_to <<~'OUTPUT'
|
107
|
+
= Document title
|
108
|
+
Author
|
109
|
+
:docfile: test.adoc
|
110
|
+
:nodoc:
|
111
|
+
:novalid:
|
112
|
+
:docnumber: 1000
|
113
|
+
:partnumber: 1-1
|
114
|
+
:tc-docnumber: 2000
|
115
|
+
:language: el
|
116
|
+
:script: Grek
|
117
|
+
:publisher: IEC,IETF,ISO
|
118
|
+
INPUT
|
119
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
120
|
+
<standard-document xmlns="http://riboseinc.com/isoxml">
|
121
|
+
<bibdata type="article">
|
122
|
+
|
123
|
+
<docidentifier>
|
124
|
+
<project-number part="1" subpart="1">ISO/IEC/IETF 1000</project-number>
|
125
|
+
</docidentifier>
|
126
|
+
<contributor>
|
127
|
+
<role type="author"/>
|
128
|
+
<organization>
|
129
|
+
<name>IEC</name>
|
130
|
+
</organization>
|
131
|
+
</contributor>
|
132
|
+
<contributor>
|
133
|
+
<role type="author"/>
|
134
|
+
<organization>
|
135
|
+
<name>IETF</name>
|
136
|
+
</organization>
|
137
|
+
</contributor>
|
138
|
+
<contributor>
|
139
|
+
<role type="author"/>
|
140
|
+
<organization>
|
141
|
+
<name>ISO</name>
|
142
|
+
</organization>
|
143
|
+
</contributor>
|
144
|
+
<contributor>
|
145
|
+
<role type="publisher"/>
|
146
|
+
<organization>
|
147
|
+
<name>IEC</name>
|
148
|
+
</organization>
|
149
|
+
</contributor>
|
150
|
+
<contributor>
|
151
|
+
<role type="publisher"/>
|
152
|
+
<organization>
|
153
|
+
<name>IETF</name>
|
154
|
+
</organization>
|
155
|
+
</contributor>
|
156
|
+
<contributor>
|
157
|
+
<role type="publisher"/>
|
158
|
+
<organization>
|
159
|
+
<name>ISO</name>
|
160
|
+
</organization>
|
161
|
+
</contributor>
|
162
|
+
<language>el</language>
|
163
|
+
<script>Grek</script>
|
164
|
+
<status format="plain">published</status>
|
165
|
+
<copyright>
|
166
|
+
<from>2018</from>
|
167
|
+
<owner>
|
168
|
+
<organization>
|
169
|
+
<name>IEC</name>
|
170
|
+
</organization>
|
171
|
+
</owner>
|
172
|
+
</copyright>
|
173
|
+
<copyright>
|
174
|
+
<from>2018</from>
|
175
|
+
<owner>
|
176
|
+
<organization>
|
177
|
+
<name>IETF</name>
|
178
|
+
</organization>
|
179
|
+
</owner>
|
180
|
+
</copyright>
|
181
|
+
<copyright>
|
182
|
+
<from>2018</from>
|
183
|
+
<owner>
|
184
|
+
<organization>
|
185
|
+
<name>ISO</name>
|
186
|
+
</organization>
|
187
|
+
</owner>
|
188
|
+
</copyright>
|
189
|
+
<editorialgroup>
|
190
|
+
<technical-committee/>
|
191
|
+
</editorialgroup>
|
192
|
+
</bibdata>
|
193
|
+
<sections/>
|
194
|
+
</standard-document>
|
195
|
+
OUTPUT
|
196
|
+
end
|
197
|
+
|
198
|
+
it "reads scripts into blank HTML document" do
|
199
|
+
system "rm -f test.html"
|
200
|
+
Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
|
201
|
+
= Document title
|
202
|
+
Author
|
203
|
+
:docfile: test.adoc
|
204
|
+
:novalid:
|
205
|
+
INPUT
|
206
|
+
html = File.read("test.html", encoding: "utf-8")
|
207
|
+
expect(html).to match(%r{<script>})
|
208
|
+
end
|
209
|
+
|
210
|
+
it "uses default fonts" do
|
211
|
+
system "rm -f test.html"
|
212
|
+
Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
|
213
|
+
= Document title
|
214
|
+
Author
|
215
|
+
:docfile: test.adoc
|
216
|
+
:novalid:
|
217
|
+
INPUT
|
218
|
+
html = File.read("test.html", encoding: "utf-8")
|
219
|
+
expect(html).to match(%r[\.Sourcecode[^{]+\{[^{]+font-family: "Courier New", monospace;]m)
|
220
|
+
expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: "Cambria", serif;]m)
|
221
|
+
expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: "Cambria", serif;]m)
|
222
|
+
end
|
223
|
+
|
224
|
+
it "uses default fonts for alt doc" do
|
225
|
+
system "rm -f test_alt.html"
|
226
|
+
Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
|
227
|
+
= Document title
|
228
|
+
Author
|
229
|
+
:docfile: test.adoc
|
230
|
+
:novalid:
|
231
|
+
INPUT
|
232
|
+
html = File.read("test_alt.html", encoding: "utf-8")
|
233
|
+
expect(html).to match(%r[\.Sourcecode[^{]+\{[^{]+font-family: "Space Mono", monospace;]m)
|
234
|
+
expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: "Lato", sans-serif;]m)
|
235
|
+
expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: "Lato", sans-serif;]m)
|
236
|
+
end
|
237
|
+
|
238
|
+
it "uses Chinese fonts" do
|
239
|
+
system "rm -f test.html"
|
240
|
+
Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
|
241
|
+
= Document title
|
242
|
+
Author
|
243
|
+
:docfile: test.adoc
|
244
|
+
:novalid:
|
245
|
+
:script: Hans
|
246
|
+
INPUT
|
247
|
+
html = File.read("test.html", encoding: "utf-8")
|
248
|
+
expect(html).to match(%r[\.Sourcecode[^{]+\{[^{]+font-family: "Courier New", monospace;]m)
|
249
|
+
expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: "SimSun", serif;]m)
|
250
|
+
expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: "SimHei", sans-serif;]m)
|
251
|
+
end
|
252
|
+
|
253
|
+
it "uses specified fonts" do
|
254
|
+
system "rm -f test.html"
|
255
|
+
Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
|
256
|
+
= Document title
|
257
|
+
Author
|
258
|
+
:docfile: test.adoc
|
259
|
+
:novalid:
|
260
|
+
:script: Hans
|
261
|
+
:body-font: Zapf Chancery
|
262
|
+
:header-font: Comic Sans
|
263
|
+
:monospace-font: Andale Mono
|
264
|
+
INPUT
|
265
|
+
html = File.read("test.html", encoding: "utf-8")
|
266
|
+
expect(html).to match(%r[\.Sourcecode[^{]+\{[^{]+font-family: Andale Mono;]m)
|
267
|
+
expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: Zapf Chancery;]m)
|
268
|
+
expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: Comic Sans;]m)
|
269
|
+
end
|
270
|
+
|
271
|
+
end
|