Re: Reconsidering Pre and Reflow

Hi Wayne,

(Chair hat off.)

For the display of code, a key aspect for me is that the underlying content is "correct", but the view of that content can vary.

Eric pointed out YAML, and Python is also a language where the spacing at the start of each line is functional, if you change it there are errors. The line below is from a python project I created:
                this_member.sail_number_other = member_form.cleaned_data['sail_number_other']

It is 94 characters long, which would have to wrap. It has 4 tabs (4 x 4 spaces = 16 cols) at the start because it is in a function (1 tab), and 3 if-statements deep, so the first space where it could line wrap is column 46. And then the next statement is 46 characters long as well! 
I'm not saying it's great code, but it is not unusual in python/Django projects.

If I put that function into a web page as part of a tutorial, it's about a 100 lines long, and some lines are over 90 characters wide, and you have to have those on one line in order to copy-paste properly (in the underlying content at least).

If the underlying content is what would be entered into an IDE, so that you can copy-paste between them, I think that rules out wrapping lots of mark-up around words and including line numbers.

Also, if you are learning code, being able to paste it into your local IDE is a very good fall-back method as it will be customised to you requirements.

To allow for 'plain' content it would need to be a block of text within a <pre>, or a rows of <div>s with CSS set for pre-wrap which would allow for row styling more easily.

There are then techniques to improve how it is displayed such as:
- Using pre-wrap to allow wrapping.
- Adding row numbers (with CSS content statements?) and background highlighting.
- Adding syntax highlighting. Ideally with a script that creates a copy of the content, wraps the statements in mark-up to style them, but has a button to switch to the plain copy-pastable view.

There is a nice ladder of effort required there, and we could certainly do techniques for the first two, and describe the last one.

If there is at least one sufficient techniques for code examples it means people cannot make a blanket argument that "it's code therefore it meets the exception for reflow". There would have to be some other reason that information is lost, or you cannot apply that technique.

Cheers,

-Alastair

Received on Thursday, 7 February 2019 09:50:20 UTC