Skip to content
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

Replicate "shortcodes" by allowing rhai scripts in markdown #55

Closed
bketelsen opened this issue Apr 2, 2022 · 1 comment
Closed

Replicate "shortcodes" by allowing rhai scripts in markdown #55

bketelsen opened this issue Apr 2, 2022 · 1 comment

Comments

@bketelsen
Copy link

I miss the concepts of shortcodes from Hugo and others. I think it would be straightforward to implement this in Bartholomew by running the markdown through the handlebars rendering engine before running it through the markdown rendering engine.

as an example I might want an alert in my blog post warning people of a potentially destructive action.

{{ alert "danger" "This might eat your data" }}

This would execute the script called "alert.rhai" with the two strings as parameters. The execution of the script would return html that would then be passed through to the markdown renderer.

Thoughts:

  • The output would have to have no html entity escaping.
  • We can share the script directory used by the templates, or for more clarity, create a new markdown-only script directory

Security considerations:

  • This introduces all sorts of dangerous injection vectors. Should it be disabled by default? Caveat Emptor?
  • we could manually strip out <script> tags, but that might be a useful bit of functionality to keep too
  • It might end up being a case where documentation is the best option and we trust the end user to inform themselves and protect against untrusted content sources

I have a prototype of this functionality that works today I'll be sending as a PR. It needs careful review.

Thanks for building Bartholomew!

@karthik2804
Copy link
Contributor

Closed with #91

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

No branches or pull requests

2 participants