Is there a way to quickly automate HTML tags across several documents from upper case to lower case? I need this done for all tags across multiple files.
Here is a small portion of what I need done...
<BODY LINK="#3366CC" BGCOLOR="WHITE" MARGINWIDTH=0 MARGINHEIGHT=0>
<TABLE WIDTH="100%" CELLPADDING=0 CELLSPACING=0 BORDER=0> to
<body link="#3366cc" bgcolor="white" marginwidth=0 marginheight=0>
<table width="100%" cellpadding=0 cellspacing=0 border=0>
Thanks!
Automated (Macro?) upper case to lower case
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
ben, your expression replaces too much - imagine this:
would end up as
Not only the alt text would be changed, but also the URL - which could lead to broken links.
Another thing - attributes like alt or title might contain the > character.
HTML can't be parsed with regexes alone - this is the reason why I do not offer a better solution...
What can be done is changing the element name:
Search for
Replace by
Automatically finding/changing the attribute names is much more difficult - as attributes may contain quotes, blanks, and = and >
e.g.
or
are both valid HTML attributes but give lots of trouble when trying to use regexes on them...
Code: Select all
<IMG SRC="BLA.PNG" ALT="Picture of George Washington">
Code: Select all
<img src="bla.png" alt="picture of george washington">
Another thing - attributes like alt or title might contain the > character.
HTML can't be parsed with regexes alone - this is the reason why I do not offer a better solution...
What can be done is changing the element name:
Search for
Code: Select all
</?[A-Za-z]+
Code: Select all
\L&
e.g.
Code: Select all
title="title='> > >'"
Code: Select all
title='title=">">">"'
Forgot something:
There are tools that have an HTML parser inside and can therefore do the job properly, e.g.
HTML Tidy
There are tools that have an HTML parser inside and can therefore do the job properly, e.g.
HTML Tidy
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
Thanks for the info everyone. MudGuard was correct in assuming the following scenario:
<IMG SRC="BLA.PNG" ALT="Picture of George Washington">
<img src="bla.png" alt="picture of george washington">
Of course, idealy the end result would be:
<img src="bla.png" alt="Picture of George Washington">
UNIX constraints also require file names (ie. bla.png) to be lower case, however any non-code text would remain the same. We are translating our HTML to XHTML
<IMG SRC="BLA.PNG" ALT="Picture of George Washington">
<img src="bla.png" alt="picture of george washington">
Of course, idealy the end result would be:
<img src="bla.png" alt="Picture of George Washington">
UNIX constraints also require file names (ie. bla.png) to be lower case, however any non-code text would remain the same. We are translating our HTML to XHTML
No. UNIX has case sensitive file names. Same goes for all derivates of UNIX that I know (including HP-UX, AIX, SINIX, Linux)UNIX constraints also require file names (ie. bla.png) to be lower case.
You can, e.g. have the following files in one folder:
bla
blA
bLa
bLA
Bla
BlA
BLa
BLA
without any problem.