ID:1977376
 
(See the best response by NullQuery.)
Code:


Problem description:
Hi, i have ask about browse and text formatting(i'm not sure this is correct word)
When i write message (input as message) and try move text to button line.


When i write this message as btrowse()
text aren't formatted. But in alert it is.
I know about < br > and /n but others people who send message can't know about this tags.


My question sound, is posible to browse allow "text formatting"?

Sorry for this poor english :(
Best response
input() doesn't provide support for rich-text formatting such as bold or italic text.

If the only thing you want is to allow players to write text on multiple lines you can replace all newlines ("\n") with the HTML-equivalent ("<br />").

See example:
/mob/verb/input_text(var/t as message)
if (t)
t = dd_replacetext(html_encode(t), "\n", "<br />")

usr << browse(t, "window=input_text")

This assumes you are using the Deadron.TextHandling library, which provides the dd_replacetext function.

If you want to do more than that you'll have to write your own rich-text editor and show it in a browser window. You may be able to use existing plugins such as TinyMCE though you'll have to load them from your own external website, a CDN or send each file as a resource to the client.
Thanks a lot.
The space before the slash in <br/> is unnecessary.
In response to Lummox JR
Lummox JR wrote:
The space before the slash in <br/> is unnecessary.

Yeah my web design and development tutor would be throwing things at you. He genuinely took marks off people for not putting a space between.

I mean, if we're being pedantic, you don't need the backslash at all, but this is programmin' county, y'all. We's here to be pendantics an NOTHIN' else.
Your tutor is wrong. It might matter if there's an attribute (then I use the space), but without one you don't need it.

Also, that's not a backslash.
In response to Lummox JR
Lummox JR wrote:
The space before the slash in <br/> is unnecessary.

It's not strictly needed, but I prefer to keep a space when ending an XML (or HTML) tag as I find it easier to read.

But if that bothers you then you definitely shouldn't look at my other projects though... ;-)
Ya, its not "needed" but I can understand somebody adding it for consistency sake. I know I generally do (ok, i lie, i like kinda sorta remember to even add the /)

Any markup that doesn't have a separate closing tag I'll close with a space and forward slash.
In response to Lavenblade
Lavenblade wrote:
Any markup that doesn't have a separate closing tag I'll close with a space and forward slash.

This is strictly-speaking only necessary if you're writing XHTML documents, from my understanding. The HTML specification does not require it.
Ah, I see. Well, it doesn't seem to hurt either way. It's just easier to maintain one convention than switch between them depending on if you're writing HTML vs XHTML. Good to know, though.