The change in `ForgeMacroPattern` is essentially about making included page's 
content available to `TOC` extension. We need to include processed page 
contents (html) into parent page, so that `TOC` will find it. Old code just put 
macro result onto html stash, which is processed after all the extensions (and 
there's no way around it), so it was hidden from `TOC` extension.

Returning html as a string does not work in this context. Actually, it includes 
page contents as needed, but `TOC` extension still can't find it (don't sure 
why). If we return html as a `etree`, then `TOC` can find it and do the job.

The `except` might happen if macro returned error, which is just text and can't 
be parsed to html, so it's ok to return that text, since there will not be any 
headers that we need to include in TOC anyway.

Regarding `slugify` you're completely right, it is only for better unicode 
handling. I was getting some "TypeError: must be unicode, not str" errors from 
within markdown, bacause `etree` that I return from `ForgeMacroPattern` is 
always returns a bytestring, when coerced into string, and slugify needed 
unicode.

Hope, this clarifies it.


---

** [tickets:#4771] TOC macro doesn't add headers of included pages [ss246]**

**Status:** code-review
**Milestone:** forge-oct-17
**Labels:** support p3 42cc 
**Created:** Thu Aug 23, 2012 12:41 PM UTC by Chris Tsai
**Last Updated:** Sat Oct 18, 2014 07:01 PM UTC
**Owner:** Igor Bondarenko

[forge:site-support:#246]

>On the page above there is a table of contents just underneath the Versions 
>Heading, and then each of the headings after that are included from seperate 
>pages per version. I would expect that the table of contents to display the 
>headings from the included pages as well as the headings from the current 
>page. This does not happen.

>It may just be me not quite understanding it, however it would be nice to have

I've put together a page demonstrating this here: 
https://sourceforge.net/p/strawhat/wiki/top/


---

Sent from sourceforge.net because [email protected] is subscribed to 
https://sourceforge.net/p/allura/tickets/

To unsubscribe from further messages, a project admin can change settings at 
https://sourceforge.net/p/allura/admin/tickets/options.  Or, if this is a 
mailing list, you can unsubscribe from the mailing list.

Reply via email to