[code] auto indentation - [wml_code] tag

Discussion of all aspects of the website, wiki, and forums, including support requests and new ideas.

Moderator: Forum Moderators

Post Reply
Posts: 936
Joined: December 15th, 2007, 8:52 am

[code] auto indentation - [wml_code] tag

Post by enclave »

It might have been spoken about...
But I'm wondering if it could be done in some future?

If I put [wml_code] instead of [code] the web page would automatically clear all spaces before text line begins (from line 1 to end) like exactly what [indent] does. And then iterate over result text array again from line 1 till end and would add 3 spaces for next line for each line beginning with [ and remove 3 spaces for each line beginning with [/
For example roughly like (example below is in non-existant programming language):

Code: Select all

var string_spacing = ""
for i=0 to wml_code_text.count do
  if string(wml_code_text[i],1) == "[" then ## if 1st character of string is "[" then
    if string(wml_code_text[i],2) == "/" then ## if 2nd character of string is "/" then
      delete(string_spacing,1,3) ## delete from 1st to 3rd character inclusive, so total 3 space break characters.. reducing total space by 3
      build_new_text_array("new_text_array_name",i,string_spacing..wml_code_text[i]) ## clear previously put line and replace with new shorter one..
      string_spacing = string_spacing + "   " ## add 3 spaces to string spacing..
It's not hard according to my understanding... and it's very useful... There is already a function [indent], so it's half job done...
[wml_code] would just combine modified [indent], new function (similar to above code) to add/remove 2 or more space breaks and [code] to make it show exactly like code shows..
Developers always have hard time or even not willing to read unindented codes, same as regular forum users... And creating indentation on the go when typing messages here is quite a nightmare (since TAB doesn't work like in text editor), plus i barely can see if i made 2 spaces or 3... and result is a untidy ugly code.. plus to be honest I hate WML indentation... I don't use it in my text editor (I use my own way of indenting to make code better readable), so for me the [wml_code] would be like a bliss...
And i'm not alone who is terrible at indenting, developers often have to tell people to use indentation so they could understand/read code better..
And I agree it's a bit easier to read with indentation in the forum.
So..any chance?

PS. same could be done with [lua_code] really... but lua is not a problem... WML is a real nightmare... but lua could be useful for some too maybe..? Just need to use if,for instead of [, and end instead of [/, while elseif would be special.. but lua seems even easier.. or at least not much harder.. just a bit different.. maybe just less needed... not as much of a problem..
Ravana wrote: May 29th, 2018, 1:31 pm You are supposed to use wmlindent.
I guess you mean the tool to modify my own code in my notepad editor? Then you misunderstood me... I don't like to indent my own code, I only want to indent code to represent it here (without using any extra editors or anything... I could create indentation tool as described above in excel and would onyl need to paste the code there and then click button to copy result into clipboard.. But this would involve a lot of efford:
1) open excel document..
2) copy/paste my code there...
3) click button to copy result to clipboard..
4) paste the result into here..
5) close excel document..
Then if I wanted to modify part of the code on the go I would need to do the same steps again, because indentation would be broken.
Wouldn't it be much easier to click a button here on the webpage which would automatically put [wml_code] [/wml_code] tags around my code and do all the work for me? Wouldn't it be much easier to just tell other people like me to just use that 1-easy-click button? Wouldn't it be much easier to just modify these people's code (being a moderator like you) with 1-easy-click button? ...
Last edited by enclave on May 29th, 2018, 2:06 pm, edited 2 times in total.
User avatar
Site Administrator
Posts: 6744
Joined: November 14th, 2006, 5:54 pm
Location: Chile

Re: [code] auto indentation - [wml_code] tag

Post by Iris »

If you write a phpBB extension for this, I'm all ears. Otherwise it's not going to happen. Although I'd greatly prefer if the focus were syntax highlighting instead of "fixing" code for newbies and lazy people.
Author of the unofficial UtBS sequels Invasion from the Unknown and After the Storm (now available for Wesnoth 1.14.x and 1.15.4+).
Post Reply