Inconsistent tag insertion in the editor, depending on tool used, when the selected text is bounded by "<" or ">"
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>
[PASS] <p><em>
=======
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
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>
=======
======= ======= ======= ------- ------- www.w3. org/1999/ xhtml"> title>TEST< /title> </head>
FULL TEXT OF TESTING FILE (TEST.XHTML)
-------
<?xml version='1.0' encoding='utf-8'?>
<html xmlns="http://
<head><
<body>
<p><i>TEST</i> TEST TEST</p>
👈
<p><i>TEST</i> TEST TEST</p>
</body>
</html>