User talk:FrozenPlum
Add topicFeel free to leave a comment here, please keep in mind that I have a neuro thing, so I have some communication issues sometimes, but I do my best. Cheers :)
Replacing pre tags with syntaxhighlight
[edit source]Hi FrozenPlum,
I'm thinking of doing a bot replacement from pre to syntaxhighlight. A comparison can be seen on my user page. The main advantage would be having syntax highlighting and a copy button on the top right.
Since you are active on this wiki, I'd love to hear your feedback on this proposal. PetraMagna (talk) 14:03, 1 September 2025 (UTC)
- Hi PetraMagna, I love the idea! Sounds great to me. And thanks in advance for the help! :) FrozenPlum (talk) 16:24, 1 September 2025 (UTC)
- Ps. I didn't realize it'd replace tags instead of adding more, so definitely that helps me understand better. Thanks for that explanation! FrozenPlum (talk) 16:37, 1 September 2025 (UTC)
- Great, it also has no affect on the example pre-loading (just tested).
If there's a way to pre-load direct to template sandbox, that'd be cool (and we could adjust the button templates for it). I don't see details on the extension page at first glance related to this, though it could be as simple as changing the url (not sure). Something I'll (or someone can) look into a bit later. FrozenPlum (talk) 17:00, 1 September 2025 (UTC) - The latter is done and working! (The blue, "Test in Sandbox" button below each example preloads as a new section direct in the user sandbox (link) page now). FrozenPlum (talk) 18:01, 1 September 2025 (UTC)
- I came up with an alternative way of doing this
{{Syntaxhighlight|<nowiki>...</nowiki>}}
- The full example is on User:PetraMagna/sandbox.
- Using a template would result in a more flexible setup (in case we want to change to a different tag or use different attributes in the future), though it is somewhat over-engineered.
- A more radical version of the template can be found on Template:DPL_Code. It outputs 2 sections: the first section displays the source code verbatim using syntaxhighlight; the second section displays the parsed output. This way, the source code does not need to be repeated twice.
- I don't know how robust it is. nowiki tempers with < and >, so I escaped them for DPL tags. There might be other hidden edge cases.
- Let me know what you think. PetraMagna (talk) 02:24, 2 September 2025 (UTC)
- Hmm, that's a tough one because I really like it (even though I wasn't initially keen on the idea of having extra templates or tags in examples (as keeping examples as simple as possible for new/novice users is an important principle in instructional design--and Miraheze/Wikitide has a lot of entry-level MW users). But, it also has some really nice advantages, which is awesome and nice work! :) If it's okay with you, I'd love an opportunity to test a bit in all the places in which I'd typically want to use it (not all are evident as I still have some plans for expansion), just to ensure it'll be mostly complication-free, and what adjustments (if any) may need to be made?
A couple of initial (completely untested) thoughts...
- This might be entirely impractical (and if so, no worries), but could it be dual purpose? For example:
- Could it be used on pages to specify the code (as you proposed) like this one... categorymatch (example 1)
- AND
-
- Could it also replace the
{{ViewTest}}template for displaying code on the manual pages, like is done for categorymatch?
- Could it also replace the
- A couple of complications...
- It would need to accept the
{{ViewTest}}parameters or similar. - Some examples intentionally provide code but exclude a result (or vice versa, so acceptance of a parameter value to toggle these for manual pages would be great--wouldn't be seen for example pages).
There are occasions where the "View Result" and "Test in sandbox" buttons may need toggled off, so accepting params for that and other necessary{{ViewTest}}would also be helpful... though, that template is VERY clunky and can definitely be improved.
- Darn, please ignore the above idea, I forgot a limitation of the Labeled Section Transclusion extension, is that "section tags cannot themselves be transcluded to work on other pages." ¯\_(ツ)_/¯
- But yeah, I like it a lot, and Lens0021 suggested something similar, but at the time I was just trying to get all the content transferred over still, get the examples fixed, and things weren't complete (or simple/clean) enough then to employ stuff like that yet (my apologies Lens0021). Plus testing its functionality with preloading/lst etc. I'm definitely open to it if we can still honour keeping the examples as simple (in edit source mode) as is possible. I can also explain the example template/tags in the general syntax part (and should if its simple enough to do). Also, I don't understand Lua enough to edit it if need be but I don't need to be the one doing that, anyone with Lua knowledge can. XD FrozenPlum (talk) 22:21, 2 September 2025 (UTC)
- Darn, we're defeated again, lol (at least now I remember why). Please see below section as to why (syntaxhighlight or any code modification shouldn't suppress parts of the output or especially disable debugging or other modes/functions as a user can enter anything at any time and end up with unexplained outout, or lack thereof). FrozenPlum (talk) 20:14, 4 September 2025 (UTC)
- Template:Syntaxhighlight is only meant to do syntax highlighting (as a replacement of
pretags). It doesn't output anything. - Template:DPL Code is the one that should be used. I'll attach an example below. PetraMagna (talk) 22:15, 4 September 2025 (UTC)
- Template:Syntaxhighlight is only meant to do syntax highlighting (as a replacement of
- Darn, we're defeated again, lol (at least now I remember why). Please see below section as to why (syntaxhighlight or any code modification shouldn't suppress parts of the output or especially disable debugging or other modes/functions as a user can enter anything at any time and end up with unexplained outout, or lack thereof). FrozenPlum (talk) 20:14, 4 September 2025 (UTC)
Re:Syntaxhighlight problem
[edit source]Okay, after some testing (I couldn't remember the reason I initially didn't want syntax highlight tags), I made some preliminary discoveries (one was a re-discovery, no idea which if any can be fixed). These eliminate the use of syntaxhighlight tags or other such suggestions for me, unfortunately.
Noresultsheader Example
[edit source]- Regular dpl3 statement
{{#dpl:
|debug = 5
|category = Fake category
|count = 5
|noresultsheader = \n''No pages found''
}}
- Gives
''No pages found''
- Template version
{{Syntaxhighlight|
{{#dpl:
|debug = 0
|category = Fake category
|count = 5
|noresultsheader = \n''No pages found''
}}
}}
- Gives
- Code
{{#dpl:
|debug = 0
|category = Fake category
|count = 5
|noresultsheader = \n''No pages found''
}}
- Result
No pages found
- Problem - Noresultsheader is omitted entirely (because now there IS no output)??? (There should be a second, "results" section here below the code view, per the template design but it is absent).
- Bare Syntax highlight tags version
<syntaxhighlight lang="wikitext" copy>
{{#dpl:
|debug = 0
|category = Fake category
|count = 5
|noresultsheader = \n''No pages found''
}}
</syntaxhighlight>
- Bare syntax highlight result
{{#dpl:
|debug = 0
|category = Fake category
|count = 5
|noresultsheader = \n''No pages found''
}}
- Problem - Again no
|debug=5output is given, it is omitted entirely or never executes.
Ah, okay, now I remember why I was initially adverse to adding such tags... they interfere somehow with essential output in many cases, such debugging and metadata functions (and probably more), which are core parts necessary to understand, test, (or correct) mistakes in output while learning. :(
- Unless these issues were remedied somehow, we need to continue exclude the use of code highlighting/wrapping from the documentation, unfortunately. :( FrozenPlum (talk) 18:49, 4 September 2025 (UTC)
The supression of debug output is most problematic, especially as examples begin to include contents from templates, parser functions, etc.
Tabular data test
[edit source]- Dpl3 example
{{#dpl:
|debug = 5
|category = Fruit examples
|include = {Fruit-Infobox}:grows:image
|table = class="wikitable sortable",Page,Grows,Image
|count = 3
}}
- Dpl3 result
{|class="wikitable sortable"
!Page
!Grows
!Image
|-
|[[Apple|Apple]]
|On trees
|Red Apple Fruit With Black Background.jpeg
|-
|[[Grape|Grape]]
|On vines
|Grapes on White Table.jpeg
|-
|[[Orange|Orange]]
|On trees
|Orange, orange peel.jpg
|}
- Syntaxhiglight example
<syntaxhighlight lang="wikitext" copy>
{{#dpl:
|debug = 5
|category = Fruit examples
|include = {Fruit-Infobox}:grows:image
|table = class="wikitable sortable",Page,Grows,Image
|count = 3
}}
</syntaxhighlight>
- Syntaxhiglight result
{{#dpl:
|debug = 5
|category = Fruit examples
|include = {Fruit-Infobox}:grows:image
|table = class="wikitable sortable",Page,Grows,Image
|count = 3
}}
- Problem - Again, syntax highlight (and thus template version) currently disables debug and other (necessary) types of output.
DPL Code example
[edit source]
- Code
{{#dpl:
|debug = 5
|category = Fake category
|count = 5
|noresultsheader = \n''No pages found''
}}
- Result
''No pages found''
^ PetraMagna (talk) 22:15, 4 September 2025 (UTC)
- Looks like
'is escaped. I can try to fix that. PetraMagna (talk) 22:16, 4 September 2025 (UTC)- Nevermind.
'is supposed to be a part of the output and it shouldn't display the result in bold. PetraMagna (talk) 22:18, 4 September 2025 (UTC)
- Nevermind.
- Oh, yeah, you're totally right, I got the templates mixing up between testing, sorry about that! XD And yeah, I should have clued in after the last template edit but I wasn't feeling great today, so moving too fast, lol.
- I'll restest when I'm feeling better, but it seems to work okay in the meantime so my vote is to just go for it (definitely I prefer the radical version, as it eliminates double-input error as users edit examples, which is a win to me). :D
- Probably we could just manually repeat result for those examples that are mucked up by < > or other characters. I can always look for and swap such ones afterwards, as I'll eventually be reviewing them all to simplify anyhow.
- FrozenPlum (talk) 22:51, 4 September 2025 (UTC)
- Yep User:PetraMagna, I love the template, it'll be great for editors and users. Thanks a bunch for this! :D
- PS. I hope you don't mind I'm swapping to the template as I resume my edits to link each parameter in the examples and reword them for conciseness. Feel free to mass-replace etc too as desired ofc! FrozenPlum (talk) 16:52, 5 September 2025 (UTC)
- Great! That's good to hear. Feel free to apply the template manually: I wasn't planning to do a bot replacement since the bot would need to collapse 2 sections of code into one, which seems like a tricky task. PetraMagna (talk) 23:00, 5 September 2025 (UTC)
- Thanks, and yeah, makes sense. There are a few places where on-page examples are condensed into tables (and the individual sandbox examples not) that are a tricky, and some places where the result needs hidden. Shouldn't take me long to swap them. :) FrozenPlum (talk) 15:18, 6 September 2025 (UTC)
- Great! That's good to hear. Feel free to apply the template manually: I wasn't planning to do a bot replacement since the bot would need to collapse 2 sections of code into one, which seems like a tricky task. PetraMagna (talk) 23:00, 5 September 2025 (UTC)