remarkable icon indicating copy to clipboard operation
remarkable copied to clipboard

Plugin Documentation

Open xErik opened this issue 4 years ago • 3 comments

Thank you for providing Remarkable.

I'd like to write plugins but the available documentation is more of an internal documentation.

I am also unsure whether every plugin is simply applied in a row during runtime - and then the plugin decides whether to process the input or not? As this means a plugin is not explicitly registered with a MARKDOWN-TAG like:

.addPlugin('MARKDOWN-TAG', isInlineOrBlock, function() {some-plugin-code})

It would be helpful to have a recipe for a simple BLOCK-Plugin with parsing and rendering from start to end:

@@@
la
la
la
@@@

As well as how to handle an INLINE-Plugin which overwrites an existing plugin, like code:

\`render me differently\`

xErik avatar Oct 11 '19 05:10 xErik

I really wish the plugin documentation would have some examples.

I'm having some real hard time figuring out how to write my own plugin. I need to read the source code of the project + source codes of other plugins.

Don't take me wrong, I know writing documentation + maintaining is hard work and I thank the maintainers for doing this.

Here's a useful resource I've found. https://github.com/facebook/docusaurus/blob/master/admin/extending-remarkable.md

antoniojps avatar Jan 15 '20 11:01 antoniojps

No matter the examples I find it hard to piece the most simple example.

omenking avatar Feb 11 '20 19:02 omenking

FYI, I wrote my own plugin that handles embedded KaTex. The code is fairly straightforward I think: index.js

There are three basic components:

  • block parsing-- parseBlockKatex()
  • inline parsing -- parseInlineKatex()
  • rendering -- renderKatex()

The first two push tokens onto the state stack when they find something interesting in the text range given to them by the state. They push an object that tells Remarkable rendering what the range of text to render with a named render function. The last function is just using the token pushed earlier to get to the content to use for rendering. In my case this content is KaTeX code that generates mathematical expressions.

My blog repo has additional customization examples. See https://github.com/bradhowes/keystrokecountdown (scroll down to Remarkable Customizations section). I show how I was able to customize fence block rendering to use Prism highlight. I also show how to handle async rendering which I needed when generating SVG files from Graphviz DOT specs.

bradhowes avatar Apr 11 '20 23:04 bradhowes