473,772 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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

Feb 9 '06 #1
5 2312
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" <la******@gmail .com> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.com.. .
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

Feb 9 '06 #2
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!

Feb 9 '06 #3
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" <la******@gmail .com> wrote in message
news:11******** *************@g 14g2000cwa.goog legroups.com...
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!

Feb 9 '06 #4
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 :\

Feb 9 '06 #5
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" <la******@gmail .com> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.com.. .
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 :\

Feb 9 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
6838
by: Peter Collinson | last post by:
Hi... Is there any way to style a List Item a different color and size than the <LI> in an Ordered List? I'd like a red super-script number and a dark blue text in a page's footnotes. And this be done using style sheets? -- - Yours truly, Pete Collinson
3
5485
by: David Ross | last post by:
I sometimes place a sidebar on a Web page, using the following: ..sideright { float: right; background-color: #fff; width: 40%; font-size: 90%; text-align: justify; margin-left: 1em; padding: 2% } ..sideleft { float: left; background-color: #fff;
33
3916
by: Jim Cobban | last post by:
I cannot get Netscape 4.79 to properly display the ordered list in the following fragment. <P>Get a specific portion of the date. Depending upon the value of index: <ol start=0> <li>complete value, usually as a <code>String</code>, or if an integral value as an <code>Integer</code>. <li>year as an <code>Integer</code> <li>month number as an <code>Integer</code>
69
16893
by: markarichman | last post by:
Why is Firefox complaining with this error: ------------------------------------------------------------ missing ) after argument list setTimeout('breakOut',5000); ------------------------------------------------------------ Here is the HTML that I'm producing:
4
1600
by: -D- | last post by:
I'm trying to write my xsl to display an unordered list fromt the xml file where location is equal to top: <siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" > <siteMapNode url="~/index.aspx" title="Home" location="top"> <siteMapNode url="~/about_us/index.aspx" title="About Us" location="top" > <siteMapNode url="~/about_us/mediaroom.aspx" title="Media Room" /> <siteMapNode url="~/about_us/awards.aspx" title="Awards" />...
1
1086
by: simplico | last post by:
I'm creating an unordered list that fits in a defined width on the left side of the page. It works fine in FF but IE is another story. Here is a watered-down version of the code: <html> <head> <title>Untitled</title> <style type="text/css"> * {margin: 0px; padding: 0px; border: 0px; border: 1px solid
3
3496
by: User | last post by:
Hi, Is it possible to transform Ordered/Unordered list into navigation dropdown menus? Is this effect achieved by CSS? or via Javascript? PLease advise Thanks.
3
7347
KevinADC
by: KevinADC | last post by:
If you are entirely unfamiliar with using Perl to sort data, read the "Sorting Data with Perl - Part One and Two" articles before reading this article. Beginning Perl coders may find this article uses unfamiliar terms and syntax. Intermediate and advanced Perl coders should find this article useful. The object of the article is to inform the reader, it is not about how to code Perl or how to write good Perl code, but to teach the Schwartzian...
1
1824
by: shapper | last post by:
Hello, I am creating 3 "elements" to display on a web site: a menu, a form and a pager to a table. In three cases I am using a list where each list item serves as a container of: - the menu items, in the menu; - of each form "field" (label + input), in the form; - of each paging button, in the pager;
0
10261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9912
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8934
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.