finanalyst / raku-pod-render

Renders Raku POD to HTML, or MarkDown. GUI to take POD from a Module and create a README.md from it. Other output formats possible by changing templates
Artistic License 2.0
8 stars 7 forks source link

Re-use of link text in generated pages #16

Closed cfa closed 1 year ago

cfa commented 1 year ago

Links to the same target from a given source document seem to re-use the first link's text.

For example:

cfa commented 1 year ago

Since those doc link targets may be updated soon, here's a reproduction that doesn't depend on the state of that repo.

Create file demo.pod6 containing

=begin pod

L<one|/a>, L<two|/a> and L<three|/b>.

=end pod

and generate HTML:

$ Rakudoc-to-html demo.pod6 
demo.html has been generated in the local directory.

This currently creates a document with the following links:

one, one and three.

Note that the second incorrectly reads "one" (instead of "two").

Here's the relevant HTML:

$ grep one demo.html 
<img id="Camelia_bug" src="/asset_files/images/Camelia.svg"><h1 class="title">NO_TITLE</h1></header><div class="pod-content"><div id=""></div><div class="pod-body no-toc"><section name="___top"><p><a href="/a.html">one</a>, <a href="/a.html">one</a> and <a href="/b.html">three</a>.</p></section>        </div>

namely <a href="/a.html">one</a>, <a href="/a.html">one</a> and <a href="/b.html">three</a>.

cfa commented 1 year ago

(@coke FYI)

finanalyst commented 1 year ago

@cfa I'm under a bit of pressure at the moment with other commitments. I'll respond here as soon as I find time.

On Fri, 10 Mar 2023, 02:07 cfa, @.***> wrote:

@.*** https://github.com/coke FYI)

— Reply to this email directly, view it on GitHub https://github.com/finanalyst/raku-pod-render/issues/16#issuecomment-1463107206, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACYZHBAQPXGHM26UWKB3JDW3KEHFANCNFSM6AAAAAAVVPTAME . You are receiving this because you are subscribed to this thread.Message ID: @.***>

cfa commented 1 year ago

No worries.

finanalyst commented 1 year ago

@cfa @coke The problem is that raku-pod-render caches each link, together with the label. So when the link appears again, the cached label (first one) is used. Thinking about how to retain the cache but ensure that the proper label is used. @cfa Thanks for golfing down the problem

finanalyst commented 1 year ago

So the question now is whether to cache each link-label pair. The link registry is used to verify whether expected links exist, which does not need unique label information. If the link does not exist, then all labels to that link (url) will not exist. But at least one label is needed to help in the debug process. So the first label will be cached with the link, but the label will be returned as received.