asciimath 2.0.4 → 2.0.5

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: 6c38e7e41750527b0992c27f6e636cb6b670eec3008563e1a5fe19fc86458991
4
- data.tar.gz: 3313df7a9524d4a4e384be1ec54f38aafe2ff70553ae65aa695c530fff5f45e9
3
+ metadata.gz: 86018ef6bb3e96fddebb125bf2d246b847378dd686cfa720398c09970ad00696
4
+ data.tar.gz: 6347a679a01a6fbfa1b56cfa366e43f80bf195a763efe9150f69067dbaf0c227
5
5
  SHA512:
6
- metadata.gz: a7b29b1332ddb6965162a5b1e82d15c459e5a9ea4d514646b0663ea52adfe5b1999d1078e850dee228160e09b5ac052dde48b39aaa946d6587b97b2658109215
7
- data.tar.gz: 6bfce3c229fea323dbfaff74ab1987802b9ae6c7b0ae32562b868bc5da2fd35bc76d0a8c9aa1e414c2765839e02065c5575d5366af89e4becadb882ee084ce08
6
+ metadata.gz: 9886f869eafa972e926c0103fc13c56a67203d2a71eaa607489169d7695225cfe3cdbf216ef325153e9d24f7ea8f57c26482a71752a9713992d866826b08a879
7
+ data.tar.gz: 985c445a620542eb3d6f851ce1c832b2c8b89c9aa1d3a2258c64d23456cddb7b36b7953de5f954c3fbbfd9769f113edc499881b88206b4bfc67137ea3cfbaf03
data/CHANGELOG.adoc CHANGED
@@ -1,5 +1,11 @@
1
1
  = Asciimath Changelog
2
2
 
3
+ == 2.0.5
4
+
5
+ Bug fixes::
6
+
7
+ * Issue #75: render `tilde x` as `\tilde{x}` instead of `\~{x}` in LaTeX output.
8
+
3
9
  == 2.0.4
4
10
 
5
11
  Bug fixes::
@@ -73,7 +73,7 @@ module AsciiMath
73
73
  :glb => "\\operatorname{glb}",
74
74
  :partial => "\\del",
75
75
  :prime => ?',
76
- :tilde => "\\~",
76
+ :tilde => "\\tilde",
77
77
  :nbsp => "\\;",
78
78
  :lceiling => "\\lceil",
79
79
  :rceiling => "\\rceil",
@@ -172,9 +172,9 @@ module AsciiMath
172
172
  if e.is_a?(AsciiMath::AST::UnaryOp) &&
173
173
  %i[underbrace overbrace].include?(e.operator.value)
174
174
  append(e)
175
- else
176
- curly(e)
177
- end
175
+ else
176
+ curly(e)
177
+ end
178
178
 
179
179
  if sub
180
180
  @latex << "_"
@@ -253,9 +253,9 @@ module AsciiMath
253
253
  b.add('!=', 'ne', :ne, :symbol)
254
254
  b.add(':=', :assign, :symbol)
255
255
  b.add('<', 'lt', :lt, :symbol)
256
- b.add('mlt', :mlt, :symbol)
256
+ b.add('mlt', 'll', :mlt, :symbol)
257
257
  b.add('>', 'gt', :gt, :symbol)
258
- b.add('mgt', :mgt, :symbol)
258
+ b.add('mgt', 'gg', :mgt, :symbol)
259
259
  b.add('<=', 'le', :le, :symbol)
260
260
  b.add('>=', 'ge', :ge, :symbol)
261
261
  b.add('-<', '-lt', 'prec', :prec, :symbol)
@@ -432,16 +432,16 @@ module AsciiMath
432
432
  b.add('ubrace', 'underbrace', :underbrace, :unary)
433
433
  b.add('obrace', 'overbrace', :overbrace, :unary)
434
434
  b.add('cancel', :cancel, :unary)
435
- b.add('bb', :bold, :unary)
436
- b.add('bbb', :double_struck, :unary)
435
+ b.add('bb', 'mathbf', :bold, :unary)
436
+ b.add('bbb', 'mathbb', :double_struck, :unary)
437
437
  b.add('ii', :italic, :unary)
438
438
  b.add('bii', :bold_italic, :unary)
439
- b.add('cc', :script, :unary)
439
+ b.add('cc', 'mathcal', :script, :unary)
440
440
  b.add('bcc', :bold_script, :unary)
441
- b.add('tt', :monospace, :unary)
442
- b.add('fr', :fraktur, :unary)
441
+ b.add('tt', 'mathtt', :monospace, :unary)
442
+ b.add('fr', 'mathfrak', :fraktur, :unary)
443
443
  b.add('bfr', :bold_fraktur, :unary)
444
- b.add('sf', :sans_serif, :unary)
444
+ b.add('sf', 'mathsf', :sans_serif, :unary)
445
445
  b.add('bsf', :bold_sans_serif, :unary)
446
446
  b.add('sfi', :sans_serif_italic, :unary)
447
447
  b.add('sfbi', :sans_serif_bold_italic, :unary)
@@ -801,7 +801,7 @@ module AsciiMath
801
801
  end
802
802
 
803
803
  DEFAULT_COLOR_TABLE = ::AsciiMath::Parser.add_default_colors(AsciiMath::ColorTableBuilder.new).build
804
- DEFAULT_PARSER_SYMBOL_TABLE = ::AsciiMath::Parser.add_default_parser_symbols(AsciiMath::SymbolTableBuilder.new).build
804
+ DEFAULT_PARSER_SYMBOL_TABLE = ::AsciiMath::Parser.add_default_parser_symbols(AsciiMath::SymbolTableBuilder.new(allow_symbol_overwrites: false)).build
805
805
  end
806
806
 
807
807
  class Expression
@@ -1,7 +1,8 @@
1
1
  module AsciiMath
2
2
  class SymbolTableBuilder
3
- def initialize()
3
+ def initialize(allow_symbol_overwrites: true)
4
4
  @table = {}
5
+ @allow_symbol_overwrites = allow_symbol_overwrites
5
6
  end
6
7
 
7
8
  def add(*args)
@@ -15,7 +16,11 @@ module AsciiMath
15
16
  entry[:value] = args.pop
16
17
 
17
18
  entry.freeze
18
- args.each { |name| @table[name.freeze] = entry }
19
+ args.map(&:freeze).each do |name|
20
+ raise "Symbol overwrites are disallowed, but were attempted for #{name}" if !@allow_symbol_overwrites && !@table[name].nil?
21
+
22
+ @table[name] = entry
23
+ end
19
24
  end
20
25
 
21
26
  def build
@@ -1,3 +1,3 @@
1
1
  module AsciiMath
2
- VERSION = "2.0.4"
2
+ VERSION = "2.0.5"
3
3
  end
@@ -25,4 +25,10 @@ describe 'AsciiMath::Parser', :variant => :ast do
25
25
  parsed = AsciiMath::parse("a + b", my_tokens_table.build)
26
26
  expect(parsed.ast).to eq(seq(identifier('a'), ::AsciiMath::AST::Symbol.new(:foo, '+', :symbol), identifier('b')))
27
27
  end
28
+
29
+ it "should support disallowing symbol overwrites" do
30
+ my_tokens_table = AsciiMath::SymbolTableBuilder.new(allow_symbol_overwrites: false)
31
+ AsciiMath::Parser.add_default_parser_symbols(my_tokens_table)
32
+ expect{my_tokens_table.add('+', :foo, :symbol)}.to raise_error 'Symbol overwrites are disallowed, but were attempted for +'
33
+ end
28
34
  end
data/spec/parser_spec.rb CHANGED
@@ -649,6 +649,11 @@ RSpec.shared_examples 'AsciiMath Examples' do
649
649
  :mathml => '<math><munder><munder accentunder="true"><mrow><mo>(</mo><mtable><mtr><mtd><mn>1</mn></mtd><mtd><mn>0</mn></mtd></mtr><mtr><mtd><mn>0</mn></mtd><mtd><mn>1</mn></mtd></mtr></mtable><mo>)</mo></mrow><mo>&#x23DF;</mo></munder><mtext>Adjustment to texture space</mtext></munder></math>'
650
650
  ))
651
651
 
652
+ example('tilde x', &should_generate(
653
+ :ast => unary(symbol('tilde'), 'x'),
654
+ :latex => '\\tilde{x}'
655
+ ))
656
+
652
657
 
653
658
  version = RUBY_VERSION.split('.').map { |s| s.to_i }
654
659
 
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciimath
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pepijn Van Eeckhoudt
8
8
  - Gark Garcia
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-04-21 00:00:00.000000000 Z
12
+ date: 2023-04-09 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A pure Ruby AsciiMath parsing and conversion library.
15
15
  email:
@@ -85,7 +85,7 @@ homepage: ''
85
85
  licenses:
86
86
  - MIT
87
87
  metadata: {}
88
- post_install_message:
88
+ post_install_message:
89
89
  rdoc_options: []
90
90
  require_paths:
91
91
  - lib
@@ -100,8 +100,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
100
  - !ruby/object:Gem::Version
101
101
  version: '0'
102
102
  requirements: []
103
- rubygems_version: 3.2.22
104
- signing_key:
103
+ rubygems_version: 3.0.3.1
104
+ signing_key:
105
105
  specification_version: 4
106
106
  summary: AsciiMath parser and converter
107
107
  test_files: