Skip to content

Conversation

OlgaRedozubova
Copy link
Contributor

@OlgaRedozubova OlgaRedozubova commented Oct 18, 2024

branch: dev/olga/add-applyMathpixMarkdownPlugins

  • Added the function applyMathpixMarkdownPlugins
  • Set version 2.0.5
  • Added test to check the function applyMathpixMarkdownPlugins
  • Updated README
import { applyMathpixMarkdownPlugins } from 'mathpix-markdown-it';

const md = applyMathpixMarkdownPlugins({
  htmlTags: true,
});

// 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:

<div>Your <strong>Markdown</strong> text with <strong>mathpix-markdown-it</strong> support!</div>

@OlgaRedozubova OlgaRedozubova self-assigned this Oct 18, 2024
@sylee957
Copy link

I'm okay with the implementation. But user-facing documentation may be added to readme.

@OlgaRedozubova
Copy link
Contributor Author

I'm okay with the implementation. But user-facing documentation may be added to readme.

Sure, I'll do it.

@OlgaRedozubova OlgaRedozubova marked this pull request as ready for review October 18, 2024 12:41
@sylee957
Copy link

Can you add type MarkdownIt for function output?

@OlgaRedozubova
Copy link
Contributor Author

Can you add type MarkdownIt for function output?

Done.


export const applyMathpixMarkdownPlugins = (options: TMarkdownItOptions = {}): MarkdownIt => {
let md: MarkdownIt = mdInit(options);
md = injectRenderRules(md);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it could better to change injectRenderRules to infer the type for MarkdownIt
injectRenderRules = (renderer: MarkdownIt) => {

@sylee957
Copy link

I still have problem for inferring the types for markdown-it.
Maybe you should add @types/markdown-it and add import
import type MarkdownIt from "markdown-it";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants