Returns from/to line lists with tabs expanded and newlines removed. Instead of tab characters being replaced by the number of spaces needed to fill in to the next tab stop, this function will fill the space with tab characters. This is done so that the difference al
(self,fromlines,tolines)
| 1782 | )).encode(charset, 'xmlcharrefreplace').decode(charset) |
| 1783 | |
| 1784 | def _tab_newline_replace(self,fromlines,tolines): |
| 1785 | """Returns from/to line lists with tabs expanded and newlines removed. |
| 1786 | |
| 1787 | Instead of tab characters being replaced by the number of spaces |
| 1788 | needed to fill in to the next tab stop, this function will fill |
| 1789 | the space with tab characters. This is done so that the difference |
| 1790 | algorithms can identify changes in a file when tabs are replaced by |
| 1791 | spaces and vice versa. At the end of the HTML generation, the tab |
| 1792 | characters will be replaced with a nonbreakable space. |
| 1793 | """ |
| 1794 | def expand_tabs(line): |
| 1795 | # hide real spaces |
| 1796 | line = line.replace(' ','\0') |
| 1797 | # expand tabs into spaces |
| 1798 | line = line.expandtabs(self._tabsize) |
| 1799 | # replace spaces from expanded tabs back into tab characters |
| 1800 | # (we'll replace them with markup after we do differencing) |
| 1801 | line = line.replace(' ','\t') |
| 1802 | return line.replace('\0',' ').rstrip('\n') |
| 1803 | fromlines = [expand_tabs(line) for line in fromlines] |
| 1804 | tolines = [expand_tabs(line) for line in tolines] |
| 1805 | return fromlines,tolines |
| 1806 | |
| 1807 | def _split_line(self,data_list,line_num,text): |
| 1808 | """Builds list of text lines by splitting text lines at wrap point |