From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-4.sys.kth.se (smtp-4.sys.kth.se [130.237.48.193]); by fantadrom.bsd.lv (OpenSMTPD) with ESMTP id 93861ad8; for ; Mon, 9 Mar 2015 03:46:59 -0500 (EST) Received: from smtp-4.sys.kth.se (localhost.localdomain [127.0.0.1]) by smtp-4.sys.kth.se (Postfix) with ESMTP id CEA8925CB for ; Mon, 9 Mar 2015 09:46:58 +0100 (CET) X-Virus-Scanned: by amavisd-new at kth.se Received: from smtp-4.sys.kth.se ([127.0.0.1]) by smtp-4.sys.kth.se (smtp-4.sys.kth.se [127.0.0.1]) (amavisd-new, port 10024) with LMTP id SNp2gmk_H9Uf for ; Mon, 9 Mar 2015 09:46:57 +0100 (CET) X-KTH-Auth: kristaps [92.136.205.40] X-KTH-mail-from: kristaps@bsd.lv X-KTH-rcpt-to: discuss@mdocml.bsd.lv Received: from pc3.home (AToulouse-651-1-38-40.w92-136.abo.wanadoo.fr [92.136.205.40]) by smtp-4.sys.kth.se (Postfix) with ESMTPSA id 33A7525D2 for ; Mon, 9 Mar 2015 09:46:49 +0100 (CET) Message-ID: <54FD5DFB.7090407@bsd.lv> Date: Mon, 09 Mar 2015 09:46:51 +0100 From: Kristaps Dzonsons User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 X-Mailinglist: mdocml-discuss Reply-To: discuss@mdocml.bsd.lv MIME-Version: 1.0 To: discuss@mdocml.bsd.lv Subject: Re: Linking in mdoc(7) References: <54FC74F4.9090200@bsd.lv> <20150309062921.GA29323@danbala.tuwien.ac.at> <13739.1425883122@CATHET.us> In-Reply-To: <13739.1425883122@CATHET.us> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 >>> I've put together a patch that does this. Enclosed. >>> Obviously, this only works in -Thtml mode; otherwise, it's >>> ignored. >> >> Theoretically, this could work (in-page) for PDF too, right? > > Yes, although I don't know of any troff that makes use of PDF's > hyperlinking abilities. Anthony, Thomas, This is certainly possible (both hypertext and in-document, which are basically the same), but requires a fair bit of elbow grease. See Section 6.6 in (e.g.) the PDF1.1 standard for reference, http://acroeng.adobe.com/PDFReference/PDF%20Reference%201.1.pdf There are a few tricky parts to this. First, you need to annotate the text itself as a link. I.e., the clicky part. You'd need to add some scaffolding to indicate that link text is beginning so that the position of opening each word in the link text (term_ps.c:967) would be recorded, then the end (term_ps.c:1024). Then, following each word, you'd create a new annotation object with its rectangle around the text. term_ps.c is incredibly simple in this regard: it outputs word by word. This is why the PS and PDF it generates is so huge. But that makes it easy because words don't straddle lines or font contexts, so the last word is on a horizontal box you can reference. Once the word has been written, as mentioned, you'd then create the annotation object. Here's the next problem: the PDF object database is fixed. Meaning, the number of allocated objects in the PDF stream is the number of fonts plus pages plus a few other things. You'd need to start by re-writing that to allow for arbitrary object counts. The link creation bits are all described in Section 6.6 of the PDf standard. Lastly, you'd need to edit the page-closing logic (term_ps.c:742) to include the table of annotation objects made for the previous page. There's a lot of text in the PDF standard about linking to bits in the PDF file itself as well as URIs. It seems that the link text is the hard part. Best, Kristaps -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQIcBAEBCgAGBQJU/V37AAoJEMT2SUY9XBESzhoP/iBFppEsEftMVv5Knqaorgrf I5+WtmLnWHXlLlVdJM3OWoKgfZxuOt6cyuXumYV+aLEc2AdDT5VpoyYD/Fe4lApu HuhZSdYydHvZGcezveTNG8ixMIZ2k1crLcPN0JrL9L9hPueCzlMqouByJIZfNvKG ZWSokWG1A0fO2+WjVK+zBkBCDnjmHfp5930T0TmYemvrN2eKnZGRi7AhnJWAVefV eEstVHj5VGLyCM/GzbbrHqZUKJms1nMtn8s6DZSO5R7J8mrOhavYNP/Ia4CH4T0l 6epP1YHGTOLY59OT/ida907l2xBLGJfRFjMdyYgntozcPqJVOeTzy0itU2SJHgfb NN6y5MejwdN18KdUV2+M/6z8SNIqvr+kw6WE+5OGl5Ws9zShbeRHtCp6svqG1gBq jUl0Am0lkRdct7NexIE7HjRyhnuiAmH3eSxK7ktKfZlKtzfUYuh8ewUGiNjYn/sN ma5D33ONCraLXvc/bsQDaFYD7m1u2Io37ma/0ydiVdJVPGlVx0qfzg44qH+XL8LQ /WPPTIT2LMgjmLnTDzsL71+PJjjHweSaZ0Wizvt9MMOkn23BxZUUyYrQFRzJIufp AUHCgZVCa8hPRuqBOTYydUU/MBlG3wVhSS0RgmklPEq410YnCQ4nTovaXKhlERS0 h6SFvx+dDs3aEG2Q3y2c =gxf9 -----END PGP SIGNATURE----- -- To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv