I have a site wherein the clients can update the individual pages by editing
the text of that page in a <textarea>. Then, when the page is displayed,
all of the newlines (\n) are converted to HTML line breaks (<br />).
However, I have come across some instances where I do not want to convert
the newlines, such as the following:
<table>
<tr>
....
</tr>
</table>
Obviously, I would not want this to be
<table><br />
<tr><br />
....
</tr><br />
</table><br />
Can anyone suggest a method for achieving this? I've tried different
mixtures of regular expressions, but my skills with those are just not up to
par.
Christopher Finke 4 4552
"Christophe r Finke" <ch************ **@hotmail.com> wrote...
: Can anyone suggest a method for achieving this? I've tried different
: mixtures of regular expressions, but my skills with those are just not up
to
: par.
Christopher, first off it's never a good idea to allow people to enter html
code in forms of a content management service. You can allow them to insert
simple tags like <i>,<b> and <u> but if you're allowing them to create
things like tables it could seriously screw up the design of the site.
A practical solution for your problem would be to do a str_replace on the
text before you store it. For example:
$remove = array("<table>\ n", "<table>\r" , "<table>\r\ n");
$text = str_replace($re move, '<table>', $text);
see: http://www.php.net/str_replace
Hope it helps,
..soma
somaBoy MX wrote: "Christophe r Finke" <ch************ **@hotmail.com> wrote...
: Can anyone suggest a method for achieving this? I've tried different : mixtures of regular expressions, but my skills with those are just not up to : par.
Christopher, first off it's never a good idea to allow people to enter html code in forms of a content management service. You can allow them to insert simple tags like <i>,<b> and <u> but if you're allowing them to create things like tables it could seriously screw up the design of the site.
A practical solution for your problem would be to do a str_replace on the text before you store it. For example:
$remove = array("<table>\ n", "<table>\r" , "<table>\r\ n"); $text = str_replace($re move, '<table>', $text);
see: http://www.php.net/str_replace
Hope it helps,
.soma
Well, depending on how much work you want to do, which wouldn't be all
that much really, you could let them put tables in providing that you
check the syntax, running it through PHP's XML Parser actually may do
the trick, in the effort to make sure for every opening tag we have a
closing tag because tables are only really a pain in that scenario if
they close and don't open or such like.
~Cameron
On 2004-01-29, Christopher Finke <ch************ **@hotmail.com> wrote: I have a site wherein the clients can update the individual pages by editing the text of that page in a <textarea>. Then, when the page is displayed, all of the newlines (\n) are converted to HTML line breaks (<br />). However, I have come across some instances where I do not want to convert the newlines, such as the following:
<table> <tr> ... </tr> </table>
Obviously, I would not want this to be
<table><br /> <tr><br /> ... </tr><br /> </table><br />
I think that if you let them write <table> etc tags, they should be
aware of the fact that newlines don't show up the way they expect it
too.
If you use output buffering, you could run tidy before outputting the
lot.
-- http://home.mysth.be/~timvw
It can't be done. You either accept HTML as input or accept plain text. Your
computer can't resolve the ambiguity when you mix the two up.
Uzytkownik "Christophe r Finke" <ch************ **@hotmail.com> napisal w
wiadomosci news:bv******** ****@ID-158177.news.uni-berlin.de... I have a site wherein the clients can update the individual pages by
editing the text of that page in a <textarea>. Then, when the page is displayed, all of the newlines (\n) are converted to HTML line breaks (<br />). However, I have come across some instances where I do not want to convert the newlines, such as the following:
<table> <tr> ... </tr> </table>
Obviously, I would not want this to be
<table><br /> <tr><br /> ... </tr><br /> </table><br />
Can anyone suggest a method for achieving this? I've tried different mixtures of regular expressions, but my skills with those are just not up
to par.
Christopher Finke
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: fis |
last post by:
Hi all,
I've problem because there are needed break lines in my texts on the
web site but i can't do it :(
My pipeline looks like: XMS -> I18N -> XSLT -> HTML
I have lot of texts in my "languages" files and these are describes
for things on my website.
Example text looks like this:
|
by: Lasse |
last post by:
I have done this simple function, it seems to work as intended, to
solve a problem i have had for a while. I couldnt find any sample
around that was working for me.
I would like to test it with you and see if there are any improvments
that i should make ;-)
It should be fast and if possible compatible with todays modern
browser-standards. It should be activated by the onload-event.
This is my code, free for all to use:
|
by: lkrubner |
last post by:
PHP has a function called nl2br() which takes all the newlines in a
string and turns them into break tags <br>. I need to do the same in
javascript. Is this about right? I'm not sure how one is supposed to
reference invisible characters in Javascript strings. I took an example
on the web and tried to modify it to my uses.
function nl2br_js(myString) {
var regX = /\n/gi ;
s = new String(myString);
|
by: Rocky Moore |
last post by:
I have a web site called HintsAndTips.com. On this site people post tips
using a very simply webform with a multi line TextBox for inputing the tip
text. This text is encode to HTML so that no tags will remain making the
page safe (I have to convert the linefeeds to <BR>s because the
Server.EncodeHTML does not do that it seems).
The problem is that users can use a special tag when editing the top to
specify an area of the tip that will...
|
by: Winshent |
last post by:
I have a multi line text in an admin page on my cms.
I am trying to capture carriage returns as and replace them with
<p></p> bfore the string gets written to the database.
I have tried all the charcontrols option and chr(13) with success.. was
using the following code:
Dim s As String = MyTextbox.Text
| |
by: Winshent |
last post by:
I have a multi line text in an admin page on my cms.
I am trying to capture carriage returns as and replace them with
<p></p> bfore the string gets written to the database.
I have tried all the charcontrols option and chr(13) with success.. was
using the following code:
Dim s As String = MyTextbox.Text
|
by: ajay2552 |
last post by:
Hi,
I have a query.
All html tags start with < and end with >. Suppose i want to display either '<' or '>' or say some text like '<Company>' in html how do i do it?
One method is to use <, > ,<Company> to display '<', '>' and '<Company>' respectively.
But is there any freeware code available which could implement the above functionality without having to use >,< and such stuff???
|
by: Nathan Sokalski |
last post by:
Something that I recently noticed in IE6 (I don't know whether it is true
for other browsers or versions of IE) is that it renders <br/and <br></br>
differently. With the <br/version, which is what most people use when they
write static code (some people use <br>, but with xhtml you are required to
close all tags), IE6 simply breaks to the next line like it is supposed to.
However, with <br></br>, which is what is sometimes generated by...
|
by: ismailc |
last post by:
Hi, I need help please.
In <TD> certain length/max length then force <BR>
I would like within a <TD> to allow certain amount of char and then force a <br>.
Is this possible, Please Assist!
Regards
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |