Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
d6f622a
Use mathml-polyfills to resolve legacy mathml codes
akhuoa Apr 10, 2026
f14ef2d
Format MathML into table style
akhuoa Apr 10, 2026
bf8abcb
Fix mathml polyfills mismatch closing fence
akhuoa Apr 10, 2026
9b5e20a
Fix math view overflow
akhuoa Apr 10, 2026
9625f7a
Fix mathml-polyfills loading
akhuoa Apr 10, 2026
4cd5714
Update math elements spacing
akhuoa Apr 10, 2026
b59bc14
Update MathML styles
akhuoa Apr 10, 2026
055e701
Update maths response json transform
akhuoa Apr 11, 2026
4590601
Add empty content fallback
akhuoa Apr 11, 2026
0338017
Format
akhuoa Apr 11, 2026
088ca5c
Format
akhuoa Apr 11, 2026
fbbff80
Use MathML namespace to create element
akhuoa Apr 13, 2026
c9ab80b
Update mathml-polyfills dynamic import
akhuoa Apr 13, 2026
a7825ff
Update comment
akhuoa Apr 13, 2026
ad01442
Fix mathml transform
akhuoa Apr 13, 2026
bba0e3e
Fix DOMParser performance
akhuoa Apr 13, 2026
a435c7f
Add unit test for mathmlTransform
akhuoa Apr 13, 2026
b19fcd2
Fix v-for key usage
akhuoa Apr 13, 2026
2734528
Format
akhuoa Apr 13, 2026
0639785
Fix format and lint errors
akhuoa Apr 13, 2026
b74be98
Merge branch 'main' into bugfix/mathml
akhuoa Apr 16, 2026
dbe3573
Merge branch 'main' into bugfix/mathml
akhuoa Apr 16, 2026
c1d41d4
Add mathml-polyfills in vendor folder
akhuoa Apr 20, 2026
68a6489
Update mathml-polyfills from https to local bundle
akhuoa Apr 20, 2026
5e9c43e
Add a readme file for mathml-polyfills vendor
akhuoa Apr 20, 2026
1e0d9d1
Change mathml-polyfills dynamic import to static import to fix build …
akhuoa Apr 20, 2026
14445bb
Fix unit test for mathml transform
akhuoa Apr 20, 2026
b0b27c5
Fix formatting and exclude vendor folder
akhuoa Apr 20, 2026
5b4e27b
Fix linting
akhuoa Apr 20, 2026
0aaa7b6
Format
akhuoa Apr 20, 2026
eec4ad8
Merge branch 'main' into bugfix/mathml
akhuoa Apr 21, 2026
e35d2eb
Remove unnecessary global resizeObserver mock used by vendor as vendo…
akhuoa Apr 21, 2026
83e7f39
Merge branch 'bugfix/mathml' of github.com:akhuoa/pmrapp-frontend int…
akhuoa Apr 21, 2026
7e84352
Merge branch 'Physiome:main' into bugfix/mathml
akhuoa Apr 21, 2026
b975a0a
Replace invisible times with visible dots
akhuoa Apr 21, 2026
afba3e4
Align the conditions in math equations
akhuoa Apr 21, 2026
4a5ccca
Update math base font size
akhuoa Apr 21, 2026
c1d39a0
Make math font sizes in different levels bigger
akhuoa Apr 21, 2026
b3b1fa8
Add vertical spacing between the fraction bar and content
akhuoa Apr 21, 2026
58bda98
Make all variables in mathml italic
akhuoa Apr 21, 2026
3a125c2
Keep first-level fraction content at parent math font size
akhuoa Apr 22, 2026
17d641a
Align left to math keywords
akhuoa Apr 22, 2026
958d6f7
Convert underscore-delimited identifiers into subscripts
akhuoa Apr 22, 2026
65b1ff6
Replace logical operator symbols with text labels
akhuoa Apr 22, 2026
99511ad
Update font sizes for math sup and sub
akhuoa Apr 22, 2026
1875327
Format math numbers
akhuoa Apr 22, 2026
3517a60
Replace exponential function e
akhuoa Apr 22, 2026
48fd97d
Convert greek letters in math
akhuoa Apr 22, 2026
8b6f5ca
Convert scientific e-notation tokens in math
akhuoa Apr 22, 2026
6c944aa
Rename variables and functions
akhuoa Apr 22, 2026
1f8e494
Format
akhuoa Apr 22, 2026
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
3 changes: 3 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
"tailwindDirectives": true
}
},
"files": {
"includes": ["**", "!src/vendor"]
},
"formatter": {
"indentStyle": "space",
"lineWidth": 100,
Expand Down
7 changes: 7 additions & 0 deletions src/components/organisms/ExposureDetail.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ vi.mock('@/utils/analytics', () => ({
trackButtonClick: vi.fn(),
}))

// Mock MathML transformer to avoid loading the vendored polyfill bundle in tests.
vi.mock('@/utils/mathTransformer', () => ({
initMathPolyfills: vi.fn().mockResolvedValue(undefined),
transformMathString: (s: string) => s,
formatMathMLTable: (s: string) => s,
}))

describe('ExposureDetail', () => {
let exposureStore: ReturnType<typeof useExposureStore>
let searchStore: ReturnType<typeof useSearchStore>
Expand Down
94 changes: 89 additions & 5 deletions src/components/organisms/ExposureDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { downloadFileFromContent, downloadWorkspaceFile } from '@/utils/download
import { getExposureIdFromResourcePath } from '@/utils/exposure'
import { formatFileCount } from '@/utils/format'
import { formatLicenseUrl } from '@/utils/license'
import { formatMathMLTable, initMathPolyfills, transformMathString } from '@/utils/mathTransformer'
import { buildSearchQuery, isValidTerm } from '@/utils/search'
import TermButton from '../atoms/TermButton.vue'

Expand Down Expand Up @@ -247,6 +248,8 @@ const toggleCodeWrap = () => {
const generateMath = async () => {
error.value = null

await initMathPolyfills()

try {
const response = await exposureStore.getExposureRawContent(
exposureId.value,
Expand All @@ -260,7 +263,11 @@ const generateMath = async () => {
(value): value is [string, string[]] => Array.isArray(value[1]) && value[1].length > 0,
)
: []
mathsJSON.value = filteredMathsJSON
const transformedMathsJSON = filteredMathsJSON.map((entry): [string, string[]] => {
const mathMLArray = entry[1].map((mathML) => formatMathMLTable(transformMathString(mathML)))
return [entry[0], mathMLArray]
})
mathsJSON.value = transformedMathsJSON
} catch (err) {
const errorMessage = err instanceof Error ? err.message : 'Failed to parse mathematics data.'
error.value = {
Expand Down Expand Up @@ -544,7 +551,7 @@ onMounted(async () => {
class="mb-6 pb-6 last:mb-0 last:pb-0 border-b border-gray-200 dark:border-gray-700 last:border-0"
>
<h4 class="font-semibold mb-4">{{ value[0] }}</h4>
<div v-for="math in value[1]" :key="math">
<div v-for="(math, mathIndex) in value[1]" :key="`${value[0]}-${mathIndex}`">
<div v-html="math" class="math-view"></div>
</div>
</div>
Expand Down Expand Up @@ -912,10 +919,87 @@ onMounted(async () => {
}

.math-view {
@apply p-2 text-center text-sm overflow-auto;
@apply p-2 text-center text-base overflow-auto;

& :deep(math > mtable) {
border-spacing: 0.5em 0.75em;
}

& :deep(math mi),
& :deep(math mo),
& :deep(math mn) {
line-height: 1.4;
padding-left: 0.05em;
padding-right: 0.05em;
}

& :deep(math mi) {
font-style: italic;
}

/* Override sup and sub script text size for nested levels. */
& :deep(math msub > msub > :nth-child(2)),
& :deep(math msup > :nth-child(2)) {
font-size: 0.7rem;
}

& :deep(math msub > msub + mi),
& :deep(math msup msup > :nth-child(2)) {
font-size: 0.58rem;
}

/* Keep first-level fraction content at the parent math font size. */
& :deep(math mfrac > :first-child),
& :deep(math mfrac > :nth-child(2)) {
font-size: 1em;
}

& :deep(math mfrac > :first-child) {
padding-bottom: 0.14em;
}

& :deep(math mfrac > :nth-child(2)) {
padding-top: 0.14em;
}

& :deep(math > mtable > mtr + mtr > mtd) {
padding-top: 0.5em;
}

& :deep(math > mtable > mtr > mtd:nth-child(1)) {
display: flex;
justify-content: flex-end;
padding-right: 0.5em;
}

& :deep(math > mtable > mtr > mtd[data-math-operator='equals']) {
text-align: center;
padding-left: 0.25em;
padding-right: 0.25em;
}

& :deep(math > mtable > mtr > mtd:nth-child(3)) {
text-align: left;
padding-left: 0.5em;
}

& :deep(mtable[data-math-piecewise='true']) {
border-spacing: 0.5em 0.35em;
}

& :deep(mtable[data-math-piecewise='true'] > mtr > mtd[data-math-piecewise='expression']) {
white-space: nowrap;
}

& :deep(mtable[data-math-piecewise='true'] > mtr > mtd[data-math-piecewise='keyword']) {
text-align: left;
white-space: nowrap;
padding-left: 0.15em;
padding-right: 0.35em;
}

& :deep(math) {
@apply flex flex-col gap-4;
& :deep(mtable[data-math-piecewise='true'] > mtr > mtd[data-math-piecewise='condition']) {
white-space: nowrap;
}
}
</style>
Loading