[rfc-i] sourcecode indentation
jhildebr at cisco.com (Joe Hildebrand (jhildebr)) Fri, 12 February 2016 20:31 UTC
From: jhildebr at cisco.com (Joe Hildebrand (jhildebr))
Date: Fri, 12 Feb 2016 20:31:02 +0000
Subject: [rfc-i] sourcecode indentation
Message-ID: <9D7378E9-C0B2-47B6-843E-1F3C8BCC8531@cisco.com>
After talking with Tony Hansen, I have an approach for sourcecode indentation that I think might work. I'm not sold on whether the usefulness of this approach is worth the complexity it imparts, so if you think this is an important use case, please speak up.
Remember, the new-in-v3 <sourcecode> element indents relative to its enclosing block, not relative to the left side of the page like <artwork>.
The prepared XML document MUST include the correct whitespace on the left side of the code so that the code can be extracted into a file later. For example:
<sourcecode name='paul.py' type='python'><![CDATA[
def foo():]]></sourcecode>
<sourcecode name='paul.py' type='python'><![CDATA[
print("hello, world!")]]></sourcecode>
If the whitespace in the second <sourcecode> were fiddled with, paul.py would be invalid when extracted.
Therefore, an indent attribute MUST only apply to the output formats. It could be an integer (with default 0). Positive numbers would add that many spaces in front of each line in every output format. Negative numbers would remove UP TO that number of spaces from the left side of every line in every output format. So:
<sourcecode indent="-4">
foo
bar
baz
</sourcecode>
Would generate:
<pre class="sourcecode">
foo
bar
baz
</pre>
In the HTML format.
I'm open to suggestions on both the design as well as whether this is worth doing.
--
Joe Hildebrand
- [rfc-i] sourcecode indentation Joe Hildebrand jhildebr
- [rfc-i] sourcecode indentation HANSEN, TONY L
- [rfc-i] sourcecode indentation Julian Reschke
- [rfc-i] sourcecode indentation Paul Kyzivat
- [rfc-i] sourcecode indentation Paul Hoffman
- [rfc-i] sourcecode indentation Brian E Carpenter
- [rfc-i] sourcecode indentation Paul Kyzivat
- [rfc-i] sourcecode indentation Carsten Bormann
- [rfc-i] sourcecode indentation Phillip Hallam-Baker
- [rfc-i] sourcecode indentation Paul Kyzivat
- [rfc-i] sourcecode indentation Paul Kyzivat
- [rfc-i] sourcecode indentation HANSEN, TONY L
- [rfc-i] sourcecode indentation Brian E Carpenter
- [rfc-i] tabs [was: sourcecode indentation] Brian E Carpenter
- [rfc-i] sourcecode indentation Carsten Bormann
- [rfc-i] tabs [was: sourcecode indentation] HANSEN, TONY L
- [rfc-i] tabs [was: sourcecode indentation] Brian E Carpenter
- [rfc-i] sourcecode indentation Joe Hildebrand jhildebr
- [rfc-i] sourcecode indentation Joe Hildebrand jhildebr