slaw 10.5.0 → 10.6.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: ba413f53b9d24192d6ce5a168eed83ca55a317dcb3768009cfdf3bf902a23327
4
- data.tar.gz: f664b13ce90bb21b65c0fffb2f780dc5937429c31ac2a9d6270259e0669f2f61
3
+ metadata.gz: 2feb9ea5e726f4300a0920de90b88f14b3a86ce4ae3dddd9a59b3bf8c855e575
4
+ data.tar.gz: 263ef515bc1a81b8cccc1788a3b107b573f3840492913cedf17ae729745d1c4b
5
5
  SHA512:
6
- metadata.gz: 0f0929aa1fcce2c86f6340fec7731f5e865e0b58b793b4f7d64ba48ec2463299498b4b96fea3487a11ab57a2ae932273e27c593395cd2ca263347006fa36a88a
7
- data.tar.gz: 72aceb516d091bd396deeb828873058a3cda366524c3e1819590ae77f021ab9a806baf0108f1239dceaaf0e7a64713e1c954ec385b5ed03563f1d702cd4b0984
6
+ metadata.gz: 573bab26b9e880856e74404058208e9fae5f400f0ee64413d771fea872e4b3b7c626ebefb5c020321dc4b4f35919b25b94801c6622e82d2f2a8dfe3507c35f61
7
+ data.tar.gz: 01d73bb0903dbee8213eae364316835361b4d34bbe0ed4a12f9dcaeb114bf1e5ec9ac46133e0570bea1998af0daaac610591da905463d64e63f1449ffd529db7
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.6.0 (10 May 2021)
90
+
91
+ * Handle sup and sub when extracting from HTML.
92
+
89
93
  ### 10.5.0 (20 April 2021)
90
94
 
91
95
  * Handle escaping inlines when unparsing.
@@ -11,9 +11,10 @@
11
11
 
12
12
  <xsl:template match="head|style|script|link" />
13
13
 
14
- <xsl:template match="ul|ol">
14
+ <!-- block containers that end with newlines -->
15
+ <xsl:template match="ul|ol|section|article|h1|h2|h3|h4|h5">
15
16
  <xsl:apply-templates />
16
- <xsl:text>&#10;</xsl:text>
17
+ <xsl:text>&#10;&#10;</xsl:text>
17
18
  </xsl:template>
18
19
 
19
20
  <xsl:template match="ul/li">
@@ -23,20 +24,23 @@
23
24
  <xsl:text>&#10;</xsl:text>
24
25
  </xsl:template>
25
26
 
27
+ <!-- numbered lists should include a number -->
26
28
  <xsl:template match="ol/li">
27
- <!-- 1. foo -->
29
+ <!-- \1. foo -->
28
30
  <xsl:text>\</xsl:text>
29
- <xsl:value-of select="position()" />
31
+ <xsl:choose>
32
+ <xsl:when test="@value">
33
+ <xsl:value-of select="@value" />
34
+ </xsl:when>
35
+ <xsl:otherwise>
36
+ <xsl:value-of select="position()" />
37
+ </xsl:otherwise>
38
+ </xsl:choose>
30
39
  <xsl:text>. </xsl:text>
31
40
  <xsl:apply-templates />
32
41
  <xsl:text>&#10;</xsl:text>
33
42
  </xsl:template>
34
43
 
35
- <xsl:template match="h1|h2|h3|h4|h5">
36
- <xsl:apply-templates />
37
- <xsl:text>&#10;&#10;</xsl:text>
38
- </xsl:template>
39
-
40
44
  <xsl:template match="p|div">
41
45
  <xsl:choose>
42
46
  <xsl:when test="starts-with(., '[') and substring(., string-length(.)) = ']'">
@@ -51,32 +55,27 @@
51
55
  <xsl:text>&#10;&#10;</xsl:text>
52
56
  </xsl:template>
53
57
 
58
+ <!-- START tables -->
59
+
54
60
  <xsl:template match="table">
55
61
  <xsl:text>{| </xsl:text>
56
- <xsl:text>
57
- |-</xsl:text>
62
+ <xsl:text>&#10;|-</xsl:text>
58
63
  <xsl:apply-templates />
59
- <xsl:text>
60
- |}
61
-
62
- </xsl:text>
64
+ <xsl:text>&#10;|}&#10;&#10;</xsl:text>
63
65
  </xsl:template>
64
66
 
65
67
  <xsl:template match="tr">
66
68
  <xsl:apply-templates />
67
- <xsl:text>
68
- |-</xsl:text>
69
+ <xsl:text>&#10;|-</xsl:text>
69
70
  </xsl:template>
70
71
 
71
72
  <xsl:template match="th|td">
72
73
  <xsl:choose>
73
74
  <xsl:when test="local-name(.) = 'th'">
74
- <xsl:text>
75
- ! </xsl:text>
75
+ <xsl:text>&#10;! </xsl:text>
76
76
  </xsl:when>
77
77
  <xsl:when test="local-name(.) = 'td'">
78
- <xsl:text>
79
- | </xsl:text>
78
+ <xsl:text>&#10;| </xsl:text>
80
79
  </xsl:when>
81
80
  </xsl:choose>
82
81
 
@@ -118,8 +117,15 @@
118
117
  </xsl:template>
119
118
 
120
119
  <xsl:template match="br">
121
- <xsl:text>
122
- </xsl:text>
120
+ <xsl:text>&#10;</xsl:text>
121
+ </xsl:template>
122
+
123
+ <xsl:template match="sup">
124
+ <xsl:text>^^</xsl:text><xsl:apply-templates /><xsl:text>^^</xsl:text>
125
+ </xsl:template>
126
+
127
+ <xsl:template match="sub">
128
+ <xsl:text>_^</xsl:text><xsl:apply-templates /><xsl:text>^_</xsl:text>
123
129
  </xsl:template>
124
130
 
125
131
 
@@ -293,7 +293,7 @@
293
293
  <xsl:text>&#10;</xsl:text>
294
294
  </xsl:if>
295
295
 
296
- <xsl:text>&#10;&#10;</xsl:text>
296
+ <xsl:text>&#10;</xsl:text>
297
297
  <xsl:apply-templates select="a:doc/a:mainBody" />
298
298
  </xsl:template>
299
299
 
data/lib/slaw/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Slaw
2
- VERSION = "10.5.0"
2
+ VERSION = "10.6.0"
3
3
  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.5.0
4
+ version: 10.6.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-04-21 00:00:00.000000000 Z
11
+ date: 2021-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake