math-to-itex 0.5.0 → 0.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
  SHA1:
3
- metadata.gz: 85ec1f622ed0650bb8015af5ede8f2775cf8be9d
4
- data.tar.gz: 5af32430d9ba4a0139531ce57149c8f11737c671
3
+ metadata.gz: ad9eb19885894425d7140a3eea899a84ec499c35
4
+ data.tar.gz: 7653c1957f9b7296bcc4925e06b59cff9b69dffe
5
5
  SHA512:
6
- metadata.gz: ce23506111f9b6503bcfc4ad46ea4a49850dc230b39ca25bacf6f0a814989bb20a2e4487265de7f26d527de6823f282293888bb75dd6077a5b07fcb0d3d3c50d
7
- data.tar.gz: 7825e268c384f29a5f1eb51d922c79e91ef60eac7dc19a3846d5935d41697173863f01d6c9633263946b91507883da85635e9755d3b76c0b8f87878ef6c04b48
6
+ metadata.gz: 2bdd032b1d6876f01df7f3a6a4fdd37346c983d734b985b60d93c13f92695f8e972b89b3a8be648bc3732c9a2d2ac3084055510b859ad09777a0b96226148a38
7
+ data.tar.gz: 9f068d67aa84fa0a1f84e441251a5647aa12c1a7420687b97ff24c9126dbb908a598c2de821ce98833ea07ddefd03825e3a16603083cce1f01e55695e45391b6
@@ -32,6 +32,9 @@ module MathToItex
32
32
  elsif maths =~ /\A\\begin{displaymath}(?!\\begin{displaymath})/
33
33
  just_maths = maths[19..-18]
34
34
  type = :display
35
+ elsif maths =~ /\A\\begin{#{MathToItex::Parser::JOINED_ENVIRONMENTS}}(?!\\begin{#{MathToItex::Parser::JOINED_ENVIRONMENTS}})/
36
+ just_maths = maths
37
+ type = :display
35
38
  end
36
39
 
37
40
  # this is the format itex2MML expects
@@ -1,5 +1,7 @@
1
1
  module MathToItex
2
2
  class Parser
3
+ ENVIRONMENTS = %w(align align\* alignat alignat\* aligned alignedat array Bmatrix bmatrix cases displaymath eqnarray eqnarray\* equation equation\* gather gather\* gathered math matrix multline multline\* pmatrix smallmatrix split subarray svg Vmatrix vmatrix)
4
+ JOINED_ENVIRONMENTS = ENVIRONMENTS.join('|')
3
5
  # https://stackoverflow.com/questions/14182879/regex-to-match-latex-equations
4
6
  REGEX = /
5
7
  (?<!\\) # negative look-behind to make sure start is not escaped
@@ -12,7 +14,7 @@ module MathToItex
12
14
  # group 3, match escaped bracket
13
15
  (\\\[)|
14
16
  # group 4, match begin equation
15
- (\\begin\{(?:equation|math|displaymath)\})
17
+ \\begin\{(#{JOINED_ENVIRONMENTS})\}
16
18
  )
17
19
  (.*?(\g<1>)?.*?) # match everything in between including nested LaTeX equations
18
20
  (?<!\\) # negative look-behind to make sure end is not escaped
@@ -23,7 +25,7 @@ module MathToItex
23
25
  # if group 3 was start, escaped bracket is end
24
26
  (?(3)\\\]|
25
27
  # otherwise group 4 was start, match end equation
26
- \\end\{(?:equation|math|displaymath)\}
28
+ \\end\{\4\}
27
29
  )))
28
30
  /xm
29
31
  end
@@ -1,3 +1,3 @@
1
1
  module MathToItex
2
- VERSION = '0.5.0'
2
+ VERSION = '0.6.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: math-to-itex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen Torikian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-06 00:00:00.000000000 Z
11
+ date: 2016-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake