mirror of
https://github.com/youfoundjk/TeXcore.git
synced 2026-07-22 07:33:31 +00:00
- Parse `obsitex` YAML codeblocks (`eq-prefix: S` or `- eq-prefix: S`) using Obsidian's `parseYaml` API. - Inject document-level `eq-prefix` into equation tags rendered in Live Preview, Reading View, and PDF export. - Support prefixed ID generation (`% id: eq-S-xxxx`) for newly auto-generated equation tags. - Update equation ID regex patterns (`/eq-[\w.-]+/`) to support dots in prefixes. - Register hidden `obsitex` markdown codeblock processor and CSS rules (`.block-language-obsitex`) to hide instructions across views. - Implement `FileIO.read()` across `ActiveNoteIO` and `NonActiveNoteIO`. - Add unit tests for `obsitex` config parsing and `getEqNumberPrefix`. - Add user-facing and architectural documentation in `docs/features/equations.md` and `docs/configuration/settings.md`.
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
import { parseObsitexConfig } from '../src/utils/obsitex';
|
|
import { getEqNumberPrefix } from '../src/utils/format';
|
|
import { App, TFile } from 'obsidian';
|
|
|
|
describe('obsitex config tests', () => {
|
|
it('parses eq-prefix with dash syntax', () => {
|
|
const content = `
|
|
# Title
|
|
|
|
\`\`\`obsitex
|
|
- eq-prefix: S
|
|
\`\`\`
|
|
|
|
$$
|
|
E = mc^2
|
|
$$
|
|
`;
|
|
const config = parseObsitexConfig(content);
|
|
expect(config.eqPrefix).toBe('S');
|
|
});
|
|
|
|
it('parses eq-prefix with standard key-value syntax', () => {
|
|
const content = `
|
|
\`\`\`obsitex
|
|
eq-prefix: S3.2
|
|
\`\`\`
|
|
`;
|
|
const config = parseObsitexConfig(content);
|
|
expect(config.eqPrefix).toBe('S3.2');
|
|
});
|
|
|
|
it('returns empty config if no obsitex block present', () => {
|
|
const content = 'Just some text\n$$ x = 1 $$';
|
|
const config = parseObsitexConfig(content);
|
|
expect(config.eqPrefix).toBeUndefined();
|
|
});
|
|
|
|
it('getEqNumberPrefix uses obsitex eqPrefix over default settings', () => {
|
|
const dummyApp = {} as App;
|
|
const dummyFile = {} as TFile;
|
|
const settings = { eqNumberPrefix: 'Default-' } as any;
|
|
|
|
const content = '```obsitex\n- eq-prefix: S\n```';
|
|
expect(getEqNumberPrefix(dummyApp, dummyFile, settings, content)).toBe('S');
|
|
expect(getEqNumberPrefix(dummyApp, dummyFile, settings, 'no obsitex block')).toBe('Default-');
|
|
});
|
|
});
|