-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UnicodeMath support #28
base: master
Are you sure you want to change the base?
Conversation
I have tried some fixes, but I can't get the tests to pass.
@hmdne Can you please give it a look? cc: @ronaldtse |
@suleman-uzair So, what are the possibilities, I see two obvious ones:
# backtick_javascript: true
# This particular thing is a macro that shields code from execution inside Opal. In this case - requirement, which will cause the entire suite to be compiled by Opal.
require "twitter-cldr" unless RUBY_ENGINE == 'opal'
if RUBY_ENGINE == 'opal'
# Backticks/x-strings allow you to execute JavaScript code, just ensure you pass an array, string, number or boolean (and expect a return of the same form) - but NOT nil, null, undefined, Ruby or JavaScript objects.
return_value = `Javascript.Code(#{variable_from_ruby})`
else
return_value = Ruby::Code(variable_from_ruby)
end Then adjust the build system of
if RUBY_ENGINE == 'opal'
require 'available_locales_opal'
else
AVAILABLE_LOCALES = YAML.load_file("locales.json")
end
def locale_supported?(locale)
AVAILABLE_LOCALES.include? locale
end # available_locales_opal.rb.erb
# This ERB file is executed by Opal at compile time (using MRI), producing an RB file.
# This RB file does not load external resources.
AVAILABLE_LOCALES = <%= YAML.load_file("locales.json").inspect %> I have tried to build on your branch a little, first there's a patch needed for plurimath due to a tricky regexp: diff --git a/lib/plurimath/latex/parser.rb b/lib/plurimath/latex/parser.rb
index b0ced07..7eb4aa4 100644
--- a/lib/plurimath/latex/parser.rb
+++ b/lib/plurimath/latex/parser.rb
@@ -8,7 +8,7 @@ module Plurimath
class Parser
attr_accessor :text
- TEXT_REGEX = %r(\\(?:mbox|text){[^}]+})
+ TEXT_REGEX = %r(\\(?:mbox|text)\{[^}]+\})
def initialize(text)
@text = pre_processing(text) Second, I dropped your diff --git a/build.sh b/build.sh
index 4713f5e..1c1f526 100755
--- a/build.sh
+++ b/build.sh
@@ -18,6 +18,25 @@ bundle exec opal --esm -sjruby \
-Ivendor/ruby-ll/ext/pureruby/ \
-Ivendor/plurimath/lib \
-pplurimath \
+ -snokogiri \
+ -sox \
+ -sox/ox \
+ -sox.so \
+ -szip \
+ -sconcurrent \
+ -sparallel \
+ -scldr-plurals \
+ -scldr/export \
+ -sjava \
+ -setc \
+ -sregexp_parser \
+ -stsort \
+ -srexml/document \
+ -stzinfo/data \
+ -stempfile \
+ -si18n \
+ -snet/ftp \
+ -stwitter_cldr/resources/requirements \
-c -e'#' > tmp/plurimath-opal.js
echo "** Minifying Plurimath-Opal with Terser" Unfortunately, while this successfully compiles our library, the library is unusable due to aforementioned issues. |
I think the best way forward is not to use twitter-cldr and go with a plain Ruby solution. The number formatting rules aren't so complex and numerous that we can extract from CLDR (or post-process twitter-cldr) directly. |
@hmdne I will add this patch in my next commit.
@ronaldtse I totally agree with you. I will open an issue for this and start working on it right away. |
@suleman-uzair so we no longer use twitter-cldr. Is this task ready to go? |
@ronaldtse I just updated the Plurimath submodule in the repo, but it's still failing for some reason, I'll look into it right after the current task. |
e931bf6
to
5ae44b1
Compare
b2de2e5
to
ee519c0
Compare
@ronaldtse, This PR is now finalized using Plurimath's latest state.
Unfortunately, LutaML-Model's Oga support is not quite smooth yet (the issue exists at lutaml/lutaml-model#100), which might cause a crash for some XMLL examples.
NumberFormatter depends on BigDecimal for numeric calculations and conversions, and Opal is raising an error similar to @hmdne, can you help/guide for BigDecimal support? I see BigDecimal class in Opal. |
It is in stdlib, so you need to |
@ronaldtse, I will merge/finalize this PR after the following PRs are merged: |
UPDATE @ronaldtse, This PR is in progress for now. |
This PR supports UnicodeMath and the test case.
close plurimath/plurimath.org/issues/38
close plurimath/plurimath#316