librelist archives

« back to archive

Link to a related file (also in the blohg repo)

Link to a related file (also in the blohg repo)

From:
Greg Ward
Date:
2012-09-13 @ 22:44
Hi folks --

I'm trying to write a blog post that links to auxiliary content (a C
source file) that I want to keep in the blohg repository. But I'm
getting stuck because the post appears in two contexts:

  http://gerg.ca/blog/
  http://gerg.ca/blog/post/2012/python-comparison/

Here is the relevant bit of rst source:

    In case you're not familiar with C syntax, that last argument means
    "``compar`` is a pointer to a function taking two generic pointer
    arguments and returning an integer". Putting ``qsort()`` and
    ``strmp()`` together is a bit non-obvious: see this sample_ code.
    
    .. _sample: ../../../attachments/python-comparison/sample-qsort.c

where I've carefully counted the number of "../" repetitions to make
the link work in its permanent location. But it doesn't work when that
post is on the front page.

I tried changing it to this:

    In case you're not familiar with C syntax, that last argument means
    "``compar`` is a pointer to a function taking two generic pointer
    arguments and returning an integer". Putting ``qsort()`` and
    ``strmp()`` together is a bit non-obvious: see
    :attachment:`python-comparison/sample-qsort.c`,

That makes a working link in both contexts, but it's not what I was
looking for. That dumps the absolute URL in the text, when I just want
a traditional "click on the underlined word" hyperlink.

Is there a nice way to do this?

Thanks --

       Greg
-- 
Greg Ward                                http://www.gerg.ca/
Everybody is going somewhere!!  It's probably a garage sale
or a disaster Movie!!

Re: [blohg] Link to a related file (also in the blohg repo)

From:
Anton Novosyolov
Date:
2012-09-13 @ 22:50
Try :attachment:`python-comparison/sample-qsort.c*|link description*`

On Fri, Sep 14, 2012 at 2:44 AM, Greg Ward <greg@gerg.ca> wrote:
> Hi folks --
>
> I'm trying to write a blog post that links to auxiliary content (a C
> source file) that I want to keep in the blohg repository. But I'm
> getting stuck because the post appears in two contexts:
>
>   http://gerg.ca/blog/
>   http://gerg.ca/blog/post/2012/python-comparison/
>
> Here is the relevant bit of rst source:
>
>     In case you're not familiar with C syntax, that last argument means
>     "``compar`` is a pointer to a function taking two generic pointer
>     arguments and returning an integer". Putting ``qsort()`` and
>     ``strmp()`` together is a bit non-obvious: see this sample_ code.
>
>     .. _sample: ../../../attachments/python-comparison/sample-qsort.c
>
> where I've carefully counted the number of "../" repetitions to make
> the link work in its permanent location. But it doesn't work when that
> post is on the front page.
>
> I tried changing it to this:
>
>     In case you're not familiar with C syntax, that last argument means
>     "``compar`` is a pointer to a function taking two generic pointer
>     arguments and returning an integer". Putting ``qsort()`` and
>     ``strmp()`` together is a bit non-obvious: see
>     :attachment:`python-comparison/sample-qsort.c`,
>
> That makes a working link in both contexts, but it's not what I was
> looking for. That dumps the absolute URL in the text, when I just want
> a traditional "click on the underlined word" hyperlink.
>
> Is there a nice way to do this?
>
> Thanks --
>
>        Greg
> --
> Greg Ward                                http://www.gerg.ca/
> Everybody is going somewhere!!  It's probably a garage sale
> or a disaster Movie!!

Re: [blohg] Link to a related file (also in the blohg repo)

From:
Greg Ward
Date:
2012-09-14 @ 00:31
On 14 September 2012, Anton Novosyolov said:
> Try :attachment:`python-comparison/sample-qsort.c*|link description*`

Thanks -- that was *very* close! The asterisks just confused things,
though. Here is the text that worked:

  In case you're not familiar with C syntax, that last argument means
  "``compar`` is a pointer to a function taking two generic pointer
  arguments and returning an integer". Putting ``qsort()`` and
  ``strmp()`` together is a bit non-obvious: see this
  :attachment:`python-comparison/sample-qsort.c|sample code`.

I found the `` syntax described in the "Quick reStructuredText" manual
(http://docutils.sourceforge.net/docs/user/rst/quickref.html). But is
that ":attachment:" thingie a blohg feature or an reST feature?
Embarassingly, I've never properly learned reST, so I'm not quite sure
where the line is between it and blohg.

-- 
Greg Ward                                http://www.gerg.ca/

Re: [blohg] Link to a related file (also in the blohg repo)

From:
Rafael Martins
Date:
2012-09-14 @ 03:42
Hi Greg,

On Thu, Sep 13, 2012 at 9:31 PM, Greg Ward <greg@gerg.ca> wrote:
> On 14 September 2012, Anton Novosyolov said:
>> Try :attachment:`python-comparison/sample-qsort.c*|link description*`
>
> Thanks -- that was *very* close! The asterisks just confused things,
> though. Here is the text that worked:
>
>   In case you're not familiar with C syntax, that last argument means
>   "``compar`` is a pointer to a function taking two generic pointer
>   arguments and returning an integer". Putting ``qsort()`` and
>   ``strmp()`` together is a bit non-obvious: see this
>   :attachment:`python-comparison/sample-qsort.c|sample code`.
>
> I found the `` syntax described in the "Quick reStructuredText" manual
> (http://docutils.sourceforge.net/docs/user/rst/quickref.html). But is
> that ":attachment:" thingie a blohg feature or an reST feature?
> Embarassingly, I've never properly learned reST, so I'm not quite sure
> where the line is between it and blohg.

Attachment support is a blohg feature.

Everything listed here is provided by blohg, and not available in a
default docutils install:
http://blohg.readthedocs.org/en/0.10.1/write/

Best regards,

-- 
Rafael Goncalves Martins
http://rafaelmartins.eng.br/