Inconsistent tag insertion in the editor, depending on tool used, when the selected text is bounded by "<" or ">"

Bug #1999349 reported by mike juvrud
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
calibre
Fix Released
Undecided
Unassigned

Bug Description

Depending on the Editor tool used (e.g. "Insert Tag" vs "Bold"), tags are inserted at different positions. Occurs when the selected text is bounded by "<" or ">".

The "Insert Tag" tool appears to work CORRECTLY (see below, where the "<em>" opening/closing tags are correctly inserted around the selected text, even when bounded by "<" and ">").

The "Bold, Italic, Underline, etc." Editor tools do NOT insert correctly, when the selection is bounded by or starts/ends with "<" or ">". See below how the "<b>" opening/closing tags do not contain the entire originally selected text.

=====================
SAMPLE TEXT TO REPRODUCE THE ISSUE IN THE EDITOR (foo.xhtml):
---------------------
<p>TEXT</p>
<p><i>SAMPLE</i> TEXT</p>
=====================
TEST ('BOLD' TAG TOOL: *INCORRECT* TAG INSERT):
---------------------
- Select contents within the paragraph tags (e.g. "TEXT", "<i>SAMPLE</i> TEXT")
- Editor Toolbar > 'Bold' tool button (or use its keyboard shortcut)
- The inserted opening and/or closing tags are NOT positioned correctly to contain the originally selected text (result below).
---------------------
RESULT:
[FAIL] <p><b>TEX</b>T</p>
[FAIL] <p><i<b>>SAMPLE</i> TEX</b>T</p>
=====================
TEST ('INSERT TAG' TOOL: *CORRECT* TAG INSERT):
---------------------
- Select contents within the paragraph tags (e.g. "TEXT", "<i>SAMPLE</i> TEXT")
- Editor Toolbar > 'INSERT TAG' tool dropdown button
- Select '<em>' (or other tag)
- The inserted tag is positioned correctly (result below)
---------------------
RESULT:
[PASS] <p><em>TEXT</em></p>
[PASS] <p><em><i>SAMPLE</i> TEXT</em></p>

=====================
ALTERNATE SAMPLE TEXT (without <p></p>) (BOLD tool FAILS)
---------------------
TEXT
<i>SAMPLE</i> TEXT
---------------------
RESULT (BOLD tool):
[PASS] <b>TEXT</b>
[FAIL] <i<b>>SAMPLE</i> TEXT</b>
---------------------
RESULT (INSERT TAG tool):
[PASS] <em>TEXT</em>
[PASS] <em><i>SAMPLE</i> TEXT</em>

=====================
Calibre version: 6.9, Windows

Tags: editor
Revision history for this message
mike juvrud (mjuv) wrote :

This behavior only occurs when there is a UNICODE character preceding the selected text where the tag is to be inserted. In the below example, the first <p></p> line of text will insert a tag correctly. The second <p></p> line will NOT insert correctly.

=====================
SAMPLE TEXT (USING CHARACTER U+1F448)
---------------------
<p><i>TEST</i> TEST TEST</p>
👈
<p><i>TEST</i> TEST TEST</p>
=====================
RESULT (selecting "<i>TEST</i> TEST TEST" and using BOLD tool to insert <b></b> tags.
---------------------
[PASS] <p><b><i>TEST</i> TEST TEST</b></p>
👈
[FAIL] <p><i<b>>TEST</i> TEST TES</b>T</p>
=====================

=====================
FULL TEXT OF TESTING FILE (TEST.XHTML)
---------------------
<?xml version='1.0' encoding='utf-8'?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>TEST</title></head>
<body>

<p><i>TEST</i> TEST TEST</p>
👈
<p><i>TEST</i> TEST TEST</p>

</body>
</html>

Revision history for this message
Kovid Goyal (kovid) wrote : Fixed in master

Fixed in branch master. The fix will be in the next release. calibre is usually released every alternate Friday.

 status fixreleased

Changed in calibre:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.