* copy & paste source code from documents @ 2016-11-26 6:52 Tobias Berndt 2016-11-26 10:40 ` Hans Hagen 0 siblings, 1 reply; 3+ messages in thread From: Tobias Berndt @ 2016-11-26 6:52 UTC (permalink / raw) To: mailing list for ConTeXt users Dear List, currently, I have to compose technical documents with a lot of source code in it. There're readers demands for a way to copy&paste this source code directly from those documents into their terminals. I tried ConTeXt’s attachment functionality, it is … ok. But most people don’t like files attatched to PDFs. Moreover, they must open it in an editor before getting contents in terminals. So, is there any possibility in ConTeXt/Lua a document reader can click on a source code statement and the content of an external file (the plain code, without any typesetting) will be loaded into the clipboard, so that they can paste this plain source code into their terminal programs to use it directly? Any help is welcome, Tobias ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: copy & paste source code from documents 2016-11-26 6:52 copy & paste source code from documents Tobias Berndt @ 2016-11-26 10:40 ` Hans Hagen 2016-11-26 12:38 ` Tobias Berndt 0 siblings, 1 reply; 3+ messages in thread From: Hans Hagen @ 2016-11-26 10:40 UTC (permalink / raw) To: ntg-context [-- Attachment #1: Type: text/plain, Size: 1961 bytes --] On 11/26/2016 7:52 AM, Tobias Berndt wrote: > > Dear List, > > currently, I have to compose technical documents with a lot of source code in it. There're readers demands for a way to copy&paste this source code directly from those documents into their terminals. I tried ConTeXt’s attachment functionality, it is … ok. But most people don’t like files attatched to PDFs. Moreover, they must open it in an editor before getting contents in terminals. So, normally a viewer is quite restricted out of security reasons > is there any possibility in ConTeXt/Lua a document reader can click on a source code statement and the content of an external file (the plain code, without any typesetting) will be loaded into the clipboard, so that they can paste this plain source code into their terminal programs to use it directly? here is an option (the last examples need an upcoming beta as i added better space support for verbatim comments) \setupinteraction[state=start] \starttext \startbuffer[a] for i=1,10 do print(i) end \stopbuffer \typebuffer[a] currently: \comment{\cldcontext{buffers.getcontent("a")}} \blank hacked: \comment{\cldcontext{string.gsub(buffers.getcontent("a"), "\string\r","\string\n")}} \blank new, space honored, still hack: \comment[space=yes]{\cldcontext{string.gsub(buffers.getcontent("a"), "\string\r","\string\n")}} \blank new, buffer honored: \comment[buffer=a]{} \blank idem: \comment[space=yes,buffer=a]{} \stoptext \definefallbackfamily[mainface][serif][texgyrepagella] \definefontfamily[mainface][sans][texgyrepagella] \setupbodyfont[mainface] \starttext ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl ----------------------------------------------------------------- [-- Attachment #2: oeps.pdf --] [-- Type: application/pdf, Size: 9802 bytes --] [-- Attachment #3: Type: text/plain, Size: 492 bytes --] ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: copy & paste source code from documents 2016-11-26 10:40 ` Hans Hagen @ 2016-11-26 12:38 ` Tobias Berndt 0 siblings, 0 replies; 3+ messages in thread From: Tobias Berndt @ 2016-11-26 12:38 UTC (permalink / raw) To: mailing list for ConTeXt users Thanks a lot, Hans, until the upcoming beta, I like the „hacked“ version. This will be an advantage to our customers, I beliefe. GREAT! > Am 26.11.2016 um 11:40 schrieb Hans Hagen <pragma@wxs.nl>: > > On 11/26/2016 7:52 AM, Tobias Berndt wrote: >> >> Dear List, >> >> currently, I have to compose technical documents with a lot of source code in it. There're readers demands for a way to copy&paste this source code directly from those documents into their terminals. I tried ConTeXt’s attachment functionality, it is … ok. But most people don’t like files attatched to PDFs. Moreover, they must open it in an editor before getting contents in terminals. So, > > normally a viewer is quite restricted out of security reasons > >> is there any possibility in ConTeXt/Lua a document reader can click on a source code statement and the content of an external file (the plain code, without any typesetting) will be loaded into the clipboard, so that they can paste this plain source code into their terminal programs to use it directly? > > here is an option (the last examples need an upcoming beta as i added better space support for verbatim comments) > > \setupinteraction[state=start] > > \starttext > > \startbuffer[a] > for i=1,10 do > print(i) > end > \stopbuffer > > \typebuffer[a] > > currently: \comment{\cldcontext{buffers.getcontent("a")}} > > \blank > > hacked: \comment{\cldcontext{string.gsub(buffers.getcontent("a"), > "\string\r","\string\n")}} > > \blank > > new, space honored, still hack: \comment[space=yes]{\cldcontext{string.gsub(buffers.getcontent("a"), > "\string\r","\string\n")}} > > \blank > > new, buffer honored: \comment[buffer=a]{} > > \blank > > idem: \comment[space=yes,buffer=a]{} > > \stoptext > > \definefallbackfamily[mainface][serif][texgyrepagella] > \definefontfamily[mainface][sans][texgyrepagella] > \setupbodyfont[mainface] > > \starttext > > > ----------------------------------------------------------------- > Hans Hagen | PRAGMA ADE > Ridderstraat 27 | 8061 GH Hasselt | The Netherlands > tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl > ----------------------------------------------------------------- > <oeps.pdf>___________________________________________________________________________________ > If your question is of interest to others as well, please add an entry to the Wiki! > > maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context > webpage : http://www.pragma-ade.nl / http://context.aanhet.net > archive : https://bitbucket.org/phg/context-mirror/commits/ > wiki : http://contextgarden.net > ___________________________________________________________________________________ ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-11-26 12:38 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2016-11-26 6:52 copy & paste source code from documents Tobias Berndt 2016-11-26 10:40 ` Hans Hagen 2016-11-26 12:38 ` Tobias Berndt
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).