e0a5f57793
Vendor the rebranded BoosAPI Desktop client (Tauri + Vue) into metapi as a monorepo subdirectory under desktop/. Source only — node_modules, dist, Cargo target and the upstream .git history are excluded. desktop/ keeps its own independent Cargo workspace (desktop/src-tauri with crates/*); it is not part of the backend boosapi crate, so a `cargo check` at the metapi root still compiles only the backend. Build the desktop app from desktop/src-tauri per desktop/README.md. Note: app icons are still placeholder assets pending the final BoosAPI logo. The updater signing keys live outside the repo and are not included.
41 lines
1.7 KiB
TypeScript
41 lines
1.7 KiB
TypeScript
import { getMarkdown, parseMarkdownToStructure } from 'stream-markdown-parser'
|
||
import { describe, expect, it } from 'vitest'
|
||
|
||
const markdown = `- 代入数据:$c=0.75\\times10^3\\ \\text{J/(kg·℃)}$,$m=1.1\\ \\text{kg}$,$\\Delta t=40℃$
|
||
- 计算得:$Q_1=0.75\\times10^3\\ \\text{J/(kg·℃)}\\times1.1\\ \\text{kg}\\times40℃=3.3\\times 10^{4}\\ \\text{J}$
|
||
- 第(1)问:学生遗漏了比热容的数量级$10^3$,将$0.75\\times10^3\\ \\text{J/(kg·℃)}$错写为$0.75\\ \\text{J/(kg·℃)}$,导致计算出的$Q_1$错误。`
|
||
|
||
function collectMathNodes(node: any, mathNodes: any[] = []) {
|
||
if (!node)
|
||
return mathNodes
|
||
|
||
if (node.type === 'math_inline' || node.type === 'math_block')
|
||
mathNodes.push(node)
|
||
|
||
if (Array.isArray(node.children))
|
||
node.children.forEach(child => collectMathNodes(child, mathNodes))
|
||
if (Array.isArray(node.items))
|
||
node.items.forEach(child => collectMathNodes(child, mathNodes))
|
||
|
||
return mathNodes
|
||
}
|
||
|
||
describe('issue #378 parse regression', () => {
|
||
it('keeps the affected unit formulas as math nodes', () => {
|
||
const md = getMarkdown('issue-378-parse')
|
||
const nodes = parseMarkdownToStructure(markdown, md, { final: true }) as any[]
|
||
const mathNodes = nodes.flatMap(node => collectMathNodes(node))
|
||
|
||
expect(mathNodes.map(node => node.raw)).toEqual([
|
||
'$c=0.75\\times10^3\\ \\text{J/(kg·℃)}$',
|
||
'$m=1.1\\ \\text{kg}$',
|
||
'$\\Delta t=40℃$',
|
||
'$Q_1=0.75\\times10^3\\ \\text{J/(kg·℃)}\\times1.1\\ \\text{kg}\\times40℃=3.3\\times 10^{4}\\ \\text{J}$',
|
||
'$10^3$',
|
||
'$0.75\\times10^3\\ \\text{J/(kg·℃)}$',
|
||
'$0.75\\ \\text{J/(kg·℃)}$',
|
||
'$Q_1$',
|
||
])
|
||
})
|
||
})
|