Or .escaped or .plain or whatever you want to call it.
Currently, because string is automatically evaluated, [code]
and {options}
are processed too. This is pretty annoying if that string is meant to be returned and put into the HTML as-is, not evaluated at all. So I have to find-replace [
, ]
, {
, and }
characters to escape them all manually.
This could be done with a .raw
property on strings, for example–to make it easier for creators to do this. (I’m guessing this would be a fairly common things people need to do, when working on non-trivial plugins, etc.)
Okay I don’t think I’m being clear here… Look at this test: https://perchance.org/test-return-string-or-plain-string-89987987#edit
Two functions are called from HTML code blocks. One returns a string with special characters and it is evaluated and those characters are no longer shown. The other returns the same string, but with special characters escaped by a
plain_text()
function beforehand. Because the special characters are escaped, they are not parsed by the engine and show as normal regular text, just with those escaping slashes removed.So you can use that kind of function to spit out untouched HTML. And such a function could be built-in to the engine fairly easily.
Yep, something like perchance.org/literal-plugin could definitely be built in - it’s a fair request. I thought you were asking for something different (i.e. stop the actual evaluation at some point in the engine vs just escaping it), though I’m not sure if my original interpretation even makes sense, or wouldn’t just be equivalent to escaping right before output to HTML anyway.
Yeah skipping processing for a given string would be ideal, but I know it’s super deeply integrated into everything currently. Just the escaping getter is all 👍