Conditional extraction of attributes in HTML tags

Déjà Vu includes a hard-coded list of which attributes are translatable for each tag. The list is:

A	TITLE	
A	ONMOUSEOVER	
A	ONMOUSEOUT	
A	ONCLICK	
APPLET	ALT	
AREA	ALT	
IMG	ALT	
INPUT	VALUE	
ISINDEX	PROMPT	
META	CONTENT	
OBJECT	STANDBY	
OBJECT	TITLE	
OPTGROUP	LABEL	
OPTION	LABEL	
OPTION	VALUE	
PARAM	VALUE	
TABLE	SUMMARY	
TD	ABBR	
TD	ONMOUSEOVER	
TD	ONMOUSEOUT	
TD	ONCLICK	
TH	ABBR	

You may wish to conditionally override items on this list. For example, you may wish to hide the contents of CONTENT in the META tag when NAME contains 'GENERATOR':

<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">

You can specify these exceptions in a file called HTMExcept.txt which, if used, must be present in the project's common source directory. This file contains five columns separated by tabs. Example:

#Ordinal	Tagname	KeyToHideWhen	ReferenceKey	ReferenceKeyPattern	
# Items are separated by tabs.
# Lines beginning with a hash mark are ignored.	
1	PARAM	VALUE	NAME	[A-Z]+[a-z]+[A-Z]+.*	
2	PARAM	VALUE	NAME	id	
1	META	CONTENT	NAME	GENERATOR	
# ReferenceKeyPattern can be either a pattern or constant text	

Each line in the file instructs Déjà Vu to hide the contents of KeyToHideWhen if the contents of ReferenceKey matches ReferenceKeyPattern when processing a tag whose name is Tagname.

The first item is a number used to distinguish between otherwise equal Tagname/KeyToHideWhen/ReferenceKey 3-tuples. It must be used always, even if there is no ambiguity.

If the first character in a line is #, the whole line will be ignored.

ReferenceKeyPattern can be either fixed text, as 'id' and 'GENERATOR' in the above example, or a regular expression. Déjà Vu uses the VBScript RegExp object. For the specification of patterns that can be used in ReferenceKeyPattern please see http://msdn.microsoft.com/scripting/vbscript/doc/vspropattern.htm and http://msdn.microsoft.com/scripting/vbscript/doc/reconIntroductionToRegularExpressions.htm.

If you don't use the HTMExcept.txt file, Déjà Vu will default to the following exceptions:

1 META CONTENT NAME GENERATOR
2 META CONTENT NAME Generator
3 META CONTENT http-equiv Content-Type
4 META CONTENT http-equiv Pragma

Hiding pieces of text that match specific patterns

It is possible to force Déjà Vu to hide pieces of text that match certain patterns and depending on what comes before or after the strings. You can put a file called HTMHide.txt in the project's common source directory, each of whose non-commented lines contains tells DV how to deal with strings. Here is a sample file with explanations on how it works:

#Pre	StringsToHide	Post	StringsToDisplay	
# Items are separated by tabs.
# Lines beginning with a hash mark are ignored.
# Any items may be empty, but the three tabs must be present.
# Pre is a pattern that describes the characters before the string in questions; 
#   if empty, DV will ignore it.
# StringsToHide is a pattern that describes the string itself; if empty, DV 
#   assumes 'any string'.
# Post is a pattern that describes the characters after the string; if empty, DV 
#   will ignore it.
# You can use StringsToDisplay rather than StringsToHide. If you do, 
#   StringsToDisplay is a pattern that describes the strings that must be 
#   displayed. All other strings will be hidden. To specify a list of strings in 
#   StringsToDisplay, separate them with '|' and enclose the list in parenthesis, 
#   as in the first example below.
# If StringsToHide is not empty, then StringsToDisplay will be ignored.
# Notice that all rows must contain exactly three tab characters even if not all 
#   the items are used.
#	
\WSession\("		"\)	(User1|User2)	
# In the above
#  Pre is: a non-word character; Session; open parenthesis; double quote.
#  StringsToHide is: empty. DV will assume this to mean 'any string'.
#  Post is: double quote; close parenthesis.
#  StringsToDisplay means: display only if the string is either User1 or User2 
#    (and therefore not if it is User, User3, UserName, Name, etc.).
#	
\WRedirect(\W)*"		"\W		
# In the above
#  Pre is: a non-word character; Redirect; a non-word character appearing zero or 
#    more times; double quote; a non-word character.
#  StringsToHide is: empty. DV will assume this to mean 'any string'.
#  Post is: double quote; a non-word character.
# The effect of this line is therefore to hide any strings that appear surrounded 
#  by Pre and Post.
#	
	.*[a-z]+[A-Z]+.*			
# In the above
#  Pre is: empty (ignored).
#  StringsToHide is: any number of characters; a lowercase letter appearing one 
#    or more times; an uppercase letter appearing one or more times; any number 
#    of characters.
#  Post is: empty (ignored).
# The effect os this line is therefore to hide all the strings described by 
#  StringsToHide, whereever they appear.	

For the specification of patterns that can be used in HTMHide.txt please see http://msdn.microsoft.com/scripting/vbscript/doc/vspropattern.htm and http://msdn.microsoft.com/scripting/vbscript/doc/reconIntroductionToRegularExpressions.htm.

Preventing line breaks in script text

Bits of text found in scripts will normally go to a new row in the Déjà Vu project. For example, in

+ "(client has " + Trim(CStr(PrevCopies)) + " copies of Déjà Vu version 2)"

the two pieces of text will end up in two different Déjà Vu rows, unless you tell Déjà Vu that

" + Trim(CStr(PrevCopies)) + "

is a pattern that does not force a row change.

You can put a file called ASPNoBreaks.txt in the project's common source directory, each of whose lines contains one pattern. Here is a sample file:

# Code patterns that don't force a sentence break
" *(\+|&) *" *
# The above pattern means: double quote; any number of spaces; plus sign or ampersand; any number of spaces; double quote; any number of spaces
" *(\+|&) *(\w|\.)*[(]*(\w|\.)*[)]* +(\+|&) *" *
# The above pattern means: double quote; any number of spaces; plus sign or ampersand; any number of spaces; word character or dot appearing zero or more times; any number of open parenthesis; word character or dot appearing zero or more times; any number of close parenthesis; at least one space; plus sign or ampersand; any number of spaces; double quote; any number of spaces

If you don't use the ASPNoBreaks.txt file, Déjà Vu will default to the above two patterns.

For the specification of patterns that can be used in ASPNoBreaks.txt please see http://msdn.microsoft.com/scripting/vbscript/doc/vspropattern.htm and http://msdn.microsoft.com/scripting/vbscript/doc/reconIntroductionToRegularExpressions.htm.

Using the above when aligning files

The above mechanisms work also when you are aligning HTMT/ASP/VBS/JS/Access files. The only difference is that you are expected to put HTMExcept.txt, HTMHide.txt or ASPNoBreaks.txt  in Déjà Vu's directory rather than in the project's common source directory.