-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Custome Parser using document.createElement does not allow html5 (div inside p) #314
Comments
Use spans not divs maybe. I think that you'd have to set |
I did replace all divs with spans. I just felt that it was rather hacky. So you are saying that the |
Yea, hacky, I'm sure it's the catchphrase for web development! Styling I think is only used when rendering it to the user in the browser. I don't think style rules are evaluated until you actually attach it to the document. To be honest I've never tried to use a div inside a p tag as it just didn't really work. I suppose technically I may have when I do things like |
The div actually comes from the mathJax rendered element for display math (versus inline math which are just spans). I highly suspect the problem we are having with list elements could also be attributed to how browser handles these. I will try to read through all of our issues on that when I am done with what I am working on at hand. The problem is that this kind of issues will likely come up everytime we use a custom parser. In my case, before I pass the textValue into the createElement parser, I had manually replace all of the non-compatible elements with compatible elements. I got away by simple Any thoughts on this @tarjei? Since the code originally came from you :) |
Yea, that possibly was the problem originally with lists. Then I re-wrote lists to use our own logic so it's mostly me to blame for lists now. |
I will look into your code then! I have meant to do that for a while now. |
@episodeyang my first thought is that you should also remember that there are quite large differences in the markup browsers generate :) I.e. if you are aiming for perfect control of the markup generated, you might be in for a world of pain :) |
I'd say that you definitely are in for a world of pain if you're trying for perfect control of the markup. As is shown by these XHTML issues that have started popping up. |
hahaha I really enjoyed your comment. It is really nice to be able to learn from someone who has a lot more experience. The goal here is not to get perfect control of the markup, but to be able to parse and do some basic custom modification to the markup after it is returned by ngModel. Right now the problem is that the So here is the fundamental question: So @tarjei basically used the Other user cases I have right now are:
|
I'm not sure why you're using Have a look here: https://github.com/fraywing/textAngular/blob/master/src/textAngular.js#L1409-L1433, that might get you along the correct path, jqlite in angular is close to as functional as jquery for our general needs so it works well enough as a DOM parser and traversal tool. |
Closed due to inactivity. |
Hi @SimeonC and @tarjei,
I am implementing a custom parser to clean up the textvalue when I ran into this rather interesting bug.
TLDR;
basically, when I use
createDocumentFragment
to create a shadow element to parse thetextvalue
, it incorrectly parses textNodes in a paragraph that are after child spans into a new paragraph.example
content:
gets converted into
code
My thoughts
<div>
inside<p>
is not supported in html4 standard, however it is support in html5. Any thoughts?ps: the code is copied from @tarjei's awesome math-jax textAngular project here:
The text was updated successfully, but these errors were encountered: