On Nov 3, 2006, at 8:21 PM, Bob Rosenberg wrote:
When I do a Check, the Checker throws me warnings about optional
missing closing tags ("<p>/<li>/etc implicitly closed") but there
seems to be no way to ask/tell BBEDIT to fix the missing tags when
I rewrite the source via Format. Is there some way I can tell
BBEDIT that I want to to inject the missing omitted tags so the
source (even though HTML not XHTML) is "well formed?
I have an old script lying around which parses the syntax checker
errors and inserts the closers for you. It appears to work with the
current release. (It relies on the format of the syntax checker error
string to extract some of its info.)
Jim
== begin script ==
set use_white_space_smarts_when_closing to true
tell application "BBEdit"
activate
set f to file of document 1
set l to check syntax f without show results
set ct to count items of l
repeat with i from ct to 1 by -1
set the_item to item i of l
set msg to message of the_item
if (msg ends with "implicitly closed here.") then
set tag_text to text 11 thru -1 of msg
set ix to -1
repeat with x from 1 to length of tag_text
if character x of tag_text is ">" then
set ix to x - 1
exit repeat
end if
end repeat
set tag_text to text 1 thru ix of tag_text
set tag_text to "</" & tag_text & ">"
set pos to (end_offset of the_item) - 1
set c to character pos of window 1
if use_white_space_smarts_when_closing then
repeat while c is in {" ", tab, return}
set pos to pos - 1
set c to character pos of window 1
end repeat
end if
set pos to pos + 1 -- we backed up one to far before
set s to tag_text & character pos of window 1
set character pos of window 1 to s
end if
end repeat
end tell
--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <[EMAIL PROTECTED]>