mathpix-markdown-it 2.0.36 → 2.0.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +23 -3
  2. package/doc/changelog.md +48 -0
  3. package/es5/bundle.js +5 -5
  4. package/es5/index.js +5 -5
  5. package/lib/contex-menu/styles.js +2 -1
  6. package/lib/contex-menu/styles.js.map +1 -1
  7. package/lib/copy-to-clipboard/clipboard-copy-styles.js +2 -1
  8. package/lib/copy-to-clipboard/clipboard-copy-styles.js.map +1 -1
  9. package/lib/markdown/md-inline-rule/diagbox-inline.js +46 -46
  10. package/lib/markdown/md-inline-rule/diagbox-inline.js.map +1 -1
  11. package/lib/markdown/md-inline-rule/mmd-icon.js +42 -46
  12. package/lib/markdown/md-inline-rule/mmd-icon.js.map +1 -1
  13. package/lib/mathpix-markdown-model/index.d.ts +34 -5
  14. package/lib/mathpix-markdown-model/index.js +105 -50
  15. package/lib/mathpix-markdown-model/index.js.map +1 -1
  16. package/lib/styles/colors.d.ts +63 -0
  17. package/lib/styles/colors.js +68 -0
  18. package/lib/styles/colors.js.map +1 -0
  19. package/lib/styles/helpers.js +22 -0
  20. package/lib/styles/helpers.js.map +1 -0
  21. package/lib/styles/index.d.ts +4 -3
  22. package/lib/styles/index.js +45 -7
  23. package/lib/styles/index.js.map +1 -1
  24. package/lib/styles/styles-code.d.ts +1 -1
  25. package/lib/styles/styles-code.js +6 -1
  26. package/lib/styles/styles-code.js.map +1 -1
  27. package/lib/styles/styles-container.js +2 -1
  28. package/lib/styles/styles-container.js.map +1 -1
  29. package/lib/styles/styles-lists.d.ts +1 -1
  30. package/lib/styles/styles-lists.js +1 -1
  31. package/lib/styles/styles-lists.js.map +1 -1
  32. package/lib/styles/styles-tabular.d.ts +1 -1
  33. package/lib/styles/styles-tabular.js +5 -2
  34. package/lib/styles/styles-tabular.js.map +1 -1
  35. package/package.json +1 -1
  36. package/pr-specs/2026-03-fix-silent-mode-state-pos.md +103 -0
  37. package/pr-specs/2026-03-mmd-css-scoping.md +267 -0
  38. package/lib/styles/halpers.js +0 -13
  39. package/lib/styles/halpers.js.map +0 -1
  40. /package/lib/styles/{halpers.d.ts → helpers.d.ts} +0 -0
package/README.md CHANGED
@@ -854,10 +854,12 @@ The `MathpixMarkdown` React element accepts the following props:
854
854
  | | returns | description | |
855
855
  |----------------------------------------------------|---------|---------------------------------------------------------------------------------------------------------------------------|---------|
856
856
  | **Style methods:** | | | |
857
+ | buildStyles(opts?: [StyleBundleOpts](https://github.com/Mathpix/mathpix-markdown-it#stylebundleopts)) | string | Single CSS builder. All style assembly methods delegate here. Modules toggled via opts. | |
857
858
  | loadMathJax() | boolean | Adds a style element into the head of the document and returns true. In case of an error, returns false. |[example](https://github.com/Mathpix/mathpix-markdown-it/tree/master/examples/react-app/use-markdownToHTML-method)|
858
- | getMathpixStyleOnly() | string | returns styles as a string. | |
859
- | getMathpixStyle(true) | string | returns styles as a string including styles for container. |[example](https://github.com/Mathpix/mathpix-markdown-it/tree/master/examples/react-app/use-render-method)|
860
- | getMathpixFontsStyle() | boolean | returns fonts styles as a string. |[example](https://github.com/Mathpix/mathpix-markdown-it/tree/master/examples/react-app/use-render-method)|
859
+ | getMathpixStyleOnly(useColors?) | string | Styles for embedded widget (no container/preview). | |
860
+ | getMathpixStyle(stylePreview?, showToc?, tocContainerName?, useColors?, isPptx?) | string | Full page styles including container. |[example](https://github.com/Mathpix/mathpix-markdown-it/tree/master/examples/react-app/use-render-method)|
861
+ | getMathpixFontsStyle() | string | Returns fonts styles as a string. |[example](https://github.com/Mathpix/mathpix-markdown-it/tree/master/examples/react-app/use-render-method)|
862
+ | getMaxWidthStyle(maxWidth?, isHideScroll?) | string | Returns CSS for math/tabular max-width constraints and optional scrollbar hiding. | |
861
863
  | **Render methods:** | | | |
862
864
  | markdownToHTML(str, options: [TMarkdownItOptions](https://github.com/Mathpix/mathpix-markdown-it#tmarkdownitoptions)) | string | Renders input text to html element as a string. |[example](https://github.com/Mathpix/mathpix-markdown-it/tree/master/examples/react-app/use-markdownToHTML-method)|
863
865
  | render(str, options: [optionsMathpixMarkdown](https://github.com/Mathpix/mathpix-markdown-it#optionsmathpixmarkdown)) | string | Renders input text to HTML element as a string and wraps it in a container. Should be used to render the entire document.|[example](https://github.com/Mathpix/mathpix-markdown-it/tree/master/examples/react-app/use-render-method)|
@@ -867,6 +869,24 @@ The `MathpixMarkdown` React element accepts the following props:
867
869
 
868
870
 
869
871
 
872
+ ### StyleBundleOpts
873
+
874
+ | | type *`default`* | description |
875
+ |--------------------------|-------------------------------|------------------------------------------------------------|
876
+ | `setTextAlignJustify` | boolean *`false`* | Enables `text-align: justify` on content blocks |
877
+ | `useColors` | boolean *`true`* | When `false`, omits color declarations from CSS output |
878
+ | `maxWidth` | string *`''`* | Sets max-width for math/tabular containers (e.g. `'800px'`)|
879
+ | `isPptx` | boolean *`false`* | Adjusts layout for PowerPoint export |
880
+ | `resetBody` | boolean *`false`* | Includes body margin/line-height reset |
881
+ | `container` | boolean *`false`* | Includes base element styles (headings, links, tables etc) |
882
+ | `mathjax` | boolean *`false`* | Includes MathJax stylesheet |
883
+ | `code` | boolean *`true`* | Includes syntax-highlighting styles |
884
+ | `preview` | boolean *`false`* | Includes `#preview` wrapper styles |
885
+ | `toc` | boolean *`false`* | Includes table-of-contents styles |
886
+ | `tocContainerName` | string *`'toc'`* | ID of the TOC container element |
887
+ | `menu` | boolean *`false`* | Includes context-menu and clipboard styles |
888
+
889
+
870
890
  ### TMarkdownItOptions
871
891
 
872
892
  | | type *`default`* | description |
package/doc/changelog.md CHANGED
@@ -1,3 +1,51 @@
1
+ # March 2026
2
+
3
+ ## [2.0.38] - Fix infinite loop in `inlineMmdIcon` and `inlineDiagbox` silent mode
4
+
5
+ - Bug Fix:
6
+ - Fixed page freeze when `\icon{...}` or `\diagbox{...}` appeared inside link labels (e.g. `[\icon{unknown}]`). The inline rules returned `true` in silent mode without advancing `state.pos`, causing an infinite loop in markdown-it's `parseLinkLabel` → `skipToken`.
7
+
8
+ - Refactoring:
9
+ - `inlineMmdIcon` and `inlineDiagbox` refactored to follow the `if (!silent) { ... } state.pos = endPos; return true;` pattern used by all other inline rules.
10
+ - `mmd-icon.ts`: extracted `endPos` constant, eliminated 6 duplicated position assignments.
11
+ - `diagbox-inline.ts`: moved `extractNextBraceContent` before the silent check so `endIndex` is available in both modes.
12
+
13
+ - Tests:
14
+ - Added 4 test cases for icon and diagbox inside link labels and bare brackets.
15
+
16
+ - Docs:
17
+ - Added implementation details in `pr-specs/2026-03-fix-silent-mode-state-pos.md`.
18
+
19
+ ## [2.0.37] - CSS scoping and style module cleanup
20
+
21
+ - CSS Scoping:
22
+ - All MMD class selectors now have `#preview-content`/`#setText` scoped variants for specificity boost.
23
+ - Bare selectors preserved as fallback for `markdownToHTML()` (no wrapper).
24
+
25
+ - Style Architecture:
26
+ - New `buildStyles(opts: StyleBundleOpts)` single CSS builder — all assembly methods delegate here.
27
+ - `MathpixStyle` restructured into 10 composable sub-functions.
28
+ - Color constants extracted into `src/styles/colors.ts`.
29
+ - `halpers.ts` renamed to `helpers.ts`.
30
+
31
+ - Improvements:
32
+ - `.tabular` now renders consistently regardless of context (standalone vs nested inside a list). Previously, list context could affect table width and font size via cascade. Fixed with explicit `margin: 0 0 1em`, `font-size: inherit`, and other defensive defaults.
33
+ - `useColors=false` now correctly omits blockquote border, table border, and mark background colors.
34
+ - `getMathpixStyle(useColors=false)` now also omits `ContainerStyle` colors (body text, headings, links, captions). Previously `ContainerStyle()` was always called with default colors.
35
+
36
+ - Bug Fixes:
37
+ - `div.svg-container` child combinator consistency (`>` for both `#preview-content` and `#setText`).
38
+ - `loadMathJax` updates existing `#Mathpix-styles` element instead of skipping.
39
+
40
+ - Breaking Changes:
41
+ - `scaleEquation` parameter removed from `loadMathJax`, `getMathpixStyleOnly`, `getMathpixStyle`, and `getMathpixMarkdownStyles`. It was never used in CSS output. If you were passing it positionally, shift your arguments. Use `buildStyles(opts)` for a named-parameter alternative.
42
+
43
+ - Dead Code Removed:
44
+ - `.empty` selector (never generated), `.preview-right` selector (used as id, not class).
45
+
46
+ - Docs:
47
+ - Added implementation details in `pr-specs/2026-03-mmd-css-scoping.md`.
48
+
1
49
  # February 2026
2
50
 
3
51
  ## [2.0.36] - 16 February 2026