-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding support for stem equations (#24)
* Adding support for stem equations * added test cases
- Loading branch information
1 parent
5587781
commit 8e36f55
Showing
5 changed files
with
111 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
|
||
require "jekyll" | ||
require "glossarist" | ||
require "plurimath" | ||
|
||
module Jekyll | ||
module Geolexica | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# (c) Copyright 2020 Ribose Inc. | ||
# | ||
|
||
RSpec.describe ::Jekyll::Geolexica::Hooks do | ||
subject do | ||
w = Object.new | ||
w.extend(described_class) | ||
w | ||
end | ||
|
||
let(:page) do | ||
instance_double( | ||
Jekyll::Geolexica::ConceptPage::HTML, | ||
output: page_output, | ||
html?: is_html, | ||
) | ||
end | ||
|
||
describe ".convert_math" do | ||
context "when page is HTML" do | ||
let(:is_html) { true } | ||
|
||
let(:page_output) do | ||
"foo stem:[a_2] bar" | ||
end | ||
|
||
let(:expected_output) do | ||
<<~OUTPUT.strip | ||
foo <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"> | ||
<mstyle displaystyle="true"> | ||
<msub> | ||
<mi>a</mi> | ||
<mn>2</mn> | ||
</msub> | ||
</mstyle> | ||
</math> | ||
bar | ||
OUTPUT | ||
end | ||
|
||
it "should convert stem:[] to MathML" do | ||
expect { subject.send(:convert_math, page) } | ||
.to change { page.output } | ||
.from(page_output) | ||
.to(expected_output) | ||
end | ||
end | ||
|
||
context "when page is not HTML" do | ||
let(:is_html) { false } | ||
|
||
let(:page_output) do | ||
"foo stem:[a_2] bar" | ||
end | ||
|
||
let(:expected_output) do | ||
<<~OUTPUT.strip | ||
foo <math xmlns=\\"http://www.w3.org/1998/Math/MathML\\" display=\\"inline\\"> <mstyle displaystyle=\\"true\\"> <msub> <mi>a</mi> <mn>2</mn> </msub> </mstyle></math> bar | ||
OUTPUT | ||
end | ||
|
||
it "should convert stem:[] to MathML" do | ||
expect { subject.send(:convert_math, page) } | ||
.to change { page.output } | ||
.from(page_output) | ||
.to(expected_output) | ||
end | ||
end | ||
end | ||
end |