nlbdev / nordic-accessible-epub-guidelines

2 stars 2 forks source link

Clarify the interpretation of block code where source PDF use a combination of semantic and layout line breaks #51

Closed martinpub closed 8 months ago

martinpub commented 1 year ago

At MTM we have observed that block snippets of code in e.g. programming books sometimes use a combination of semantic line breaks and line breaks out of layout necessity, e.g. running towards the end of the edge of the page. Therefore, the following instruction in the current version of the guidelines could be improved: "In blocks of computer code, spaces and empty lines must be preserved."

We should add that the correct markup of code blocks involves interpretation alongside the principle to capture the text verbatim.

Do you agree? Of course, we should also be aware that this can create long, non-breakable lines, see #49.

AndersEkl commented 1 year ago

Elaborate section about code.

jonaslil commented 9 months ago

Would this be enough, using the issue description by @martinpub :

In blocks of computer code, spaces, line breaks and empty lines must be preserved. It should be noted, however, that the correct mark up of code blocks involves interpretation alongside the principle of capturing the text verbatim. For example, programming books may sometimes use a mix of semantic line breaks, which must be preserved, and line breaks necessitated by the print layout.

As to the issue of long, non-breakable lines: I did some quick testing and in most cases, it seems enough to add pre {overflow: auto} or pre {overlow-x: auto} to the stylesheet to make a horizontal scroll-bar appear. In this way, the lines aren't clipped and remain readable. (Thorium also requires white-space: pre;, otherwise it will line-wrap the code lines.) So we don't need any additional mark up to handle this, I think.

Adding @oscarlcarlsson to this thread also.

josteinaj commented 9 months ago

In code editors, when you enable word wrapping, you normally distinguish lines by their line number in the margin, and sometimes using slightly different background colors on alternating lines (or at least the one your cursor is on). Line spacing could also indicate what is a new line, and what is not.

jonaslil commented 8 months ago

That's a good point, @josteinaj. But I don't think these means of distinguishing lines are usually present in programming books?

Thinking about updating the guidelines with the suggested paragraph and closing this issue shortly.

martinpub commented 8 months ago

In blocks of computer code, spaces, line breaks and empty lines must be preserved. It should be noted, however, that the correct mark up of code blocks involves interpretation alongside the principle of capturing the text verbatim. For example, programming books may sometimes use a mix of semantic line breaks, which must be preserved, and line breaks necessitated by the print layout.

Yes, this is sufficient. Thanks @jonaslil!