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

Re: select between tags clip

Expand Messages
  • John Zeman
    ... Julie I ll zip and email you the one Hugo and I put together a few years ago which works very nicely for me. I d post it here but it s long enough that
    Message 1 of 16 , Aug 13, 2005
    • 0 Attachment
      --- In ntb-clips@yahoogroups.com, Julie <gleits@c...> wrote:
      > I'm looking for a clip I swear I've seen (but can't seem to find)
      > that selects an entire HTML tag, for example everything from <a
      > href... etc to </a>
      >
      > Anyone point me in the right direction?
      >
      > Too lazy to invent the wheel when I know I've seen it turning...
      >
      > Julie


      Julie I'll zip and email you the one Hugo and I put together a few years ago which works very nicely for me. I'd post it here but it's long enough that all the yahoo inserted line breaks would make it a challenge to reassemble.

      Also I think Ed might have constructed a similar clip awhile back. I never followed what he did very closely but you might want to check it out too.

      John
    • Julie
      ... Thanks, John, that was exactly the one I was looking for! I figured someone would have it at their finger tips, and works like a charm as is . The one
      Message 2 of 16 , Aug 14, 2005
      • 0 Attachment
        At 8/13/2005 10:56 PM, John Zeman wrote:

        >Julie I'll zip and email you the one Hugo and I put together a few
        >years ago which works very nicely for me. I'd post it here but it's
        >long enough that all the yahoo inserted line breaks would make it a
        >challenge to reassemble.


        Thanks, John, that was exactly the one I was looking for! I figured
        someone would have it at their finger tips, and works like a charm
        "as is". The one in the Sample Code library would've needed a lot of
        fiddling around with to get to that form.

        Makes it quite easy to strip HTML out of specific text, and reformat
        all in one fell swoop!

        Julie
      • Marbux
        ... John, if you wouldn t mind, I would be very grateful if you sent me a copy too. It sounds like it would take care of a problem I ve been spinning my wheels
        Message 3 of 16 , Aug 15, 2005
        • 0 Attachment
          At 8/13/2005 10:56 PM, John Zeman wrote:

          >>Julie I'll zip and email you the one Hugo and I put together a few
          >>years ago which works very nicely for me. I'd post it here but it's
          >>long enough that all the yahoo inserted line breaks would make it a
          >>challenge to reassemble.
          >>
          >>
          >Thanks, John, that was exactly the one I was looking for! I figured
          >someone would have it at their finger tips, and works like a charm
          >"as is". The one in the Sample Code library would've needed a lot of
          >fiddling around with to get to that form.
          >
          >Makes it quite easy to strip HTML out of specific text, and reformat
          >all in one fell swoop!
          >
          John, if you wouldn't mind, I would be very grateful if you sent me a
          copy too. It sounds like it would take care of a problem I've been
          spinning my wheels on for some time.

          Best regards,

          Marbux
        • Don - htmlfixit.com
          Here are some we did a while ago: ;*** Effort by Don Passenger ;*** don@htmlfixit.com ;*** discuss things live in chat at http://htmlfixit.com ;*** based on
          Message 4 of 16 , Aug 15, 2005
          • 0 Attachment
            Here are some we did a while ago:
            ;*** Effort by Don Passenger
            ;*** don@...
            ;*** discuss things live in chat at http://htmlfixit.com
            ;*** based on work by Larry and Jody and maybe Wayne
            ;*******************************************************
            ;*** will check for a matching html tag

            ^!Continue [C]If cursor is in the tag you want to find a match for click
            continue

            ;### initialize everything
            ;assume we have our cursor in a tag
            ;look backwards to find the starting <
            ^!Find "<" TIBS
            ;exit if find fails
            ^!IfError EXIT
            ^!SetScreenUpdate Off
            ^!ClearVariables

            ;### %TAG% will be empty if cursor is not inside a tag.
            ^!Set %TAG%="^$GetHtmlTag(TRUE)$"
            ^!IfTrue ^$IsEmpty(^%TAG%)$ NotTag
            ;if self closing get out too
            ^!If "/>" = "^$StrCopyRight("^$GetSelection$";2)$" SelfClosing


            ;### So we found a tag. What tag is it?
            ^!Set %TAGNAME%="^$GetHtmlTagName("^%TAG%";UPPERCASE)$"
            ;got to forwards or backwards routine depending if
            ;start or finish tag is selected at start of clip
            ^!If "/" = "^$StrCopyLeft("^%TAGNAME%";1)$" FindNextTagBackwards ELSE
            FindNextTagForwards

            :FindNextTagForwards
            ^!Jump Select_Start
            ;figure out where cursor is
            ^!Set %row%="^$GetRow$"
            ^!Set %column%="^$GetCol$"
            ^!Find ">" TIS
            ^!Set %TAGCOUNT%=1
            :TagForwardLoop
            ^!Find "<" TIS
            ^!IfError UnMatched
            ^!Set %TAGTEMP%="^$GetHtmlTag(TRUE)$"
            ^!IfTrue ^$IsEmpty(^%TAGTEMP%)$ NextTag
            ^!Set %TAGTEMPNAME%="^$GetHtmlTagName("^%TAGTEMP%";UPPERCASE)$"
            ^!If "/" = "^$StrCopyLeft("^%TAGTEMPNAME%";1)$" EndTag ELSE BeginTag

            :EndTag
            ^!If "^$StrDeleteLeft("^%TAGTEMPNAME%";1)$" <> "^%TAGNAME%" Skip_2
            ^!Dec %TAGCOUNT%
            ^!If "^%TAGCOUNT%" = "0" Match
            ^!Goto NextTag

            :BeginTag
            ^!If "^%TAGTEMPNAME%" <> "^%TAGNAME%" Skip_2
            ^!Inc %TAGCOUNT%
            ^!If "^%TAGCOUNT%" = "0" Match
            ^!Goto NextTag

            :NextTag
            ^!Jump Select_End
            ^!Goto TagForwardLoop


            :FindNextTagBackwards
            ^!Jump Select_End
            ;figure out where cursor is
            ^!Set %row%="^$GetRow$"
            ^!Set %column%="^$GetCol$"
            ^!Find "<" TIBS
            ^!Set %TAGCOUNT%=1
            :TagBackwardLoop
            ^!Find "<" TIBS
            ^!IfError UnMatched
            ^!Set %TAGTEMP%="^$GetHtmlTag(TRUE)$"
            ^!IfTrue ^$IsEmpty(^%TAGTEMP%)$ NextTag2
            ^!Set %TAGTEMPNAME%="^$GetHtmlTagName("^%TAGTEMP%";UPPERCASE)$"
            ^!If "/" = "^$StrCopyLeft("^%TAGTEMPNAME%";1)$" EndTag2 ELSE BeginTag2

            :EndTag2
            ^!If "^%TAGTEMPNAME%" <> "^%TAGNAME%" Skip_2
            ^!Inc %TAGCOUNT%
            ^!If "^%TAGCOUNT%" = "0" Match
            ^!Goto NextTag2

            :BeginTag2
            ^!If "^%TAGTEMPNAME%" <> "^$StrDeleteLeft("^%TAGNAME%";1)$" Skip_2
            ^!Dec %TAGCOUNT%
            ^!If "^%TAGCOUNT%" = "0" Match
            ^!Goto NextTag2

            :NextTag2
            ^!Jump Select_START
            ^!Goto TagBackwardLoop



            :Match
            ^!SetScreenUpdate On
            ^!Info [C]Bingo, we have a match!.
            ^!If "/" = "^$StrCopyLeft("^%TAGNAME%";1)$" MatchBackwardJump ELSE
            MatchForwardJump
            :MatchForwardJump
            ^!Jump SELECT_END
            ^!Goto MatchFinish
            :MatchBackwardJump
            ^!Jump SELECT_START
            :MatchFinish
            ^!SelectTo ^%row%:^%column%
            ^!Goto Finish

            :UnMatched
            ^!SetCursor ^%row%:^%column%
            ^!Info [C]This appears to be an unmatched Tag. We made it to the end of
            your document without finding a match.
            ^!Goto Finish


            :NotTag
            ^!SetCursor ^%row%:^%column%
            ^!Info [C]This appears to not be an html tag. Remember have your cursor
            inside the tag when starting this clip.
            ^!Goto Finish


            :SelfClosing
            ^!SetCursor ^%row%:^%column%
            ^!Info [C]Your tag is self closing - quit messing with me! Self closing
            tags end in /> like <br />


            ;### clean up and go home
            :Finish
            ^!SetScreenUpdate On
            ^!ClearVariables
            ;line 131 if you have all lines unrapped (including blank lines)
          • Don - htmlfixit.com
            and another rendition with Hugo s adjustment to mine: ;*** Effort by Don Passenger ;*** don@htmlfixit.com ;*** discuss things live in chat at
            Message 5 of 16 , Aug 15, 2005
            • 0 Attachment
              and another rendition with Hugo's adjustment to mine:
              ;*** Effort by Don Passenger
              ;*** don@...
              ;*** discuss things live in chat at http://htmlfixit.com
              ;*** based on work by Larry and Jody and maybe Wayne
              ;*** Hugo Adjusted this one
              ;*******************************************************
              ;*** will check for a matching html tag

              ;^!Continue [C]Is cursor in the tag you want to find a match for and
              then start clip

              ;### initialize everything
              ;assume we have our cursor in a tag
              ;look backwards to find the starting <

              ; ----------------------------------------------***
              ; COMMENTED OUT ALMOST ALL CONTINUES AND INFOS TO
              ; GAIN SOME SPEED -
              ; I'VE PUT THIS ONE AT THE BEGINNING OF THE CLIP
              ^!ClearVariables
              ; ----------------------------------------------***
              ^!Find "<" TIBS
              ;exit if find fails
              ^!IfError EXIT
              ;figure out where cursor is
              ^!Set %row%="^$GetRow$"
              ^!Set %column%="^$GetCol$"
              ; ----------------------------------------------***
              ^!SET %START%=^%row%:^%column%
              ; ADDED THIS TO BE ABLE TO HAVE EVERYTHING
              ; SELECTED AT THE END OF THE CLIP
              ; ----------------------------------------------***
              ^!SetScreenUpdate Off
              ^!SetWordWrap Off



              ;### %TAG% will be empty if cursor is not inside a tag.
              ^!Set %TAG%="^$GetHtmlTag(TRUE)$"
              ^!IfTrue ^$IsEmpty(^%TAG%)$ NotTag
              ^!If "/>" = "^$StrCopyRight("^$GetSelection$";2)$" SelfClosing


              ;### So we found a tag. What tag is it?
              ^!Set %TAGNAME%="^$GetHtmlTagName("^%TAG%";UPPERCASE)$"
              ^!Continue ^%TAGNAME%
              ^!Jump Select_End
              ^!Set %TAGCOUNT%=1
              ;^!Info [C]^%TAGCOUNT%
              ^!If "/" = "^$StrCopyLeft("^%TAGNAME%";1)$" FindNextTagBackwards ELSE
              FindNextTagForwards

              :FindNextTagForwards
              ^!Find "<" TIS
              ^!IfError UnMatched
              ^!Set %TAGTEMP%="^$GetHtmlTag(TRUE)$"
              ^!IfTrue ^$IsEmpty(^%TAGTEMP%)$ NextTag
              ^!Set %TAGTEMPNAME%="^$GetHtmlTagName("^%TAGTEMP%";UPPERCASE)$"
              ^!If "/" = "^$StrCopyLeft("^%TAGTEMPNAME%";1)$" EndTag ELSE BeginTag

              :EndTag
              ;^!Info [C]End Tag
              ^!If "^$StrDeleteLeft("^%TAGTEMPNAME%";1)$" <> "^%TAGNAME%" Skip_2
              ^!Dec %TAGCOUNT%
              ^!If "^%TAGCOUNT%" = "0" Match
              ^!Goto NextTag

              :BeginTag
              ;^!Info [C]Beginning Tag
              ^!If "^%TAGTEMPNAME%" <> "^%TAGNAME%" Skip_2
              ^!Inc %TAGCOUNT%
              ^!If "^%TAGCOUNT%" = "0" Match
              ^!Goto NextTag

              :NextTag
              ;^!Info [C]^%TAGCOUNT% -- ^%TAGTEMPNAME%

              ^!Jump Select_End
              ^!Goto FindNextTagForwards


              :FindNextTagBackwards
              ;^!Info [C]Backwards not working yet ... will search towards the front
              of the document
              ^!Goto Finish



              :Match
              ^!SetScreenUpdate On
              ^!SetWordWrap On
              ^!Info [C]Bingo, we have a match!.
              ^!Jump SELECT_END
              ; ----------------------------------------------***
              ; CHANGED THE SELECTTO IN ORDER TO HAVE EVERYTHING
              ; SELECTED
              ;^!SelectTo ^%row%:^%column%
              ^!SelectTo ^%START%
              ; ----------------------------------------------***
              ^!Goto Finish

              :UnMatched
              ^!SetCursor ^%row%:^%column%
              ^!Info [C]This appears to be an unmatched Tag. We made it to the end of
              your document without finding a match.
              ^!Goto Finish


              :NotTag
              ^!SetCursor ^%row%:^%column%
              ;^!Info [C]This appears to not be an html tag. Remember have your
              cursor inside the tag when starting this clip.
              ^!Goto Finish


              :SelfClosing
              ^!SetCursor ^%row%:^%column%
              ^!Info [C]Your tag is self closing - quit messing with me! Self closing
              tags end in /> like <br />


              ;### clean up and go home
              :Finish
              ^!SetScreenUpdate On
              ^!SetWordWrap On
              ^!ClearVariables
              ;line 126 if you have all lines unrapped (including blank lines)
            • Don - htmlfixit.com
              and last but not least, Hugo and Johns I think ... ... ; LAST MODIFIED: MONDAY, DECEMBER 30, 2002 ^!SetScreenUpdate OFF ;-----------------------
              Message 6 of 16 , Aug 15, 2005
              • 0 Attachment
                and last but not least, Hugo and Johns I think ...

                : 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 15
                ^!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.
              • Jeffery Scism
                John, if you wouldn t mind, I would be very grateful if you sent me a ... ME Too Please. Jeff Scism [Non-text portions of this message have been removed]
                Message 7 of 16 , Aug 15, 2005
                • 0 Attachment
                  John, if you wouldn't mind, I would be very grateful if you sent me a

                  >copy too. It sounds like it would take care of a problem I've been
                  >spinning my wheels on for some time.
                  >
                  >Best regards,
                  >
                  >Marbux
                  >
                  ME Too Please.

                  Jeff Scism


                  [Non-text portions of this message have been removed]
                • hsavage
                  ... John, Why not post it on the clips list and it will be available to all? ºvº 05.08.15 hrs hsavage@pobox.com
                  Message 8 of 16 , Aug 15, 2005
                  • 0 Attachment
                    Jeffery Scism wrote:
                    > John, if you wouldn't mind, I would be very grateful if you sent me a
                    >
                    >> copy too. It sounds like it would take care of a problem I've been
                    >> spinning my wheels on for some time.
                    >>
                    >> Best regards,
                    >>
                    >> Marbux
                    >>
                    > ME Too Please.
                    >
                    > Jeff Scism

                    John,

                    Why not post it on the clips list and it will be available to all?

                    ºvº
                    05.08.15
                    hrs > hsavage@...
                  • loro
                    ... Because it can be downloaded from clip repository page? ^_^ At least I think this clip is what it s all about. http://notetab.com/clipbooks/textsel.zip
                    Message 9 of 16 , Aug 15, 2005
                    • 0 Attachment
                      >Why not post it on the clips list and it will be available to all?

                      Because it can be downloaded from clip repository page? ^_^

                      At least I think this clip is what it's all about.

                      http://notetab.com/clipbooks/textsel.zip
                      (From http://notetab.com/html.php#Utilities )

                      Lotta
                    • John Zeman
                      ... That s not the one Lotta. Don included it in his list of clips, and my apologies to Don for my not getting the name right while talking to Julie when I
                      Message 10 of 16 , Aug 15, 2005
                      • 0 Attachment
                        --- In ntb-clips@yahoogroups.com, loro <loro-spam01-@t...> wrote:
                        >
                        > >Why not post it on the clips list and it will be available to all?
                        >
                        > Because it can be downloaded from clip repository page? ^_^
                        >
                        > At least I think this clip is what it's all about.
                        >
                        > http://notetab.com/clipbooks/textsel.zip
                        > (From http://notetab.com/html.php#Utilities )
                        >
                        > Lotta


                        That's not the one Lotta. Don included it in his list of clips, and my apologies to Don for my not getting the name right while talking to Julie when I said Ed created a similar clip.

                        To eliminate line splicing I just uploaded the zipped clip to the files section of the NoteTab HTML forum, you can download it here:

                        http://groups.yahoo.com/group/ntb-html/files/

                        John
                      Your message has been successfully submitted and would be delivered to recipients shortly.