View Single Post
Old 03-14-2014, 11:38 AM   #9
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,461
Karma: 27757440
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
This is an html source code editor, there is no guarantee that the selected text does not contain other tags. You cannot just assume it is text a plunk it in the middle of an <a> tag.

There are three possible behaviors for the insert link action when text is selected:

1) Delete the selected text and insert the <a> tag (this is what currently happens)

2) Ignore the selected text and insert the <a> tag either before or after it depending on the current cursor position at the start or end of the selection.

3) Wrap the selected text in <a> tags.

1) and 2) have the advantage that the insertion of the <a> tag can be guaranteed to not produce invalid HTML. Trying to make that guarantee with (3) is very difficult. The best that you could probably do is detect a potential problem and bail with an error message.
kovidgoyal is offline   Reply With Quote