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

Re: [Clip] text lines to BBCode list

Expand Messages
  • Don
    Just adapt the list from html ... I think insert text instead of inserthtml and hten change what is inserted. ^!If ^$GetSelSize$ 0 FormatSelection ^!Set
    Message 1 of 12 , Jun 27, 2011
    • 0 Attachment
      Just adapt the list from html ... I think insert text instead of
      inserthtml and hten change what is inserted.

      ^!If ^$GetSelSize$ > 0 FormatSelection
      ^!Set %Count%=^?{How many items?=1|2|_3|4|5|6|7|8|9}
      ^!InsertHtml <^&>^P^$StrFill(" <LI></LI>^P";^%Count%)$</^&>^P
      ^!Goto End

      :FormatSelection
      ^!Select PARAGRAPHS
      ^!SetListDelimiter ^P
      ^!SetArray %Items%=^$GetSelection$

      ^!Set %Indent%=" "
      ^!Set %GroupIndent%=""
      ^!Set %IndentSize%=^$Calc(^$StrSize("^%Items1%!")$ -
      ^$StrSize("^$StrTrim("^%Items1%!")$")$)$
      ^!If ^%IndentSize% > 0 ^!Set
      %Indent%=^$StrCopy("^%Items1%";1;^%IndentSize%)$
      ^!If ^%IndentSize% > 2 ^!Set
      %GroupIndent%=^$StrCopy("^%Indent%";1;^$Calc(^%IndentSize% - 2)$)$

      ^!Set %Index%=1; %ItemsCount%=^%Items0%; %ListStr%=^%GroupIndent%<^&>^P

      :StartLoop
      ^!If ^%Index% > ^%ItemsCount% EndLoop
      ^!Set %Line%=^$StrTrim("^%Items^%Index%%")$

      ^!IfTrue ^$IsEmpty("^%Line%")$ Next ELSE Skip
      ^!If ^%Index% = ^%ItemsCount% EndLoop

      ^!IfFalse ^$IsEmpty("^%Line%")$ ^!Set %Line%=^%Indent%<LI>^%Line%</LI>
      ^!Set %ListStr%=^%ListStr%^%Line%^P
      ^!Inc %Index%
      ^!Goto StartLoop

      :EndLoop
      ^!InsertHtml ^%ListStr%^%GroupIndent%</^&>^P

      On 6/27/2011 10:25 AM, CR wrote:
      > Hi,
      > I would like a clip library to change multiple lines of plain text, into a BBCode numbered list. Many forum softwares do not properly change selected lines of text to a properly formatted BBCode list. So I would like this highlighted text:
      >
      > one
      > two
      > three
      > four
      > five
      >
      > changed to this:
      > [LIST=1]
      > [*]one
      > [*]two
      > [*]three
      > [*]four
      > [*]five
      > [/LIST]
      >
      > I looked on the Notetab website clip libraries and did not see anything for BBCode.
      >
      > Thanks.
      >
      >
      >
      >
      > ------------------------------------
      >
      > Fookes Software: http://www.fookes.com/
      > NoteTab website: http://www.notetab.com/
      > NoteTab Discussion Lists: http://www.notetab.com/groups.php
      >
      > ***
      > Yahoo! Groups Links
      >
      >
      >
      >
    • diodeom
      ... With your multiple lines selected, this should suffice: ^!Replace ^ [*] HARS ^!InsertText [list=1]^p^$GetSelection$^p[/list]
      Message 2 of 12 , Jun 27, 2011
      • 0 Attachment
        --- In ntb-clips@yahoogroups.com, "CR" <chuckr69@...> wrote:
        >
        > Hi,
        > I would like a clip library to change multiple lines of plain text, into a BBCode numbered list. Many forum softwares do not properly change selected lines of text to a properly formatted BBCode list. So I would like this highlighted text:
        >
        > one
        > two
        > three
        > four
        > five
        >
        > changed to this:
        > [LIST=1]
        > [*]one
        > [*]two
        > [*]three
        > [*]four
        > [*]five
        > [/LIST]
        >

        With your multiple lines selected, this should suffice:

        ^!Replace "^" >> "[*]" HARS
        ^!InsertText [list=1]^p^$GetSelection$^p[/list]
      • Don
        Wow! Do you need to turn off wordwrap for it to work?
        Message 3 of 12 , Jun 27, 2011
        • 0 Attachment
          Wow! Do you need to turn off wordwrap for it to work?

          > With your multiple lines selected, this should suffice:
          >
          > ^!Replace "^" >> "[*]" HARS
          > ^!InsertText [list=1]^p^$GetSelection$^p[/list]
        • diodeom
          ... Regex properly recognizes lines regardless of how they are displayed for our convenience. BTW, here s a seed library of tiny clips for common BB
          Message 4 of 12 , Jun 27, 2011
          • 0 Attachment
            --- In ntb-clips@yahoogroups.com, Don <don@...> wrote:
            >
            > Wow! Do you need to turn off wordwrap for it to work?
            >

            Regex properly recognizes lines regardless of how they are displayed for our convenience.

            BTW, here's a seed "library" of tiny clips for common BB formatting of selected text:

            H="BB Bold"
            [b]^&[/b]

            H="BB Italicise"
            [i]^&[/i]

            H="BB Red"
            [color=red]^&[/color]

            ... etc.
          • Axel Berger
            ... ^^ Slight error here. The newline is part of the last selected line, so this should be: ^!InsertText [list=1]^p^$GetSelection$[/list]^p (Tested, just to
            Message 5 of 12 , Jun 27, 2011
            • 0 Attachment
              diodeom wrote:
              > ^!Replace "^" >> "[*]" HARS
              > ^!InsertText [list=1]^p^$GetSelection$^p[/list]
              ^^
              Slight error here. The newline is part of the last selected line, so
              this should be:

              ^!InsertText [list=1]^p^$GetSelection$[/list]^p

              (Tested, just to make sure I don't spout nonsense.)

              Axel
            • diodeom
              ... It s no nonsense if the selection is stretched (for no good reason) to the beginning of the next line below (instead of stopping on the last character of
              Message 6 of 12 , Jun 27, 2011
              • 0 Attachment
                Axel Berger wrote:
                >
                > diodeom wrote:
                > > ^!Replace "^" >> "[*]" HARS
                > > ^!InsertText [list=1]^p^$GetSelection$^p[/list]
                >
                > Slight error here. The newline is part of the last selected line, so
                > this should be:
                >
                > ^!InsertText [list=1]^p^$GetSelection$[/list]^p
                >
                > (Tested, just to make sure I don't spout nonsense.)
                >

                It's no nonsense if the selection is stretched (for no good reason) to the beginning of the next line below (instead of stopping on the last character of the last desired line).
              • Axel Berger
                ... No good reason may be, but it s what usually happens. I select lines by placing the cursor at the left margin and selecting with . There may
                Message 7 of 12 , Jun 27, 2011
                • 0 Attachment
                  diodeom wrote:
                  > if the selection is stretched (for no good reason) to the
                  > beginning of the next line below (instead of stopping on the
                  > last character of the last desired line).

                  No good reason may be, but it's what usually happens. I select lines by
                  placing the cursor at the left margin and selecting with <Shift><Down>.
                  There may be other ways to select lines, but not, I believe, simpler
                  ones, unless using the mouse which I mostly avoid.

                  Axel
                • Alec Burgess
                  Axel: if I understand the problem here ... cursor winds up positioned at beginning of following line resulting in an unwanted r n and you don t want to use
                  Message 8 of 12 , Jun 28, 2011
                  • 0 Attachment
                    Axel:
                    if I understand the "problem" here ... cursor winds up positioned at
                    beginning of following line resulting in an unwanted \r\n and you don't
                    want to use mouse

                    how about: after getting to where you want to be with <shift>+<down>
                    just key: <shift>+<left>

                    Doesn't that get you where you want to be with only one extra keystroke?
                    (move finger from <down> to <left> while continuing to hold down <Shift>

                    Regards ... Alec (buralex@gmail& WinLiveMess - alec.m.burgess@skype)

                    On 2011-06-28 00:32, Axel Berger wrote:
                    > diodeom wrote:
                    > > if the selection is stretched (for no good reason) to the
                    > > beginning of the next line below (instead of stopping on the
                    > > last character of the last desired line).
                    >
                    > No good reason may be, but it's what usually happens. I select lines by
                    > placing the cursor at the left margin and selecting with <Shift><Down>.
                    > There may be other ways to select lines, but not, I believe, simpler
                    > ones, unless using the mouse which I mostly avoid.
                  • diodeom
                    ... I believe a sensible no-mouse approach could be to hit the key once just as soon as you exceede a proper selection after punching your last .
                    Message 9 of 12 , Jun 28, 2011
                    • 0 Attachment
                      Axel Berger wrote:
                      >
                      > No good reason may be, but it's what usually happens. I select lines by
                      > placing the cursor at the left margin and selecting with <Shift><Down>.
                      > There may be other ways to select lines, but not, I believe, simpler
                      > ones, unless using the mouse which I mostly avoid.
                      >

                      I believe a sensible no-mouse approach could be to hit the <Left> key once just as soon as you exceede a proper selection after punching your last <Down>.

                      If I were to anticipate and compensate for any habitual or accidental imprecision of a user, I'd probably employ a broad set of conditionals rather than just assume and provide for a single flavor of innaccurate input, even if indeed usual. Please consider that your "slight error" correction produces incorrect results from correctly selected data.
                    • Axel Berger
                      ... It would, if it were a problem. For all practical putposes I just remember that selecting blocks of complete lines makes the newline at the end of the last
                      Message 10 of 12 , Jun 28, 2011
                      • 0 Attachment
                        Alec Burgess wrote:
                        > Doesn't that get you where you want to be with only one extra
                        > keystroke?

                        It would, if it were a problem. For all practical putposes I just
                        remember that selecting blocks of complete lines makes the newline at
                        the end of the last or single line part of the selection and write my
                        clips accordingly. In the one case where I replace the newline by
                        semicolon plus space I simply don't select the last line and am happy
                        too.

                        Thus for me, and I had assumed others, diodeom's clip had to changed in
                        that one place.

                        Axel
                      • Axel Berger
                        ... Right you are. I had assumed my way of doing it was the normal or natural way. If it isn t then my remark won t make much sense to most people. Axel
                        Message 11 of 12 , Jun 28, 2011
                        • 0 Attachment
                          diodeom wrote:
                          > If I were to anticipate and compensate for any habitual or
                          > accidental imprecision of a user,

                          Right you are. I had assumed my way of doing it was the "normal" or
                          natural way. If it isn't then my remark won't make much sense to most
                          people.

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