how to transform a list form of hyphens to an html unordered list

Discussion in 'ASP .Net' started by ibiza, Feb 9, 2006.

  1. ibiza

    ibiza Guest

    Hi all,

    I have a question which I have no ideal of the answer...I am currently
    working on a web application and at some time, I have a string
    representing a short text. This could be a simple example :

    "This is my list :\n\r-list item 1\n\r-list item 2\n\r-list item
    3\n\r\n\rThis was a great list."

    Let's say this outputs like that :
    -------------------------------------------
    This is my list :
    -list item 1
    -list item 2
    -list item 3

    This was a great list.
    -------------------------------------------

    Would it be simple with regular expression to transform the list formed
    of hyphens("-") to an HTML unordered list? I mean that the preceding
    example would rather output as :
    -------------------------------------------
    This is my list :
    <ul><li>list item 1</li>
    <li>list item 2</li>
    <li>list item 3</li></ul>

    This was a great list.
    -------------------------------------------

    I have some experience with regular expression but have not a clue on
    how to do this...I also see some problems as if the string starts with
    an hyphen, as it would also need to transform correctly, event if it
    doesn't have the /n/r before the hyphen("-").
    e.g. "-list item 1/n/r- list item 2" should output as :
    -------------------------------------------
    <ul><li>list item 1</li>
    <li>list item 2</li><ul>
    -------------------------------------------

    And what about if there are two lists separated by some carriage
    returns?...As you can see, I really don't know where to start with this
    problem. :/

    Thanks in advance,

    ibiza
     
    ibiza, Feb 9, 2006
    #1
    1. Advertising

  2. Do you have a finite list of ways that this information could be formatted?
    For instance, do you allow spaces before and after the dash (-) or maybe
    returns between each list item? In other words, is the information that you
    receive predictable?

    If it is predictable, I would just go through the list one line at a time
    and output it into a new string with the appropriate markup.

    "ibiza" <> wrote in message
    news:...
    > Hi all,
    >
    > I have a question which I have no ideal of the answer...I am currently
    > working on a web application and at some time, I have a string
    > representing a short text. This could be a simple example :
    >
    > "This is my list :\n\r-list item 1\n\r-list item 2\n\r-list item
    > 3\n\r\n\rThis was a great list."
    >
    > Let's say this outputs like that :
    > -------------------------------------------
    > This is my list :
    > -list item 1
    > -list item 2
    > -list item 3
    >
    > This was a great list.
    > -------------------------------------------
    >
    > Would it be simple with regular expression to transform the list formed
    > of hyphens("-") to an HTML unordered list? I mean that the preceding
    > example would rather output as :
    > -------------------------------------------
    > This is my list :
    > <ul><li>list item 1</li>
    > <li>list item 2</li>
    > <li>list item 3</li></ul>
    >
    > This was a great list.
    > -------------------------------------------
    >
    > I have some experience with regular expression but have not a clue on
    > how to do this...I also see some problems as if the string starts with
    > an hyphen, as it would also need to transform correctly, event if it
    > doesn't have the /n/r before the hyphen("-").
    > e.g. "-list item 1/n/r- list item 2" should output as :
    > -------------------------------------------
    > <ul><li>list item 1</li>
    > <li>list item 2</li><ul>
    > -------------------------------------------
    >
    > And what about if there are two lists separated by some carriage
    > returns?...As you can see, I really don't know where to start with this
    > problem. :/
    >
    > Thanks in advance,
    >
    > ibiza
    >
     
    Peter Rilling, Feb 9, 2006
    #2
    1. Advertising

  3. ibiza

    ibiza Guest

    well, if I give this possibility to the users, I'd appreciate they
    respect some format :)
    e.g. always a carriage return then a "-". As soon as this is
    encountered, this means a list to the application. If he decides to add
    spaces after the "-", I guess they should be rendered maybe? And if he
    decides to input two carriage returns in a row, this would mean the end
    of the list and a new paragraph.

    As for going line per line, the problem for me is the beginning and the
    end of the list. I mean, how can I find where it does begin and
    end?...could you give me some help with this?

    thanks a lot for your reply!
     
    ibiza, Feb 9, 2006
    #3
  4. ibiza,

    If it's formatting user data entered into a text box. Check out freetextbox:
    http://www.freetextbox.com

    It's a WYSIWIG editor that would let your users create the list themselves
    without having to know html markup. You can enable and disable any buttons
    in the editor you'd like.

    --
    Sincerely,

    S. Justin Gengo, MCP
    Web Developer / Programmer

    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzsche
    "ibiza" <> wrote in message
    news:...
    > well, if I give this possibility to the users, I'd appreciate they
    > respect some format :)
    > e.g. always a carriage return then a "-". As soon as this is
    > encountered, this means a list to the application. If he decides to add
    > spaces after the "-", I guess they should be rendered maybe? And if he
    > decides to input two carriage returns in a row, this would mean the end
    > of the list and a new paragraph.
    >
    > As for going line per line, the problem for me is the beginning and the
    > end of the list. I mean, how can I find where it does begin and
    > end?...could you give me some help with this?
    >
    > thanks a lot for your reply!
    >
     
    S. Justin Gengo [MCP], Feb 9, 2006
    #4
  5. ibiza

    ibiza Guest

    thanks for the tip :)

    but unfortunately, there is a licensing cost (it's for my work so I
    guess they ought to buy it if I'd use it) and it's too much for what I
    need...regex should be well enough for my problem, but I have
    difficulties with the correct one to use :\
     
    ibiza, Feb 9, 2006
    #5
  6. Ibiza,

    No, you don't have to pay a dime unless you need to use the "Pro" features
    or want the source code.

    A quote from the licensing section of the creator's site:

    Free License (free!)
    You may download FreeTextBox 3.0 and include it in all your projects
    including those you host and those you redistrubute. Pro features of
    FreeTextBox 3.0 will be disabled.

    --
    Sincerely,

    S. Justin Gengo, MCP
    Web Developer / Programmer

    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzsche
    "ibiza" <> wrote in message
    news:...
    > thanks for the tip :)
    >
    > but unfortunately, there is a licensing cost (it's for my work so I
    > guess they ought to buy it if I'd use it) and it's too much for what I
    > need...regex should be well enough for my problem, but I have
    > difficulties with the correct one to use :\
    >
     
    S. Justin Gengo [MCP], Feb 9, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. spaghetti

    Re: "Soft" hyphens

    spaghetti, Jun 24, 2003, in forum: HTML
    Replies:
    0
    Views:
    940
    spaghetti
    Jun 24, 2003
  2. Jukka K. Korpela

    Re: "Soft" hyphens

    Jukka K. Korpela, Jun 24, 2003, in forum: HTML
    Replies:
    0
    Views:
    948
    Jukka K. Korpela
    Jun 24, 2003
  3. Augustus

    Re: "Soft" hyphens

    Augustus, Jun 24, 2003, in forum: HTML
    Replies:
    4
    Views:
    918
    Anonymous Joe
    Jun 25, 2003
  4. Nico Grubert
    Replies:
    0
    Views:
    312
    Nico Grubert
    Jun 30, 2010
  5. Stefan Behnel
    Replies:
    0
    Views:
    525
    Stefan Behnel
    Jun 30, 2010
Loading...

Share This Page