mathpix-markdown-it 2.0.36 → 2.0.37
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.
- package/README.md +23 -3
- package/doc/changelog.md +32 -0
- package/es5/bundle.js +5 -5
- package/es5/index.js +5 -5
- package/lib/contex-menu/styles.js +2 -1
- package/lib/contex-menu/styles.js.map +1 -1
- package/lib/copy-to-clipboard/clipboard-copy-styles.js +2 -1
- package/lib/copy-to-clipboard/clipboard-copy-styles.js.map +1 -1
- package/lib/mathpix-markdown-model/index.d.ts +34 -5
- package/lib/mathpix-markdown-model/index.js +105 -50
- package/lib/mathpix-markdown-model/index.js.map +1 -1
- package/lib/styles/colors.d.ts +63 -0
- package/lib/styles/colors.js +68 -0
- package/lib/styles/colors.js.map +1 -0
- package/lib/styles/helpers.js +22 -0
- package/lib/styles/helpers.js.map +1 -0
- package/lib/styles/index.d.ts +4 -3
- package/lib/styles/index.js +45 -7
- package/lib/styles/index.js.map +1 -1
- package/lib/styles/styles-code.d.ts +1 -1
- package/lib/styles/styles-code.js +6 -1
- package/lib/styles/styles-code.js.map +1 -1
- package/lib/styles/styles-container.js +2 -1
- package/lib/styles/styles-container.js.map +1 -1
- package/lib/styles/styles-lists.d.ts +1 -1
- package/lib/styles/styles-lists.js +1 -1
- package/lib/styles/styles-lists.js.map +1 -1
- package/lib/styles/styles-tabular.d.ts +1 -1
- package/lib/styles/styles-tabular.js +5 -2
- package/lib/styles/styles-tabular.js.map +1 -1
- package/package.json +1 -1
- package/pr-specs/2026-03-mmd-css-scoping.md +267 -0
- package/lib/styles/halpers.js +0 -13
- package/lib/styles/halpers.js.map +0 -1
- /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()
|
|
859
|
-
| getMathpixStyle(
|
|
860
|
-
| getMathpixFontsStyle() |
|
|
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,35 @@
|
|
|
1
|
+
# March 2026
|
|
2
|
+
|
|
3
|
+
## [2.0.37] - CSS scoping and style module cleanup
|
|
4
|
+
|
|
5
|
+
- CSS Scoping:
|
|
6
|
+
- All MMD class selectors now have `#preview-content`/`#setText` scoped variants for specificity boost.
|
|
7
|
+
- Bare selectors preserved as fallback for `markdownToHTML()` (no wrapper).
|
|
8
|
+
|
|
9
|
+
- Style Architecture:
|
|
10
|
+
- New `buildStyles(opts: StyleBundleOpts)` single CSS builder — all assembly methods delegate here.
|
|
11
|
+
- `MathpixStyle` restructured into 10 composable sub-functions.
|
|
12
|
+
- Color constants extracted into `src/styles/colors.ts`.
|
|
13
|
+
- `halpers.ts` renamed to `helpers.ts`.
|
|
14
|
+
|
|
15
|
+
- Improvements:
|
|
16
|
+
- `.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.
|
|
17
|
+
- `useColors=false` now correctly omits blockquote border, table border, and mark background colors.
|
|
18
|
+
- `getMathpixStyle(useColors=false)` now also omits `ContainerStyle` colors (body text, headings, links, captions). Previously `ContainerStyle()` was always called with default colors.
|
|
19
|
+
|
|
20
|
+
- Bug Fixes:
|
|
21
|
+
- `div.svg-container` child combinator consistency (`>` for both `#preview-content` and `#setText`).
|
|
22
|
+
- `loadMathJax` updates existing `#Mathpix-styles` element instead of skipping.
|
|
23
|
+
|
|
24
|
+
- Breaking Changes:
|
|
25
|
+
- `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.
|
|
26
|
+
|
|
27
|
+
- Dead Code Removed:
|
|
28
|
+
- `.empty` selector (never generated), `.preview-right` selector (used as id, not class).
|
|
29
|
+
|
|
30
|
+
- Docs:
|
|
31
|
+
- Added implementation details in `pr-specs/2026-03-mmd-css-scoping.md`.
|
|
32
|
+
|
|
1
33
|
# February 2026
|
|
2
34
|
|
|
3
35
|
## [2.0.36] - 16 February 2026
|