Page 1 of 2
marking text in html or xml
Posted: Wed Sep 14, 2016 12:27 pm
by pbaumann
I'm editing files in html and xml. Very often it would be convenient to have the following functionality available
looking for
00FFFF
Finding
<td class="kat" style="background-color:#00FFFF;color:red">..
resulting that cursor is located into the front of 00FFFF and 00FFFF is marked.
I would like to extend the marking to the left side resulting in marked (the leading space is not shown by the forum software)
style="background-color:#00FFFF
(i. e. marking to the beginning of the attribute) and in the second step to the right side resulting in
style="background-color:#00FFFF;color:red"
(i. e. marking the complete HTML attribute). Then I could continue to delete or to cut out (CTRL-C) or do whatever I want with the marked character(s).
Similar question is marking only the text between the double quotes, i. e.
"background-color:#00FFFF;color:red"
or
background-color:#00FFFF;color:red
or marking the whole element like
<td class="kat" style="background-color:#00FFFF;color:red">..</td>
Posted: Wed Sep 14, 2016 9:06 pm
by ben_josephs
Please clarify why you can't just search for
style="background-color:#00FFFF;color:red"
or
background-color:#00FFFF;color:red
or whatever.
Why I can't just search after certain style
Posted: Thu Sep 15, 2016 6:47 am
by pbaumann
You are right, I could search for the given content.
The background is (what I have forgotten to describe) that I'm working in a big documentation (ca. 2500 HTML-files, roughly 30 MB). This documentation of an interface is delivered on a regular basis to "consumers" (to be exact: depending on planned or introduced, resulting in two versions: "production" and "development" (i. e. description on coming changes). In average there is every month one delivery - this will be overruled by the volume of each change which has to be documented in the delivery, respectively).
Changes to previous versions are highlighted with HTML methods, using the same color (like #00FFFF) for same releases. The documentation could contain more than one change in one delivery (i. e. more than one color of highlighting). 00FFFF stands here only as one example - different releases having different colors.
My question is triggered by the attempt to automate the process of editing: An usual task is to strip all highlighting for a certain change (because it went productive). So I'm looking for every point where 00FFFF is used (that is my usual approach: find all points where the 00FFFF is used).
style="background-color:#00FFFF;color:red"
is only one example of possible highlighting. Ohers are
style="background-color:#00FFFF;color:blue"
style="background-color:#00FFFF"
<table class="banner"><tr><td align="center "style="background-color:#00FFFF">With color aquamarin marked changes planned for release xyz</td></tr></table>
and some more. Given of the exact structure found by the search I'll treat it in a proper way: Just deleting a paragraph, marking some code and delete ist, modifying code or so on. Or make a special treatment in cases where some representation of different future releases are mixed (i. e. in (database-) tables which are part of the documentation and where different cells are modified in different releases, or rows inserted in different releases or mixtures of inserting rows and modifying cells).
With my question I'm trying to have one macro or combination of key hits to mark and to delete the
<td class="kat" style="background-color:#00FFFF;color:red">..</td>
or
background-color:#00FFFF;color:red
or
style="background-color:#00FFFF;color:red"
I know that I could use also CSS to switch off highlighting just changing one line in fonts.css. But actually I don't have the time to change my process of editing and the structure of my document, because to use CSS I have to prepare some things in the existing documentation.
Posted: Thu Sep 15, 2016 7:10 am
by ben_josephs
Do you want a single search expression to match all of these? The description "and some more" is not helpful.
Method: To locate all positions where 00FFFF is used
Posted: Thu Sep 15, 2016 7:27 am
by pbaumann
No, I don't want a full automated skript for every circumstance because there are many possible variations of HTML-code.
The only point for sure is that in the code to be modified is a 00FFFF (or another color). The approach is to identify these locations which have to bei treated. And decide what to do. If I see
background-color:#00FFFF;color:red
which has a probability of 10 or 20 percent I would like to have a macro to get rid of this HTML. If I know to solve this (i. e. create this macro) I could look around and define other macros for other circumstances with the hope to cover up to (a guess) 70% of cases.
One comment: I've tried the inverse approach: Looking for EVERY combination and treat it (but I have to check also every "change", i. e. could not automate it) and then fixing the rest. This turned out to be ineffective because of two reasons:
- 1. Number of hits / spots (in "small" releases 500 positions in the document which have to be treated, in larger even more).
- 2. Changes in the documentation are usually located near by other - from the editorial point of view it is better to treat them sequentially (so you could write a "historical" comment or some other editorial stuff)
Posted: Thu Sep 15, 2016 9:24 am
by ben_josephs
You wrote:I would like to have a macro to get rid of this HTML
I don't understand. To delete selected text you don't need a macro. You just enter
<Del> or
<BS>.
Why I want a macro
Posted: Thu Sep 15, 2016 9:58 am
by pbaumann
The workflow is as follows: Identify places which has to be modified by looking after 00FFFF.
It is somewhat likely that some of the places have the (surrounding) structure
style="background-color:#00FFFF;color:blue"
So I would like to extend the marked area from
00FFFF
to
style="background-color:#00FFFF;color:blue"
using a macro. How to define this macro?
Remark: I appreciate your support - thank you for your efforts. I'm sad because my description is obviously not understandable (perhaps my knowledge of english language?) and beg your pardon.
Posted: Thu Sep 15, 2016 10:04 am
by ben_josephs
Why not just search for
style="background-color:#00FFFF;color:blue"
?
Posted: Thu Sep 15, 2016 11:06 am
by pbaumann
But that was your question yesterday (Wed Sep 14, 2016 9:06 pm ), wasn't?
I'll try it again: The workflow is as follows:
1. Identify the next occurance of the description of a change (visible on the color used to markup; in our example 00FFFF).
2. Analyze, what is written there. Based on syntax and content decide how to clean up or to change the content. One of MANY possibiities is that the 00FFFF is part of
Code: Select all
style="background-color:#00FFFF;color:red"
where the style is obsolete and has to be deleted. To ease the work (i. e. to navigate the cursor and mark
Code: Select all
style="background-color:#00FFFF;color:red"
and then delete the text) it would be convenient just pressing the key-combination to mark this text (for example ALT F10) followed by delete-key.
Please keep in mind, that this is only one of many variants which are not easy to forecast (I could preview each combination of occurence). So I have to look on it and then - if suitable - react with my macro. Also my example is stripped down in complexity and for that it seems perhaps ridiculous not to search directly.
Posted: Thu Sep 15, 2016 12:18 pm
by ben_josephs
Are you asking just how to record a macro to extend the selection? What difficulty are you finding in doing that?
Posted: Fri Sep 16, 2016 10:19 am
by pbaumann
I have a proposition: I'll divide the solution (=creation of suitable macro) into steps - that would be very educational not only for me.
The starting point is as followed: With F5 I have performed a search to a hex code like 00FFFF (or #00FFFF) and the result is hit of a text position. This hit is already marked (you could use CTRL-X to cut out, if you want).
The next step would be a macro to extend the marked characters to the left to a given starting point (e. g.
). How could this be done? Thx!
Posted: Fri Sep 16, 2016 3:10 pm
by ben_josephs
If you've selected 00FFFF in
style="background-color:#00FFFF;color:blue"
then
<Right><Shift+Ctrl+Left><Shift+Ctrl+Left><Shift+Ctrl+Left><Shift+Ctrl+Left><Shift+Ctrl+Left><Shift+Ctrl+Left><Shift+Ctrl+Left>
that is
<Right> followed by <Shift+Ctrl+Left> seven times
extends the selection to
style="background-color:#00FFFF
Posted: Fri Sep 16, 2016 4:06 pm
by pbaumann
This works perfect. I think this is also applicable to create a macro (I didn't try it because I just answer this with my tablet). Remark for me: Shift+CTRL+Left steps one word.
Let's go to the next step. I would like to extend the marked area to the right and to deal with the following situations (keep in mind that
is already marked).
style="background-color:#00FFFF;color:blue"
style="background-color:#00FFFF;color:red"
style="background-color:#00FFFF"
style="background-color:#00FFFF;"
style="background-color:#00FFFF;color:rgb(51,0,102)"
style="background-color:#00FFFF;color:blue;font-family:Arial;"
style="background-color:#00FFFF;color:blue;font-family:Arial;font-size:120%;"
The quotes represent the text which should be marked by this next step.
Posted: Sun Sep 18, 2016 2:59 pm
by ben_josephs
If you've selected 00FFFF in
style="background-color:#00FFFF;color:blue"
then
<Left> followed by <Ctrl+Left> 6 times followed by <Shift+Ctrl+Right> 11 times followed by <Shift+Right>
extends the selection to
style="background-color:#00FFFF;color:blue"
Alternatively, you can use TextPad's SelectSwapEnds, which swaps the cursor between the ends of the selection. This command is not available through the menus and it's not assigned a shortcut key by default. But you can it assign a shortcut key, say <Ctrl+Insert>:
Configure | Preferences | Keyboard | Categories: Selection | Commands: SelectSwapEnds | Press new shortcut key: | <Ctrl+Insert>,
then Assign.
If you've assigned the <Ctrl+Insert> shortcut to the SelectSwapEnds command, then if you've selected 00FFFF in
style="background-color:#00FFFF;color:blue"
then
<Left> followed by <Shift+Ctrl+Left> 6 times followed by <Ctrl+Insert> followed by <Shift+Ctrl+Right> 5 times followed by <Shift+Right>
extends the selection to
style="background-color:#00FFFF;color:blue"
You can work out key sequences for your other examples yourself.
Thanks, it is working
Posted: Tue Sep 20, 2016 5:22 am
by pbaumann
Thanks, it is working. Especially the SelectSwapEnds is interesting (and I didn't know it - it would be interesting to have an overview of existing category / commands).
However as a programmer: Is there a more generic way to work with i.e. marking / extending the mark until a special character (which has in some way to be defined). That means also to reduce the number of repeats.
One point as a hint to others: One could influence the number of repeats of <Shift+Ctrl+Right> etc. by choosing in
Configure | Preferences | classes (documents) | HTML (or whatever you use) | Syntax
in the lower part more characters to be treated as part of a word. (I have an environment with German language so perhaps my translation to the english words used in the menus is not hitting the words there).