Sujet : Re: Automating an atypical search & replace
De : the_stan_brown (at) *nospam* fastmail.fm (Stan Brown)
Groupes : comp.editorsDate : 14. Jul 2024, 07:08:54
Autres entêtes
Organisation : Oak Road Systems
Message-ID : <MPG.40fd0b51d7b0134e99030d@news.individual.net>
References : 1
User-Agent : MicroPlanet-Gravity/3.0.11 (GRC)
On Sat, 13 Jul 2024 11:08:48 -0500, Richard Owlett wrote:
I'm reformatting some HTML files containing chapters of the KJV Bible.
My source follows the practice of italicizing some words.
I find italics distracting.
These occurrences are consistently of the form
<span class='add'>arbitrary_text</span>
I wish to delete "<span class='add'>" and *ASSOCIATED* "</span>".
Obviously it would not be wise to fully automate the action.
I wish to find all occurrences of <span
class='add'>arbitrary_text</span> an manually confirm the edit.
In general, is it feasible?
Yes, of course. Any editor above the level of Notepad ought to be
able to do this. (Sadly, a lot of editors are not above the level of
Notepad.)
For instance, in Vim you would use this command after opening the
file:
:%s;<span class='add'>\([^<]*\)</span>;\1;gc
% = process every line of the file
\( ... \) makes that part of the pattern match addressable
[^>]* matches a string of characters not including a <. If there is
other HTML between span and /span, it will not match.
\1 = the text found between span and /span
gc = do every occurrence on each line, but confirm each one
Can KDE's Kate do it?
I've no idea.
But there's an easier solution. Change the definition of class add in
your style sheet:
span.add { font-style:normal; }
Then you won't have to edit the HTML at all.
-- Stan Brown, Tehachapi, California, USA https://BrownMath.com/Shikata ga nai...