Description
Given an HTML file with several `A' elements, we want to do some work on
`A' elements whose start tags are <a href=XX>:
- Remove the start tag, i.e., <a href=XX>,
- Remove the associated end tag, </a>,
- But keep the texts between the start and the end tags.
|
| Raw Input
| text1 <a href=normal>text2
</a> text3
<a href=XX>text4
text5</a> text6 <a href=normal>text7</a> text8 <a href=XX>text9</a> text10
<a href=XX>text11</a> text12 <a href=XX>text13</a> text14 <a href=normal>
text15</a>
|
|
| Desired Output
| text1 <a href=normal>text2
</a> text3
text4
text5 text6 <a href=normal>text7</a> text8 text9 text10
text11 text12 text13 text14 <a href=normal>
text15</a>
|
|
Script and Comments
Script1 [ 1] :top
[ 2] /<a href=XX>/!b
[ 3] s/<a href=XX>/\n/
[ 4] /\n.*<\/a>/!{
[ 5] s/\n//
[ 6] :loop
[ 7] n
[ 8] /<\/a>/!b loop
[ 9] }
[10] s/<\/a>([^\n]*)$/\1/
[11] s/\n//
[12] b top
| |