8000 TeX on Markup widgets Div, Paragraph by IuryPiva · Pull Request #11585 · bokeh/bokeh · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
2bcffb9
TeX working on div widgets
IuryPiva Sep 10, 2021
d6a2328
add missing inline prop to bokeh
IuryPiva Sep 11, 2021
3b073f2
baselins for tex on div
IuryPiva Sep 11, 2021
2ab38cc
check for property exist instead of getting all property values
IuryPiva Sep 11, 2021
f266a8c
restore default options
IuryPiva Sep 11, 2021
936e05f
use mathjax namespace
IuryPiva Sep 11, 2021
c7bd719
export mathjax provider
IuryPiva Sep 11, 2021
ec53f89
update div imports
IuryPiva Sep 11, 2021
277257b
remove log and unnecessary filter
IuryPiva Sep 11, 2021
678cfe1
update mathjax namespace
IuryPiva Sep 11, 2021
d5308dd
update find math function
IuryPiva Sep 11, 2021
cf6a318
unit tests find_math_parts
IuryPiva Sep 11, 2021
a24d884
update docstrings
IuryPiva Sep 11, 2021
6205be8
check for mathstrings by default; have a disable flag
IuryPiva Sep 11, 2021
22b09b2
update markups to accept tex
IuryPiva Sep 11, 2021
1f1a55b
update import order
IuryPiva Sep 11, 2021
146c6a4
update baselines
IuryPiva Sep 11, 2021
1689425
remove outdated baselines
IuryPiva Sep 11, 2021
cef673a
change is_tex_string to contains_tex_string
IuryPiva Sep 11, 2021
0f75ec5
give latex tests some threshold
IuryPiva Sep 11, 2021
b40b20d
threshold fix
IuryPiva Sep 11, 2021
f9e94c3
fix wrong style on paragraph
IuryPiva Sep 11, 2021
64eaae9
remove needless thresholds
IuryPiva Sep 11, 2021
42972b3
removed tex support from pre
IuryPiva Sep 11, 2021
88d8eb5
Merge branch 'branch-2.4' into iurypiva/mathtext-on-div-widget
IuryPiva Sep 11, 2021
d87fe63
Fix typo
IuryPiva Sep 11, 2021
c6384df
smaller sample text for pre test not latex
IuryPiva Sep 11, 2021
b71ca9b
update pre baselines
IuryPiva Sep 11, 2021
8fe2742
use doublequotes
IuryPiva Sep 11, 2021
5ffd54c
snake case
IuryPiva Sep 12, 2021
28cffab
remove random whitespace
IuryPiva Sep 12, 2021
50fee9d
update docstrings
IuryPiva Sep 12, 2021
f27068a
replace find math with regexs and mathjax implementation
IuryPiva Sep 13, 2021
227aa05
move processing of tex to views
IuryPiva Sep 13, 2021
0557249
output which tests has caused errors
IuryPiva Sep 13, 2021
9ac23e8
update contains_tex check
IuryPiva Sep 13, 2021
abcf63e
check if parts are undefined
IuryPiva Sep 13, 2021
9398619
update docstrings
IuryPiva Sep 13, 2021
4966a6a
add line between tests
IuryPiva Sep 13, 2021
d2e590f
remove test description
IuryPiva Sep 13, 2021
47f26af
rename find_math to find_tex
IuryPiva Sep 13, 2021
19099b2
remove todo warning
IuryPiva Sep 13, 2021
d440f03
remove needless regex flag
IuryPiva Sep 13, 2021
85769d5
update provider interaction
IuryPiva Sep 13, 2021
caf6540
make code consistent with other markups
IuryPiva Sep 13, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
unit tests find_math_parts
  • Loading branch information
IuryPiva committed Sep 11, 2021
commit cf6a318766b521fb9ffdcace1de2ab3ad87a4825
157 changes: 157 additions & 0 deletions bokehjs/test/unit/ 8000 models/text/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
import {expect} from "assertions"

import {TeX} from "@bokehjs/models/text/math_text"
import {PlainText} from "@bokehjs/models/text/plain_text"
import {find_math_parts} from "@bokehjs/models/text/utils"

describe("text utils", () => {
describe("find_math_parts find tex elements on strings", () => {
function isTeX(text_model: PlainText): text_model is TeX {
return text_model instanceof TeX
}
function isPlainText(text_model: PlainText) {
return !(text_model instanceof TeX)
}

it("resolve to textbox when delimiters are only on end", () => {
const parts = find_math_parts("test$$")
expect(parts.length).to.be.equal(1)
expect(isPlainText(parts[0])).to.be.true
expect(parts[0].text).to.be.equal("test$$")
})
it("resolve to textbox when delimiters are only on start", () => {
const parts = find_math_parts("$$test")
expect(parts.length).to.be.equal(1)
expect(isPlainText(parts[0])).to.be.true
expect(parts[0].text).to.be.equal("$$test")
})
it("find block tex elements with delimiters $$ and $$", () => {
const parts = find_math_parts("$$test$$")
expect(parts.length).to.be.equal(1)
expect(isTeX(parts[0]))
expect(isTeX(parts[0]) && !parts[0].inline)
expect(parts[0].text).to.be.equal("test")
})
it("find block tex elements with delimiters \\[ and \\]", () => {
const parts = find_math_parts("\\[test\\]")
expect(parts.length).to.be.equal(1)
expect(isTeX(parts[0]))
expect(isTeX(parts[0]) && !parts[0].inline)
expect(parts[0].text).to.be.equal("test")
})
it("find inline tex elements with delimiters \\( and \\)", () => {
const parts = find_math_parts("\\(test\\)")
expect(parts.length).to.be.equal(1)
expect(isTeX(parts[0]))
expect(isTeX(parts[0]) && parts[0].inline)
})
it("starts with one delimiter and with other", () => {
const parts = find_math_parts("$$test\\]")
expect(parts.length).to.be.equal(1)
expect(isPlainText(parts[0]))
expect(parts[0].text).to.be.equal("$$test\\]")
})
it("starts with open delimiter and has an pair later", () => {
const parts = find_math_parts("$$test $$ end $$")
expect(parts.length).to.be.equal(2)
expect(isTeX(parts[0]))
expect((parts[0] as TeX).inline).to.be.false
expect(isPlainText(parts[1]))
expect(parts[0].text).to.be.equal("test ")
expect(parts[1].text).to.be.equal(" end $$")
})
it("starts with open delimiter and has an different pair later", () => {
const parts = find_math_parts("\\[test $$end$$")
expect(parts.length)
expect(parts.length).to.be.equal(2)
expect(isPlainText(parts[0]))
expect(isTeX(parts[1]))
expect((parts[1] as TeX).inline).to.be.false
expect(parts[0].text).to.be.equal("\\[test ")
expect(parts[1].text).to.be.equal("end")
})
it("starts with text then open delimiter and has an different pair later", () => {
const parts = find_math_parts("text \\[text $$latex$$")
expect(parts.length)
expect(parts.length).to.be.equal(2)
expect(isPlainText(parts[0]))
expect(isTeX(parts[1]))
expect((parts[1] as TeX).inline).to.be.false
expect(parts[0].text).to.be.equal("text \\[text ")
expect(parts[1].text).to.be.equal("latex")
})
it("ignore nested different delimiters", () => {
const parts = find_math_parts("$$ tex [ tex ] tex $$")
expect(parts.length)
expect(parts.length).to.be.equal(1)
expect(isTeX(parts[0]))
expect((parts[0] as TeX).inline).to.be.false
expect(parts[0].text).to.be.equal(" tex [ tex ] tex ")
})
it("ends on first end delimiter even if there is more after", () => {
const parts = find_math_parts("$$tex$$text$$tex$$")
expect(parts.length)
expect(parts.length).to.be.equal(3)
expect(isTeX(parts[0]))
expect((parts[0] as TeX).inline).to.be.false
expect(isPlainText(parts[1]))
expect(isTeX(parts[2]))
expect((parts[2] as TeX).inline).to.be.false
expect(parts[0].text).to.be.equal("tex")
expect(parts[1].text).to.be.equal("text")
expect(parts[2].text).to.be.equal("tex")
})
it("multiple pairs", () => {
const parts = find_math_parts(
"When \\(a \\ne 0\\), there are two solutions to \\(ax^2 + bx + c = 0\\) and they are $$x = {-b \\pm \\sqrt{b^2-4ac} \\over 2a}.$$"
)
expect(parts.length)
expect(parts.length).to.be.equal(6)
expect(isPlainText(parts[0]))
expect(isTeX(parts[1]))
expect((parts[1] as TeX).inline).to.be.true
expect(isPlainText(parts[2]))
expect(isTeX(parts[3]))
expect((parts[3] as TeX).inline).to.be.true
expect(isPlainText(parts[4]))
expect(isTeX(parts[5]))
expect((parts[5] as TeX).inline).to.be.false
expect(parts[0].text).to.be.equal("When ")
expect(parts[1].text).to.be.equal("a \\ne 0")
expect(parts[2].text).to.be.equal(", there are two solutions to ")
expect(parts[3].text).to.be.equal("ax^2 + bx + c = 0")
expect(parts[4].text).to.be.equal(" and they are ")
expect(parts[5].text).to.be.equal("x = {-b \\pm \\sqrt{b^2-4ac} \\over 2a}.")
})
it("have many open delimiter but only first closes", () => {
const parts = find_math_parts("part0$$part1\\[part2\\(part3$$")
expect(parts.length)
expect(parts.length).to.be.equal(2)
expect(isPlainText(parts[0]))
expect(isTeX(parts[1]))
expect((parts[1] as TeX).inline).to.be.false
expect(parts[0].text).to.be.equal("part0")
expect(parts[1].text).to.be.equal("part1\\[part2\\(part3")
})
it("have many open delimiter but only middle closes", () => {
const parts = find_math_parts("part0$$part1\\[part2\\(part3\\]")
expect(parts.length)
expect(parts.length).to.be.equal(2)
expect(isPlainText(parts[0]))
expect(isTeX(parts[1]))
expect((parts[1] as TeX).inline).to.be.false
expect(parts[0].text).to.be.equal("part0$$part1")
expect(parts[1].text).to.be.equal("part2\\(part3")
})
it("have many open delimiter but only last closes", () => {
const parts = find_math_parts("part0$$part1\\[part2\\(part3\\)")
expect(parts.length)
expect(parts.length).to.be.equal(2)
expect(isPlainText(parts[0]))
expect(isTeX(parts[1]))
expect((parts[1] as TeX).inline).to.be.true
expect(parts[0].text).to.be.equal("part0$$part1\\[part2")
expect(parts[1].text).to.be.equal("part3")
})
})
})
0