asciidoctor-iso 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.gitattributes +2 -0
  3. data/.travis.yml +5 -0
  4. data/Gemfile.lock +12 -10
  5. data/README.adoc +113 -16
  6. data/bin/rspec +18 -0
  7. data/lib/asciidoctor/iso/base.rb +30 -28
  8. data/lib/asciidoctor/iso/blocks.rb +33 -33
  9. data/lib/asciidoctor/iso/cleanup.rb +79 -33
  10. data/lib/asciidoctor/iso/cleanup_block.rb +71 -18
  11. data/lib/asciidoctor/iso/cleanup_ref.rb +35 -30
  12. data/lib/asciidoctor/iso/converter.rb +0 -3
  13. data/lib/asciidoctor/iso/front.rb +29 -16
  14. data/lib/asciidoctor/iso/html/isodoc.css +34 -0
  15. data/lib/asciidoctor/iso/html/wordstyle.css +138 -6
  16. data/lib/asciidoctor/iso/inline.rb +10 -22
  17. data/lib/asciidoctor/iso/isodoc.rng +66 -16
  18. data/lib/asciidoctor/iso/isostandard.rng +129 -15
  19. data/lib/asciidoctor/iso/lists.rb +49 -42
  20. data/lib/asciidoctor/iso/macros.rb +12 -8
  21. data/lib/asciidoctor/iso/section.rb +53 -37
  22. data/lib/asciidoctor/iso/table.rb +9 -1
  23. data/lib/asciidoctor/iso/utils.rb +18 -13
  24. data/lib/asciidoctor/iso/validate.rb +100 -24
  25. data/lib/asciidoctor/iso/validate_requirements.rb +106 -0
  26. data/lib/asciidoctor/iso/validate_section.rb +85 -65
  27. data/lib/asciidoctor/iso/validate_style.rb +68 -115
  28. data/lib/asciidoctor/iso/version.rb +1 -1
  29. data/spec/asciidoctor-iso/base_spec.rb +193 -0
  30. data/spec/asciidoctor-iso/blocks_spec.rb +426 -0
  31. data/spec/asciidoctor-iso/cleanup_spec.rb +687 -0
  32. data/spec/asciidoctor-iso/inline_spec.rb +159 -0
  33. data/spec/asciidoctor-iso/lists_spec.rb +189 -0
  34. data/spec/asciidoctor-iso/macros_spec.rb +20 -0
  35. data/spec/asciidoctor-iso/refs_spec.rb +194 -0
  36. data/spec/asciidoctor-iso/section_spec.rb +301 -0
  37. data/spec/asciidoctor-iso/table_spec.rb +307 -0
  38. data/spec/asciidoctor-iso/validate_spec.rb +749 -0
  39. data/spec/examples/english.yaml +69 -0
  40. data/spec/examples/rice.adoc +30 -28
  41. data/spec/examples/rice.doc +3035 -2865
  42. data/spec/examples/rice.html +281 -234
  43. data/spec/examples/rice.preview.html +30 -20
  44. data/spec/examples/rice.xml +250 -282
  45. data/spec/spec_helper.rb +87 -0
  46. metadata +17 -2
@@ -44,15 +44,12 @@ module Asciidoctor
44
44
  # alias_method :pass, :content
45
45
  alias_method :embedded, :content
46
46
  alias_method :verse, :quote
47
- alias_method :literal, :content
48
47
  alias_method :audio, :skip
49
48
  alias_method :video, :skip
50
49
  alias_method :inline_button, :skip
51
50
  alias_method :inline_kbd, :skip
52
51
  alias_method :inline_menu, :skip
53
52
  alias_method :inline_image, :skip
54
-
55
-
56
53
  end
57
54
  end
58
55
  end
@@ -10,9 +10,10 @@ module Asciidoctor
10
10
  module ISO
11
11
  module Front
12
12
  def metadata_id(node, xml)
13
+ part, subpart = node&.attr("partnumber")&.split(/-/)
13
14
  xml.docidentifier do |i|
14
15
  i.project_number node.attr("docnumber"),
15
- **attr_code(part: node.attr("partnumber"))
16
+ **attr_code(part: part, subpart: subpart)
16
17
  if node.attr("tc-docnumber")
17
18
  i.tc_document_number node.attr("tc-docnumber")
18
19
  end
@@ -33,7 +34,7 @@ module Asciidoctor
33
34
  type: node.attr("#{compname}-type"))
34
35
  end
35
36
 
36
- def metadata_author(node, xml)
37
+ def metadata_author(_node, xml)
37
38
  xml.contributor do |c|
38
39
  c.role **{ type: "author" }
39
40
  c.organization do |a|
@@ -68,8 +69,8 @@ module Asciidoctor
68
69
 
69
70
  def metadata_status(node, xml)
70
71
  xml.status do |s|
71
- s.stage ( node.attr("docstage") || "60" )
72
- s.substage ( node.attr("docsubstage") || "60" )
72
+ s.stage (node.attr("docstage") || "60")
73
+ s.substage (node.attr("docsubstage") || "60")
73
74
  end
74
75
  end
75
76
 
@@ -88,27 +89,39 @@ module Asciidoctor
88
89
  metadata_author(node, xml)
89
90
  metadata_publisher(node, xml)
90
91
  xml.language node.attr("language")
91
- xml.script "Latn"
92
+ xml.script (node.attr("script") || "Latn")
92
93
  metadata_status(node, xml)
93
94
  metadata_copyright(node, xml)
94
95
  metadata_committee(node, xml)
95
96
  end
96
97
 
98
+ def title_intro(node, t, lang, at)
99
+ return unless node.attr("title-intro-#{lang}")
100
+ t.title_intro(**attr_code(at)) do |t1|
101
+ t1 << node.attr("title-intro-#{lang}")
102
+ end
103
+ end
104
+
105
+ def title_main(node, t, lang, at)
106
+ t.title_main **attr_code(at) do |t1|
107
+ t1 << node.attr("title-main-#{lang}")
108
+ end
109
+ end
110
+
111
+ def title_part(node, t, lang, at)
112
+ return unless node.attr("title-part-#{lang}")
113
+ t.title_part(**attr_code(at)) do |t1|
114
+ t1 << node.attr("title-part-#{lang}")
115
+ end
116
+ end
117
+
97
118
  def title(node, xml)
98
119
  ["en", "fr"].each do |lang|
99
120
  xml.title do |t|
100
121
  at = { language: lang, format: "text/plain" }
101
- node.attr("title-intro-#{lang}") and
102
- t.title_intro **attr_code(at) do |t1|
103
- t1 << node.attr("title-intro-#{lang}")
104
- end
105
- t.title_main **attr_code(at) do |t1|
106
- t1 << node.attr("title-main-#{lang}")
107
- end
108
- node.attr("title-part-#{lang}") and
109
- t.title_part **attr_code(at) do |t1|
110
- t1 << node.attr("title-part-#{lang}")
111
- end
122
+ title_intro(node, t, lang, at)
123
+ title_main(node, t, lang, at)
124
+ title_part(node, t, lang, at)
112
125
  end
113
126
  end
114
127
  end
@@ -239,6 +239,24 @@ p.AltTerms, li.AltTerms, div.AltTerms
239
239
  mso-bidi-font-family:"Cambria";
240
240
  mso-ansi-language:EN-GB;
241
241
  mso-bidi-font-weight:normal;}
242
+ p.DeprecatedTerms, li.DeprecatedTerms, div.DeprecatedTerms
243
+ {mso-style-name:"DeprecatedTerm\(s\)";
244
+ mso-style-priority:8;
245
+ mso-style-unhide:no;
246
+ mso-style-next:Definition;
247
+ margin:0cm;
248
+ margin-bottom:.0001pt;
249
+ line-height:12.0pt;
250
+ mso-pagination:widow-orphan;
251
+ page-break-after:avoid;
252
+ mso-hyphenate:none;
253
+ tab-stops:20.15pt;
254
+ font-size:11.0pt;
255
+ font-family:"Cambria",serif;
256
+ mso-fareast-font-family:Calibri;
257
+ mso-bidi-font-family:"Cambria";
258
+ mso-ansi-language:EN-GB;
259
+ mso-bidi-font-weight:normal;}
242
260
  p.TermNum, li.TermNum, div.TermNum
243
261
  {mso-style-name:TermNum;
244
262
  mso-style-priority:7;
@@ -662,3 +680,19 @@ a.TableFootnoteRef
662
680
  aside {
663
681
  font-size:10.0pt;
664
682
  }
683
+
684
+ /*
685
+ div.example {
686
+ border:solid black .25pt;
687
+ mso-border-alt:solid black .25pt;
688
+ padding:10pt;
689
+ mso-padding-alt:10.0pt 10.0pt 10.0pt 10.0pt;
690
+ margin:10pt;
691
+ mso-margin-alt:10.0pt 10.0pt 10.0pt 10.0pt;
692
+ }
693
+ */
694
+
695
+ div.example {
696
+ margin-left:70.9pt;
697
+ text-indent:-70.9pt;
698
+ }
@@ -438,16 +438,14 @@ a:link, span.MsoHyperlink
438
438
  mso-style-unhide:no;
439
439
  mso-style-parent:"";
440
440
  mso-ansi-language:EN;
441
- color:blue;
442
- text-decoration:underline;
443
- text-underline:single;}
441
+ color:black;
442
+ text-decoration:none;}
444
443
  a:visited, span.MsoHyperlinkFollowed
445
444
  {mso-style-noshow:yes;
446
445
  mso-style-priority:99;
447
446
  mso-themecolor:followedhyperlink;
448
- color:#954F72;
449
- text-decoration:underline;
450
- text-underline:single;}
447
+ text-decoration:none;
448
+ color:black;}
451
449
  span.MsoPlaceholderText
452
450
  {mso-style-noshow:yes;
453
451
  mso-style-priority:99;
@@ -977,6 +975,140 @@ div.WordSection1
977
975
  margin-left:0cm;
978
976
  text-indent:0cm;
979
977
  mso-bidi-font-family:"Cambria";}
978
+ /* ordered list */
979
+ @list l2
980
+ {mso-list-id:525294607;
981
+ mso-list-template-ids:67633181;}
982
+ @list l2:level1
983
+ {mso-level-number-format:alpha-lower;
984
+ mso-level-text:"%1\)";
985
+ mso-level-tab-stop:none;
986
+ mso-level-number-position:left;
987
+ margin-left:18.0pt;
988
+ text-indent:-18.0pt;}
989
+ @list l2:level2
990
+ {mso-level-text:"%2\)";
991
+ mso-level-tab-stop:none;
992
+ mso-level-number-position:left;
993
+ margin-left:36.0pt;
994
+ text-indent:-18.0pt;}
995
+ @list l2:level3
996
+ {mso-level-number-format:roman-lower;
997
+ mso-level-text:"%3\)";
998
+ mso-level-tab-stop:none;
999
+ mso-level-number-position:left;
1000
+ margin-left:54.0pt;
1001
+ text-indent:-18.0pt;}
1002
+ @list l2:level4
1003
+ {mso-level-number-format:alpha-upper;
1004
+ mso-level-text:"%4\)";
1005
+ mso-level-tab-stop:none;
1006
+ mso-level-number-position:left;
1007
+ margin-left:72.0pt;
1008
+ text-indent:-18.0pt;}
1009
+ @list l2:level5
1010
+ {mso-level-number-format:roman-upper;
1011
+ mso-level-text:"%5\)";
1012
+ mso-level-tab-stop:none;
1013
+ mso-level-number-position:left;
1014
+ margin-left:90.0pt;
1015
+ text-indent:-18.0pt;}
1016
+ @list l2:level6
1017
+ {mso-level-number-format:alpha-lower;
1018
+ mso-level-text:"%6\)";
1019
+ mso-level-tab-stop:none;
1020
+ mso-level-number-position:left;
1021
+ margin-left:108.0pt;
1022
+ text-indent:-18.0pt;}
1023
+ @list l2:level7
1024
+ {mso-level-tab-stop:none;
1025
+ mso-level-text:"%7\)";
1026
+ mso-level-number-position:left;
1027
+ margin-left:126.0pt;
1028
+ text-indent:-18.0pt;}
1029
+ @list l2:level8
1030
+ {mso-level-number-format:roman-lower;
1031
+ mso-level-text:"%8\)";
1032
+ mso-level-tab-stop:none;
1033
+ mso-level-number-position:left;
1034
+ margin-left:144.0pt;
1035
+ text-indent:-18.0pt;}
1036
+ @list l2:level9
1037
+ {mso-level-number-format:alpha-upper;
1038
+ mso-level-text:"%9\)";
1039
+ mso-level-tab-stop:none;
1040
+ mso-level-number-position:left;
1041
+ margin-left:162.0pt;
1042
+ text-indent:-18.0pt;}
1043
+ /* Unordered list */
1044
+ @list l3
1045
+ {mso-list-id:1308196397;
1046
+ mso-list-type:hybrid;
1047
+ mso-list-template-ids:-277327948 -457018030 67633155 67633157 67633153 67633155 67633157 67633153 67633155 67633157;}
1048
+ @list l3:level1
1049
+ {mso-level-number-format:bullet;
1050
+ mso-level-text:—;
1051
+ mso-level-tab-stop:none;
1052
+ mso-level-number-position:left;
1053
+ margin-left:18.0pt;
1054
+ text-indent:-18.0pt;}
1055
+ @list l3:level2
1056
+ {mso-level-number-format:bullet;
1057
+ mso-level-text:—;
1058
+ mso-level-tab-stop:none;
1059
+ mso-level-number-position:left;
1060
+ margin-left:36.0pt;
1061
+ text-indent:-18.0pt;}
1062
+ @list l3:level3
1063
+ {mso-level-number-format:bullet;
1064
+ mso-level-text:—;
1065
+ mso-level-tab-stop:none;
1066
+ mso-level-number-position:left;
1067
+ margin-left:54.0pt;
1068
+ text-indent:-18.0pt;}
1069
+ @list l3:level4
1070
+ {mso-level-number-format:bullet;
1071
+ mso-level-text:—;
1072
+ mso-level-tab-stop:none;
1073
+ mso-level-number-position:left;
1074
+ margin-left:72.0pt;
1075
+ text-indent:-18.0pt;}
1076
+ @list l3:level5
1077
+ {mso-level-number-format:bullet;
1078
+ mso-level-text:—;
1079
+ mso-level-tab-stop:none;
1080
+ mso-level-number-position:left;
1081
+ margin-left:90.0pt;
1082
+ text-indent:-18.0pt;}
1083
+ @list l3:level6
1084
+ {mso-level-number-format:bullet;
1085
+ mso-level-text:—;
1086
+ mso-level-tab-stop:none;
1087
+ mso-level-number-position:left;
1088
+ margin-left:108.0pt;
1089
+ text-indent:-18.0pt;}
1090
+ @list l3:level7
1091
+ {mso-level-number-format:bullet;
1092
+ mso-level-text:—;
1093
+ mso-level-tab-stop:none;
1094
+ mso-level-number-position:left;
1095
+ margin-left:126.0pt;
1096
+ text-indent:-18.0pt;}
1097
+ @list l3:level8
1098
+ {mso-level-number-format:bullet;
1099
+ mso-level-text:—;
1100
+ mso-level-tab-stop:none;
1101
+ mso-level-number-position:left;
1102
+ margin-left:144.0pt;
1103
+ text-indent:-18.0pt;}
1104
+ @list l3:level9
1105
+ {mso-level-number-format:bullet;
1106
+ mso-level-text:—;
1107
+ mso-level-tab-stop:none;
1108
+ mso-level-number-position:left;
1109
+ margin-left:162.0pt;
1110
+ text-indent:-18.0pt;}
1111
+
980
1112
  table.MsoNormalTable
981
1113
  {mso-style-name:"Table Normal";
982
1114
  mso-tstyle-rowband-size:0;
@@ -1,10 +1,9 @@
1
- require 'asciidoctor/extensions'
1
+ require "asciidoctor/extensions"
2
2
 
3
3
  module Asciidoctor
4
4
  module ISO
5
5
  module Inline
6
-
7
- def is_refid?(x)
6
+ def refid?(x)
8
7
  @refids.include? x
9
8
  end
10
9
 
@@ -18,8 +17,6 @@ module Asciidoctor
18
17
  inline_anchor_link node
19
18
  when :bibref
20
19
  inline_anchor_bibref node
21
- else
22
- warning(node, "unknown anchor type", node.type.inspect)
23
20
  end
24
21
  end
25
22
 
@@ -30,12 +27,12 @@ module Asciidoctor
30
27
  end
31
28
 
32
29
  def inline_anchor_xref(node)
33
- matched = /^fn(: (?<text>.*))?$/.match node.text
30
+ matched = /^fn(:\s*(?<text>.*))?$/.match node.text
34
31
  f = matched.nil? ? "inline" : "footnote"
35
32
  c = matched.nil? ? node.text : matched[:text]
36
33
  t = node.target.gsub(/^#/, "").gsub(%r{(.)(\.xml)?#.*$}, "\\1")
37
- noko do |xml|
38
- xml.xref c, **attr_code(target: t, type: f)
34
+ noko do |xml|
35
+ xml.xref c, **attr_code(target: t, type: f)
39
36
  end.join
40
37
  end
41
38
 
@@ -66,7 +63,7 @@ module Asciidoctor
66
63
  def inline_footnote(node)
67
64
  noko do |xml|
68
65
  @fn_number += 1
69
- xml.fn **{reference: @fn_number} do |fn|
66
+ xml.fn **{ reference: @fn_number } do |fn|
70
67
  fn.p { |p| p << node.text }
71
68
  footnote_style(node, node.text)
72
69
  end
@@ -80,22 +77,14 @@ module Asciidoctor
80
77
  end.join("\n")
81
78
  end
82
79
 
83
- def page_break(node)
84
- noko do |xml|
85
- xml << node.text
86
- xml.pagebreak
87
- end.join("\n")
80
+ def page_break(_node)
81
+ noko { |xml| xml.pagebreak }.join("\n")
88
82
  end
89
83
 
90
- def thematic_break(node)
91
- noko do |xml|
92
- xml << node.text
93
- xml.hr
94
- end.join("\n")
84
+ def thematic_break(_node)
85
+ noko { |xml| xml.hr }.join("\n")
95
86
  end
96
87
 
97
-
98
-
99
88
  def inline_quoted(node)
100
89
  noko do |xml|
101
90
  case node.type
@@ -122,7 +111,6 @@ module Asciidoctor
122
111
  end
123
112
  end.join
124
113
  end
125
-
126
114
  end
127
115
  end
128
116
  end
@@ -24,9 +24,6 @@
24
24
  <define name="standard-document">
25
25
  <element name="standard-document">
26
26
  <ref name="bibdata"/>
27
- <zeroOrMore>
28
- <ref name="docrelation"/>
29
- </zeroOrMore>
30
27
  <optional>
31
28
  <ref name="version"/>
32
29
  </optional>
@@ -47,15 +44,27 @@
47
44
  </element>
48
45
  </define>
49
46
  <define name="docrelation">
50
- <element name="docrelation">
47
+ <element name="relation">
51
48
  <attribute name="type">
52
49
  <choice>
50
+ <value>parent</value>
51
+ <value>child</value>
53
52
  <value>obsoletes</value>
54
53
  <value>updates</value>
55
54
  <value>complements</value>
55
+ <value>derivedFrom</value>
56
+ <value>adoptedFrom</value>
57
+ <value>equivalent</value>
58
+ <value>identical</value>
59
+ <value>nonequivalent</value>
56
60
  </choice>
57
61
  </attribute>
58
- <ref name="eref"/>
62
+ <element name="bibitem">
63
+ <ref name="BibliographicItem"/>
64
+ </element>
65
+ <zeroOrMore>
66
+ <ref name="locality"/>
67
+ </zeroOrMore>
59
68
  </element>
60
69
  </define>
61
70
  <define name="status">
@@ -110,10 +119,24 @@
110
119
  <ref name="content"/>
111
120
  <ref name="clause"/>
112
121
  <ref name="terms"/>
122
+ <ref name="symbols-abbrevs"/>
113
123
  </choice>
114
124
  </oneOrMore>
115
125
  </element>
116
126
  </define>
127
+ <define name="symbols-abbrevs">
128
+ <element name="symbols-abbrevs">
129
+ <optional>
130
+ <attribute name="id">
131
+ <data type="ID"/>
132
+ </attribute>
133
+ </optional>
134
+ <optional>
135
+ <ref name="section-title"/>
136
+ </optional>
137
+ <ref name="dl"/>
138
+ </element>
139
+ </define>
117
140
  <define name="section-title">
118
141
  <element name="title">
119
142
  <text/>
@@ -192,7 +215,7 @@
192
215
  <data type="ID"/>
193
216
  </attribute>
194
217
  </optional>
195
- <attribute name="type">
218
+ <attribute name="obligation">
196
219
  <choice>
197
220
  <value>normative</value>
198
221
  <value>informative</value>
@@ -471,7 +494,9 @@
471
494
  <ref name="Alignments"/>
472
495
  </attribute>
473
496
  </optional>
474
- <ref name="quote-source"/>
497
+ <optional>
498
+ <ref name="quote-source"/>
499
+ </optional>
475
500
  <optional>
476
501
  <ref name="quote-author"/>
477
502
  </optional>
@@ -1281,15 +1306,26 @@
1281
1306
  <value>chapter</value>
1282
1307
  <value>page</value>
1283
1308
  <value>whole</value>
1309
+ <value>table</value>
1310
+ <value>annex</value>
1311
+ <value>figure</value>
1312
+ <value>note</value>
1313
+ <value>example</value>
1284
1314
  </choice>
1285
1315
  </attribute>
1286
- <zeroOrMore>
1287
- <ref name="localityreference"/>
1288
- </zeroOrMore>
1316
+ <ref name="referenceFrom"/>
1317
+ <optional>
1318
+ <ref name="referenceTo"/>
1319
+ </optional>
1320
+ </element>
1321
+ </define>
1322
+ <define name="referenceFrom">
1323
+ <element name="referenceFrom">
1324
+ <text/>
1289
1325
  </element>
1290
1326
  </define>
1291
- <define name="localityreference">
1292
- <element name="reference">
1327
+ <define name="referenceTo">
1328
+ <element name="referenceTo">
1293
1329
  <text/>
1294
1330
  </element>
1295
1331
  </define>
@@ -1302,6 +1338,11 @@
1302
1338
  <ref name="BibliographicItem"/>
1303
1339
  </element>
1304
1340
  </define>
1341
+ <define name="bibitem_no_id">
1342
+ <element name="bibitem">
1343
+ <ref name="BibliographicItem"/>
1344
+ </element>
1345
+ </define>
1305
1346
  <define name="BibItemType" combine="choice">
1306
1347
  <choice>
1307
1348
  <value>article</value>
@@ -1329,9 +1370,9 @@
1329
1370
  </oneOrMore>
1330
1371
  <ref name="formattedref"/>
1331
1372
  </choice>
1332
- <optional>
1373
+ <zeroOrMore>
1333
1374
  <ref name="source"/>
1334
- </optional>
1375
+ </zeroOrMore>
1335
1376
  <zeroOrMore>
1336
1377
  <ref name="docidentifier"/>
1337
1378
  </zeroOrMore>
@@ -1365,6 +1406,9 @@
1365
1406
  <optional>
1366
1407
  <ref name="copyright"/>
1367
1408
  </optional>
1409
+ <zeroOrMore>
1410
+ <ref name="docrelation"/>
1411
+ </zeroOrMore>
1368
1412
  </define>
1369
1413
  <define name="BibData">
1370
1414
  <optional>
@@ -1378,9 +1422,9 @@
1378
1422
  <optional>
1379
1423
  <ref name="formattedref"/>
1380
1424
  </optional>
1381
- <optional>
1425
+ <zeroOrMore>
1382
1426
  <ref name="source"/>
1383
- </optional>
1427
+ </zeroOrMore>
1384
1428
  <zeroOrMore>
1385
1429
  <ref name="docidentifier"/>
1386
1430
  </zeroOrMore>
@@ -1412,6 +1456,9 @@
1412
1456
  <ref name="status"/>
1413
1457
  </optional>
1414
1458
  <ref name="copyright"/>
1459
+ <zeroOrMore>
1460
+ <ref name="docrelation"/>
1461
+ </zeroOrMore>
1415
1462
  </define>
1416
1463
  <define name="btitle">
1417
1464
  <element name="title">
@@ -1425,6 +1472,9 @@
1425
1472
  </define>
1426
1473
  <define name="source">
1427
1474
  <element name="source">
1475
+ <optional>
1476
+ <attribute name="type"/>
1477
+ </optional>
1428
1478
  <data type="anyURI"/>
1429
1479
  </element>
1430
1480
  </define>