PennMUSH Community

Ticket #7550 (new suggested feature)

Opened 6 months ago

Last modified 6 months ago

html() etc.

Reported by: Mercutio Assigned to:
Priority: minor Milestone:
Keywords: html() Pueblo SQL PHP Cc:
Visibility: Public

Description

Recently, Mike wrote a hack to the PennMUSH server which created a new function which would output any 'pennmush' code as 'html'. (Used by me to output a textfile into an SQL database, then outputted as an HTML file along with PHP. Creating things such as dynamic-news entries etc.) Now, I know that Pennmush has a same function which does the exact opposite, or rather, displays HTML as if it were PENNMUSH. Abiding to <font>, <br> and so on.

However, to use this function, one /needs/ to have Pueblo enabled on the game. I suggest allowing for a definition/compile option... or even simply enabling; the html() function to be able to be used without having Pueblo enabled to the game.

Attachments

htmlencode.patch.txt (11.0 kB) - added by Talvo on 01/29/08 14:12:54.

Change History

01/29/08 14:12:11 changed by Talvo

'Hack' is the most accurate description of the patch I did. It's basically a copy of the code for decompose() that converts the internal markup codes into <font>, <b> and <u> tags for ansi, and the appropriate html tags for Pueblo, and then converts text to the appropriate HTML entities instead of escaping it for MUSHcode. It does seem to work correctly, though, at least, and would be a useful feature for mainstream Penn, I think, given how well PennMUSHes can tie into the outside world via SQL and suchlike now. Someone else can probably rewrite it better than I did, but I'll include the patch I made, anyway, which adds an htmlencode() function.

(The problem Mercutio mentioned about needing to have Pueblo enabled only applies to markup generated by things like tagwrap(), which seem to only bother to do anything when Pueblo is enabled, presumably to save the time of adding the tags when they'll always just be stripped away again. But if that were changed, so it always generated the markup - even if it wouldn't be sent to players b/c of Pueblo being disabled - it would make the function work fully.)

Example:
think htmlencode(ansi(rh,<This> & [tagwrap(a,href=www.pennmush.org,this)] are%b%b%btests))
<font color="red"><b>&lt;This&gt; &amp; <a href=www.pennmush.org>this</a> are&nbsp; &nbsp;tests</b></font>

01/29/08 14:12:54 changed by Talvo

  • attachment htmlencode.patch.txt added.

01/30/08 08:07:22 changed by Mercutio

Another possibility to the problem is writing an exact opposite of htmlencode()... I think? Maybe. Something that transforms HTML to Penn directly, instead of using it as markup and then sending it. Pennencode? I dunno.