http://qs321.pair.com?node_id=11146819

Hi

if I look with Chrome at that post

and at the embedded code I notice that the tab width settings are 4 and 8.

And it's also 8 if I copy that code to the textarea for composing a post. ²

Suggestion: Is there a way to homogenize that to one of these? Best with CSS?

There is no need to discuss that mixing tabs and whitespace is a bad habit, or that the mainstream is against tabs for formatting. And I don't really have an opinion which width would be better suited here...°

But I think it would be beneficial for newbies if they saw the same result before and after posting.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

°) My subjective preference is 4, which doesn't mean it's the objective overall solution.

²) Which means the OP didn't notice the problematic display prior to submitting.

update

there is a CSS setting called tab-size

see

and when I use the dev-console in my browser to change the style, it seems to work fine...

plz check with other browsers and discuss the options. :)

Replies are listed 'Best First'.
Re: Consistent tab width settings
by LanX (Saint) on Sep 12, 2022 at 19:11 UTC
    OK, since I got no other feedback on topic...

    I looked into it, and there are not many things we seem to be able to do about it ...

    ... except to change the default CSS for textareas.

    textarea {width: 100%;tab-size: 4;}

    in line 173 of common.css

    There is no way for a simple pmdev like me to provide a better patch.

    /* This CSS controls presentation details common to all six original t +hemes. */ /* This CSS has been moved to a regular file on the server(s), for performance reasons. If it needs to be altered, chat with a god. If it doesn't, chat with a god anyway. Gods are people, too. */

    hence I'll message a link to this post to the gods and pray... :)

Re: Consistent tab width settings
by jwkrahn (Abbot) on Sep 10, 2022 at 22:27 UTC

    Maybe there should be a perltidy button next to preview/create?

      Nice idea. However, we are encouraged (and rightly so) to wrap data within <code> ... </code> tags as well and perltidy will complain loudly about code it can't parse. We also sometimes see actual code in other languages as source material. I can just see this creating more problems than it solves in the long run.


      🦛

        Kludgy ui but were there some way to click something next to a code section (edit akin to the d/l link) that would return/add the tidied content for that block. Really I'm not coming up with anything I'd call good save heading down the path of madness to a more rich-text-y WYSIWYMG (... What You May Get) editor.

        The cake is a lie.
        The cake is a lie.
        The cake is a lie.

Re: Consistent tab width settings
by atcroft (Abbot) on Sep 10, 2022 at 23:06 UTC

    As editors (and, apparently, browsers) can represent tabs differently, the best advice is probably to use spaces instead of tabs in your code (and many editors can do this conversion for you). Running a snippet through perltidy (as previously recommended) is probably also a very good idea.

    Personally, I try to use 4-spaces for most code ('perltidy -l 123 -ple' unless I am trying to match someone else's formatting, or have another limitation), but I may have used 2-spaces for some code examples, and I try to avoid the question of how many spaces is "best" (as that argument is almost as long and as bad as those of editor choice).

    Just my thoughts...

      Again: Not the question.

      It's very easy: some ppl use tabs and the editing looks different to the final display.

      Making that consistent° will spare us from seeing some ugly code.

      off topic

      If you want to forbid tabs altogether, you or others are free to implement² an untabify feature like in emacs and many other IDEs.

      But that's another discussion and step. And it won't make misformatted code better readable. Especially as long as the input textarea looks different to the final rendering (sic).

      Regarding perltiy: I'm looking forward to see the patch³ to integrate this here.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

      °) should be easy

      ²) not that easy, but feasable

      ³) LOL

Re: Consistent tab width settings
by harangzsolt33 (Chaplain) on Oct 21, 2022 at 15:56 UTC
    Here's an idea. Someone earlier mentioned that it would be nice if the perl code between CODE tags would be fed through some filter like perltidy. (However, sometimes I may post snippets from other programming languages inside the code tags such as assembly, VBScript or JavaScript, so it would have to be some sort of general formatter that can recognize the source code first and format it accordingly. So, not all CODE blocks contain perl code. That's what I want to insert here.) But I think, it would be a nice feature to have a filter or automatic format option.
Re: Consistent tab width settings
by Anonymous Monk on Sep 11, 2022 at 09:18 UTC
    Can you play devils advocate to your original post?