Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
4 posts
|
Hi,
I've noticed that sections without a declared id have their links generated based on the title and, in case of duplicates, add a counter to them: Example: == A === B == X === B results in links "_B" for (A/B) and "_B_2" (for X/B). Is it possible to change this strategy so that the parent section id is used instead? So for the given example, the links would be: _A_B and _X_B ? Thanks, Costin |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
Administrator
2681 posts
|
Costin, class SectionCurrently, there isn't a way to change it, short of monkeypatching the Section class. def generate_id # implement custom strategy here end endGiven that there are likely numerous requirements about how to autogenerate an id beyond the limited control AsciiDoc / Asciidoctor provide out of the box, I see this as a something well worth making pluggable. In fact, I need to do this anyway since there is a place in the code where I need to generate an id this way that isn't a section. The first step is to refactor the generate_id method by pulling it up into a SectionIdGenerator implementation. Then, we can perhaps introduce a method in the Extension registration that lets you set your own implementation. Extensions.register do |document| sectid_generator, InheritableSectionIdGenerator end We could introduce a bunch of built-in generators, but that just seems like a fishing expedition, at least this early in the game. I'd say we introduce those when it's obvious that we sorely need them...though we could put the implementation classes in Asciidoctor so all you have to do is register one. Can you file an issue for this enhancement? I'm also interest in feedback, particularly around naming and the design strategy for how the generators get created. Given your expertise, I have a feeling you're pretty good at this sort of thing :) On Sun, Aug 18, 2013 at 12:09 PM, costin [via Asciidoctor :: Discussion] <[hidden email]> wrote: Hi, ... [show rest of quote] -- Dan Allen | http://google.com/profiles/dan.j.allen |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
4 posts
|
Raised https://github.com/asciidoctor/asciidoctor/issues/576
Cheers, On 20/08/2013 9:16 AM, mojavelinux [via Asciidoctor :: Discussion] wrote: > Costin, > > Currently, there isn't a way to change it, short of monkeypatching the Section class. > > class Section > def generate_id > # implement custom strategy here > end > end > > Given that there are likely numerous requirements about how to autogenerate an id beyond the limited control AsciiDoc / > Asciidoctor provide out of the box, I see this as a something well worth making pluggable. In fact, I need to do this > anyway since there is a place in the code where I need to generate an id this way that isn't a section. > > The first step is to refactor the generate_id method by pulling it up into a SectionIdGenerator implementation. Then, we > can perhaps introduce a method in the Extension registration that lets you set your own implementation. > > Extensions.register do |document| > sectid_generator, InheritableSectionIdGenerator > end > > We could introduce a bunch of built-in generators, but that just seems like a fishing expedition, at least this early in > the game. I'd say we introduce those when it's obvious that we sorely need them...though we could put the implementation > classes in Asciidoctor so all you have to do is register one. > > Can you file an issue for this enhancement? I'm also interest in feedback, particularly around naming and the design > strategy for how the generators get created. Given your expertise, I have a feeling you're pretty good at this sort of > thing :) > > -Dan > > > > On Sun, Aug 18, 2013 at 12:09 PM, costin [via Asciidoctor :: Discussion] <[hidden email] > </user/SendEmail.jtp?type=node&node=476&i=0>> wrote: > > Hi, > > I've noticed that sections without a declared id have their links generated based on the title and, in case of > duplicates, add a counter to them: > > Example: > == A > === B > == X > === B > > results in links "_B" for (A/B) and "_B_2" (for X/B). > > Is it possible to change this strategy so that the parent section id is used instead? So for the given example, the > links would be: _A_B and _X_B ? > > Thanks, > Costin > > ------------------------------------------------------------------------------------------------------------------------ > If you reply to this email, your message will be added to the discussion below: > http://discuss.asciidoctor.org/Using-the-parent-section-id-in-section-link-tp463.html > To start a new topic under Asciidoctor :: Discussion, email [hidden email] </user/SendEmail.jtp?type=node&node=476&i=1> > To unsubscribe from Asciidoctor :: Discussion, click here. > NAML > <http://discuss.asciidoctor.org/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> > > > > > > -- > Dan Allen | http://google.com/profiles/dan.j.allen > > > ------------------------------------------------------------------------------------------------------------------------ > If you reply to this email, your message will be added to the discussion below: > http://discuss.asciidoctor.org/Using-the-parent-section-id-in-section-link-tp463p476.html > To unsubscribe from Using the parent section id in section link, click here > < > NAML > <http://discuss.asciidoctor.org/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> > ... [show rest of quote] -- Costin |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
Administrator
2681 posts
|
Thanks Costin! This feature is going to be a great addition to Asciidoctor. On Tue, Aug 20, 2013 at 3:11 AM, costin [via Asciidoctor :: Discussion] <[hidden email]> wrote: Raised https://github.com/asciidoctor/asciidoctor/issues/576 ... [show rest of quote] -- Dan Allen | http://google.com/profiles/dan.j.allen |
Free forum by Nabble | Edit this page |