A problem of most online markdown previewer is simply that the previewer does not follow the cursor.
This previewer solves that problem by unist
and remark
.
This previewer is a React Component providing markdown compied VDOM and auto-scroll feature. Therefore,
you can style it by css
or by the provided interface props.styles
.
See Demo at github pages, styled by skeleton.css
.
Just like other npm package
npm i --save remark-react-previewer
Then you can put the following code in JSX.
<Previewer
cursorPosition = {line, column}
markdown = {string}
/>
For customizing styles, you could use css or pass an styles:{tagName:cssInJS}
to props.
props.styles
CSS in JS like Radium to style elements.
props.styles
should be a nested Object likeprops.styles = {tagName: cssInJS}
, where thetagName
isli
,h1
and other html tagsroot
for the rootdiv
scrolled
for the cursor matched element.
- Passing a callback function for smoothie scroll~
- FootNote Support
- Clever Scroll for Code and Blockquote
- Editor Support as neovim-extension. (Will be another package)
- After Editor Support, A greasemonkey plugin for render markdown in rich-text editors like in quora and zhihu.
I write an unist
plugin to find the mdast node matching the cursor. You may like it~