Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Hi there,
How can I insert additional links in the TOC that are not related to sections? Cheers, Andres |
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
|
Andres, This is not currently possible, short of implementing your own table of contents (i.e., outline). You can do the latter by either extending the Html5Converter class and overriding the outline method: or implementing a custom template where the outline is emitted, for instance the document.html.slim: We should probably have a way to "promote" an element to the TOC. The question is, which element is it? Would it be more appropriate to simply have something like a list of figures, tables, etc? Cheers, -Dan On Sun, Aug 3, 2014 at 1:27 PM, aalmiray [via Asciidoctor :: Discussion] <[hidden email]> wrote: Hi there, 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 |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
In reply to this post by aalmiray
I have an extension that does just this:
# Add all the functions we have hyperlinked into the toc. class CustomTocPostprocessor < Asciidoctor::Extensions::Postprocessor def process(document, output) $headings.each do |name, headings| prefix = headings[:prefix] section = %Q{<ul class="sectlevel2">\n} + headings[:functions].map {|f| %Q{<li><a href="##{prefix}_#{f}">#{f}<\/a><\/li>\n}}.join + '</ul>' # Pick up the last occurrence of name so we know we have the one in the behavioural model section. output = output.sub(/(.*<li><a href=".*?#{name}<\/a><\/li>)/m, '\1' + section) end output end end Basically I am including a lot of source code sections into the document and I want to add in the function names into the TOC. The $headings is a hash of section names with details of the functions in each section. The hyperlink to the action contents is formed from the section prefix (in case the same function name exists across sections) and the function name. Dave. |
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
|
Nice one! This would make a good demo for the extensions lab. -Dan On Sep 16, 2014 4:07 AM, "daveb [via Asciidoctor :: Discussion]" <[hidden email]> wrote:
I have an extension that does just this: ... [show rest of quote] |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Feel free to use this as you see fit.
One part I don't like about this is using the global to pass arbitrary data into the extension, but it works and is expedient. Dave. |
Free forum by Nabble | Edit this page |