Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR into master from dev/olga/add-applyMathpixMarkdownPlugins #350

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,38 @@ import {
<img width="370" alt="Screen Shot 2022-05-03 at 17 21 50" src="https://user-images.githubusercontent.com/32493105/166471623-fd3f6a5b-84e4-4d43-afcd-0384e83eb2df.png">


## mathpix-markdown-it setup and advanced capabilities

The `applyMathpixMarkdownPlugins` function initializes a `markdown-it` instance and applies a set of plugins, including `mathpix-markdown-it` and other extensions to enhance Markdown functionality, such as tables, footnotes, subscript and superscript symbols, and more.

### Parameters:

- `options` (TMarkdownItOptions): An options object for configuring the `markdown-it` instance. This object may contain settings that are passed to `markdown-it` and the plugins being used. By default, an empty object is passed.

### Return Value:

- The function returns a configured `markdown-it` instance with the applied plugins and custom rendering rules.

### Usage Example:

```js
import { applyMathpixMarkdownPlugins } from 'mathpix-markdown-it';

const md = applyMathpixMarkdownPlugins({
htmlTags: true, // Example option for markdown-it
});

// We use a configured instance for Parsing Markdown
const renderedHtml = md.render('Your **Markdown** text with \\textbf{mathpix-markdown-it} support!');
console.log(renderedHtml);
```

renderedHtml:
```html
<div>Your <strong>Markdown</strong> text with <strong>mathpix-markdown-it</strong> support!</div>
```


# Documentation

## React components
Expand Down
2 changes: 1 addition & 1 deletion es5/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion es5/index.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import MathpixLoader from './components/mathpix-loader';
import MathpixMarkdown from './components/mathpix-markdown';
import { mathpixMarkdownPlugin, initMathpixMarkdown } from './markdown/mathpix-markdown-plugins';
import { applyMathpixMarkdownPlugins } from './markdown';
import { mdPluginMathJax, mdPluginHighlightCode, mdPluginText, mdPluginTOC, mdPluginAnchor, mdPluginTableTabular, mdPluginList, mdPluginChemistry, mdPluginCollapsible, mdLatexFootnotes, mdSetPositionsAndHighlight } from "./markdown/mdPluginConfigured";
import { MathpixMarkdownModel, TMarkdownItOptions, optionsMathpixMarkdown, TOutputMath, TOutputMathJax, THtmlSanitize, TTocStyle, THighlight, ParserErrors, CodeHighlight, Footnotes, RenderOptions } from "./mathpix-markdown-model";
import { ISmilesOptions } from './markdown/md-chemistry';
Expand All @@ -9,4 +10,4 @@ import { rest_mmd_footnotes_list } from './markdown/md-latex-footnotes/utils';
import { FootnoteItem } from './markdown/md-latex-footnotes/interfaces';
import { eLabelType, ILabel, getLabelsList, getLabelByKeyFromLabelsList, clearLabelsList } from "./markdown/common/labels";
import { normalizeLink } from './helpers/normalize-link';
export { MathpixLoader, MathpixMarkdown, MathpixMarkdownModel, mathpixMarkdownPlugin, mdPluginCollapsible, mdLatexFootnotes, mdSetPositionsAndHighlight, initMathpixMarkdown, mdPluginMathJax, mdPluginHighlightCode, mdPluginText, mdPluginTOC, mdPluginAnchor, mdPluginTableTabular, mdPluginList, mdPluginChemistry, TMarkdownItOptions, optionsMathpixMarkdown, TOutputMath, TOutputMathJax, THtmlSanitize, ISmilesOptions, resetTheoremEnvironments, rest_mmd_footnotes_list, FootnoteItem, TTocStyle, THighlight, CodeHighlight, ParserErrors, Footnotes, eLabelType, ILabel, getLabelsList, getLabelByKeyFromLabelsList, clearLabelsList, normalizeLink, RenderOptions };
export { MathpixLoader, MathpixMarkdown, MathpixMarkdownModel, mathpixMarkdownPlugin, mdPluginCollapsible, mdLatexFootnotes, mdSetPositionsAndHighlight, initMathpixMarkdown, mdPluginMathJax, mdPluginHighlightCode, mdPluginText, mdPluginTOC, mdPluginAnchor, mdPluginTableTabular, mdPluginList, mdPluginChemistry, TMarkdownItOptions, optionsMathpixMarkdown, TOutputMath, TOutputMathJax, THtmlSanitize, ISmilesOptions, resetTheoremEnvironments, rest_mmd_footnotes_list, FootnoteItem, TTocStyle, THighlight, CodeHighlight, ParserErrors, Footnotes, eLabelType, ILabel, getLabelsList, getLabelByKeyFromLabelsList, clearLabelsList, normalizeLink, RenderOptions, applyMathpixMarkdownPlugins };
4 changes: 3 additions & 1 deletion lib/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/markdown/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { TMarkdownItOptions } from '../mathpix-markdown-model';
/** String transformtion pipeline */
export declare const markdownToHtmlPipeline: (content: string, options?: TMarkdownItOptions) => any;
export declare const markdownToHtmlPipeline: (content: string, options?: TMarkdownItOptions) => string;
/**
* convert a markdown text to html
*/
export declare function markdownToHTML(markdown: string, options?: TMarkdownItOptions): string;
export declare const applyMathpixMarkdownPlugins: (options?: TMarkdownItOptions) => MarkdownIt;
9 changes: 8 additions & 1 deletion lib/markdown/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/markdown/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading