discuss@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: Kristaps Dzonsons <kristaps@bsd.lv>
To: discuss@mdocml.bsd.lv
Subject: Re: Linking in mdoc(7)
Date: Mon, 09 Mar 2015 09:46:51 +0100	[thread overview]
Message-ID: <54FD5DFB.7090407@bsd.lv> (raw)
In-Reply-To: <13739.1425883122@CATHET.us>

-----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

  reply	other threads:[~2015-03-09  8:46 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <sfid-H20150308-171308-+043.19-1@spamfilter.osbf.lua>
2015-03-08 16:12 ` Kristaps Dzonsons
2015-03-09  6:29   ` Thomas Klausner
2015-03-09  6:38     ` Anthony J. Bentley
2015-03-09  8:46       ` Kristaps Dzonsons [this message]
2015-03-09 11:12         ` Joerg Sonnenberger
2015-03-09 11:34           ` Kristaps Dzonsons
2015-03-09 11:09   ` Steffen Nurpmeso
2015-03-09 11:46     ` Ingo Schwarze
2015-03-09 12:25       ` Kristaps Dzonsons
2015-03-09 15:36         ` Kristaps Dzonsons
2015-03-10 16:30           ` Steffen Nurpmeso
2015-03-11  8:05             ` Kristaps Dzonsons
2015-03-11  8:15               ` Anthony J. Bentley
2015-03-11 10:07               ` Steffen Nurpmeso
2015-03-09 13:11       ` Steffen Nurpmeso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54FD5DFB.7090407@bsd.lv \
    --to=kristaps@bsd.lv \
    --cc=discuss@mdocml.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).