https://bugzilla.wikimedia.org/show_bug.cgi?id=31865

       Web browser: ---
             Bug #: 31865
           Summary: Tag <dws> for discarding whitespaces.
           Product: MediaWiki
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: Unprioritized
         Component: Parser
        AssignedTo: [email protected]
        ReportedBy: [email protected]
    Classification: Unclassified


I propose tag <dws>. Preprocessor should discard the tag and all the
whitespaces after it. Primary purpose of the tag -- freestyle formatting for
templates. Let us consider an example:

* Some introductory text {{ template1 | param1=value1 | param2=value2 |
param3=value3 | ... }} continuation {{ template2 | param1=value1 |
param2=value2 | param3=value3 | ... }} and, finally, finish.

Not too readable. I would like to reformat it, use linebreaks and indents for
better readability. Since leading and trailing whitespace is often ignored in
templates, the example could be reformatted to:

* Some introductory text {{ template1 
| param1=value1 
| param2=value2 
| param3=value3 
| ... 
}} continuation {{ template2 
| param1=value1 
| param2=value2 
| param3=value3 
| ... 
}} and, finally, finish.

I can add indents:

* Some introductory text {{ template1 
    | param1=value1 
    | param2=value2 
    | param3=value3 
    | ... 
}} continuation {{ template2 
    | param1=value1 
    | param2=value2 
    | param3=value3 
    | ... 
}} and, finally, finish.

or add linebreak before template name:

* Some introductory text {{ 
    template1 
    | param1=value1 
    | param2=value2 
    | param3=value3 
    | ... 
}} continuation {{ 
    template2 
    | param1=value1 
    | param2=value2 
    | param3=value3 
    | ... 
}} and, finally, finish.

but anyway, braces must remain on the same line with surrounding text.

Using <dws> the example could be reformatted to:

*   Some introductory text <dws>
    {{  template1 
        | param1=value1 
        | param2=value2 
        | param3=value3 
        | ... 
    }} <dws>
    continuation <dws>
    {{  template2 
        | param1=value1 
        | param2=value2 
        | param3=value3 
        | ... 
    }} <dws>
    and, finally, finish.

Much better to my taste. 

This is a simple example. The more complex template code, the more value of
good formatting. 

Other possible applications:

1. Unnamed leading and trailing whitespaces are not ignored in unnamed template
arguments. <dws> may be used to format code:

{{  some template with unnamed arguments 
    |first unnamed argument value<dws>
    |second unnamed argument value<dws>
}}

2. If someone wants to avoid too long lines in wiki code:

* Linebreak terminates list element, <dws>
  so entire element must be written in one long line. <dws>
  But tag dws allows writing it in multiple short lines.

I think there are even more applications... I have been using the tag in my
templates for some time and found in extremely helpful.

-- 
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
You are on the CC list for the bug.

_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to