slaw 10.6.0 → 10.7.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 +4 -4
- data/.github/workflows/test.yml +22 -0
- data/README.md +4 -0
- data/lib/slaw/grammars/inlines.treetop +7 -1
- data/lib/slaw/grammars/inlines_nodes.rb +9 -0
- data/lib/slaw/grammars/za/act_text.xsl +17 -5
- data/lib/slaw/version.rb +1 -1
- data/spec/fixtures/roundtrip-escapes.txt +4 -0
- data/spec/generator_spec.rb +21 -0
- data/spec/za/act_inline_spec.rb +13 -0
- metadata +3 -3
- data/.travis.yml +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e4cdd070ad171d0d999cbaa93da4fb2723df0a2d430679833d3588903049575
|
4
|
+
data.tar.gz: 33bffb144c455bb8d35f7c8dc7e3593041eead5d1c76569575afa8df73bd0a8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
@@ -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"
|
63
|
-
|
64
|
-
|
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="'
|
68
|
-
<xsl:with-param name="replacement"><xsl:value-of select="'
|
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> </xsl:text>
|
402
414
|
</xsl:template>
|
data/lib/slaw/version.rb
CHANGED
data/spec/generator_spec.rb
CHANGED
@@ -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
|
|
data/spec/za/act_inline_spec.rb
CHANGED
@@ -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.
|
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-
|
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
|