Skip to content

Commit

Permalink
Latest Plurimath version and Unicodemath support
Browse files Browse the repository at this point in the history
  • Loading branch information
suleman-uzair committed Dec 20, 2024
1 parent 4ef246a commit ee519c0
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:mantic
FROM ubuntu:24.04

RUN apt-get update && apt-get upgrade -y && apt-get install -y ragel ruby gcc g++ ruby-dev npm git wget make ruby-bundler libyaml-dev && apt-get clean

Expand Down
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ gem 'equivalent-xml', path: 'vendor/equivalent-xml'
gem 'ruby-ll', path: 'vendor/ruby-ll'
gem 'htmlentities', path: 'vendor/htmlentities'
gem 'opal', path: 'vendor/opal'
gem 'mml', git: 'https://github.com/plurimath/mml.git', branch: 'update/plurimath-js-support'

gem 'opal-rspec', '>= 1.1.0a'

Expand All @@ -22,3 +23,5 @@ gem 'rack'
gem 'rackup'
gem 'simplecov'
gem 'ox'
gem 'unitsml'
gem 'monitor'
9 changes: 8 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@ bundle exec opal --esm -sjruby \
-qerb \
-rcorelib/array/pack \
-ropal-parser \
-gunitsml \
-ghtmlentities \
-goga \
-gparslet \
-gzeitwerk \
-gmonitor \
-sox \
-sox/ox \
-sox.so \
-Ivendor/oga/lib/ \
-Ivendor/oga/xml/ \
-Ivendor/oga/xpath/ \
-Ivendor/oga/ext/pureruby/ \
-Ivendor/ruby-ll/lib/ \
-Ivendor/ruby-ll/ext/pureruby/ \
-Ivendor/plurimath/lib \
-pplurimath \
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
"scripts": {
"test": "npm run test:js && npm run test:rb",
"test:js": "npm run build && jest",
"test:rb": "podman run --rm -it -v.:/srv:z plurimath-js /bin/bash -c './setup.sh && env/plurimath'",
"test:rb": "podman run --rm -it -v $(pwd):/srv:z plurimath-js /bin/bash -c './setup.sh && env/plurimath'",
"podman:build": "podman build -t plurimath-js .",
"podman:shell": "podman run --rm -it -v.:/srv:z plurimath-js",
"podman:bundle": "podman run --rm -it -v.:/srv:z plurimath-js /bin/bash -c './setup.sh && ./build.sh'",
"podman:shell": "podman run --rm -it -v $(pwd):/srv:z plurimath-js",
"podman:bundle": "podman run --rm -it -v $(pwd):/srv:z plurimath-js /bin/bash -c './setup.sh && ./build.sh'",
"build": "npm run podman:build && npm run podman:bundle",
"submodule:init": "git submodule init && npm run submodule:update",
"submodule:update": "git submodule update"
Expand Down
9 changes: 9 additions & 0 deletions spec/to-unicodemath.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Plurimath from "../dist"

describe('to unicodemath', () => {
it('', () => {
const math = new Plurimath('∑_𝑥^𝑦 𝑧', 'unicode')

expect(math.toUnicodemath().trim()).toBe('∑_(𝑥)^(𝑦)▒〖𝑧〗')
})
})
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,8 @@ export default class Plurimath {
toDisplay(lang: string) {
return this.data.$to_display(lang);
}

toUnicodemath() {
return this.data.$to_unicodemath();
}
}
3 changes: 2 additions & 1 deletion src/plurimath-opal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ declare namespace Opal {

namespace Plurimath {
namespace Math {
type Format = 'asciimath' | 'latex' | 'mathml' | 'html' | 'mahtml' | 'omml'
type Format = 'asciimath' | 'latex' | 'mathml' | 'html' | 'unicode' | 'omml'
function $parse(data: string | unknown, format: Format): ParserResult

type TransmuterFunction = () => string
Expand All @@ -17,6 +17,7 @@ declare namespace Opal {
$to_html: TransmuterFunction
$to_omml: TransmuterFunction
$to_display: (string) => string
$to_unicodemath: TransmuterFunction
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion vendor/plurimath
Submodule plurimath updated 3596 files

0 comments on commit ee519c0

Please sign in to comment.