If it's relying on new lines for paragraphs, then would it also have <a> tags for links? Wouldn't it be one or the other?
If it's relying on new lines for paragraphs, then would it also have <a> tags for links? Wouldn't it be one or the other?
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
"Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program." - Linus Torvalds
Anime Views Forums
Bernie
Markdown generally allows HTML. Specific implementations may differ.
http://jsfiddle.net/traq/vG3U6/
You really didn't need a jsfiddle to ask me that traq:
(text.split("<").length - 1)tells us how many opening tags if you want to know how many there are.
"Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program." - Linus Torvalds
Anime Views Forums
Bernie
I don't know if I can nudge some of you in the right direction but is there something that can go like this?
Where the dots are we need to tell that only new lines between the tags must be stripped...Code:text = text.replace('/<([^<>]+)>/g','"<" ...... ">"');
Or am I totally off?
You could have a try with something along the lines of:
Code:text.replace(/(<\S+)\n*(\S+>)/g, "$1$2");
"Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program." - Linus Torvalds
Anime Views Forums
Bernie
http://jsfiddle.net/traq/kRsND/
Actually didn't end up using a look-ahead (my idea required a look-behind also, which javascript apparently doesn't implement).
I could only get it to work by putting it in a loop, though. I'm not sure why thegmodifier isn't having the effect I expect (probably, I misunderstand what regex means by "global"). Removing it has no effect on the result.
for reference, here's the regex I'm using:Code:/(<[^>]*)\n+([^>]*>)/g // explanation: ( // start $1 < // opening bracket [^>]* // anything not a closing bracket ) // end first match \n+ // one or more newlines ( // start $2 [^>]* // anything not a closing bracket > // closing bracket ) // end $2 // then I just replaced the *whole* match with only $1 and $2.
fixed. http://jsfiddle.net/traq/kRsND/
Code:var regex = /(<[^>\n]*)\s+([^>\n]*>)/g; /* ( // start $1 < // opening bracket [^>\n]* // anything not a closing bracket *or* a newline ) // end $1 \s+ // one or more *whitespace* (including newlines) ( // start $2 [^>\n]* // anything not a closing bracket *or* a newline > // closing bracket ) // end $2 */ text = text.replace( regex,'$1 $2' ); // note the single non-breaking space between $1 and $2
qwikad.com (12-21-2012)
glad we could help.
once you've completed your testing,
If your question has been answered, please mark your thread "resolved":
- On your original post (post #1), click [edit], then click [go advanced].
- In the "thread prefix" box, select "Resolved".
- Click [save changes].
Bookmarks