Hi Pablo,
\showframe
\setupinteraction[state=start]
\starttext
\startbuffer[abc]
def foo(x):
if x == 0:
bar()
else:
baz(x)
foo(x - 1)
\stopbuffer
\comment[location=leftmargin,
space=yes,
buffer=abc,
title={Python code}]
{}\typebuffer[abc]
\stoptext
This might solve what you need. At least, this is the approach that I
use to provide text that can be directly copied.
I'm on Linux and last time I tested on Windows there were extra lines in
the comments.
That's actually something I had never thought of, using PDF comments, thanks!.
It's a really nice approach, though weirdly it doesn't work on Okular (Linux+KDE)
for me, even though attachments worked fine. I'll try and see why that is.
What I had in mind was rather the following:
\starttext
\starttyping[space=on]
def foo(x):
y = bar(x)
if y:
return x
return y
foo(1)
\stoptyping
\stoptext
but with ordinary char32 spaces rather than \textcontrolspace characters.
Best regards,