View Single Post
Old 12-16-2020, 01:16 PM   #25
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,737
Karma: 24031401
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by KevinH View Post
Based on the images and discussion above ... something like an AutoReplace tool or plugin that allows you to load and save a text file. The text file would be pipe delimited one entry per line with what to find first then a "|" character then the replacement text followed by a new line (or cr/lf for Windows).
Since most user probably maintain such list with a spreadsheet app, I'd recommend that the input files should be two-column .csv or tab-delimited files, because both can be easily exported.

Quote:
Originally Posted by KevinH View Post
All text files would be utf-8 encoded.
This is a good idea, because some Windows apps still save .csv files as ANSI/CP1252 files, but most can save UTF-8 files.

Quote:
Originally Posted by KevinH View Post
That sounds very very doable, although it may be better as a plugin.
Agreed. I actually might write one over the Christmas break, if enough users are interested and KevinH isn't interested in writing it.


Quote:
Originally Posted by elibrarian View Post
Given it is made as a plugin, wouldn't Python's regex engine be able to handle something in that direction?
Python actually has two regex engines (re and regex) and one of them even has limited support for fuzzy searches.

Quote:
Originally Posted by elibrarian View Post
(I would have no objections to a plugin - would the plugin implementation be significant slower than a C++ implementation in the Sigil core if working with big files/many replacements?)
That depends on the implementation and the number of entries in the list. A C++ implementation would definitely be faster, but a pure Python solution shouldn't be that much slower, especially, if the list isn't too long.

Last edited by Doitsu; 12-16-2020 at 01:30 PM.
Doitsu is offline   Reply With Quote