plurimath 0.3.6 → 0.3.7

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: 10711816eed513eb42250bdc90628a5ed3c9847cb33546e7df19ea29ca56b85e
4
- data.tar.gz: 872e488b9b856e55c6e00ac6c19e089853950ec8a58fb4057abe601efee88604
3
+ metadata.gz: 39522e32ac4e62af9eb862173a64e6e8650a9531bae27f321f25c6a1bc594e95
4
+ data.tar.gz: df5419195046dcf270cd4561c8cf3f9657536217a370d7a9aef150d7ca6aec72
5
5
  SHA512:
6
- metadata.gz: b916d733033785acb282ffe2544e05387b65b54f53e83ba7f28cbb7e73ea71f8766129adb8d369560cb3b2df46de6f5215d68bb85755c3bb1b3d35e44963403e
7
- data.tar.gz: 07204d723d30656e42791e79d954864da64acc41dbf84dff936e8fc88a51ca4a22d40b8fd426bd81f523a829837d5c0e8f7fcd5569a12025eb5128dc00cda0de
6
+ metadata.gz: 0a2c7880f03ba5d70c508b61f9c272be5a4780cbc5a30f56e142f7aa6798b5a8059051c6ecaf80ac9c209ab2cda977d55d7354f28e06e42c3dd439e3e96c0349
7
+ data.tar.gz: f2c0962524dc14232b0a48a4cd92015551f39603087bc42b08e73d0a3e66952ae2ab260f13166d159de378bd1757c24b0039a58d5b0fd129fb7be431f523e6a1
@@ -3,12 +3,17 @@
3
3
  module Plurimath
4
4
  module Math
5
5
  class Formula < Core
6
- attr_accessor :value, :left_right_wrapper
6
+ attr_accessor :value, :left_right_wrapper, :displaystyle
7
7
 
8
- def initialize(value = [], left_right_wrapper = true)
8
+ def initialize(
9
+ value = [],
10
+ left_right_wrapper = true,
11
+ displaystyle: true
12
+ )
9
13
  @value = value.is_a?(Array) ? value : [value]
10
14
  left_right_wrapper = false if @value.first.is_a?(Function::Left)
11
15
  @left_right_wrapper = left_right_wrapper
16
+ @displaystyle = displaystyle
12
17
  end
13
18
 
14
19
  def ==(object)
@@ -20,12 +25,12 @@ module Plurimath
20
25
  value.map(&:to_asciimath).join(" ")
21
26
  end
22
27
 
23
- def to_mathml
28
+ def to_mathml(display_style: displaystyle)
24
29
  math_attrs = {
25
30
  xmlns: "http://www.w3.org/1998/Math/MathML",
26
31
  display: "block",
27
32
  }
28
- style_attrs = { displaystyle: "true" }
33
+ style_attrs = { displaystyle: display_style }
29
34
  math = Utility.ox_element("math", attributes: math_attrs)
30
35
  style = Utility.ox_element("mstyle", attributes: style_attrs)
31
36
  Utility.update_nodes(style, mathml_content)
@@ -21,10 +21,12 @@ module Plurimath
21
21
  end
22
22
 
23
23
  def parse
24
- ox_nodes = Ox.load(text, strip_namespace: true).nodes
25
- nodes = parse_nodes(ox_nodes)
24
+ ox_nodes = Ox.load(text, strip_namespace: true)
25
+ display_style = ox_nodes&.locate("*/mstyle/@displaystyle")&.first
26
+ nodes = parse_nodes(ox_nodes.nodes)
26
27
  Math::Formula.new(
27
28
  Transform.new.apply(nodes).flatten.compact,
29
+ displaystyle: display_style
28
30
  )
29
31
  end
30
32
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Plurimath
4
- VERSION = "0.3.6"
4
+ VERSION = "0.3.7"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plurimath
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-26 00:00:00.000000000 Z
11
+ date: 2023-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parslet