Format javascript code Webuilder 2022 vs 2025

Post your questions and problem reports here

Moderator: kfury77

Forum rules
Please try to follow these guidelines. This will help to receive faster and more accurate response.
  • Check the Support section of the corresponding product first. Chances are you will find your answer there;
  • Do not create new topics for already reported problems. Add your comments to the existing topics instead;
  • Create separate topic for each problem request. Do NOT post a number of non-related problem reports in a single topic;
  • Give your topic a meaningful title. Titles such as "A question," "Bug report" and "Help!" provide others no clue what your message is about;
  • Include the version number of the software you are using;
  • This is not an official customer support helpdesk. If you need a prompt and official response, please contact our support team directly instead. It may take a while until you receive a reply in the forum;
Post Reply
Guilimus
Posts: 4
Joined: Sun Aug 11, 2019 5:40 pm

Format javascript code Webuilder 2022 vs 2025

Post by Guilimus »

Hi - I prefer the functionality to format JS code in Webuilder 2022 - specifically the formatting options

Webuilder 2022 - after formatting (for myself nice and neat)
var weekday =["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday",];

WeBuilder 2025 - after formatting (for myself - not necessary, to much white space, to many lines)
var weekday = [
'Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday',
];
I cannot find an option to control this behaviour.
User avatar
Aivars
Blumentals Software Developer
Posts: 2457
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: Format javascript code Webuilder 2022 vs 2025

Post by Aivars »

Hi - in JavaScript formatter dialog, go to Misc tab and set "Line width for wrapping" to something larger e.g. 150 - this controls when your long lines get split for readability. And in "JavaScript" tab you can set quote style to Double quotes.
Blumentals Software Programmer
Guilimus
Posts: 4
Joined: Sun Aug 11, 2019 5:40 pm

Re: Format javascript code Webuilder 2022 vs 2025

Post by Guilimus »

Hi - Thanks for the reply. I set "Line width for wrapping" to 155 then 255 + quote style to Double quotes.

The above changes did fix the problem with the example code but still changes:

/* I know - doc.write not so good - However it is exactly what I want as it deletes all HTML */
var mylinkstyle = "<style> a:link { color: black; text-decoration: none;} \
a:visited { color: black; text-decoration: none; } \
a:hover { color: grey; text-decoration: none !important;} \
</style>";

document.write(mylinkstyle,
"  ", dayname, " ", day, " ", monthname, " ", year,
" ", hours, ":", min, ampm, " ",
"<a href='#'title='(Week #)'>(", weeknum, ")</a> ",
"<a href='#'title='(Day #-Days to end / # in Year)'>(", daynum, "-",
daytoend, " / ", yeardays, ")</a>");

TO:
/* I know - doc.write not so good - However it is exactly what I want as it deletes all HTML */
var mylinkstyle =
"<style> a:link { color: black; text-decoration: none;} \
a:visited { color: black; text-decoration: none; } \
a:hover { color: grey; text-decoration: none !important;} \
</style>";

document.write(
mylinkstyle,
"  ",
dayname,
" ",
day,
" ",
monthname,
" ",
year,
" ",
hours,
":",
min,
ampm,
" ",
"<a href='#'title='(Week #)'>(",
weeknum,
")</a> ",
"<a href='#'title='(Day #-Days to end / # in Year)'>(",
daynum,
"-",
daytoend,
" / ",
yeardays,
")</a>"
);

I prefer to leave line width to 90. The above problem is only in 2025 not 2022.
Thanks Bill D.
User avatar
Aivars
Blumentals Software Developer
Posts: 2457
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: Format javascript code Webuilder 2022 vs 2025

Post by Aivars »

Were you actively using the old formatter? We might bring it back as a legacy command, but it's really old and every time I've tried to use it, I could not find the configuration that formats well in the modern style. The philosophy behind the new formatter is to make every code look the same so that any programmer can effortlessly read code of another programmer and it's the most popular formatter now.
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
Posts: 2457
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: Format javascript code Webuilder 2022 vs 2025

Post by Aivars »

One more thing - you can add this before the line that you don't want changed:
// prettier-ignore
Blumentals Software Programmer
Guilimus
Posts: 4
Joined: Sun Aug 11, 2019 5:40 pm

Re: Format javascript code Webuilder 2022 vs 2025

Post by Guilimus »

Hi - Thanks for the reply
Yes indeed - I am still using the "old formatter"!

Your suggestion to use // prettier-ignore works, I only need 4 of these, so problem solved. Is "// prettier-ignore" etc documented anywhere?

Let me explain where I coming from. On my small laptop, the statements that are broken(on every comma) into many separate lines do not even show one complete line of code while only using about a 1.5 inch column down the left of my screen. The saving grace is - I have a very nice background.

Back in the day, and I'm going to give away my age here - I use to use Punch Cards! Your new formatter would have significantly increased the stack of cards. Also use to use a line editor on a hard copy terminal that, with some long forgotten command, would display the current line plus 3 lines above and below, quite a paper gobbler.

I hope that the above has at the least given a bit of a chuckle.

Thanks for producing an excellent editor which I enjoy using, just can't keep away from a keyboard. In my opinion editors such as yours have made a significant contribution to quality, readable and understandable code.

Anyone figure out my age, last column.

Cheers Bill D.
natalie321
Posts: 1
Joined: Tue May 16, 2023 6:44 am

Re: Format javascript code Webuilder 2022 vs 2025

Post by natalie321 »

Webuilder 2025 may automatically space out arrays when formatting, but you can manually edit the array format to reduce the white space following these steps:
Select the array code.
Use Ctrl + Shift + F to format, then manually remove extra spaces or line breaks. This won't be a perfect solution if you're formatting frequently Block Blast, but it might help until the program matches your preferences.
crampvour
Posts: 2
Joined: Thu Nov 21, 2024 5:55 am
Location: United States

Re: Format javascript code Webuilder 2022 vs 2025

Post by crampvour »

If WeBuilder 2025 still doesn’t offer enough granularity in formatting controls, you may want to consider using external code formatting tools that can be configured to your exact specificationsspace waves, and then you can copy-paste the formatted code into WeBuilder.
Post Reply