1 [[!template id=gitbranch branch=GiuseppeBilotta/scanif author="Giuseppe Bilotta"]]
3 When a directive that should be run during scan preprocessing is inside
4 an if directive, it doesn't get called because the if preprocessing does
7 I've written a simple [[patch]] to fix the issue, currently hosted on the
8 scanif branch of my repository. The patch also passes the preview option
9 back to the Ikiwiki::preprocess call, making sure that whatever is being
10 reprocessed is done so in the same conditions as the original call.
12 > One problem with this is that it has the same dependency-ordering problems
13 > as inline-based or pagespec-based trails with my [[plugins/contrib/trail]]
14 > plugin: `if` takes a pagespec, but pagespecs aren't guaranteed to match
15 > correctly until everything has been scanned (for instance, `link()` might
16 > give the wrong results because a page that added or deleted a link hasn't
17 > been scanned yet). If you have a clever idea for how to fix this, I'd love
18 > to hear it - being able to specify a [[plugins/contrib/trail]] in terms
19 > of a sorted pagespec would be useful. --[[smcv]]
21 >> I have a solution to the dependency-ordering problem in a different
22 >> branch of my repository, with a post_scan hook mechanism which I use to
23 >> be able to sort outer inline pages according to the last modification
24 >> date of their nested inline pages. The way I implemented it currently,
25 >> though, doesn't use the existing hooks mechanism of ikiwiki (because
26 >> it's something which I believe to be more efficiently done the way I
27 >> implemented it) so I don't know how likely it is to be included
30 >> For what it's worth, I think that my post_scan hook mechanism would work
31 >> rather fine with your trail plugin.
33 >>> We discussed this on IRC, and I think it's actually more complicated
34 >>> than that: the branch to sort by newest inlined entry wants a
35 >>> "pagespecs now work" hook, whereas for trail I want a "sorting now
39 >>> * pagespecs now work (post-scan)
40 >>> * Giuseppe's version of inline can decide what each inline
41 >>> contains, and thus decide where they go in `inline(mtime)`
43 >>> * pagespecs and sorting now work (pre-render)
44 >>> * my trail plugin can decide what each trail contains, and
45 >>> also sort them in the right order (which might be
46 >>> `inline(mtime)`, so might be undefined until pagespecs work)
51 >> However, the case of the if
52 >> directive is considerably more complicated, because the conditional
53 >> can introduce a much stronger feedback effect in the pre/post scanning
54 >> dependency. In fact, it's probably possible to build a couple of pages
55 >> with vicious conditional dependency circles that would break/unbreak
56 >> depending on which pass we are in. And I believe this is an intrinsic
57 >> limitation of the system, which cannot be solved at all.