[rfc-i] sourcecode indentation

Brian E Carpenter brian.e.carpenter at gmail.com
Sat Feb 13 13:40:55 PST 2016


On 14/02/2016 09:56, Paul Hoffman wrote:
> On 12 Feb 2016, at 15:52, HANSEN, TONY L wrote:
> 
>> A better example of outdent would be
>>
>> <sourcecode indent="-4">
>>  foo
>>    bar
>>      baz
>> </sourcecode>
>>
>> which would generate:
>>
>> <pre class="sourcecode">
>> foo
>> bar
>>  baz
>> </pre>
>>
>> in the HTML format.
>>
>> A more common variation might be where the input is coming from elsewhere and you have no control over the indentation used
>> there:
>>
>> <sourcecode indent="-4" src="http://URL to the source code"/>
>>  or
>>
>> <sourcecode indent="16" src="http://URL to the source code"/>
>>
>> The use case for this is very specific, but probably not something that would get used often.
>>
>> If you think you would find it useful, please speak up.
> 
> I will speak up against this idea. For sourcecode where indentation is important, seeing an example at the left margin might
> cause the reader to think that the code is in fact not indented. Your example above is a classic one: someone seeing that text
> would assume that "foo" and "bar" are at the same level when they are not. I would prefer not to have the RFC format have a
> display hinting mechanism that could be used to make examples harder to interpret.

It's worse than that. In Python, it can invalidate the example completely.

if whatever:
    this
that

is very different from

if whatever:
    this
    that

but indent="-4" would reduce them both to

if whatever:
this
that

which is invalid syntax. It's a dangerous toy, in other words.

    Brian


More information about the rfc-interest mailing list