slaw 10.1.0 → 10.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d22fb48ee19e9ed5571d8796df269da08ae60f968f952b5e5438ae469d26130
4
- data.tar.gz: f297e70e1b31bb3262cea12e7422b22a2375db139edeb8107f74024fd1e559a2
3
+ metadata.gz: f76b66445a595e5130d1a3af8b153498d41007416bcd7c5ced418d4339030303
4
+ data.tar.gz: cd28f4839c8ecd4b430a6111a3c5ec3df764af84674b1e6205d54ac27b3c734f
5
5
  SHA512:
6
- metadata.gz: 02a8a4b0f06923911a3a88e6afc9b4220845abbc77180c1983e443ae493eecebe11f42f6dd60063f0dbb37a097b31188a971d4b60376d8a0574cc081705c7774
7
- data.tar.gz: f086fa4f09fdf8ca3be435dd579652d1812859e07282e35b5d39e242894f07046f922e6e493fef2e8ad9bf62d65893c5750eb3020dedaa9fd7af8633e93a586b
6
+ metadata.gz: f04d34041c3dc21f552b81af8d331d4440cd7c36d94e38007d15be8b467cca15b2bedbc1b5d1fb7d652ebd2b263f695a02afd337ce20df5c0e5eca7b1ec02050
7
+ data.tar.gz: dae3ef8b12f13761543a90b1711b301af9a3368cbde2387c8c00adf717c6a297ddfcfe108b9ef53073b370178574877a978fb8968d63317ed736ca1c49417232
data/README.md CHANGED
@@ -86,6 +86,11 @@ You can create your own grammar by creating a gem that provides these files and
86
86
 
87
87
  ## Changelog
88
88
 
89
+ ### 10.2.0 (4 September 2020)
90
+
91
+ * support inline superscript `^^text^^`
92
+ * support inline subscript `_^text^_`
93
+
89
94
  ### 10.1.0 (18 June 2020)
90
95
 
91
96
  * hcontainer elements have name attributes, to be compliant with AKN 3.0
@@ -20,7 +20,7 @@ module Slaw
20
20
  end
21
21
 
22
22
  rule inline_item
23
- remark / image / ref / bold / italics / [^\n]
23
+ remark / image / ref / bold / italics / superscript / subscript / [^\n]
24
24
  <InlineItem>
25
25
  end
26
26
 
@@ -57,6 +57,18 @@ module Slaw
57
57
  <Ref>
58
58
  end
59
59
 
60
+ rule superscript
61
+ # ^^foo^^
62
+ '^^' content:(!'^^' inline_item)+ '^^'
63
+ <Superscript>
64
+ end
65
+
66
+ rule subscript
67
+ # _^foo^_
68
+ '_^' content:(!'^_' inline_item)+ '^_'
69
+ <Subscript>
70
+ end
71
+
60
72
  end
61
73
  end
62
74
  end
@@ -71,6 +71,26 @@ module Slaw
71
71
  end
72
72
  end
73
73
 
74
+ class Superscript < Treetop::Runtime::SyntaxNode
75
+ def to_xml(b, idprefix)
76
+ b.sup { |b|
77
+ for e in content.elements
78
+ e.inline_item.to_xml(b, idprefix)
79
+ end
80
+ }
81
+ end
82
+ end
83
+
84
+ class Subscript < Treetop::Runtime::SyntaxNode
85
+ def to_xml(b, idprefix)
86
+ b.sub { |b|
87
+ for e in content.elements
88
+ e.inline_item.to_xml(b, idprefix)
89
+ end
90
+ }
91
+ end
92
+ end
93
+
74
94
  end
75
95
  end
76
96
  end
@@ -275,6 +275,18 @@
275
275
  <xsl:text>**</xsl:text>
276
276
  </xsl:template>
277
277
 
278
+ <xsl:template match="a:sup">
279
+ <xsl:text>^^</xsl:text>
280
+ <xsl:apply-templates />
281
+ <xsl:text>^^</xsl:text>
282
+ </xsl:template>
283
+
284
+ <xsl:template match="a:sub">
285
+ <xsl:text>_^</xsl:text>
286
+ <xsl:apply-templates />
287
+ <xsl:text>^_</xsl:text>
288
+ </xsl:template>
289
+
278
290
  <xsl:template match="a:eol">
279
291
  <xsl:text>&#10;</xsl:text>
280
292
  </xsl:template>
@@ -1,3 +1,3 @@
1
1
  module Slaw
2
- VERSION = "10.1.0"
2
+ VERSION = "10.2.0"
3
3
  end
@@ -498,4 +498,30 @@ EOS
498
498
  end
499
499
  end
500
500
 
501
+ describe 'superscript' do
502
+ it 'should handle superscript' do
503
+ node = parse :generic_container, <<EOS
504
+ Hello ^^super **bold** ^^ foo
505
+ EOS
506
+ to_xml(node, "").should == '<hcontainer eId="hcontainer_1" name="hcontainer">
507
+ <content>
508
+ <p>Hello <sup>super <b>bold</b> </sup> foo</p>
509
+ </content>
510
+ </hcontainer>'
511
+ end
512
+ end
513
+
514
+ describe 'subscript' do
515
+ it 'should handle subscript' do
516
+ node = parse :generic_container, <<EOS
517
+ Hello _^sub **bold** ^_ foo
518
+ EOS
519
+ to_xml(node, "").should == '<hcontainer eId="hcontainer_1" name="hcontainer">
520
+ <content>
521
+ <p>Hello <sub>sub <b>bold</b> </sub> foo</p>
522
+ </content>
523
+ </hcontainer>'
524
+ end
525
+ end
526
+
501
527
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slaw
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.1.0
4
+ version: 10.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Kempe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-18 00:00:00.000000000 Z
11
+ date: 2020-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake