endpnt/andoc — Issue #8: html escaping and text selections
Author: endpnt
Created: 2011-11-13 12:30:32+00:00
State: open
Labels: Bug, JS

For every saved selection, the start and end position based on the original raw plain text data is calculated and saved. As soon as the raw data has to be escaped for HTML rendering, those start and end positions become invalid.

The single char < or > or & becomes a & etc and JS seems to count those as 5 instead of 1 in the range object.

This is messing up all offsets and the selections don't get applied or wrongly applied while rendering selections.

Also, new selections by the user will probably contain wrong start and end positions if there is any escaped character in the document.

currently < and > are translated as [ and ] to avoid the problem.

related function:
https://github.com/endpnt/andoc/blob/master/static/andoc.js#L115

this code finds all escaped chars
https://github.com/endpnt/andoc/blob/master/static/andoc.js#L124

here the html should be escaped with |e instead of the |replace(... hack
https://github.com/endpnt/andoc/blob/master/templates/doc/raw.html#L46