]> sipb.mit.edu Git - ikiwiki.git/blob - doc/bugs/conditional_preprocess_during_scan.mdwn
despam
[ikiwiki.git] / doc / bugs / conditional_preprocess_during_scan.mdwn
1 [[!template id=gitbranch branch=GiuseppeBilotta/scanif author="[[GiuseppeBilotta]]"]]
2
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
5 not run during scan.
6
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.
11
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]]
20
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
28 >> upstream.
29
30 >> For what it's worth, I think that my post_scan hook mechanism would work
31 >> rather fine with your trail plugin.
32
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
36 >>> works" hook:
37 >>>
38 >>> * scan
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)`
42 >>>     order
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)
47 >>> * render
48 >>>
49 >>> --[[smcv]]
50
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.