2
submitted 2 months ago by wthit56@lemmy.world to c/perchance@lemmy.world

This is frustrating when making certain kinds of plugins. For example, you want to pass in some HTML, but you can't because perchance decides the block isn't code anymore.

Ideally, all code within a [code block] would be ignored until its final ].

Oh while I'm on the topic... Please ignore any [] or {} inside of <script> tags or in things like onclick="" attributes. Would make life a lot easier ;p

top 10 comments
sorted by: hot top controversial new old
[-] VioneT@lemmy.world 1 points 2 months ago

Can you give an example of what you are using the [] in the HTML panel for? It might be easier to write the script that you want to execute on the List Editor instead of writing the whole thing inside the [] in the HTML editor.

[-] wthit56@lemmy.world 1 points 2 months ago

Someone on Reddit wanted to use a spoiler plugin (for the sake of example...) [spoiler("text")] with an image tag [spoiler("<img src='...' />")] which would be just fine, and it's nothing complicated. But perchance says "Oh look a tag, I guess there's no code here after all."

Some things are just better to be done in-place in the HTML, know what I mean? Rather than using a list item just because perchance works differently for the HTML stuff to the list stuff. I'd say it would be more consistent to work the same in both, know what I mean?

[-] VioneT@lemmy.world 1 points 2 months ago

I guess that is just how the plugin works. Mostly caters only to spoiler texts.

Here is a simple one I made that allows HTML as an input.: https://perchance.org/9xaiky68ni

[-] wthit56@lemmy.world 2 points 2 months ago

No, you're missing the point, sorry.

This bit: [spoiler("<img src='...' />")]. That in the HTML pane means the code block is entirely ignored. Your example doesn't have such a code block, which is why it works.

[-] VioneT@lemmy.world 2 points 2 months ago

Ah, I see it now. I never really used it like that.

You can, however, use &lt; as the < for the HTML, to essentially escape it from being understood as HTML directly like so:

[spoiler(`&lt;h1>A Spoiler Function&lt;/h1>
&lt;img style\="aspect-ratio: 768/512; height: 200px;" src\="https://user-uploads.perchance.org/file/c3e7005097f3fdad94bb003c300e6865.webp">
&lt;p>Lorem Ipsum&lt;/p>
&lt;button onclick\="event.stopPropagation(), update(minimalOut)">randomize&lt;/button>`)]

And you would be able to use it as an HTML. I've updated the demo generator to showcase it.

[-] wthit56@lemmy.world 1 points 2 months ago

Wow okay that's bizarre! So it turns < etc. into regular characters before passing it to the function or something? Where is any of this documented?! 😂

That is not how these things work normally; < will show just that character in the HTML document. The fact it doesn't do that if you use it in code to pass as a string to a function which then returns it... just to get around this breaking-code-blocks behaviour is... just out of this world 😅

There's so much going on with this engine under the hood that if you actually have any understanding of real, regular JS... it drives you insane 🥴

Okay at least that's a workaround. But seriously... it should just ignore stuff in [code blocks] entirely so you don't have to have all this deep knowledge and you don't have to go insane trying to understand it.

[-] perchance@lemmy.world 3 points 2 months ago* (last edited 2 months ago)

if you actually have any understanding of real, regular JS… it drives you insane [...] But seriously… it should just ignore stuff in [code blocks] entirely so you don’t have to have all this deep knowledge and you don’t have to go insane trying to understand it.

I agree 100% - at some point I'll fix all these issues. I'd like it to be a very thin/robust/predictable layer on top of raw web platform stuff.

Where is any of this documented?!

https://perchance.org/known-bugs which is linked from https://perchance.org/resources but I agree it's not very easy to find, and these issues obviously ideally wouldn't exist in the first place.

So it turns < etc. into regular characters before passing it to the function or something?

The problem here (and the way to mentally model this - CC @VioneT@lemmy.world) is that the output HTML is fully rendered without any Perchance-specific stuff first (i.e. just setting innerHTML), and then the square blocks are evaluated in any text nodes on the page. So the underlying issue is the same for your original request, and this question about < and &lt;. I'll add this explanation to the existing item for this on /known-bugs page. I guess the simple way of explaining it is "HTML parsing gets priority".

But I agree it shouldn't. So yeah it's a silly bug, and the only reason I haven't fixed it is because it'd be a breaking change, and so requires a manifest/versioning type thing to be added as a header HTML comment to existing generators which are relying on this ~bug.

Thanks for bringing up the issue though - it's nice to have fresh eyes on this stuff, and hearing complaints helps me prioritize.

[-] wthit56@lemmy.world 1 points 2 months ago

Oh, I see... I guess that's why it works out like that. Thanks for explaining.

I kind of enjoy this stuff. For a number of years I was part of a somewhat niche community for another user-creation platform for video games called Dreams. I taught, helped, answered questions, and wrote my own documentation just through reverse-engineering stuff within the engine.

I've already started on one for perchance, just explaining the methods/properties on list nodes. thinking of doing more, but some of this stuff is quite hard to figure out by myself--and a lot of it just isn't explicitly explained anywhere.

Dreams had the same issue: great software with really deep features that no one but the devs understood or knew existed. So I'd scour their streams for clues to such features, then explore them fully in the engine to get as accurate a picture of it as I could--then added it to my documentation.

Hard work, but I seem to just enjoy stuff like that. ;p

[-] VioneT@lemmy.world 1 points 2 months ago

I've also made some tutorials/articles on some parts of Perchance. They are available on the Learn Tab of the /hub.

I think the most useful and less wordy that I made is: Perchance Snippets.

[-] wthit56@lemmy.world 1 points 2 months ago

Nice--I'll check those out too 👍

this post was submitted on 26 Jul 2024
2 points (100.0% liked)

Perchance - Create a Random Text Generator

415 readers
2 users here now

⚄︎ Perchance

This is a Lemmy Community for perchance.org, a platform for sharing and creating random text generators.

Feel free to ask for help, share your generators, and start friendly discussions at your leisure :)

This community is mainly for discussions between those who are building generators. For discussions about using generators, especially the popular AI ones, the community-led Casual Perchance forum is likely a more appropriate venue.

See this post for the Complete Guide to Posting Here on the Community!

Rules

1. Please follow the Lemmy.World instance rules.

2. Be kind and friendly.

  • Please be kind to others on this community (and also in general), and remember that for many people Perchance is their first experience with coding. We have members for whom English is not their first language, so please be take that into account too :)

3. Be thankful to those who try to help you.

  • If you ask a question and someone has made a effort to help you out, please remember to be thankful! Even if they don't manage to help you solve your problem - remember that they're spending time out of their day to try to help a stranger :)

4. Only post about stuff related to perchance.

  • Please only post about perchance related stuff like generators on it, bugs, and the site.

5. Refrain from requesting Prompts for the AI Tools.

  • We would like to ask to refrain from posting here needing help specifically with prompting/achieving certain results with the AI plugins (text-to-image-plugin and ai-text-plugin) e.g. "What is the good prompt for X?", "How to achieve X with Y generator?"
  • See Perchance AI FAQ for FAQ about the AI tools.
  • You can ask for help with prompting at the 'sister' community Casual Perchance, which is for more casual discussions.
  • We will still be helping/answering questions about the plugins as long as it is related to building generators with them.

6. Search through the Community Before Posting.

  • Please Search through the Community Posts here (and on Reddit) before posting to see if what you will post has similar post/already been posted.

founded 1 year ago
MODERATORS