Ionaru / Ionaru/easy-markdown-editor

RFE: allow a callback for link generation

Open
#34 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
3.1k
Forks
363
PR merge metrics
No merged PRs in 30d

Description

### I'm submitting a...
- [ ] Bug report
- [x] Feature request

### Reproduction steps
N/A

### Version information
EasyMDE version: hopefully the next one ;)

i would like to have a callback (as part of the config options) which gets called when the editor/previewer wants to render a link. The callback should get the link URI and the label as arguments and should return the "rendered" form of the link as an HTML string (or, if the internal API supports it, as a DOM element - that would give us more flexibility). If the callback is not set, or returns the undefined value, the previewer should use its current default behaviour.

Concrete use case: i'd like to replace an old custom blog/wiki of mine which uses the Google Code Wiki format. It runs as a one-page app and loads new wiki pages (in the same app session) when a user clicks on a link to a wiki page (yet treats external links "as usual"). That is only possible because the Google Code Wiki parser allows me to replace (via a callback) its default link generator with one which i use to check "is this a link to a wiki page, and if so, create a custom link". Such a callback also makes it possible to replace anchor tags with, e.g., spans with on-click handlers, which might conceivably be useful as an anti-bot/spider method.

As an example:

https://fossil.wanderinghorse.net/wikis/cson

The "TableOfContents" link on the first page is a link to another wiki page, which the Google Code Wiki parser has allowed me to customize the link for. Tapping the link loads the requested page via ajax and feeds it into the app.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.