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

Re: [NH] match html tag

Expand Messages
  • Don - htmlfixit.com
    ... No it doesn t to my knowledge. It matches brackets with control + M, but that isn t helpful here. It should be fairly easy to do this with a clip and I
    Message 1 of 5 , Jan 10, 2005
      juliesassurance wrote:
      >
      >
      > Hi
      >
      > I sent this same Q to the subscribe email for this grp.
      > Didnt know if it would be seen there so sending again here.
      >
      > Does NoteTab have a feature that matches or finds a beginning tag with
      > its end tag.
      >
      > Most useful would be <Table and /Table>
      >
      > If so, where do I access this feature?
      >
      > Julie & Russ
      >
      > PS I did a search in Help and could not find: match html tag

      No it doesn't to my knowledge. It matches brackets with control + M,
      but that isn't helpful here. It should be fairly easy to do this with a
      clip and I would suggest that one be prepared over on the clips list. I
      was in fact debating doing this very thing a few weeks ago. To my
      knowledge, there isn't an existing clip that does this.

      The logic is simple enough, you find the first tag, say <table> and then
      wish to find the corresponding </table> tag. What you do is set a
      counter to 1 when you find the tag in question, then you add one every
      time you find another <table> tag and subtract one for every </table>
      tag you find. When you get to zero, you have found your matching
      bracket. I may try to throw it together.

      I have copied this to clips and would suggest that the conversation
      occur over there, although we may wish to post the result back here
      when/if there is one.

      Don
    • Hugo Paulissen
      ... with ... Julie, Don, No, but this will be of help, I hope. A couple of years ago John Z. and I developed the following clip. I haven t used it for a while
      Message 2 of 5 , Jan 10, 2005
        > > Does NoteTab have a feature that matches or finds a beginning tag
        with
        > > its end tag.

        Julie, Don,

        No, but this will be of help, I hope. A couple of years ago John Z.
        and I developed the following clip. I haven't used it for a while
        since I'm not doing much HTML lately...

        As usual, watch out with the long lines...

        Hugo

        : SELECT MATCHING TAGS Hugo and John
        ; LAST MODIFIED: MONDAY, DECEMBER 30, 2002
        ^!SetScreenUpdate OFF
        ;-----------------------

        ^!ClearVariable %ISTHISAMISMATCH%

        ^!Jump SELECT_START
        :FINDTAG
        ^!find "<" BS
        :SETTAG
        ^!Set %TAG%=^$GetHtmlTagName("^$GetHtmlTag$";Lowercase)$
        ^!Set %STARTPOS%=^$GetRow$:^$GetCol$
        ^!IfTrue ^$StrPos("!";"^%TAG%";0)$ SELECTTAG
        ^!IfTrue ^$StrPos("/";"^%TAG%";0)$ ENDTAG
        ^!Find "/^%TAG%>" IS
        ^!IFERROR SELECTTAG
        :KEEPSEARCHING
        ^!Jump Select_END
        ^!SelectTo ^%STARTPOS%
        ^!Set %Selection%=^$GetSelection$
        ^!Set %FindNextMatch%=^$StrCount("<^%TAG%";"^%Selection%";0;1)$
        ^!Set %EndTagCount%=^$StrCount("</^%TAG%>";"^%Selection%";0;1)$
        ^!IF ^%FindNextMatch%<>^%EndTagCount% JUMPOVER
        ^!GoTO SELECTTAG
        :JUMPOVER
        ;-------------------------
        ^!If ^%FindNextMatch%-^%EndTagCount%=^%ISTHISAMISMATCH%
        THISISAMISMATCH
        ^!Set %ISTHISAMISMATCH%=^%FindNextMatch%-^%EndTagCount%
        ;-------------------------
        ^!Jump Select_END
        ^!Find "/^%TAG%>" IS
        ^!GoTo KEEPSEARCHING

        :THISISAMISMATCH
        ^!SetCursor ^%StartPOS%
        ^!MoveCursor 1
        ^!Select HTMLTAG
        ^!SetWizardTitle Tag mismatch. Review your code...
        ^!SetWizardLabel The corresponding tag could not be found!

        ; BEGIN ONE LONG LINE
        ^!Set %WhatNext%=^?{(T=L)Go to the last corresponding endtag?=_No,
        just select the tag that doesn't have a match^=No|Yes, and select
        anything in between^=Select|Yes, and insert corresponding tag after
        the selection^=Jump}
        ; END ONE LONG LINE

        ^!If ^%WhatNext%=No END
        ^!If ^%WhatNext%<>NO ^!Find <^%TAG\a*/^%TAG%> RS
        ^!If ^%WhatNext%=Jump ^!MoveCursor 1
        ^!If ^%WhatNext%=Jump ^!InsertTEXT ^%NL%<!--INSERTED NEW ENDTAG HERE--
        >^%NL%</^%TAG%>^%NL%^%NL%
        ^!GoTo END

        :FINDNoMATCH
        ^!SetCursor ^%ENDPOS%
        ^!MoveCursor -1
        ^!GoTo SELECTTAG

        :ENDTAG
        ^!Set %TAG%=^$strReplace("/";"";"^%TAG%";0;0)$
        ^!Find ">" IS
        ^!Jump Select_END
        ^!Set %ENDPOS%=^$GetRow$:^$getCol$
        :FindBeginningTag
        ^!Find "<^%TAG%" BIS
        ^!IFERROR STEPBACK
        ^!If "^$GetSelection$" = "<b" BR
        :NoBR
        ^!SelectTo ^%ENDPOS%
        ^!Set %Selection%=^$GetSelection$
        ^!Set %FindPrevious%=^$StrCount("</^%TAG%";"^%Selection%";0;1)$
        ^!IF ^%FindPrevious%>1 AGAIN
        ^!GOTO END
        :AGAIN
        ^!Jump Select_START
        ^!Dec %FindPrevious%
        ^!Find "<^%TAG%" BIS
        ;***** INSERTED ERRORCHECK
        ^!IfERROR FINDNoMATCH
        ^!SelectTo ^%ENDPOS%
        ^!IF ^%FindPrevious%>1 AGAIN

        ; BEGIN ONE LONG LINE
        ^!IF ^$StrCount("/^%TAG%>";"^$GetSelection$";0;0)$<>^$StrCount("<^%
        TAG%";"^$GetSelection$";0;0)$ AGAIN
        ; END ONE LONG LINE

        ^!GOTO END
        :STEPBACK
        ^!MoveCursor -1
        :SELECTTAG
        ^!If ^$GetSelSize$>3 END
        ^!Select HTMLTAG
        ^!STATUSSHOW Could not locate matching tag...
        ^!Delay 7
        ^!GoTo End

        ; BR TRAP TO NOT FALSE BOLD TAGS
        :BR
        ^!Select +2
        ^!If "^$GetSelection$" <> "<br>" NoBR
        ^!Jump SELECT_START
        ^!GoTo FindBeginningTag

        ;---------------------------------------------------------------------
        -----
        ; Revision History
        ; SUNDAY, NOVEMBER 24, 2002
        ; Clip would fail if character entities were in the document.
        ; Added a / in the following line so it became:
        ; ^!Set %FindPrevious%=^$StrCount("</^%TAG%";"^%Selection%";0;1)$
        ;
        ; MONDAY, DECEMBER 30, 2002
        ; Noticed if searching backwards for a <b> tag when started from a
        </b> tag,
        ; the clip would fail if any <br> elements were in between the <b>
        </b> tags
        ; Added the BR trap to eliminate that.
      • Don - htmlfixit.com
        ... I am about done with one as well ... since I didn t remember yours. I ll try to finish it later tonight or tomorrow just for fun. If I do I ll post it.
        Message 3 of 5 , Jan 10, 2005
          >>>Does NoteTab have a feature that matches or finds a beginning tag
          >
          > with
          >
          >>>its end tag.
          >
          >
          > Julie, Don,
          >
          > No, but this will be of help, I hope. A couple of years ago John Z.
          > and I developed the following clip. I haven't used it for a while
          > since I'm not doing much HTML lately...
          >
          I am about done with one as well ... since I didn't remember yours.
          I'll try to finish it later tonight or tomorrow just for fun. If I do
          I'll post it. I'll see how it compares.I won't look at yours til I am
          done with mine.
        • Alan_C
          Hi, ... Have checked out, in the Utilities Library the clip select_between_tags which selects in between chosen matching html tags (I ve not tried it, just
          Message 4 of 5 , Jan 11, 2005
            Hi,

            >>>>Does NoteTab have a feature that matches or finds a beginning tag
            >>with
            >>
            >>>>its end tag.

            Have checked out, in the Utilities Library the clip

            select_between_tags

            which selects in between chosen matching html tags (I've not tried it,
            just looked briefly at its code and comments inside it).

            --
            Alan.
          • Don - htmlfixit.com
            ... Alan, It doesn t work. It is fooled by nested tags. Mine and the other one are both better. Ours include the tags, but we could make it do that easy
            Message 5 of 5 , Jan 12, 2005
              Alan_C wrote:
              > Hi,
              >
              >
              >>>>>Does NoteTab have a feature that matches or finds a beginning tag
              >>>with
              >>>>>its end tag.
              >
              >
              > Have checked out, in the Utilities Library the clip
              >
              > select_between_tags
              >
              > which selects in between chosen matching html tags (I've not tried it,
              > just looked briefly at its code and comments inside it).
              >
              Alan,

              It doesn't work. It is fooled by nested tags. Mine and the other one
              are both better. Ours include the tags, but we could make it do that
              easy enough. That one should be deleted from the Utility Library as it
              doesn't do what it is supposed to do to be honest.
            Your message has been successfully submitted and would be delivered to recipients shortly.