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
Custom markdown tags #454
Comments
react-md-editor/core/src/Editor.tsx Lines 75 to 78 in f04dde8
@asimaranov This is possible. You need <MDEditor
previewOptions={{
remarkPlugins: [],
rehypePlugins: []
}}
/>
|
@asimaranov like this? https://codesandbox.io/embed/markdown-editor-for-react-uiwjs-react-md-editor-issues-454-5wb792?fontsize=14&hidenavigation=1&theme=dark import React from "react";
import ReactDOM from "react-dom";
import MDEditor from "@uiw/react-md-editor";
import rehypeRewrite, { getCodeString } from "rehype-rewrite";
// No import is required in the WebPack.
// import "@uiw/react-md-editor/dist/markdown-editor.css";
const mkdStr = `
Markdown Editor
Editor $good$
Editor $good \`google\` $
`;
const REG = /\$(.*?)\$/gi;
function App() {
const [value, setValue] = React.useState(mkdStr);
return (
<div className="container">
<h3>Auto</h3>
<MDEditor
height={200}
previewOptions={{
rehypePlugins: [
[
rehypeRewrite,
{
rewrite: (node, index, parent) => {
if (node.type === "element" && node.tagName === "p") {
let text = getCodeString(node.children);
if (REG.test(text)) {
text = text.replace(REG, (txt) => {
return "█".repeat(txt.length);
});
node.children = [
{
type: "text",
value: text
}
];
}
}
}
}
]
]
}}
value={value}
onChange={setValue}
/>
</div>
);
} |
Wow, thanks, you're my hero |
Hello, Is there way to catch a char in actual writing with Thank you |
Hello there. Are there ways to add custom markdown tags? For example I want to make text between $ signs to be rendered with my style. So
$text$
in markdown should become<mytag>text</mytag>
in the result htmlThe text was updated successfully, but these errors were encountered: