Loading ...
Sorry, an error occurred while loading the content.

6263Re: [NH] Tidy config file

Expand Messages
  • John Zeman
    Nov 24, 2007
    • 0 Attachment
      --- In ntb-html@yahoogroups.com, "Corl DeLuna" <corl@...> wrote:
      >
      > Hi John,
      >
      > I have the same problems with tidy, would you please share your clip?
      >
      > Thanks,
      > Corl
      >
      >


      Sure I'll glad to Corl. I had better explain a few things about my
      clip however.

      The clip first makes sure the document being processed ends in .HTM or
      .HTML or .PHP. If it doesn't, the clip aborts.

      The clip avoids using Tidy if it finds <!-- DO NOT USE TIDY ON THIS
      PAGE --> anywhere in the document.

      After tidy and my clip processing, the clip sends the document to the
      CSE HTML Validator command line processor for evaluation. If you do
      not use the Validator you'll need to comment out any lines that contain

      C:\PROGRAM FILES\HTMLVALIDATOR80\

      Or you will get an error.

      Also I would try it out on a test html document before using it on an
      important one. The clip is tailored to my wants and needs which may
      be quite a bit different than yours.

      Last, in the event my copy and paste here results in syntax errors due
      to Yahoo mangling, below is a link to the zipped file.

      http://divinepurses.biz/jz/tidy-and-validate-clip.zip

      Clip contents to follow:


      Tidy and Validate HTML
      ; LAST MODIFIED: August 28, 2007

      ; IF WARNING ABOUT TIDY IS IN PAGE, ABORT
      =====================================
      ^!Find "<!-- DO NOT USE TIDY ON THIS PAGE -->" TIWS
      ^!IfError ^!Set %NOTIDY%=off
      ;^!StatusShow Aborted Processing
      ;^!Sound ^$GetSoundPath$Fart.wav
      ;^!Delay 10
      ;^!GoTo End

      ; ENSURE IT IS AN HTML FILE
      ===================================================
      :Step2
      ^!If "^$GetExt(^**)$" = ".html" DoIt
      ^!If "^$GetExt(^**)$" = ".htm" DoIt
      ^!If "^$GetExt(^**)$" = ".php" DoIt
      ^!GoTo OOPS

      :DoIt
      ; GET CURRENT ACTIVE LIBRARY NAME
      =============================================
      ^!ProgIniSave
      ^!Set %LIB%="^$GetValue("Clipbook:DefaultLibrary")$"

      ; SAVE THEN SAVE A COPY OF THE FILE BEFORE RUNNING TIDY JUST IN CASE
      ==========
      ^!Save
      ^!Set %DocName%=^$GetDocName$
      ^!Save AS c:\temp\Ebackup.bak
      ^!Close
      ^!Open ^%DocName%

      ^!If "^%NOTIDY%" <> "off" ^!StatusShow TIDY was skipped
      ^!If "^%NOTIDY%" = "off" ^!RunTidy
      ^!Delay 10
      ^!StatusClose


      ; AFTER TIDY, DO A LITTLE OF MY OWN TIDYING
      ===================================
      ; INSERT LINES BREAKS WHERE DESIRED
      ===========================================
      ^!Replace "</head>^P<body" >> "</head>^P^P<body" ATIWS
      ^!Replace "</tr>^P<tr>" >> "</tr>^P^P<tr>" ATIWS
      ^!Replace "</li>^P<li" >> "</li>^P^P<li" ATIWS
      ;^!Replace "</p>^P" >> "</p>^P^P" ATIWS
      ^!Replace "</p>^P^P</li>" >> "</p>^P</li>" ATIWS
      ^!Replace "</p>^P^P</td>" >> "</p>^P</td>" ATIWS
      ^!Replace "<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01
      Transitional//EN">" >> "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
      Transitional//EN">" TWS

      ^!Replace "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML
      4.01//EN"^P"http://www.w3.org/TR/html4/strict.dtd">" >> "<!DOCTYPE
      HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
      "http://www.w3.org/TR/html4/strict.dtd">" TS

      ; GET RID OF EXCESS CARRIAGE RETURNS IN GENERAL
      ===============================
      :KillPs
      ^!Replace "^P^P^P" >> "^P^P" ATIWS
      ^!IfError RockOn
      ^!GoTo KillPs

      :RockOn
      ;//////////////////////////////////////////////////////////////////////////////
      ; ANY LITERAL CHARACTERS THAT COULD BE AHEAD OR BEHIND A COMMENT
      ==============
      ^!Set %QUALIFIERS%=[<>().a-z A-Z0-9]
      ; PUT ANY COMMENTS THAT DO NOT START ON A NEW LINE ON A NEW LINE BY
      ===========
      ; ^!SetDebug On
      ^!Replace "(^%QUALIFIERS%)(<!-- .* -->)" >> "$1\r\n$2" WARST
      ; PUT ANYTHING AFTER A COMMENT ON A NEW LINE
      ==================================
      ^!Replace "(<!-- .* -->)(^%QUALIFIERS%)" >> "$1\r\n$2" WARST
      ;//////////////////////////////////////////////////////////////////////////////

      ; ^!SetDebug On
      ^!Save
      ^!StatusShow A backup was made of the original was made and is
      c:\temp\Ebackup.bak
      ^!SetScreenUpdate off

      ; VALIDATE USING CSE
      ==========================================================
      ^!ShellWait "C:\Program Files\HTMLValidator80\cmdlineprocessor.exe"
      -r1 "^**"

      ; AFTER A SHORT DELAY MAKE SURE OUTPUT.TXT IS NOT OPEN
      ________________________
      ^!Delay 5
      ^!If "^$GetDocIndex("C:\Program Files\HTMLValidator80\output.txt")$"
      <> "0" problem
      ^!GoTo End

      ; IF OUTPUT.TXT IS OPEN, THERE WAS AN ERROR SO SEND FILE TO CSE
      _______________
      :problem
      ^!Close "C:\Program Files\HTMLValidator80\output.txt"
      ^!Open ^%DocName%
      ^!Shell "C:\Program Files\HTMLValidator80\cse80.exe" "^**"
      ^!GoTo End

      :OOPS
      ^!Sound ^$GetSoundPath$Fart.wav
      ^!Info The current file is not a php, htm, or html file, try again.
      ^!GoTo End
    • Show all 21 messages in this topic