slaw 10.6.0 → 10.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2feb9ea5e726f4300a0920de90b88f14b3a86ce4ae3dddd9a59b3bf8c855e575
4
- data.tar.gz: 263ef515bc1a81b8cccc1788a3b107b573f3840492913cedf17ae729745d1c4b
3
+ metadata.gz: 6e4cdd070ad171d0d999cbaa93da4fb2723df0a2d430679833d3588903049575
4
+ data.tar.gz: 33bffb144c455bb8d35f7c8dc7e3593041eead5d1c76569575afa8df73bd0a8e
5
5
  SHA512:
6
- metadata.gz: 573bab26b9e880856e74404058208e9fae5f400f0ee64413d771fea872e4b3b7c626ebefb5c020321dc4b4f35919b25b94801c6622e82d2f2a8dfe3507c35f61
7
- data.tar.gz: 01d73bb0903dbee8213eae364316835361b4d34bbe0ed4a12f9dcaeb114bf1e5ec9ac46133e0570bea1998af0daaac610591da905463d64e63f1449ffd529db7
6
+ metadata.gz: b69cf6e2303be5096d3697ced6fe3bb1538d46a5657c718f8e1c6e8e4edee1b1c24ea4b7a6f199920499412b716cfa21e0fddb72be46928377d02145236831cf
7
+ data.tar.gz: 13744a12c6e8f62d90cd6fd4b553e3d45f4dd7b38ca076c6da2d2dcea7e72a31feb9345f687d7d29fa5a0d9a8874c4a506929f5c1a73838f2b551df8cc063806
@@ -0,0 +1,22 @@
1
+ name: Test
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+ runs-on: ubuntu-latest
8
+
9
+ strategy:
10
+ matrix:
11
+ ruby-version: [2.7, 2.6]
12
+
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ - name: Set up Ruby ${{ matrix.ruby-version }}
16
+ uses: ruby/setup-ruby@v1
17
+ with:
18
+ ruby-version: ${{ matrix.ruby-version }}
19
+ - name: Install dependencies
20
+ run: bundle install
21
+ - name: Run tests
22
+ run: bundle exec rake
data/README.md CHANGED
@@ -86,6 +86,10 @@ You can create your own grammar by creating a gem that provides these files and
86
86
 
87
87
  ## Changelog
88
88
 
89
+ ### 10.7.0 (11 June 2021)
90
+
91
+ * Support underlines with `__text__`
92
+
89
93
  ### 10.6.0 (10 May 2021)
90
94
 
91
95
  * Handle sup and sub when extracting from HTML.
@@ -20,7 +20,7 @@ module Slaw
20
20
  end
21
21
 
22
22
  rule inline_item
23
- remark / image / ref / bold / italics / superscript / subscript / '\\'? [^\n]
23
+ remark / image / ref / bold / italics / superscript / subscript / underline / '\\'? [^\n]
24
24
  <InlineItem>
25
25
  end
26
26
 
@@ -69,6 +69,12 @@ module Slaw
69
69
  <Subscript>
70
70
  end
71
71
 
72
+ rule underline
73
+ # __foo__
74
+ '__' content:(!'__' inline_item)+ '__'
75
+ <Underline>
76
+ end
77
+
72
78
  end
73
79
  end
74
80
  end
@@ -96,6 +96,15 @@ module Slaw
96
96
  end
97
97
  end
98
98
 
99
+ class Underline < Treetop::Runtime::SyntaxNode
100
+ def to_xml(b, idprefix)
101
+ b.u { |b|
102
+ for e in content.elements
103
+ e.inline_item.to_xml(b, idprefix)
104
+ end
105
+ }
106
+ end
107
+ end
99
108
  end
100
109
  end
101
110
  end
@@ -59,13 +59,19 @@
59
59
  <xsl:call-template name="string-replace-all">
60
60
  <xsl:with-param name="text">
61
61
  <xsl:call-template name="string-replace-all">
62
- <xsl:with-param name="text" select="$text" />
63
- <xsl:with-param name="value"><xsl:value-of select="'\'" /></xsl:with-param>
64
- <xsl:with-param name="replacement"><xsl:value-of select="'\\'" /></xsl:with-param>
62
+ <xsl:with-param name="text">
63
+ <xsl:call-template name="string-replace-all">
64
+ <xsl:with-param name="text" select="$text" />
65
+ <xsl:with-param name="value"><xsl:value-of select="'\'" /></xsl:with-param>
66
+ <xsl:with-param name="replacement"><xsl:value-of select="'\\'" /></xsl:with-param>
67
+ </xsl:call-template>
68
+ </xsl:with-param>
69
+ <xsl:with-param name="value"><xsl:value-of select="'**'" /></xsl:with-param>
70
+ <xsl:with-param name="replacement"><xsl:value-of select="'\*\*'" /></xsl:with-param>
65
71
  </xsl:call-template>
66
72
  </xsl:with-param>
67
- <xsl:with-param name="value"><xsl:value-of select="'**'" /></xsl:with-param>
68
- <xsl:with-param name="replacement"><xsl:value-of select="'\*\*'" /></xsl:with-param>
73
+ <xsl:with-param name="value"><xsl:value-of select="'__'" /></xsl:with-param>
74
+ <xsl:with-param name="replacement"><xsl:value-of select="'\_\_'" /></xsl:with-param>
69
75
  </xsl:call-template>
70
76
  </xsl:with-param>
71
77
  <xsl:with-param name="value"><xsl:value-of select="'//'" /></xsl:with-param>
@@ -397,6 +403,12 @@
397
403
  <xsl:text>^_</xsl:text>
398
404
  </xsl:template>
399
405
 
406
+ <xsl:template match="a:u">
407
+ <xsl:text>__</xsl:text>
408
+ <xsl:apply-templates />
409
+ <xsl:text>__</xsl:text>
410
+ </xsl:template>
411
+
400
412
  <xsl:template match="a:eol">
401
413
  <xsl:text>&#10;</xsl:text>
402
414
  </xsl:template>
data/lib/slaw/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Slaw
2
- VERSION = "10.6.0"
2
+ VERSION = "10.7.0"
3
3
  end
@@ -18,3 +18,7 @@ nested ** stars in // italics \*\* // and bold **
18
18
 
19
19
  super ^^with \^\^ hats \^\^^^ and sub _^\_^ with \^_ end tokens \^_^_
20
20
 
21
+ underlines __underline with _ underscores__ and \_\_escaped underlines \_\_
22
+
23
+ mixed __underline **and \_\_ bold**__
24
+
@@ -237,6 +237,27 @@ XML
237
237
 
238
238
  Hello [there](/za/act/123) friend.
239
239
 
240
+ '
241
+ end
242
+
243
+ it 'should unparse underlines correctly' do
244
+ doc = xml2doc(section(<<XML
245
+ <num>1.</num>
246
+ <paragraph id="section-19.paragraph-0">
247
+ <content>
248
+ <p>Hello <u>underlined</u>.</p>
249
+ </content>
250
+ </paragraph>
251
+ XML
252
+ ))
253
+
254
+ text = subject.text_from_act(doc)
255
+ text.should == 'BODY
256
+
257
+ 1.
258
+
259
+ Hello __underlined__.
260
+
240
261
  '
241
262
  end
242
263
 
@@ -535,4 +535,17 @@ EOS
535
535
  end
536
536
  end
537
537
 
538
+ describe 'underline' do
539
+ it 'should handle underline' do
540
+ node = parse :generic_container, <<EOS
541
+ Text __with underline__ and _ under__scores__.
542
+ EOS
543
+ to_xml(node, "").should == '<hcontainer eId="hcontainer_1" name="hcontainer">
544
+ <content>
545
+ <p>Text <u>with underline</u> and _ under<u>scores</u>.</p>
546
+ </content>
547
+ </hcontainer>'
548
+ end
549
+ end
550
+
538
551
  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.6.0
4
+ version: 10.7.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: 2021-05-10 00:00:00.000000000 Z
11
+ date: 2021-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -103,9 +103,9 @@ executables:
103
103
  extensions: []
104
104
  extra_rdoc_files: []
105
105
  files:
106
+ - ".github/workflows/test.yml"
106
107
  - ".gitignore"
107
108
  - ".rspec"
108
- - ".travis.yml"
109
109
  - Gemfile
110
110
  - LICENSE.txt
111
111
  - README.md
data/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.7.0
4
- - 2.6.2
5
- before_install:
6
- - gem update bundler