Add support for the markdownify filter #720
Replies: 7 comments
-
I've opened a PR for this, but it has some issues. I have left PR comments on it. |
Beta Was this translation helpful? Give feedback.
-
As we're discussing on that PR, I prefer markdown functionalities not built in LiquidJS. Currently LiquidJS is a small lib without dependencies bundled in. Markdown is a whole system of parsers and renders which also has a significant bundle size impact. I'm thinking maybe it's better to create a |
Beta Was this translation helpful? Give feedback.
-
That sounds like a good idea! Is there a plugin system already or would we be introducing one for these more complex and bigger filters? |
Beta Was this translation helpful? Give feedback.
-
There is one, try this: https://liquidjs.com/tutorials/plugins.html The concerning part is we've got to maintain it once there's breaking changes on LiquidJS, and plugins tend to depend a lot on LiquidJS codebase. |
Beta Was this translation helpful? Give feedback.
-
There is one, try this: https://liquidjs.com/tutorials/plugins.html The concerning part is we got to maintain it once there's breaking changes on LiquidJS, and plugins tend to depend a lot on LiquidJS codebase. |
Beta Was this translation helpful? Give feedback.
-
I will try to write the plugin and I will keep it in my personal account if you want and put a disclaimer about the status of maintenance. I need it for me right now so I will develop it and put it up and try to maintain it, but I make no promises and if it breaks and someone else needs it working, I will invite them to contribute fixes. Since it will be in my personal account, it will be apparent that it is not an official LiquidJS plugin. But I would like this plugin to work in the Playground so if you don't mind I would try to extend the playground to allow loading plugins as well. I use the Playground a lot and the contributions I have made so far were motivated by adding missing pieces I needed to the Playground. |
Beta Was this translation helpful? Give feedback.
-
That's a good idea. And I'm happy to incorporate e2e test for plugins to ensure they're not broken. |
Beta Was this translation helpful? Give feedback.
-
Hi!
In addition to the
push
andsample
Jekyll filters I've added recently, I am looking at addingmarkdownify
(convert Markdown to HTML) to make the Playground usable for my scripts which also use this filter.This is a string to string filter, so it would go to https://github.com/harttle/liquidjs/blob/master/src/filters/string.ts.
My idea is to pull in an NPM package for converting MarkDown to HTML. I see the library is so far dependency-free except for
commander
and I am not sure if you would be okay with adding a dependency for is. If not, let me know.But if you would be, I've looked at the most popular ones here:
https://www.npmjs.com/search?ranking=popularity&q=markdown
The top result has a last release 10 years ago so I am thinking of pulling in
marked
.Additionally, Marked recommend to run the output HTML through an HTML sanitizer library to stop any sort of XSS attacks and the like.
They recommend https://github.com/cure53/DOMPurify specifically so I would use that as well.
Overall the filter should look roughly something like this:
I will add the XSS case as one of the test cases to make sure the sanitisation works.
I am working on this ATM but please LMK if you see any issues in the meanwhile and I will address everything in the PR once I am ready to publish it!
Beta Was this translation helpful? Give feedback.
All reactions