Access4all / EPUB

3 stars 1 forks source link

Markup produced by the editor is invalid (Chrome/FF) #29

Closed jmuheim closed 9 years ago

jmuheim commented 9 years ago

In both Chrome and FF it's pretty easy to produce invalid markup by accident. I also noticed that Chrome and FF don't behave exactly the same way, i.e. they are not producing the same code all the time.

Already after a few keystrokes (like enter, delete, some text, etc.) the produced markup isn't correct anymore: tags aren't nested correctly anymore, there are unnecessary br elements, empty p elements, non breaking spaces, etc.

Screenshot

Screenshot of the editor

Produced code

<p>
<h4 aria-level="4" role="heading">asdf</h4>
<p>
</p>
<figure class="right50">
<img src="http://access-for-all.ch/images/stories/logo/logo2.gif" alt="This is the alt text" height="auto" width="100%">
<figcaption>
<p>this is the legend <br>
</p>
</figcaption>
</figure>Cool, this is working nicely!</p>
<p>&nbsp;<br>
</p>
qtnc commented 9 years ago

I already know that, and I unfortunately think that it's allmost impossible to avoid completely the generation of invalid HTML.

Specifically, I myself observed that chrome often add empty <p>, while firefox is constantly adding <br> everywhere. I tried by many means to remove them directly while editing, but they seem to appear quite unpredictably.

For nbsp, sometimes the browser also adds them automatically and randomly, but sometimes it's volontire. For example, in Chrome, if an element is completely empty, you aren't always able to place the cursor inside it, and sometimes it even incorrectly place the cursor to the next non-empty element when you ask it to be placed inside the empty element. To avoid browser stupidities of that sort easily, I therefore volontarily add nbsp all the time.

Sorry, but the most reliable in WYSIWYG editing is . . . Internet Explorer !

All these problems leas to appliing filtering on save. Most of the invalidity above should disappear when you save:

This filtering is done automatically on save, but you can also force it by pressing F9 at any time.

jmuheim commented 9 years ago

Yeah I thought that it's a pretty nasty situation with the different browsers.

Thanks for explaining the main problems.

qtnc commented 9 years ago

I think I have explained well enough the situation, why it is still there and how I deal with it. So I close the issue. You may reopen it if you find something that isn't caught by my HTML code cleaner for example.