[rfc-i] sourcecode indentation
HANSEN, TONY L
tony at att.com
Fri Feb 12 15:52:47 PST 2016
On 2/12/16, 3:31 PM, "rfc-interest on behalf of Joe Hildebrand (jhildebr)" <rfc-interest-bounces at rfc-editor.org on behalf of jhildebr at cisco.com> wrote:
>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[
> <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:
>In the HTML format.
>I'm open to suggestions on both the design as well as whether this is worth doing.
A better example of outdent would be
which would generate:
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"/>
<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.
More information about the rfc-interest