-
Notifications
You must be signed in to change notification settings - Fork 438
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
Markdown extensions to support Math, Tables, etc. not working #936
Comments
Hi, thanks for reporting your issue. Could you please provide a working example of your config, the text you typed in and the rendered text you expected to see? (Related: #751) |
Hi @ix5, thank you for looking into this. Here is the configuration in use:
You can see the examples in the link I posted, but sure I can add them here as well for clarity:
You can see that 'bold/strike/emphasis' have tags added, but the other two 'underline/highlight' don't, despite the extensions being specified in the config
Hope this helps tracking things down, if I can provide more information just let me know. |
Hello. Thanks for isso, that's a very nice comments engine. |
Markdown on Github explains that it works ```math but also with '$$' : Therefore it should works with isso too. |
Hi @joseph-vidal-rosset, sorry for the late response. Isso's markdown parser is misaka, which needs some configuration to allow more advanced syntax. As for LaTeX: You need something to actually render in the browser. misaka simply ignores/doesn't modify anything between https://docs.mathjax.org/en/v2.7-latest/start.html#mathjax-cdn suggests e.g.:
We as the Isso project would do well to make the handling of markdown parsing more intuitive and automatic as well as align it with GHFM. I have tried documenting the current behavior here: docs: Configure how comments are rendered. |
As for
As for your table not displaying: That's unfortunately a similar issue, you need to allow the We plan on doing the right thing for you when you enable a markdown extension automatically (e.g. allow all table-related elements when you use the |
Hello @ix5 , thank you for the additional information, we finally have a direction to explore on fixing this. Using your suggestion, I was able to get "underline" to work via the "u" tag, but nothing else. "highlight" still does nothing (what would be the tag for that?), while the "table" also does absolutely nothing. Is this the correct syntax for the
I tried adding all the table-related tags there as well, with no difference. Really not sure why
That would be great indeed, but until that's in place it would be great to be able to get these extensions working even manually, since right now the documentation you point to at docs: Configure how comments are rendered is a bit misleading since most extensions don't do anything... |
Hmm, ok, but that's a third-party JavaScript library with no connection to What kind of "parsing" is meant here? I don't think it's a problem if this functionality is not actually supported, but in that case we should fix the documentation so that people don't waste time troubleshooting something that was never intended to work... |
That would be the
For me,
As well as with
Yes, the issue is known. We have to decide just how much we want to overhaul the whole system without breaking setups of existing users.
That's due to the underlying misaka library choices: FSX/misaka#71 (comment)
Feel free to submit a PR |
Hi @ix5 , Thank you for the clarifications, this was very helpful to finally fix and understand the behaviour here!
Done, works fine, thanks!
Interestingly, I had to track this for a bit. It seemed to work fine in a new comment, but not in the existing one(s). What eventually turned out to be the problem was that the rendering did not kick in if there was any text right next to the table, it would keep it as 'code' then. Adding a line break made it render fine!
Yes, all of these work now after adding the missing tags under
This was pretty unclear to me until spending some time to read the information in that comment. Basically, the
Ok, done -- #1017 -- I've added the above few notes, hope it's ok! |
I am sorry, but for me the situation stays the same: neither ==highlight== nor table nor math formula are rendered in isso comments... |
Maybe if you paste the contents of your |
Sorry, I did not restart isso, and it works now, for |
Super, great to hear, also to have that note here in case other people run into the same issue!
Yes, that is actually expected behaviour, as detailed by @ix5 above. I have a PR attempting to improve the documentation around this -- basically the I've researched those a bit (both are JavaScript based and also require a consistent amount of custom fonts), and each have some pros and cons: MathJax is a much smaller library (14k or so) and with better compatibility for ancient browsers (we're talking really ancient), but it's also very slow to render and suffers from a nasty FOUC effect (Flash Of Unstyled Content); KaTeX is a significantly "heavier" library (over 200k minified), but it's more modern and lightning fast, avoiding FOUC altogether. Remains up to everyone to choose the best one for their use case (I'd go with KaTeX personally). Interestingly, there's also the option of parsing the LaTeX server-side: KaTeX for example provides this (but being written in JS, it means you'd need to have an entire NodeJS infrastructure on the server); but there are also Python implementations for this -- for example, mdtex2html, which I've tested on the above equations and comes up very nicely in MathML (supported in all modern browsers without extra fonts or JS necessary): @ix5 -- would you be interested in pursuing a way to integrate this, or perhaps latex2html directly, into Isso? It could be run only if math is detected in the comments, and would avoid the need for external and heavy libraries and post-processing. Happy to study options if you find it can fit the scope. |
MathJax is very efficient and it is used in my blog. Unfortunately, it is not used in isso. The best, in my opinion, would be the option of using it in comments. |
If you already have MathJax running on your blog, then it should just be a matter of getting it to parse the comments after Isso. You could either delay its loading and running for until after Isso is done (moving the script to the footer and removing any |
Regarding @mgc8's suggestion about integrating a latex/mathml conversion tool: It would be nice to hear from existing users whether they would be interested in that or if their own control over math rendering is more important. We should also figure out the order of the following steps:
I'm not sure whether we could introduce vulnerabilities if we do the latex conversion after the bleach step since perhaps users could do |
You are very probably right. I have to look again on MathJax 3 Documentation, how to use MathJax on dynamic contents. |
I suggest a help in isso-documentation to use MathJax with isso... |
That makes sense, although I'm not sure how many users read this issue... How about this: we can have the server-side parsing controlled by an option, which would default to the current behaviour if missing or not set, thus not affecting any existing setup? Then, only the users who really want to have that would turn it on.
That is a very good point, security is critical in a case like this. I would say that Alternatively, we can also run the
... though that would still potentially leave some malicious manipulation possible to output HTML; although nothing is perfect, |
Thus further complicating our already byzantine maze of configuration options into which you've already felt yourself getting trapped...
That's certainly an issue, thank you for raising that (I wasn't aware). People suggest using nh3 so a switch in the future should be investigated. In general, math rendering on the server makes sense, since hooking the mathjax/... calls, especially for the edit/preview fields, is a pain. We currently provide mostly barebones functionality and trust our mostly-technical users to DIY the rest. If we find a way to make this less painful while keeping Isso simple enough, I'm all for that. |
To be honest, I don't think the confusion here stemmed from the configuration options, but rather the unintuitive behaviour of the software behind-the-scenes. Overall, Isso has a pretty succint configuration compared to other similar pieces of software. With the recent patches that add some more sanity to the way Of course, if you have already something else in mind as part of future plans for improvement here, let me know and perhaps we can aim for that instead?
From what I see in the (many) comments on that,
Agreed on all counts, if other people have comments and suggestions on the topic, that would be great to hear. |
You're right in that the markdown handling will be improving a bit, but that may be a bit for naught if we are to change our renderer. I would prefer to expose sensible options to users rather than have them learn the intricacies of our renderer/sanitizer, which might not translate 1-to-1 for the different packages ( We can lessen the confusion of the current markdown configuration via better documentation and improvements to auto-enabling allowed HTML elements when toggling a feature flag, but it'd be much better for existing and especially new users to just make this whole system intuitive. I'd prefer to make the defaults more like GitHub-flavored markdown (meaning also enabling more extensions by default) and expose extensions to users via generic names ( But that's just my own opinion and I'm willing to be convinced otherwise. Discussing this here is a good first step towards finding a solution. My idea would be something like this: [markdown]
line-break = single # hard-warp
raw-html = false # escape
[markdown.features]
tables = true
latex-math = render # or 'skip', 'escape'
images = false
links = true
# Enabled by default
highlight = true
underline = true
strikethrough = true
no-intra-emphasis = true
# ... As for latex/math handling on the server vs client (via JS), the client isn't really ready for that as I see it. We do not provide a reliable hook mechanism for newly inserted comments (or even the preview field) so that Mathjax could listen for that - and unless this sorry state of affairs changes, I'd rather simply do the right thing for them on the server. Letting users know that something is here-be-dragons territory always sucks. Let's improve the client and expose extensibility mechanisms and a whole lot of problems suddenly get easier.
Good to know.
Perhaps a more focused approach with actionable items might lead to better and clearer results. Right know we're burying the conversation deep in this thread, which was originally a bug report (I'm absolutely guilty of perpetuating this as well). Suggestions are always great, and we have lots of drive-by contributions with small to medium-sized fixes/improvements, but so far, no features/improvements of a larger scale (as would be required by the overhaul in markdown handling) have been contributed in recent times. If you feel that you would like to overhaul this system or know someone for whom this would be just the right challenge, go for it! While I personally am neither a great coder nor could design a good system, I'd be happy to review any proposals and contribute docs, migration advisories (from old handling to new) and tests. |
Using MathJax 3 dynamically in DOM is not quite easy. If someone would succeed to use MathJax in isso comments, an explanation online would be very welcome.... |
Checklist
master
branch does not fix my issueWhat is not working?
The documentation here makes note of a number of extensions that can be added to the default Markdown editor, such as "math", "footnotes", "highlight", "tables" etc. However, even after adding them to the configuration, there does not seem to be any change, and no errors in the logs either.
How can one reproduce this issue?
Isso configuration file contains the following [markup] section:
The "default" ones -- "autolink, fenced-code, no-intra-emphasis, strikethrough, superscript" work correctly and as expected, adding and removing them from the line produces the expected results. However, "math, highlight, tables, underline" produce no effect whatsoever. A demo can be seen on this page, the last comment:
https://mihnea.net/hello-world/#isso-11
Is there something I'm missing from the installation? The Misaka library appears to be present under
isso/lib/python3.9/site-packages/misaka
and is at version 2.1.1.The text was updated successfully, but these errors were encountered: