Skip to content

Commit 6d18a6d

Browse files
staredclaude
andcommitted
Consolidate TypeScript utilities for cleaner imports
- Merge latexUtils.ts + utils/latexParser.ts → utils/latex.ts - Merge colorUtils.ts into colorSchemes.ts (single getTermColor) - Move export-only utils (escape.ts, htmlConverter.ts) into export/ - Merge types.ts into export/index.ts (inline ColorScheme, ExportFormat) - Delete 5 small files, cleaner import paths Before: 7 utility files scattered across src/ and utils/ After: 3 logical groups (utils/latex, utils/colorSchemes, export/*) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 439fe20 commit 6d18a6d

File tree

13 files changed

+44
-89
lines changed

13 files changed

+44
-89
lines changed

src/export/beamerExport.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
// Based on texample.net/tikz/examples/beamer-arrows/ pattern
33

44
import type { ParsedContent } from '../parser';
5-
import type { ColorScheme } from './types';
6-
import { transformHtmlClass } from '../utils/latexParser';
7-
import { convertHtmlDescription } from '../utils/htmlConverter';
8-
import { escapePreservingMath, escapeLaTeX } from '../utils/escape';
9-
import { getTermColor } from '../utils/colorUtils';
5+
import type { ColorScheme } from '.';
6+
import { transformHtmlClass } from '../utils/latex';
7+
import { convertHtmlDescription } from './htmlConverter';
8+
import { escapePreservingMath, escapeLaTeX } from './escape';
9+
import { getTermColor } from '../utils/colorSchemes';
1010

1111
// Escape LaTeX text while preserving inline math ($...$)
1212
const escapeLatexPreservingMath = (text: string) => escapePreservingMath(text, escapeLaTeX);

src/export/htmlExport.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
// Exports standalone HTML documents with internal CSS and interactive hover
33

44
import type { ParsedContent } from '../parser';
5-
import type { ColorScheme } from './types';
5+
import type { ColorScheme } from '.';
66
import katex from 'katex';
7-
import { transformHtmlClass } from '../utils/latexParser';
8-
import { escapePreservingMath, escapeHTML } from '../utils/escape';
9-
import { getTermColor } from '../utils/colorUtils';
7+
import { transformHtmlClass } from '../utils/latex';
8+
import { escapePreservingMath, escapeHTML } from './escape';
9+
import { getTermColor } from '../utils/colorSchemes';
1010

1111
// Inject colors into LaTeX while preserving \htmlClass for interactivity
1212
function injectColorsIntoLatex(latex: string, termOrder: string[], colorScheme: ColorScheme): string {

src/export/index.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
// Export module dispatcher and re-exports
2-
// Main entry point for all export functionality
1+
// Export module - types, dispatcher, and re-exports
32

43
import type { ParsedContent } from '../parser';
5-
import type { ColorScheme, ExportFormat } from './types';
64
import { exportToHTML } from './htmlExport';
75
import { exportToLaTeX } from './latexExport';
86
import { exportToBeamer } from './beamerExport';
97
import { exportToTypst } from './typstExport';
108

11-
// Re-export types
12-
export type { ColorScheme, ExportFormat } from './types';
9+
// Types
10+
export interface ColorScheme {
11+
name: string;
12+
colors: string[];
13+
}
14+
15+
export type ExportFormat = 'html' | 'latex' | 'beamer' | 'typst';
1316

1417
// Re-export individual export functions
1518
export { exportToHTML } from './htmlExport';

src/export/latexExport.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
// Non-interactive: colors defined in preamble, applied with \textcolor
33

44
import type { ParsedContent } from '../parser';
5-
import type { ColorScheme } from './types';
6-
import { transformHtmlClass } from '../utils/latexParser';
7-
import { convertHtmlDescription } from '../utils/htmlConverter';
8-
import { escapePreservingMath, escapeLaTeX } from '../utils/escape';
9-
import { getTermColor } from '../utils/colorUtils';
5+
import type { ColorScheme } from '.';
6+
import { transformHtmlClass } from '../utils/latex';
7+
import { convertHtmlDescription } from './htmlConverter';
8+
import { escapePreservingMath, escapeLaTeX } from './escape';
9+
import { getTermColor } from '../utils/colorSchemes';
1010

1111
// Escape LaTeX text while preserving inline math ($...$)
1212
const escapeLatexPreservingMath = (text: string) => escapePreservingMath(text, escapeLaTeX);

src/export/types.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/export/typstExport.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
// Defines colors as variables at the top, references them throughout
44

55
import type { ParsedContent } from '../parser';
6-
import type { ColorScheme } from './types';
6+
import type { ColorScheme } from '.';
77
import { tex2typst } from 'tex2typst';
8-
import { transformHtmlClass } from '../utils/latexParser';
9-
import { convertHtmlDescription } from '../utils/htmlConverter';
10-
import { escapePreservingMath } from '../utils/escape';
11-
import { getTermColor } from '../utils/colorUtils';
8+
import { transformHtmlClass } from '../utils/latex';
9+
import { convertHtmlDescription } from './htmlConverter';
10+
import { escapePreservingMath } from './escape';
11+
import { getTermColor } from '../utils/colorSchemes';
1212

1313
/**
1414
* Escape Typst special characters

src/latexUtils.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Parser for interactive math markdown format
22

3-
import { findMatchingBrace } from './latexUtils';
3+
import { findMatchingBrace } from './utils/latex';
44

55
export interface ParsedContent {
66
title: string; // Title from # heading

0 commit comments

Comments
 (0)