Open curbengh opened 5 years ago
However, while integrating with remark can help pangu understands markdown, a hexo post could also contain non-markdown markup like tag plugin.
As such, another approach is to parse the rendered HTML instead.
But so far I have yet to try a full markdown->HTML parser. https://github.com/hexojs/hexo-filter-auto-spacing/pull/8 only parses markdown, but not to HTML. Probably the limitation still applies even in a full parser, but thanks to your plugin, it is now easier to try.
As now, the only way to add it I can see is to reparse the HTML after all hexo post-processing using rehype, and apply pango on text nodes. Applying it directly to the HTML AST produced by remark-rehype would break the tag plugin, as you mentionned.
Anyway, I'm not even sure the tag plugin can be using with this renderer. I will try to look at it soon; and to provide pango integration, hopefully without breaking anything. Or are you working on it right now?
So far I only wanted to try adding "remark-pangu" plugin into this renderer. If it doesn't work, then I'll just hold off for now.
Reparsing using remark-rehype is interesting, but I'm still not familiar with the remark ecosystem. Currently I'm still holding off getting deep into it because (frankly) the issue is not that major. Using cheerio is not pretty but good enough as an interim fix.
In the meantime, I'll also test tag plugin with this plugin.
Thanks for looking into this despite just an aesthetic thing, I'm sure I can learn more about unified/remark from you.
Feel free to ask your questions if any, I'll try to answer as best as I can.
I haven't had a chance to test tag plugins with this plugin, but I just found hexo-renderer-pandoc doc mentions about it, https://github.com/wzpan/hexo-renderer-pandoc#issues-related-to-hexo-tags. It could be of interest.
I just tested tag plugins like {% raw %}
and {% post_link %}
, which is rendered as <!--1-->
.
Thanks for trying tag plugins; I will do an implementation for these at the end of the week. I will mark these with a special MAST attribute so that will will be able to ignore them in Pango and therefore add it without much overhead; will publish a major after these two features are implemented.
Some news here because I said I would do it; the way it works in hexo is quite a mess, and we actually have a problem with remark
directly, not any of it's plugins... I see only one solution to this day: stop escaping html content and reescape tags by hand, not using the default remark escaper. This kind of practice is usually best avoided, so I'm trying to find another way to do this. I thought about deescaping html comments at the end witch seems to me like the best solution right now. Anyway, I will fix this, just need more time ;)
I created #4 for Pangu. This discussion is for tag plugins.
More than a month after the initial report, this issue will finally be solved soon. I introduced a new branch next
including the feature; it will be merged and published after resolution of all problems listed in the v2.0 milestone.
pangu adds a space between chinese characters and ASCII characters (including numbers). For example,
becomes
It's simply for aesthetic, yet somehow this convention is gaining in popularity.
Currently hexo-filter-auto-spacing adds space to path/url, which it shouldn't.
For example, if I have a post at "http://example.com/你好abc" and I want to link it in another post. The plugin would a space so it becomes "http://example.com/你好 abc", so it becomes invalid.
Basically, hexo-filter-auto-spacing doesn't (and currently cannot) differentiate between a text and a path; it should process a text, but not a path/url.
The idea is that by integrating with remark, remark can help pangu to differentiate them so it doesn't add a space to places it shouldn't.
I'll play around with this plugin in the meantime, to see if it is viable.