Aiming to convert first row of a html table from to tags.
So, I wrote the following code.
(defun tdtoth ()
(if (search-forward "</tr>" nil t)
(while (search-forward "td" nil t)
(replace-match "th" 1))))
And executed it while I was on in the following text:
<tr>
<td> Some text </td>
<td> Another thing </td>
</tr>
The idea being search for </tr>
only once and while that is not happening, replace every td
with th
But that code does not work. What is wrong and how do I set it right?
<tr>...</tr>
. Thereafter you can easily perform any replacements restricted to that region. Narrowing the buffer works as follows: Put point on<tr>
and typeC-_
(the underscore stands for a space). That sets mark and therefore starts the region. Search for</tr>
viaC-s
and typeC-x n n
fornarrow-to-region
.