From 7b24072546fdcda160ac37f4abc6d6e0bc6c8f81 Mon Sep 17 00:00:00 2001 From: "http://www.cse.unsw.edu.au/~willu/" Date: Wed, 20 May 2009 21:30:16 -0400 Subject: Responses --- doc/todo/tracking_bugs_with_dependencies.mdwn | 32 ++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'doc/todo') diff --git a/doc/todo/tracking_bugs_with_dependencies.mdwn b/doc/todo/tracking_bugs_with_dependencies.mdwn index 8b36f1e59..a3250f178 100644 --- a/doc/todo/tracking_bugs_with_dependencies.mdwn +++ b/doc/todo/tracking_bugs_with_dependencies.mdwn @@ -196,21 +196,39 @@ account all comments above (which doesn't mean it is above reproach :) ). --[[W > Very belated code review of last version of the patch: > > * `is_globlist` is no longer needed + +>> Good :) + > * I don't understand why the pagespec match regexp is changed > from having flags `igx` to `ixgs`. Don't see why you > want `.` to match '\n` in it, and don't see any `.` in the regexp > anyway? + +>> Because you have to define all the named pagespecs in the pagespec, you sometimes end up with very long pagespecs. I found it useful to split them over multiple lines. That didn't work at one point and I added the 's' to make it work. I may have further altered the regex since then to make the 's' redundant. Remove it and see if multi-line pagespecs still work. :) + > * Some changes of `@_` to `%params` in `pagespec_makeperl` do not > make sense to me. I don't see where \%params is defined and populated, > except with `\$params{specFunc}`. + +>> I'm not a perl hacker. This was a mighty battle for me to get going. There is probably some battlefield carnage from my early struggles learning perl left here. +>> Part of this is that @_ / @params already existed as a way of passing in extra parameters. I didn't want to pollute that top level namespace - just at my own parameter (a hash) which contained the data I needed. + > * Seems that the only reason `match_glob` has to check for `~` is > because when a named spec appears in a pagespec, it is translated > to `match_glob("~foo")`. If, instead, `pagespec_makeperl` checked > for named specs, it could convert them into `check_named_spec("foo")` > and avoid that ugliness. + +>> Yeah - I wanted to make named specs syntactically different on my first pass. You are right in that this could be made a fallback - named specs always override pagenames. + > * The changes to `match_link` seem either unecessary, or incomplete. > Shouldn't it check for named specs and call > `check_named_spec_existential`? + +>> An earlier version did. Then I realised it wasn't actually needed in that case - match_link() already included a loop that was like a type of existential matching. Each time through the loop it would +>> call match_glob(). match_glob() in turn will handle the named spec. I tested this version briefly and it seemed to work. I remember looking at this again later and wondering if I had mis-understood +>> some of the logic in match_link(), which might mean there are cases where you would need an explicit call to check_named_spec_existential() - I never checked it properly after having that thought. + > * Generally, the need to modify `match_*` functions so that they > check for and handle named pagespecs seems suboptimal, if > only because there might be others people may want to use named @@ -221,13 +239,25 @@ account all comments above (which doesn't mean it is above reproach :) ). --[[W > that is not a page name at all, and it could be weird > if such a parameter were accidentially interpreted as a named > pagespec. (But, that seems unlikely to happen.) + +>> Possibly. I'm not sure which I prefer between the current solution and that one. Each have advantages and disadvantages. +>> It really isn't much code for the match functions to add a call to check_named_spec_existential(). + > * I need to check if your trick to avoid infinite recursion > works if there are two named specs that recursively > call one-another. I suspect it does, but will test this > myself.. -> + +>> It worked for me. :) + > --[[Joey]] +>> There is one issue that I've been thinking about that I haven't raised anywhere (or checked myself), and that is how this all interacts with page dependencies. +>> Firstly, I'm not sure anymore that the `pagespec_merge` function will continue to work in all cases. Secondly, it seems that there are two types of dependency, and ikiwiki +>> currently only handles one of them. The first type is "Rebuild this page when any of these other pages changes" - ikiwiki handles this. The second type is "rebuild this page when +>> set of pages referred to by this pagespec changes" - ikiwiki doesn't seem to handle this. I suspect that named pagespecs would make that second type of dependency more +>> important. I'll try to come up with a good example. -- [[Will]] + ---- diff --git a/IkiWiki.pm b/IkiWiki.pm -- cgit v1.2.3 From 6a0cffc41b0cac86d444138b05140f2043c96c80 Mon Sep 17 00:00:00 2001 From: "http://www.cse.unsw.edu.au/~willu/" Date: Thu, 21 May 2009 00:56:53 -0400 Subject: Comment on potential bug --- doc/todo/tracking_bugs_with_dependencies.mdwn | 3 +++ 1 file changed, 3 insertions(+) (limited to 'doc/todo') diff --git a/doc/todo/tracking_bugs_with_dependencies.mdwn b/doc/todo/tracking_bugs_with_dependencies.mdwn index a3250f178..464f68363 100644 --- a/doc/todo/tracking_bugs_with_dependencies.mdwn +++ b/doc/todo/tracking_bugs_with_dependencies.mdwn @@ -258,6 +258,9 @@ account all comments above (which doesn't mean it is above reproach :) ). --[[W >> set of pages referred to by this pagespec changes" - ikiwiki doesn't seem to handle this. I suspect that named pagespecs would make that second type of dependency more >> important. I'll try to come up with a good example. -- [[Will]] +>>> Hrm, I was going to build an example of this with backlinks, but it looks like that is handled as a special case at the moment (line 458 of render.pm). I'll see if I can break +>>> things another way. Fixing this properly would allow removal of that special case. -- [[Will]] + ---- diff --git a/IkiWiki.pm b/IkiWiki.pm -- cgit v1.2.3 From f97f102b04e7ae67bd3db5320dd34496309de5fe Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 21 May 2009 13:33:46 -0400 Subject: response --- doc/todo/tracking_bugs_with_dependencies.mdwn | 83 ++++++++++++++++++++++++--- 1 file changed, 75 insertions(+), 8 deletions(-) (limited to 'doc/todo') diff --git a/doc/todo/tracking_bugs_with_dependencies.mdwn b/doc/todo/tracking_bugs_with_dependencies.mdwn index 464f68363..417d5910e 100644 --- a/doc/todo/tracking_bugs_with_dependencies.mdwn +++ b/doc/todo/tracking_bugs_with_dependencies.mdwn @@ -206,12 +206,51 @@ account all comments above (which doesn't mean it is above reproach :) ). --[[W >> Because you have to define all the named pagespecs in the pagespec, you sometimes end up with very long pagespecs. I found it useful to split them over multiple lines. That didn't work at one point and I added the 's' to make it work. I may have further altered the regex since then to make the 's' redundant. Remove it and see if multi-line pagespecs still work. :) +>>> Well, I can tell you that multi-line pagespecs are supported w/o +>>> your patch .. I use them all the time. The reason I find your +>>> use of `/s` unlikely is because without it `\s` already matches +>>> a newline. Only if you want to treat a newline as non-whitespace +>>> is `/s` typically necessary. --[[Joey]] + > * Some changes of `@_` to `%params` in `pagespec_makeperl` do not > make sense to me. I don't see where \%params is defined and populated, > except with `\$params{specFunc}`. ->> I'm not a perl hacker. This was a mighty battle for me to get going. There is probably some battlefield carnage from my early struggles learning perl left here. ->> Part of this is that @_ / @params already existed as a way of passing in extra parameters. I didn't want to pollute that top level namespace - just at my own parameter (a hash) which contained the data I needed. +>> I'm not a perl hacker. This was a mighty battle for me to get going. +>> There is probably some battlefield carnage from my early struggles +>> learning perl left here. Part of this is that @_ / @params already +>> existed as a way of passing in extra parameters. I didn't want to +>> pollute that top level namespace - just at my own parameter (a hash) +>> which contained the data I needed. + +>>> I think I understand how the various `%params` +>>> (there's not just one) work in your code now, but it's really a mess. +>>> Explaining it in words would take pages.. It could be fixed by, +>>> in `pagespec_makeperl` something like: +>>> +>>> my %specFuncs; +>>> push @_, specFuncs => \%specFuncs; +>>> +>>> With that you have the hash locally available for populating +>>> inside `pagespec_makeperl`, and when the `match_*` functions +>>> are called the same hash data will be available inside their +>>> `@_` or `%params`. No need to change how the functions are called +>>> or do any of the other hacks. +>>> +>>> Currently, specFuncs is populated by building up code +>>> that recursively calls `pagespec_makeperl`, and is then +>>> evaluated when the pagespec gets evaluated. My suggested +>>> change to `%params` will break that, but that had to change +>>> anyway. +>>> +>>> It probably has a security hole, and is certianly inviting +>>> one, since the pagespec definition is matched by a loose regexp (`.*`) +>>> and then subject to string interpolation before being evaluated +>>> inside perl code. I recently changed ikiwiki to never interpolate +>>> user-supplied strings when translating pagespecs, and that +>>> needs to happen here too. The obvious way, it seems to me, +>>> is to not generate perl code, but just directly run perl code that +>>> populates specFuncs. > * Seems that the only reason `match_glob` has to check for `~` is > because when a named spec appears in a pagespec, it is translated @@ -229,6 +268,10 @@ account all comments above (which doesn't mean it is above reproach :) ). --[[W >> call match_glob(). match_glob() in turn will handle the named spec. I tested this version briefly and it seemed to work. I remember looking at this again later and wondering if I had mis-understood >> some of the logic in match_link(), which might mean there are cases where you would need an explicit call to check_named_spec_existential() - I never checked it properly after having that thought. +>>> In the common case, `match_link` does not call `match_glob`, +>>> because the link target it is being asked to check for is a single +>>> page name, not a glob. + > * Generally, the need to modify `match_*` functions so that they > check for and handle named pagespecs seems suboptimal, if > only because there might be others people may want to use named @@ -243,6 +286,9 @@ account all comments above (which doesn't mean it is above reproach :) ). --[[W >> Possibly. I'm not sure which I prefer between the current solution and that one. Each have advantages and disadvantages. >> It really isn't much code for the match functions to add a call to check_named_spec_existential(). +>>> But if a plugin adds its own match function, it has +>>> to explicitly call that code to support named pagespecs. + > * I need to check if your trick to avoid infinite recursion > works if there are two named specs that recursively > call one-another. I suspect it does, but will test this @@ -250,17 +296,38 @@ account all comments above (which doesn't mean it is above reproach :) ). --[[W >> It worked for me. :) +> * I also need to verify if memoizing the named pagespecs has +> really guarded against very expensive pagespecs DOSing the wiki.. + > --[[Joey]] >> There is one issue that I've been thinking about that I haven't raised anywhere (or checked myself), and that is how this all interacts with page dependencies. ->> Firstly, I'm not sure anymore that the `pagespec_merge` function will continue to work in all cases. Secondly, it seems that there are two types of dependency, and ikiwiki ->> currently only handles one of them. The first type is "Rebuild this page when any of these other pages changes" - ikiwiki handles this. The second type is "rebuild this page when ->> set of pages referred to by this pagespec changes" - ikiwiki doesn't seem to handle this. I suspect that named pagespecs would make that second type of dependency more ->> important. I'll try to come up with a good example. -- [[Will]] - ->>> Hrm, I was going to build an example of this with backlinks, but it looks like that is handled as a special case at the moment (line 458 of render.pm). I'll see if I can break +>> Firstly, I'm not sure anymore that the `pagespec_merge` function will continue to work in all cases. + +>>> The problem I can see there is that if two pagespecs +>>> get merged and both use `~foo` but define it differently, +>>> then the second definition might be used at a point when +>>> it shouldn't (but I haven't verified that really happens). +>>> That could certianly be a show-stopper. --[[Joey]] + +>> Secondly, it seems that there are two types of dependency, and ikiwiki +>> currently only handles one of them. The first type is "Rebuild this +>> page when any of these other pages changes" - ikiwiki handles this. +>> The second type is "rebuild this page when set of pages referred to by +>> this pagespec changes" - ikiwiki doesn't seem to handle this. I +>> suspect that named pagespecs would make that second type of dependency +>> more important. I'll try to come up with a good example. -- [[Will]] + +>>> Hrm, I was going to build an example of this with backlinks, but it +>>> looks like that is handled as a special case at the moment (line 458 of +>>> render.pm). I'll see if I can breapk >>> things another way. Fixing this properly would allow removal of that special case. -- [[Will]] +>>>> I can't quite understand the distinction you're trying to draw +>>>> between the two types of dependencies. Backlinks are a very special +>>>> case though and I'll be suprised if they fit well into pagespecs. +>>>> --[[Joey]] + ---- diff --git a/IkiWiki.pm b/IkiWiki.pm -- cgit v1.2.3 From c5ff3c191bccdc9a8816ab8733eb6af0f39a2d0a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 21 May 2009 14:27:56 -0400 Subject: fix clone url for davidbrember's repo, and add it to the git repo list --- doc/git.mdwn | 1 + doc/todo/comment_by_mail.mdwn | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'doc/todo') diff --git a/doc/git.mdwn b/doc/git.mdwn index 8aa7250a7..b218240c7 100644 --- a/doc/git.mdwn +++ b/doc/git.mdwn @@ -39,6 +39,7 @@ into [[Joey]]'s working tree. This is recommended. :-) * [[jelmer]] `git://git.samba.org/jelmer/ikiwiki.git` * [[hendry]] `git://webconverger.org/git/ikiwiki` * [[jon]] `git://github.com/jmtd/ikiwiki.git` +* [[davidbremner]] `http://pivot.cs.unb.ca/git/ikipostal.git` ## branches diff --git a/doc/todo/comment_by_mail.mdwn b/doc/todo/comment_by_mail.mdwn index 6d3eeb044..bf934176a 100644 --- a/doc/todo/comment_by_mail.mdwn +++ b/doc/todo/comment_by_mail.mdwn @@ -22,7 +22,7 @@ mailbox. I would be interested in any ideas people have about security. > posts as they come in. --[[Joey]] * work in progress can be - - [cloned](http://pivot.cs.unb.ca/git/ikiperl.git), or + - [cloned](http://pivot.cs.unb.ca/git/ikipostal.git), or - [browsed](http://pivot.cs.unb.ca/git/?p=ikipostal.git;a=summary) -- cgit v1.2.3 From f0577ace82fee328aaf7093e160a7cb31be71e2b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 21 May 2009 14:36:25 -0400 Subject: update --- doc/todo/mbox.mdwn | 3 +++ 1 file changed, 3 insertions(+) (limited to 'doc/todo') diff --git a/doc/todo/mbox.mdwn b/doc/todo/mbox.mdwn index f7744563c..5b5728fee 100644 --- a/doc/todo/mbox.mdwn +++ b/doc/todo/mbox.mdwn @@ -17,3 +17,6 @@ I'd like to be able to drop an unmodified RFC2822 email message into ikiwiki, an > Your gitweb doesn't tell me where I can git pull this from, which I'd > like to do ... --[[Joey]] + +>> Found it: --[[Joey]] + -- cgit v1.2.3 From 285ef010c440a4c83093fbf0d2ac922849a873a4 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 21 May 2009 14:51:57 -0400 Subject: add contrib plugin page for the mailbox plugin --- doc/plugins/contrib/mailbox.mdwn | 18 ++++++++++++++++++ doc/todo/mbox.mdwn | 8 ++------ 2 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 doc/plugins/contrib/mailbox.mdwn (limited to 'doc/todo') diff --git a/doc/plugins/contrib/mailbox.mdwn b/doc/plugins/contrib/mailbox.mdwn new file mode 100644 index 000000000..b7a9f81c7 --- /dev/null +++ b/doc/plugins/contrib/mailbox.mdwn @@ -0,0 +1,18 @@ +[[!template id=plugin name=mailbox author="[[DavidBremner]]"]] +[[!tag type/format]] + +The `mailbox` plugin adds support to ikiwiki for +rendering mailbox file into a page displaying the mails +in the mailbox. It supports mbox, maildir, and MH folders, +does threading, and deals with MIME. + +One hitch I noticed was that it is not currently possible to treat a +maildir or an MH directory as a page (i.e. just call it foo.mh and have it +transformed to page foo). I'm not sure if this is possible and worthwhile +to fix. It is certainly workable to use a [[!mailbox ]] directive. +-- [[DavidBremner]] + +This plugin is not in ikiwiki yet, but can be downloaded +from + + diff --git a/doc/todo/mbox.mdwn b/doc/todo/mbox.mdwn index 5b5728fee..31e4a9863 100644 --- a/doc/todo/mbox.mdwn +++ b/doc/todo/mbox.mdwn @@ -3,7 +3,7 @@ I'd like to be able to drop an unmodified RFC2822 email message into ikiwiki, an > We're discussing doing just that (well, whole mailboxes, really) over in > [[comment_by_mail]] --[[Joey]] >> The ->> [mailbox](http://pivot.cs.unb.ca/git/?p=ikimailbox.git;a=summary) +>> [[plugins/mailbox]] >> plugin is roughly feature complete at this point. It can read mbox, maildir, and >> MH folders, does threading, and deals with MIME (now with >> pagespec based sanity checking). No doubt lots of things could be @@ -15,8 +15,4 @@ I'd like to be able to drop an unmodified RFC2822 email message into ikiwiki, an >> It is certainly workable >>> to use a \[[!mailbox ]] directive. -- [[DavidBremner]] -> Your gitweb doesn't tell me where I can git pull this from, which I'd -> like to do ... --[[Joey]] - ->> Found it: --[[Joey]] - +[[done]] -- cgit v1.2.3 From fb955a49456545774e8d434049e76c7231e28194 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 21 May 2009 14:59:21 -0400 Subject: add contrib plugin page for postal plugin --- doc/plugins/contrib/postal.mdwn | 39 +++++++++++++++++++++++++++++++ doc/todo/comment_by_mail.mdwn | 52 +---------------------------------------- 2 files changed, 40 insertions(+), 51 deletions(-) create mode 100644 doc/plugins/contrib/postal.mdwn (limited to 'doc/todo') diff --git a/doc/plugins/contrib/postal.mdwn b/doc/plugins/contrib/postal.mdwn new file mode 100644 index 000000000..b14c80d3b --- /dev/null +++ b/doc/plugins/contrib/postal.mdwn @@ -0,0 +1,39 @@ +[[!template id=plugin name=postal author="[[DavidBremner]]"]] +[[!tag type/useful]] + +The `postal` plugin allows users to send mail to +a special address to comment on a page. It uses the [[mailbox]] +plugin to display their comments in the wiki. + +This plugin is not in ikiwiki yet, but can be downloaded +from + +Details: + + * Adds a mailto: url to each page matching some pagespec + (currently every page gets a comment footer) + + * This mailto url goes to an address identifying the page (something like + user-iki-blog~I\_hate\_markdown@host.fqdn.tld). + [more details](http://www.cs.unb.ca/~bremner/blog/posts/encoding) + + * on the mail receiving end, these messages are either deleted, or ran through + a filter to be turned into blog posts. As a first step, I have +[written](http://pivot.cs.unb.ca/git/?p=ikipostal.git;a=blob_plain;f=filters/postal-filer.pl;hb=010357a08e9) +a filter that decodes the address and writes the message into an appropriate +mailbox. I would be interested in any ideas people have about security. + + * the same plugin can check for comments on a particular page next time the wiki + is generated, and add a link. (more or less done) + > If the filter just checks in the posts into revision control, the + > post-commit hook would handle updating the wiki to include those + > posts as they come in. --[[Joey]] + * work in progress can be + + - [cloned](http://pivot.cs.unb.ca/git/ikipostal.git), or + - [browsed](http://pivot.cs.unb.ca/git/?p=ikipostal.git;a=summary) + +The current version of this plugin is now running on my home page. See for example +[a recent post in my blog](http://www.cs.unb.ca/~bremner/blog/posts/can-i-haz-a-distributed-rss/). +Unfortunately although the [[mailbox|todo/mbox]] renderer supports threading, I haven't had +a chance to implement comments on comments yet. --[[DavidBremner]] diff --git a/doc/todo/comment_by_mail.mdwn b/doc/todo/comment_by_mail.mdwn index bf934176a..87e57417e 100644 --- a/doc/todo/comment_by_mail.mdwn +++ b/doc/todo/comment_by_mail.mdwn @@ -1,53 +1,3 @@ I would like to allow comments on ikiwiki pages without CGI. -I have in mind something like - * Use a pagetemplate hook - in a plugin (DONE) - * add a mailto: url to each page matching some pagespec - (currently every page gets a comment footer) - * this mailto url goes to an address identifying the page (something like - user-iki-blog~I\_hate\_markdown@host.fqdn.tld). (DONE) - [more details](http://www.cs.unb.ca/~bremner/blog/posts/encoding) - - * on the mail receiving end, these messages are either deleted, or ran through - a filter to be turned into blog posts. As a first step, I have -[written](http://pivot.cs.unb.ca/git/?p=ikipostal.git;a=blob_plain;f=filters/postal-filer.pl;hb=010357a08e9) -a filter that decodes the address and writes the message into an appropriate -mailbox. I would be interested in any ideas people have about security. - - * the same plugin can check for comments on a particular page next time the wiki - is generated, and add a link. (more or less done) - > If the filter just checks in the posts into revision control, the - > post-commit hook would handle updating the wiki to include those - > posts as they come in. --[[Joey]] - * work in progress can be - - - [cloned](http://pivot.cs.unb.ca/git/ikipostal.git), or - - [browsed](http://pivot.cs.unb.ca/git/?p=ikipostal.git;a=summary) - - -Any comments? Write them here or send them to [[DavidBremner]] - -> I don't want to derail this with too much blue-skying, but I was thinking -> earlier that it would be nice if ikiwiki could do something sensible with -> mailbox files, such as turning them into a (threaded?) blog display. -> -> One reason I was thinking about that was just that it would be nice to -> be able to use ikiwiki for mailing list archives. But another reason was -> that it would be nice to solve the problem described in -> [[discussion_page_as_blog]]. For that you really want a threaded system, -> and mailbox file formats already have threading. -> -> If that were done, it would tie into what you're working on in an -> interesting way, since the incoming mail would only need to be committed to -> the appropriate mailbox file, with ikiwiki then running to process it. -> --[[Joey]] ->> It is an interesting idea. I like that it uses an arbitrary MUA ->> as a "moderation" interface. After I killed a debian BTS entry with ->> clumsy pseudoheader editing I think any ->> reference info should also be encoded into the address. - -The current version of this plugin is now running on my home page. See for example -[a recent post in my blog](http://www.cs.unb.ca/~bremner/blog/posts/can-i-haz-a-distributed-rss/). -Unfortunately although the [[mailbox|todo/mbox]] renderer supports threading, I haven't had -a chance to implement comments on comments yet. [[DavidBremner]] +> [[done]], see [[plugins/contrib/postal]] -- cgit v1.2.3 From 36dbd21be6384d187c40e6ae97ff7384461e3c7a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 21 May 2009 15:37:09 -0400 Subject: update re format directive --- doc/todo/syntax_highlighting.mdwn | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) (limited to 'doc/todo') diff --git a/doc/todo/syntax_highlighting.mdwn b/doc/todo/syntax_highlighting.mdwn index b5d083ba5..87ba77cad 100644 --- a/doc/todo/syntax_highlighting.mdwn +++ b/doc/todo/syntax_highlighting.mdwn @@ -1,9 +1,13 @@ There's been a lot of work on contrib syntax highlighting plugins. One should be picked and added to ikiwiki core. -Ideally, it should support both converting whole source files into wiki +We want to support both converting whole source files into wiki pages, as well as doing syntax highlighting as a preprocessor directive -(which is either passed the text, or reads it from a file). +(which is either passed the text, or reads it from a file). But, +the [[ikiwiki/directive/format]] directive makes this easy enough to +do if the plugin only supports whole source files. So, syntax plugins +do no really need their own preprocessor directive, unless it makes +things easier for the user. ## The big list of possibilities @@ -105,24 +109,12 @@ like this: return; } -## format directive +## format directive and comments -Rather than making syntax highlight plugins have to provide a preprocessor -directive as well as handling whole source files, perhaps a generic format -directive could be used: - - \[[!format pl """..."""]] - -That would run the text through the pl htmlizer, from the syntax hightligh -plugin. OTOH, if "rst" were given, it would run the text through the rst -htmlizer. So, more generic, allows mixing different types of markup on one -page, as well as syntax highlighting. Does require specifying the type of -format, instead of allowing it to be guessed (which some syntax highlighters -can do). (This directive is now implemented..) - -Hmm, this would also allow comments inside source files to have mdwn -embedded in them, without making the use of mdwn a special case, or needing -to postprocess the syntax highlighter output to find comments. +Hmm, the [[ikiwiki/directive/format]] directive would also allow comments +inside source files to have mdwn embedded in them, without making the use +of mdwn a special case, or needing to postprocess the syntax highlighter +output to find comments. /* \[[!format mdwn """ @@ -130,4 +122,5 @@ to postprocess the syntax highlighter output to find comments. """]] */ -Note that this assumes that directives are expanded in source files. +Note that this assumes that directives are expanded in source files, +which has its own set of problems. -- cgit v1.2.3 From 0541c8ee9d866170782ea3321df39d40928999ea Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 21 May 2009 15:52:20 -0400 Subject: update --- doc/todo/syntax_highlighting.mdwn | 48 ++++++++------------------------------- 1 file changed, 10 insertions(+), 38 deletions(-) (limited to 'doc/todo') diff --git a/doc/todo/syntax_highlighting.mdwn b/doc/todo/syntax_highlighting.mdwn index 87ba77cad..f37a36587 100644 --- a/doc/todo/syntax_highlighting.mdwn +++ b/doc/todo/syntax_highlighting.mdwn @@ -41,12 +41,6 @@ releases the 5 or 6 language definitions he has running on his web site, it migh using a perl module, or a multiple-backend solution that can use a perl module as one option. (Or, if there's a great highlighter python module, we could use an external plugin..) -* Currently no single plugin supports both modes of operation (directive - and whole source file to page). - - > This is now fixed by the [[ikiwiki/directive/format]] directive for all - > whole-source-file plugins, right? - * Nothing seems to support [[wiki-formatted_comments|wiki-formatted_comments_with_syntax_plugin]] inside source files. Doing this probably means post-processing the @@ -73,41 +67,19 @@ releases the 5 or 6 language definitions he has running on his web site, it migh * The whole-file plugins all get confused if there is a `foo.c` and a `foo.h`. This is trivially fixable now by passing the keepextension option when - registering the htmlize hooks, though. + registering the htmlize hooks, though. That also should handle the + case of source files with names that do not contain an extension (ie, + "Makefile") -- in this case you just register the while filename + in the htmlize hook. * Whole-file plugins register a bunch of htmlize hooks. The wacky thing about it is that, when creating a new page, you can then pick "c" or - "h" or "pl" etc from the dropdown that normally has "mdwn" etc in it. - Is this a bug, or a feature? (Even if a feature, plugins with many - extensions make the dropdown unusable.. One way to deal with that is have - a config setting that lists what extensions to offer highlighting for. - Most people won't need/want the dozens some engines support.) -* The per page highlighters can't handle creating wiki pages from - "Makefile", or other files without a significant extension. - Not clear how to fix this, as ikiwiki is very oriented toward file - extensions. The workaround is to use a directive on a wiki page, pulling - in the Makefile. - - > I wonder how hard it would be to make a patch whereby a file with - > no `.` in the name, and a name that matches a filetype, and where - > that filetype was registered `keepextension`, then the file is just - > chosen as the appropriate type. This would allow `Makefile` to - > work. - -like this: + "h" or "pl" etc from the dropdown that normally has "Markdown" etc in it. + Is this a bug, or a feature? Even if a feature, plugins with many + extensions make the dropdown unusable.. - diff --git a/IkiWiki.pm b/IkiWiki.pm - index 8d728c9..1bd46a9 100644 - --- a/IkiWiki.pm - +++ b/IkiWiki.pm - @@ -618,6 +618,8 @@ sub pagetype ($) { - - if ($page =~ /\.([^.]+)$/) { - return $1 if exists $hooks{htmlize}{$1}; - + } elsif ($hooks{htmlize}{$page}{keepextension}) { - + return $page; - } - return; - } + Perhaps the thing to do here is to use the new `longname` parameter to + the format hook, to give them all names that will group together at or + near the end of the list. Ie: "Syntax: perl", "Syntax: C", etc. ## format directive and comments -- cgit v1.2.3 From aefbe930bba9a611f9c72a3170002f90cfc3e1dc Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 21 May 2009 15:56:19 -0400 Subject: note --- .../automatic_use_of_syntax_plugin_on_source_code_files/discussion.mdwn | 1 + 1 file changed, 1 insertion(+) (limited to 'doc/todo') diff --git a/doc/todo/automatic_use_of_syntax_plugin_on_source_code_files/discussion.mdwn b/doc/todo/automatic_use_of_syntax_plugin_on_source_code_files/discussion.mdwn index 8bc75420d..64bc21ee0 100644 --- a/doc/todo/automatic_use_of_syntax_plugin_on_source_code_files/discussion.mdwn +++ b/doc/todo/automatic_use_of_syntax_plugin_on_source_code_files/discussion.mdwn @@ -51,6 +51,7 @@ I hit a wall the following example (the last commit in the above repo). >>> I don't know what is going wrong for you... source-highlight, Markdown or something else. +>>>> It's a well-known bug in old versions of markdown. --[[Joey]] >>> I do find it interesting the way the sourcecode `div` and the list get interleaved. That >>> just looks like a Markdown thing though. >>> In any case, I've updated the patch below to include most of your changes. -- [[Will]] -- cgit v1.2.3 From 3a1ff1d0dc4b09d211e075b653c5a3767d05b74e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 21 May 2009 16:06:05 -0400 Subject: link --- doc/todo/syntax_highlighting.mdwn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'doc/todo') diff --git a/doc/todo/syntax_highlighting.mdwn b/doc/todo/syntax_highlighting.mdwn index f37a36587..576d456f3 100644 --- a/doc/todo/syntax_highlighting.mdwn +++ b/doc/todo/syntax_highlighting.mdwn @@ -30,7 +30,7 @@ things easier for the user. * [[users/jasonblevins]]'s code plugin uses src-highlight, and supports both while file and directive use. -* [hlsimple](http://pivot.cs.unb.ca/git/?p=ikiplugins.git;a=blob_plain;f=IkiWiki/Plugin/hlsimple.pm;hb=HEAD) is a wrapper for the the perl module Syntax::Highlight::Engine::Simple. This is pure perl, pretty simple, uses css. It ought to be pretty fast (according to the author, and just because it is not external). +* [hlsimple](http://pivot.cs.unb.ca/git/?p=ikiplugins.git;a=blob_plain;f=IkiWiki/Plugin/hlsimple.pm;hb=HEAD) is a wrapper for the the perl module [[!cpan Syntax::Highlight::Engine::Simple]]. This is pure perl, pretty simple, uses css. It ought to be pretty fast (according to the author, and just because it is not external). On the other hand, there are not many predefined languages yet. Defining language syntaxes is about as much work as source-highlight, but in perl. I plan to package the base module for debian. Perhaps after the author releases the 5 or 6 language definitions he has running on his web site, it might be suitable for inclusion in ikiwiki. [[DavidBremner]] -- cgit v1.2.3 From 3a949d1a04c85276b0b8691d77c8ca72efd3acbe Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 21 May 2009 16:30:55 -0400 Subject: updates --- doc/todo/syntax_highlighting.mdwn | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'doc/todo') diff --git a/doc/todo/syntax_highlighting.mdwn b/doc/todo/syntax_highlighting.mdwn index 576d456f3..29e868d16 100644 --- a/doc/todo/syntax_highlighting.mdwn +++ b/doc/todo/syntax_highlighting.mdwn @@ -14,7 +14,7 @@ things easier for the user. * [[plugins/contrib/highlightcode]] uses [[!cpan Syntax::Highlight::Engine::Kate]], operates on whole source files only, has a few bugs (see [here](http://u32.net/Highlight_Code_Plugin/), and needs to be updated to - support [[bugs/multiple_pages_with_same_name]]. + support [[bugs/multiple_pages_with_same_name]]. (Currently a 404 :-( ) * [[!cpan IkiWiki-Plugin-syntax]] only operates as a directive. Interestingly, it supports multiple highlighting backends, including Kate and Vim. @@ -35,12 +35,18 @@ On the other hand, there are not many predefined languages yet. Defining langua work as source-highlight, but in perl. I plan to package the base module for debian. Perhaps after the author releases the 5 or 6 language definitions he has running on his web site, it might be suitable for inclusion in ikiwiki. [[DavidBremner]] -## General problems +## General problems / requirements * Using non-perl syntax highlighting backends is slow. I'd prefer either using a perl module, or a multiple-backend solution that can use a perl module as one option. (Or, if there's a great highlighter python module, we could use an external plugin..) +* Engines that already support a wide variety of file types are of + course preferred. If the engine doesn't support a particular type + of file, it could fall back to doing something simple like + adding line numbers. (IkiWiki-Plugin-syntax does this.) +* Emitting html that uses CSS to control the display is preferred, + since it allows for easy user customization. * Nothing seems to support [[wiki-formatted_comments|wiki-formatted_comments_with_syntax_plugin]] inside source files. Doing this probably means post-processing the -- cgit v1.2.3 From 93254bf2f65d19584d11d7c453224e0ff73c0861 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 21 May 2009 16:37:48 -0400 Subject: update --- doc/todo/syntax_highlighting.mdwn | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'doc/todo') diff --git a/doc/todo/syntax_highlighting.mdwn b/doc/todo/syntax_highlighting.mdwn index 29e868d16..f50784e29 100644 --- a/doc/todo/syntax_highlighting.mdwn +++ b/doc/todo/syntax_highlighting.mdwn @@ -73,7 +73,8 @@ releases the 5 or 6 language definitions he has running on his web site, it migh * The whole-file plugins all get confused if there is a `foo.c` and a `foo.h`. This is trivially fixable now by passing the keepextension option when - registering the htmlize hooks, though. That also should handle the + registering the htmlize hooks, though. There's also a noextension option + that should handle the case of source files with names that do not contain an extension (ie, "Makefile") -- in this case you just register the while filename in the htmlize hook. -- cgit v1.2.3 From 3adacbac47386b235074cdf39824af6758a1b282 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 21 May 2009 17:23:42 -0400 Subject: update --- doc/todo/syntax_highlighting.mdwn | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'doc/todo') diff --git a/doc/todo/syntax_highlighting.mdwn b/doc/todo/syntax_highlighting.mdwn index f50784e29..f269aeb7c 100644 --- a/doc/todo/syntax_highlighting.mdwn +++ b/doc/todo/syntax_highlighting.mdwn @@ -21,13 +21,13 @@ things easier for the user. * [[plugins/contrib/syntax]] only operates as a directive ([[not_on_source_code_files|automatic_use_of_syntax_plugin_on_source_code_files]]), and uses [[!cpan Text::VimColor]]. -* [[plugins/contrib/sourcehighlight]] uses src-highlight, and operates on +* [[plugins/contrib/sourcehighlight]] uses source-highlight, and operates on whole source files only. Needs to be updated to support [[bugs/multiple_pages_with_same_name]]. * [[sourcecode|todo/automatic_use_of_syntax_plugin_on_source_code_files/discussion]] - also uses src-highlight, and operates on whole source files. + also uses source-highlight, and operates on whole source files. Updated to work with the fix for [[bugs/multiple_pages_with_same_name]]. Untested with files with no extension, e.g. `Makefile`. -* [[users/jasonblevins]]'s code plugin uses src-highlight, and supports both +* [[users/jasonblevins]]'s code plugin uses source-highlight, and supports both while file and directive use. * [hlsimple](http://pivot.cs.unb.ca/git/?p=ikiplugins.git;a=blob_plain;f=IkiWiki/Plugin/hlsimple.pm;hb=HEAD) is a wrapper for the the perl module [[!cpan Syntax::Highlight::Engine::Simple]]. This is pure perl, pretty simple, uses css. It ought to be pretty fast (according to the author, and just because it is not external). @@ -37,16 +37,28 @@ releases the 5 or 6 language definitions he has running on his web site, it migh ## General problems / requirements -* Using non-perl syntax highlighting backends is slow. I'd prefer either - using a perl module, or a multiple-backend solution that can use a perl - module as one option. (Or, if there's a great highlighter python module, - we could use an external plugin..) +* Using non-perl syntax highlighting backends is slower. All things equal, + I'd prefer either using a perl module, or a multiple-backend solution that + can use a perl module as one option. (Or, if there's a great highlighter + python module, we could use an external plugin..) + + Of course, some perl modules are also rather slow.. Kate, for example + can only process about 33 lines of C code, or 14 lines of + debian/changelog per second. That's **30 times slower than markdown**! + + By comparison, source-highlight can do about 5000 lines of C code per + second... And launching the program 100 times on an empty file takes about + 5 seconds. + * Engines that already support a wide variety of file types are of course preferred. If the engine doesn't support a particular type of file, it could fall back to doing something simple like adding line numbers. (IkiWiki-Plugin-syntax does this.) +* XHTML output. * Emitting html that uses CSS to control the display is preferred, - since it allows for easy user customization. + since it allows for easy user customization. (Engine::Simple does + this; Kate can be configured to do it; source-highlight can be + made to do it via the switches `--css /dev/null --no-doc`) * Nothing seems to support [[wiki-formatted_comments|wiki-formatted_comments_with_syntax_plugin]] inside source files. Doing this probably means post-processing the -- cgit v1.2.3 From ebe7fbae1889cd7ac4ef375bb8903f2b628c9606 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 21 May 2009 17:37:52 -0400 Subject: source-highlight C++ library --- doc/todo/syntax_highlighting.mdwn | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'doc/todo') diff --git a/doc/todo/syntax_highlighting.mdwn b/doc/todo/syntax_highlighting.mdwn index f269aeb7c..2bbaeedfa 100644 --- a/doc/todo/syntax_highlighting.mdwn +++ b/doc/todo/syntax_highlighting.mdwn @@ -48,7 +48,9 @@ releases the 5 or 6 language definitions he has running on his web site, it migh By comparison, source-highlight can do about 5000 lines of C code per second... And launching the program 100 times on an empty file takes about - 5 seconds. + 5 seconds, which isn't bad. And, it has a C++ library, which it + seems likely perl bindings could be written for, to eliminate + even that overhead. * Engines that already support a wide variety of file types are of course preferred. If the engine doesn't support a particular type -- cgit v1.2.3 From 9108d76289d9cf8775d1b284d1b97f442c58070d Mon Sep 17 00:00:00 2001 From: bremner Date: Thu, 21 May 2009 18:21:31 -0400 Subject: note that highlight should be slightly easier to call from perl than source-highlight --- doc/todo/syntax_highlighting.mdwn | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'doc/todo') diff --git a/doc/todo/syntax_highlighting.mdwn b/doc/todo/syntax_highlighting.mdwn index 2bbaeedfa..81ba19bc8 100644 --- a/doc/todo/syntax_highlighting.mdwn +++ b/doc/todo/syntax_highlighting.mdwn @@ -51,6 +51,11 @@ releases the 5 or 6 language definitions he has running on his web site, it migh 5 seconds, which isn't bad. And, it has a C++ library, which it seems likely perl bindings could be written for, to eliminate even that overhead. + > [highlight](http://www.andre-simon.de) has similar features to source-highlight, and swig bindings + > that should make it trivial in principle to call from perl. I like highlight a bit better because + > it has a pass-through feature that I find very useful. My memory is unfortunately a bit fuzzy as to how + > well the swig bindings work. [[DavidBremner]] + * Engines that already support a wide variety of file types are of course preferred. If the engine doesn't support a particular type -- cgit v1.2.3 From e17694193b1ac8af351122ebe4f8693120fc83f3 Mon Sep 17 00:00:00 2001 From: "http://www.cse.unsw.edu.au/~willu/" Date: Thu, 21 May 2009 21:10:55 -0400 Subject: treatise on dependencies --- doc/todo/tracking_bugs_with_dependencies.mdwn | 61 +++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'doc/todo') diff --git a/doc/todo/tracking_bugs_with_dependencies.mdwn b/doc/todo/tracking_bugs_with_dependencies.mdwn index 417d5910e..ac57965ef 100644 --- a/doc/todo/tracking_bugs_with_dependencies.mdwn +++ b/doc/todo/tracking_bugs_with_dependencies.mdwn @@ -310,6 +310,10 @@ account all comments above (which doesn't mean it is above reproach :) ). --[[W >>> it shouldn't (but I haven't verified that really happens). >>> That could certianly be a show-stopper. --[[Joey]] +>>>> Even if that works, this is a good argument for having a syntactic difference between named pagespecs and normal pages. +>>>> If you're joining two pagespecs with 'or', you don't want a named pagespec in the first part overriding a page name in the +>>>> second part. Oh, and I assume 'or' has the right operator precedence that "a and b or c" is "(a and b) or c", and not "a and (b or c)" -- [[Will]] + >> Secondly, it seems that there are two types of dependency, and ikiwiki >> currently only handles one of them. The first type is "Rebuild this >> page when any of these other pages changes" - ikiwiki handles this. @@ -328,6 +332,63 @@ account all comments above (which doesn't mean it is above reproach :) ). --[[W >>>> case though and I'll be suprised if they fit well into pagespecs. >>>> --[[Joey]] +>>>>> The issue is that the existential pagespec matching allows you to build things that have similar +>>>>> problems to backlinks. +>>>>> e.g. the following inline: + + \[[!inline pages="define(~done, link(done)) and link(~done)" archive=yes]] + +>>>>> includes any page that links to a page that links to done. Now imagine I add a new link to 'done' on +>>>>> some random page somewhere - a page which some other page links to which didn't previously get included - the set of pages accepted by the pagespec, and hence the set of +>>>>> pages inlined, will change. But, there is no dependency anywhere on the page that I altered, so +>>>>> ikiwiki will not rebuild the page with the inline in it. What is happening is that the page that I altered affects +>>>>> the set of pages matched by the pagespec without itself being matched by the pagespec, and hence included in the dependency list. + +>>>>> For another example, imagine I added a `match_word()` function. It matches any page that contains the given word. As with a backlink, +>>>>> it is now possible to change the set of pages referred to by a pagespec without changing any of the pages currently referred to by the +>>>>> pagespec. If I have an inline of all pages that include the word "abracadabra", then it would have to depend upon all pages to detect +>>>>> any new uses of that word. + +>>>>> To make this work well, I think you need to recognise two types of dependencies for each page (and no +>>>>> special cases for particular types of links, eg backlinks). The first type of dependency says, "The content of +>>>>> this page depends upon the content of these other pages". The `add_depends()` in the shortcuts +>>>>> plugin is of this form: any time the shortcuts page is edited, any page with a shortcut on it +>>>>> is rebuilt. The inline plugin also needs to add dependencies of this form to detect when the inlined +>>>>> content changes. By contrast, the map plugin does not need a dependency of this form, because it +>>>>> doesn't actually care about the content of any pages, just which pages it needs to include (which we'll handle next). + +>>>>> The second type of dependency says, "The content of this page depends upon the exact set of pages matched +>>>>> by this pagespec". The first type of dependency was about the content of some pages, the second type is about +>>>>> which pages get matched by a pagespec. This is the type of dependency tracking that the map plugin needs. +>>>>> If the set of pages matched by map pagespec changes, then the page with the map on it needs to be rebuilt to show a different list of pages. +>>>>> Inline needs this type of dependency as well as the previous type - This type handles a change in which pages +>>>>> are inlined, the previous type handles a change in the content of any of those pages. Shortcut does not need this type of +>>>>> dependency. Most of the places that use `add_depends()` seem to need this type of dependency rather than the first type. + +>>>>> Implementation Details: The first type of dependency can be handled very similarly to the current +>>>>> dependency system. You just need to keep a list of pages that the content depends upon. You could +>>>>> keep that list as a pagespec, but if you do this you might want to check that the pagespec doesn't change, +>>>>> possibly by adding a dependency of the second type along with the dependency of the first type. + +>>>>> The second type of dependency is a little more tricky. For each page, we'd need a list of pagespecs that +>>>>> the page depended on, and for each pagespec you'd want to store the list of pages that currently match it. +>>>>> On refresh, you'd need to check each pagespec to see if the set of pages that match it has changed, and if +>>>>> that set has changed, then rebuild the dependent page(s). Oh, and for this second type of dependency, I +>>>>> don't think you can merge pagespecs. If I wanted to know if either "*" or "link(done)" changes, then just checking +>>>>> to see if the set of pages matched by "* or link(done)" changes doesn't work. + +>>>>> The current system works because even though you usually want dependencies of the second type, the set of pages +>>>>> referred to by a pagespec can only change if one of those pages itself changes. i.e. A dependency check of the +>>>>> first type will catch a dependency change of the second type with current pagespecs. +>>>>> This doesn't work with backlinks, and it doesn't work with existential matching. Backlinks are currently special-cased. I don't know +>>>>> how to special-case existential matching - I suspect you're better off just getting the dependency tracking right. + +>>>>> I also tried to come up with other possible solutions: e.g. can we find the dependencies for a pagespec? That +>>>>> would be the set of pages where a change on one of those pages could lead to a change in the set of pages matched by the pagespec. +>>>>> For old-style pagespecs without backlinks, the dependency set for a pagespec is the same as the set of pages the pagespec matches. +>>>>> Unfortunately, with existential matching, the set of pages that each +>>>>> pagespec depends upon can quickly become "*", which is not very useful. -- [[Will]] + ---- diff --git a/IkiWiki.pm b/IkiWiki.pm -- cgit v1.2.3 From 173decd15eb64cba31aa544cb1d7b995484d7c4b Mon Sep 17 00:00:00 2001 From: "http://www.cse.unsw.edu.au/~willu/" Date: Thu, 21 May 2009 21:22:09 -0400 Subject: remove bad example --- doc/todo/tracking_bugs_with_dependencies.mdwn | 5 ----- 1 file changed, 5 deletions(-) (limited to 'doc/todo') diff --git a/doc/todo/tracking_bugs_with_dependencies.mdwn b/doc/todo/tracking_bugs_with_dependencies.mdwn index ac57965ef..8eedc49e0 100644 --- a/doc/todo/tracking_bugs_with_dependencies.mdwn +++ b/doc/todo/tracking_bugs_with_dependencies.mdwn @@ -344,11 +344,6 @@ account all comments above (which doesn't mean it is above reproach :) ). --[[W >>>>> ikiwiki will not rebuild the page with the inline in it. What is happening is that the page that I altered affects >>>>> the set of pages matched by the pagespec without itself being matched by the pagespec, and hence included in the dependency list. ->>>>> For another example, imagine I added a `match_word()` function. It matches any page that contains the given word. As with a backlink, ->>>>> it is now possible to change the set of pages referred to by a pagespec without changing any of the pages currently referred to by the ->>>>> pagespec. If I have an inline of all pages that include the word "abracadabra", then it would have to depend upon all pages to detect ->>>>> any new uses of that word. - >>>>> To make this work well, I think you need to recognise two types of dependencies for each page (and no >>>>> special cases for particular types of links, eg backlinks). The first type of dependency says, "The content of >>>>> this page depends upon the content of these other pages". The `add_depends()` in the shortcuts -- cgit v1.2.3 From 1fcb97e13188d85a6df6635d3b42812ca46e145b Mon Sep 17 00:00:00 2001 From: "http://www.cse.unsw.edu.au/~willu/" Date: Thu, 21 May 2009 23:33:16 -0400 Subject: responses --- doc/todo/tracking_bugs_with_dependencies.mdwn | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'doc/todo') diff --git a/doc/todo/tracking_bugs_with_dependencies.mdwn b/doc/todo/tracking_bugs_with_dependencies.mdwn index 8eedc49e0..8268e4026 100644 --- a/doc/todo/tracking_bugs_with_dependencies.mdwn +++ b/doc/todo/tracking_bugs_with_dependencies.mdwn @@ -252,6 +252,11 @@ account all comments above (which doesn't mean it is above reproach :) ). --[[W >>> is to not generate perl code, but just directly run perl code that >>> populates specFuncs. +>>>> I don't think this is as bad as you make out, but your addition of the +>>>> data array will break with the recursion my patch adds in pagespec_makeperl. +>>>> To fix that I'll need to pass a reference to that array into pagespec_makeperl. +>>>> I think I can then do the same thing to $params{specFuncs}. -- [[Will]] + > * Seems that the only reason `match_glob` has to check for `~` is > because when a named spec appears in a pagespec, it is translated > to `match_glob("~foo")`. If, instead, `pagespec_makeperl` checked @@ -314,6 +319,8 @@ account all comments above (which doesn't mean it is above reproach :) ). --[[W >>>> If you're joining two pagespecs with 'or', you don't want a named pagespec in the first part overriding a page name in the >>>> second part. Oh, and I assume 'or' has the right operator precedence that "a and b or c" is "(a and b) or c", and not "a and (b or c)" -- [[Will]] +>>>>> Looks like its bracketed in the code anyway... -- [[Will]] + >> Secondly, it seems that there are two types of dependency, and ikiwiki >> currently only handles one of them. The first type is "Rebuild this >> page when any of these other pages changes" - ikiwiki handles this. @@ -369,8 +376,8 @@ account all comments above (which doesn't mean it is above reproach :) ). --[[W >>>>> the page depended on, and for each pagespec you'd want to store the list of pages that currently match it. >>>>> On refresh, you'd need to check each pagespec to see if the set of pages that match it has changed, and if >>>>> that set has changed, then rebuild the dependent page(s). Oh, and for this second type of dependency, I ->>>>> don't think you can merge pagespecs. If I wanted to know if either "*" or "link(done)" changes, then just checking ->>>>> to see if the set of pages matched by "* or link(done)" changes doesn't work. +>>>>> don't think you can merge pagespecs. If I wanted to know if either "\*" or "link(done)" changes, then just checking +>>>>> to see if the set of pages matched by "\* or link(done)" changes doesn't work. >>>>> The current system works because even though you usually want dependencies of the second type, the set of pages >>>>> referred to by a pagespec can only change if one of those pages itself changes. i.e. A dependency check of the -- cgit v1.2.3 From 9b5bf6ff85d7e738317aa87b68581082d9542394 Mon Sep 17 00:00:00 2001 From: "http://www.cse.unsw.edu.au/~willu/" Date: Fri, 22 May 2009 00:43:45 -0400 Subject: response --- doc/todo/tracking_bugs_with_dependencies.mdwn | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'doc/todo') diff --git a/doc/todo/tracking_bugs_with_dependencies.mdwn b/doc/todo/tracking_bugs_with_dependencies.mdwn index 8268e4026..84b2448a6 100644 --- a/doc/todo/tracking_bugs_with_dependencies.mdwn +++ b/doc/todo/tracking_bugs_with_dependencies.mdwn @@ -277,6 +277,19 @@ account all comments above (which doesn't mean it is above reproach :) ). --[[W >>> because the link target it is being asked to check for is a single >>> page name, not a glob. +>>>> A named pagespec should fall into the glob case. These two pagespecs should be the same: + + link(a*) + +>>>> and + + define(aStar, a*) and link(aStar) + +>>>> In the first case, we want the pagespec to match any page that links to a page matching the glob. +>>>> In the second case, we want the pagespec to match any page that links to a page matching the named spec. +>>>> match_link() was already doing existential part. The patches to this code were simply to remove the `lc()` +>>>> call from the named pagespec name. Can that `lc` be removed entirely? -- [[Will]] + > * Generally, the need to modify `match_*` functions so that they > check for and handle named pagespecs seems suboptimal, if > only because there might be others people may want to use named -- cgit v1.2.3 From 47cff6eda61701a6142b40b93991fd9a84f065c4 Mon Sep 17 00:00:00 2001 From: "http://www.cse.unsw.edu.au/~willu/" Date: Fri, 22 May 2009 02:04:33 -0400 Subject: Update patch --- doc/todo/tracking_bugs_with_dependencies.mdwn | 203 +++++++++++++------------- 1 file changed, 100 insertions(+), 103 deletions(-) (limited to 'doc/todo') diff --git a/doc/todo/tracking_bugs_with_dependencies.mdwn b/doc/todo/tracking_bugs_with_dependencies.mdwn index 84b2448a6..04d5f2ba0 100644 --- a/doc/todo/tracking_bugs_with_dependencies.mdwn +++ b/doc/todo/tracking_bugs_with_dependencies.mdwn @@ -404,113 +404,107 @@ account all comments above (which doesn't mean it is above reproach :) ). --[[W >>>>> Unfortunately, with existential matching, the set of pages that each >>>>> pagespec depends upon can quickly become "*", which is not very useful. -- [[Will]] +Patch updated to use closures rather than inline generated code for named pagespecs. Also includes some new use of ErrorReason where appropriate. -- [[Will]] + ---- diff --git a/IkiWiki.pm b/IkiWiki.pm - index 4e4da11..8b3cdfe 100644 + index 061a1c6..1e78a63 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm - @@ -1550,7 +1550,16 @@ sub globlist_to_pagespec ($) { - - sub is_globlist ($) { - my $s=shift; - - return ( $s =~ /[^\s]+\s+([^\s]+)/ && $1 ne "and" && $1 ne "or" ); - + return ! ($s =~ / - + (^\s* - + [^\s(]+ # single item - + (\( # possibly with parens after it - + ([^)]* # with stuff inside those parens - + (\([^)]*\))*)* # maybe even nested parens - + \))?\s*$ - + ) | - + (\s and \s) | (\s or \s) # or we find 'and' or 'or' somewhere - + /xs); - } - - sub safequote ($) { - @@ -1631,7 +1640,7 @@ sub pagespec_merge ($$) { + @@ -1774,8 +1774,12 @@ sub pagespec_merge ($$) { return "($a) or ($b)"; } -sub pagespec_translate ($) { - +sub pagespec_makeperl ($) { + +# is perl really so dumb it requires a forward declaration for recursive calls? + +sub pagespec_translate ($$); + + + +sub pagespec_translate ($$) { my $spec=shift; + + my $specFuncsRef=shift; - # Support for old-style GlobLists. - @@ -1650,12 +1659,14 @@ sub pagespec_translate ($) { + # Convert spec to perl code. + my $code=""; + @@ -1789,7 +1793,9 @@ sub pagespec_translate ($) { | \) # ) | - \w+\([^\)]*\) # command(params) - + define\(\s*~\w+\s*,((\([^()]*\)) | ([^()]+))+\) # define(~specName, spec) - spec can contain parens 1 deep + + define\(\s*~\w+\s*,((\([^()]*\)) | ([^()]+))+\) # define(~specName, spec) - spec can contain parens 1 deep + | - + \w+\([^()]*\) # command(params) - params cannot contain parens + + \w+\([^())]*\) # command(params) - params cannot contain parens | [^\s()]+ # any other text ) - \s* # ignore whitespace - - }igx) { - + }igxs) { - my $word=$1; - if (lc $word eq 'and') { - $code.=' &&'; - @@ -1666,16 +1677,23 @@ sub pagespec_translate ($) { + @@ -1805,10 +1811,19 @@ sub pagespec_translate ($) { elsif ($word eq "(" || $word eq ")" || $word eq "!") { $code.=' '.$word; } - elsif ($word =~ /^(\w+)\((.*)\)$/) { - + elsif ($word =~ /^define\(\s*~(\w+)\s*,(.*)\)$/s) { - + $code .= " (\$params{specFuncs}->{$1}="; # (exists \$params{specFuncs}) && - + $code .= "memoize("; - + $code .= &pagespec_makeperl($2); - + $code .= ")"; - + $code .= ") "; + + elsif ($word =~ /^define\(\s*(~\w+)\s*,(.*)\)$/s) { + + my $name = $1; + + my $subSpec = $2; + + my $newSpecFunc = pagespec_translate($subSpec, $specFuncsRef); + + return if $@ || ! defined $newSpecFunc; + + $specFuncsRef->{$name} = $newSpecFunc; + + push @data, qq{Created named pagespec "$name"}; + + $code.="IkiWiki::SuccessReason->new(\$data[$#data])"; + } + elsif ($word =~ /^(\w+)\((.*)\)$/s) { if (exists $IkiWiki::PageSpec::{"match_$1"}) { - - $code.="IkiWiki::PageSpec::match_$1(\$page, ".safequote($2).", \@_)"; - + $code.="IkiWiki::PageSpec::match_$1(\$page, ".safequote($2).", \%params)"; + push @data, $2; + - $code.="IkiWiki::PageSpec::match_$1(\$page, \$data[$#data], \@_)"; + + $code.="IkiWiki::PageSpec::match_$1(\$page, \$data[$#data], \@_, specFuncs => \$specFuncsRef)"; } else { - $code.=' 0'; - } + push @data, qq{unknown function in pagespec "$word"}; + @@ -1817,7 +1832,7 @@ sub pagespec_translate ($) { } else { - - $code.=" IkiWiki::PageSpec::match_glob(\$page, ".safequote($word).", \@_)"; - + $code.=" IkiWiki::PageSpec::match_glob(\$page, ".safequote($word).", \%params)"; + push @data, $word; + - $code.=" IkiWiki::PageSpec::match_glob(\$page, \$data[$#data], \@_)"; + + $code.=" IkiWiki::PageSpec::match_glob(\$page, \$data[$#data], \@_, specFuncs => \$specFuncsRef)"; } } - @@ -1683,8 +1701,18 @@ sub pagespec_translate ($) { - $code=0; + @@ -1826,7 +1841,7 @@ sub pagespec_translate ($) { } - + return 'sub { my $page=shift; my %params = @_; '.$code.' }'; - +} - + - +sub pagespec_translate ($) { - + my $spec=shift; - + - + my $code = pagespec_makeperl($spec); - + - + # print STDERR "Spec '$spec' generated code '$code'\n"; - + no warnings; - return eval 'sub { my $page=shift; '.$code.' }'; - + return eval $code; + + return eval 'memoize (sub { my $page=shift; '.$code.' })'; } sub pagespec_match ($$;@) { - @@ -1699,7 +1727,7 @@ sub pagespec_match ($$;@) { + @@ -1839,7 +1854,7 @@ sub pagespec_match ($$;@) { + unshift @params, 'location'; + } - my $sub=pagespec_translate($spec); - return IkiWiki::FailReason->new("syntax error in pagespec \"$spec\"") if $@; - - return $sub->($page, @params); - + return $sub->($page, @params, specFuncs => {}); - } + - my $sub=pagespec_translate($spec); + + my $sub=pagespec_translate($spec, +{}); + return IkiWiki::ErrorReason->new("syntax error in pagespec \"$spec\"") + if $@ || ! defined $sub; + return $sub->($page, @params); + @@ -1850,7 +1865,7 @@ sub pagespec_match_list ($$;@) { + my $spec=shift; + my @params=@_; + - my $sub=pagespec_translate($spec); + + my $sub=pagespec_translate($spec, +{}); + error "syntax error in pagespec \"$spec\"" + if $@ || ! defined $sub; + + @@ -1872,7 +1887,7 @@ sub pagespec_match_list ($$;@) { sub pagespec_valid ($) { - @@ -1748,11 +1776,78 @@ sub new { + my $spec=shift; + + - my $sub=pagespec_translate($spec); + + my $sub=pagespec_translate($spec, +{}); + return ! $@; + } + + @@ -1919,6 +1934,68 @@ sub new { package IkiWiki::PageSpec; @@ -518,15 +512,14 @@ account all comments above (which doesn't mean it is above reproach :) ). --[[W + my $page=shift; + my $specName=shift; + my %params=@_; - + - + error("Unable to find specFuncs in params to check_named_spec()!") unless exists $params{specFuncs}; + + + + return IkiWiki::ErrorReason->new("Unable to find specFuncs in params to check_named_spec()!") + + unless exists $params{specFuncs}; + + my $specFuncsRef=$params{specFuncs}; - + - + return IkiWiki::FailReason->new("Named page spec '$specName' is not valid") + + + + return IkiWiki::ErrorReason->new("Named page spec '$specName' is not valid") + unless (substr($specName, 0, 1) eq '~'); - + - + $specName = substr($specName, 1); + + if (exists $specFuncsRef->{$specName}) { + # remove the named spec from the spec refs @@ -537,7 +530,7 @@ account all comments above (which doesn't mean it is above reproach :) ). --[[W + $specFuncsRef->{$specName} = $sub; + return $result; + } else { - + return IkiWiki::FailReason->new("Page spec '$specName' does not exist"); + + return IkiWiki::ErrorReason->new("Page spec '$specName' does not exist"); + } +} + @@ -546,14 +539,14 @@ account all comments above (which doesn't mean it is above reproach :) ). --[[W + my $specName=shift; + my $funcref=shift; + my %params=@_; - + - + error("Unable to find specFuncs in params to check_named_spec_existential()!") unless exists $params{specFuncs}; + + + + return IkiWiki::ErrorReason->new("Unable to find specFuncs in params to check_named_spec_existential()!") + + unless exists $params{specFuncs}; + my $specFuncsRef=$params{specFuncs}; + - + return IkiWiki::FailReason->new("Named page spec '$specName' is not valid") + + return IkiWiki::ErrorReason->new("Named page spec '$specName' is not valid") + unless (substr($specName, 0, 1) eq '~'); - + $specName = substr($specName, 1); - + + + + if (exists $specFuncsRef->{$specName}) { + # remove the named spec from the spec refs + # when we recurse to avoid infinite recursion @@ -565,7 +558,7 @@ account all comments above (which doesn't mean it is above reproach :) ). --[[W + my $tempResult = $funcref->($page, $nextpage, %params); + if ($tempResult) { + $specFuncsRef->{$specName} = $sub; - + return $tempResult; + + return IkiWiki::SuccessReason->new("Existential check of '$specName' matches because $tempResult"); + } + } + } @@ -573,12 +566,14 @@ account all comments above (which doesn't mean it is above reproach :) ). --[[W + $specFuncsRef->{$specName} = $sub; + return IkiWiki::FailReason->new("No page in spec '$specName' was successfully matched"); + } else { - + return IkiWiki::FailReason->new("Named page spec '$specName' does not exist"); + + return IkiWiki::ErrorReason->new("Named page spec '$specName' does not exist"); + } +} + - sub match_glob ($$;@) { - my $page=shift; + sub derel ($$) { + my $path=shift; + my $from=shift; + @@ -1937,6 +2014,10 @@ sub match_glob ($$;@) { my $glob=shift; my %params=@_; @@ -586,30 +581,31 @@ account all comments above (which doesn't mean it is above reproach :) ). --[[W + return check_named_spec($page, $glob, %params); + } + - my $from=exists $params{location} ? $params{location} : ''; - - # relative matching - @@ -1782,11 +1877,12 @@ sub match_internal ($$;@) { + $glob=derel($glob, $params{location}); + + my $regexp=IkiWiki::glob2re($glob); + @@ -1959,8 +2040,9 @@ sub match_internal ($$;@) { sub match_link ($$;@) { my $page=shift; - my $link=lc(shift); - + my $fulllink=shift; + + my $fullLink=shift; my %params=@_; - + my $link=lc($fulllink); + + my $link=lc($fullLink); + $link=derel($link, $params{location}); my $from=exists $params{location} ? $params{location} : ''; - - - + - # relative matching - if ($link =~ m!^\.! && defined $from) { - $from=~s#/?[^/]+$##; - @@ -1804,19 +1900,32 @@ sub match_link ($$;@) { + @@ -1975,25 +2057,37 @@ sub match_link ($$;@) { } else { return IkiWiki::SuccessReason->new("$page links to page $p matching $link") - if match_glob($p, $link, %params); - + if match_glob($p, $fulllink, %params); + + if match_glob($p, $fullLink, %params); + $p=~s/^\///; + $link=~s/^\///; + return IkiWiki::SuccessReason->new("$page links to page $p matching $link") + - if match_glob($p, $link, %params); + + if match_glob($p, $fullLink, %params); } } return IkiWiki::FailReason->new("$page does not link to $link"); @@ -631,23 +627,24 @@ account all comments above (which doesn't mean it is above reproach :) ). --[[W sub match_created_before ($$;@) { my $page=shift; my $testpage=shift; - + my @params=@_; + my %params=@_; + - + + if (substr($testpage, 0, 1) eq '~') { - + return check_named_spec_existential($page, $testpage, \&match_created_before, @params); + + return check_named_spec_existential($page, $testpage, \&match_created_before, %params); + } + + + $testpage=derel($testpage, $params{location}); if (exists $IkiWiki::pagectime{$testpage}) { - if ($IkiWiki::pagectime{$page} < $IkiWiki::pagectime{$testpage}) { - @@ -1834,6 +1943,11 @@ sub match_created_before ($$;@) { - sub match_created_after ($$;@) { - my $page=shift; + @@ -2014,6 +2108,10 @@ sub match_created_after ($$;@) { my $testpage=shift; - + my @params=@_; - + + my %params=@_; + + if (substr($testpage, 0, 1) eq '~') { - + return check_named_spec_existential($page, $testpage, \&match_created_after, @params); + + return check_named_spec_existential($page, $testpage, \&match_created_after, %params); + } + + + $testpage=derel($testpage, $params{location}); if (exists $IkiWiki::pagectime{$testpage}) { - if ($IkiWiki::pagectime{$page} > $IkiWiki::pagectime{$testpage}) { -- cgit v1.2.3 From 5b2945cc921b222b07415ebea0c0d699f2a9dace Mon Sep 17 00:00:00 2001 From: "http://www.cse.unsw.edu.au/~willu/" Date: Fri, 22 May 2009 02:30:58 -0400 Subject: response --- doc/todo/tracking_bugs_with_dependencies.mdwn | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'doc/todo') diff --git a/doc/todo/tracking_bugs_with_dependencies.mdwn b/doc/todo/tracking_bugs_with_dependencies.mdwn index 04d5f2ba0..707790a75 100644 --- a/doc/todo/tracking_bugs_with_dependencies.mdwn +++ b/doc/todo/tracking_bugs_with_dependencies.mdwn @@ -307,6 +307,9 @@ account all comments above (which doesn't mean it is above reproach :) ). --[[W >>> But if a plugin adds its own match function, it has >>> to explicitly call that code to support named pagespecs. +>>>> Yes, and it can do that in just three lines of code. But if we automatically check for named pagespecs all the time we +>>>> potentially break any matching function that doesn't accept pages, or wants to use multiple arguments. + > * I need to check if your trick to avoid infinite recursion > works if there are two named specs that recursively > call one-another. I suspect it does, but will test this @@ -433,7 +436,7 @@ Patch updated to use closures rather than inline generated code for named pagesp - \w+\([^\)]*\) # command(params) + define\(\s*~\w+\s*,((\([^()]*\)) | ([^()]+))+\) # define(~specName, spec) - spec can contain parens 1 deep + | - + \w+\([^())]*\) # command(params) - params cannot contain parens + + \w+\([^()]*\) # command(params) - params cannot contain parens | [^\s()]+ # any other text ) -- cgit v1.2.3 From 83826b39cfefd2588da09ca427d48f11a92ea8c0 Mon Sep 17 00:00:00 2001 From: "http://www.cse.unsw.edu.au/~willu/" Date: Fri, 22 May 2009 02:36:11 -0400 Subject: response --- doc/todo/tracking_bugs_with_dependencies.mdwn | 2 ++ 1 file changed, 2 insertions(+) (limited to 'doc/todo') diff --git a/doc/todo/tracking_bugs_with_dependencies.mdwn b/doc/todo/tracking_bugs_with_dependencies.mdwn index 707790a75..6e55e46af 100644 --- a/doc/todo/tracking_bugs_with_dependencies.mdwn +++ b/doc/todo/tracking_bugs_with_dependencies.mdwn @@ -331,6 +331,8 @@ account all comments above (which doesn't mean it is above reproach :) ). --[[W >>> it shouldn't (but I haven't verified that really happens). >>> That could certianly be a show-stopper. --[[Joey]] +>>>> I think this can happen in the new closure based code. I don't think this could happen in the old code. -- [[Will]] + >>>> Even if that works, this is a good argument for having a syntactic difference between named pagespecs and normal pages. >>>> If you're joining two pagespecs with 'or', you don't want a named pagespec in the first part overriding a page name in the >>>> second part. Oh, and I assume 'or' has the right operator precedence that "a and b or c" is "(a and b) or c", and not "a and (b or c)" -- [[Will]] -- cgit v1.2.3 From 4008106c66869b8285680e90c501a91debb1652b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 22 May 2009 18:08:50 -0400 Subject: response --- doc/todo/tracking_bugs_with_dependencies.mdwn | 55 ++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) (limited to 'doc/todo') diff --git a/doc/todo/tracking_bugs_with_dependencies.mdwn b/doc/todo/tracking_bugs_with_dependencies.mdwn index 6e55e46af..b63c73916 100644 --- a/doc/todo/tracking_bugs_with_dependencies.mdwn +++ b/doc/todo/tracking_bugs_with_dependencies.mdwn @@ -257,6 +257,9 @@ account all comments above (which doesn't mean it is above reproach :) ). --[[W >>>> To fix that I'll need to pass a reference to that array into pagespec_makeperl. >>>> I think I can then do the same thing to $params{specFuncs}. -- [[Will]] +>>>>> You're right -- I did not think the recursive case through. +>>>>> --[[Joey]] + > * Seems that the only reason `match_glob` has to check for `~` is > because when a named spec appears in a pagespec, it is translated > to `match_glob("~foo")`. If, instead, `pagespec_makeperl` checked @@ -283,13 +286,18 @@ account all comments above (which doesn't mean it is above reproach :) ). --[[W >>>> and - define(aStar, a*) and link(aStar) + define(aStar, a*) and link(~aStar) >>>> In the first case, we want the pagespec to match any page that links to a page matching the glob. >>>> In the second case, we want the pagespec to match any page that links to a page matching the named spec. >>>> match_link() was already doing existential part. The patches to this code were simply to remove the `lc()` >>>> call from the named pagespec name. Can that `lc` be removed entirely? -- [[Will]] +>>>>> I think we could get rid of it. `bestlink` will lc it itself +>>>>> if the uppercase version does not exist; `match_glob` matches +>>>>> insensitively. +>>>>> --[[Joey]] + > * Generally, the need to modify `match_*` functions so that they > check for and handle named pagespecs seems suboptimal, if > only because there might be others people may want to use named @@ -310,6 +318,25 @@ account all comments above (which doesn't mean it is above reproach :) ). --[[W >>>> Yes, and it can do that in just three lines of code. But if we automatically check for named pagespecs all the time we >>>> potentially break any matching function that doesn't accept pages, or wants to use multiple arguments. +>>>>> 3 lines of code, plus the functions called become part of the API, +>>>>> don't forget about that.. +>>>>> +>>>>> Yes, I think that is the tradeoff, the question is whether to export +>>>>> the additional complexity needed for that flexability. +>>>>> +>>>>> I'd be suprised if multiple argument pagespecs become necessary.. +>>>>> with the exception of this patch there has been no need for them yet. +>>>>> +>>>>> There are lots of pagespecs that take data other than pages, +>>>>> indeed, that's really the common case. So far, none of them +>>>>> seem likely to take data that starts with a `~`. Perhaps +>>>>> the thing to do would be to check if `~foo` is a known, +>>>>> named pagespec, and if not, just pass it through unchanged. +>>>>> Then there's little room for ambiguity, and this also allows +>>>>> pagespecs like `glob(~foo*)` to match the literal page `~foo`. +>>>>> (It will make pagespec_merge even harder tho.. see below.) +>>>>> --[[Joey]] + > * I need to check if your trick to avoid infinite recursion > works if there are two named specs that recursively > call one-another. I suspect it does, but will test this @@ -339,6 +366,13 @@ account all comments above (which doesn't mean it is above reproach :) ). --[[W >>>>> Looks like its bracketed in the code anyway... -- [[Will]] +>>>> Perhaps the thing to do is to have a `clear_defines()` +>>>> function, then merging `A` and `B` yields `(A) or (clear_defines() and (B))` +>>>> That would deal with both the cases where `A` and `B` differently +>>>> define `~foo` as well as with the case where `A` defines `~foo` while +>>>> `B` uses it to refer to a literal page. +>>>> --[[Joey]] + >> Secondly, it seems that there are two types of dependency, and ikiwiki >> currently only handles one of them. The first type is "Rebuild this >> page when any of these other pages changes" - ikiwiki handles this. @@ -385,11 +419,25 @@ account all comments above (which doesn't mean it is above reproach :) ). --[[W >>>>> are inlined, the previous type handles a change in the content of any of those pages. Shortcut does not need this type of >>>>> dependency. Most of the places that use `add_depends()` seem to need this type of dependency rather than the first type. +>>>>>> Note that inline and map currently achieve the second type of dependency by +>>>>>> explicitly calling `add_depends` for each page the displayed. +>>>>>> If any of those pages are removed, the regular pagespec would not +>>>>>> match them -- since they're gone. However, the explicit dependency +>>>>>> on them does cause them to match. It's an ugly corner I'd like to +>>>>>> get rid of. --[[Joey]] + >>>>> Implementation Details: The first type of dependency can be handled very similarly to the current >>>>> dependency system. You just need to keep a list of pages that the content depends upon. You could >>>>> keep that list as a pagespec, but if you do this you might want to check that the pagespec doesn't change, >>>>> possibly by adding a dependency of the second type along with the dependency of the first type. +>>>>>> An example of the current system not tracking enough data is +>>>>>> where A inlines B which inlines C. A change to C will cause B to +>>>>>> rebuild, but A will not "notice" that B has implicitly changed. +>>>>>> That example suggests it might be fixable without explicitly storing +>>>>>> data, by causing a rebuild of B to be treated as a change to B. +>>>>>> --[[Joey]] + >>>>> The second type of dependency is a little more tricky. For each page, we'd need a list of pagespecs that >>>>> the page depended on, and for each pagespec you'd want to store the list of pages that currently match it. >>>>> On refresh, you'd need to check each pagespec to see if the set of pages that match it has changed, and if @@ -411,6 +459,11 @@ account all comments above (which doesn't mean it is above reproach :) ). --[[W Patch updated to use closures rather than inline generated code for named pagespecs. Also includes some new use of ErrorReason where appropriate. -- [[Will]] +> * Perl really doesn't need forward declarations, honest! +> * I have doubts about memoizing the anonymous sub created by +> `pagespec_translate`. +> * Think where you wrote `+{}` you can just write `{}` + ---- diff --git a/IkiWiki.pm b/IkiWiki.pm -- cgit v1.2.3 From 6c8dd33b7886641407d4036105c7a12c7e8e1dc0 Mon Sep 17 00:00:00 2001 From: "http://www.cse.unsw.edu.au/~willu/" Date: Fri, 22 May 2009 21:14:16 -0400 Subject: Response --- doc/todo/tracking_bugs_with_dependencies.mdwn | 43 +++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'doc/todo') diff --git a/doc/todo/tracking_bugs_with_dependencies.mdwn b/doc/todo/tracking_bugs_with_dependencies.mdwn index b63c73916..3a761731b 100644 --- a/doc/todo/tracking_bugs_with_dependencies.mdwn +++ b/doc/todo/tracking_bugs_with_dependencies.mdwn @@ -337,6 +337,14 @@ account all comments above (which doesn't mean it is above reproach :) ). --[[W >>>>> (It will make pagespec_merge even harder tho.. see below.) >>>>> --[[Joey]] +>>>>>> I've already used multi-argument pagespec match functions in +>>>>>> my data plugin. It is used for having different types of links. If +>>>>>> you want to have multiple types of links, then the match function +>>>>>> for them needs to take both the link name and the link type. +>>>>>> I'm trying to think of a way we could have both - automatically +>>>>>> handle the existential case unless the function indicates somehow +>>>>>> that it'll do it itself. Any ideas? -- [[Will]] + > * I need to check if your trick to avoid infinite recursion > works if there are two named specs that recursively > call one-another. I suspect it does, but will test this @@ -373,6 +381,33 @@ account all comments above (which doesn't mean it is above reproach :) ). --[[W >>>> `B` uses it to refer to a literal page. >>>> --[[Joey]] +>>>>> I don't think this will work with the new patch, and I don't think it was needed with the old one. +>>>>> Under the old patch, pagespec_makeperl() generated a string of unevaluated, self-contained, perl +>>>>> code. When a new named pagespec was defined, a recursive call was made to get the perl code +>>>>> for the pagespec, and then that code was used to add something like `$params{specFuncs}->{name} = sub {recursive code} and ` +>>>>> to the result of the calling function. This means that at pagespec testing time, when this code is executed, the +>>>>> specFuncs hash is built up as the pagespec is checked. In the case of the 'or' used above, later redefinitions of +>>>>> a named pagespec would have redefined the specFunc at the right time. It should have just worked. However... + +>>>>> Since my original patch, you started using closures for security reasons (and I can see the case for that). Unfortunately this +>>>>> means that the generated perl code is no longer self-contained - it needs to be evaluated in the same closure it was generated +>>>>> so that it has access to the data array. To make this work with the recursive call I had two options: a) make the data array a +>>>>> reference that I pass around through the pagespec_makeperl() functions and have available when the code is finally evaluated +>>>>> in pagespec_translate(), or b) make sure that each pagespec is evaluated in its correct closure and a perl function is returned, not a +>>>>> string containing unevaluated perl code. + +>>>>> I went with option b). I did it in such a way that the hash of specfuncs is built up at translation time, not at execution time. This +>>>>> means that with the new code you can call specfuncs that get defined out of order: + + ~test and define(~test, blah) + +>>>>> but it also means that using a simple 'or' to join two pagespecs wont work. If you do something like this: + + ~test and define(~test, foo) and define(~test, baz) + +>>>>> then the last definition (baz) takes precedence. +>>>>> In the process of writing this I think I've come up with a way to change this back the way it was, still using closures. -- [[Will]] + >> Secondly, it seems that there are two types of dependency, and ikiwiki >> currently only handles one of them. The first type is "Rebuild this >> page when any of these other pages changes" - ikiwiki handles this. @@ -460,10 +495,18 @@ account all comments above (which doesn't mean it is above reproach :) ). --[[W Patch updated to use closures rather than inline generated code for named pagespecs. Also includes some new use of ErrorReason where appropriate. -- [[Will]] > * Perl really doesn't need forward declarations, honest! + +>> It complained (warning, not error) when I didn't use the forward declaration. :( + > * I have doubts about memoizing the anonymous sub created by > `pagespec_translate`. + +>> This is there explicitly to make sure that runtime is polynomial and not exponential. + > * Think where you wrote `+{}` you can just write `{}` +>> Possibly :) -- [[Will]] + ---- diff --git a/IkiWiki.pm b/IkiWiki.pm -- cgit v1.2.3 From 8ae260015fa6ecd5aa39a84898f42837935c9953 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 22 May 2009 22:57:03 -0400 Subject: highlight: New plugin supporting syntax highlighting of pretty much anything. * debian/control: Add suggests for libhighlight-perl, although that package is not yet created by Debian's highlight source package. (See #529869) --- IkiWiki/Plugin/highlight.pm | 118 +++++++++++++++++++++ debian/changelog | 10 ++ debian/control | 2 +- doc/plugins/highlight.mdwn | 72 +++++++++++++ doc/style.css | 18 ++++ ..._use_of_syntax_plugin_on_source_code_files.mdwn | 3 + doc/todo/syntax_highlighting.mdwn | 28 ++--- doc/todo/syntax_highlighting/discussion.mdwn | 2 + ...wiki-formatted_comments_with_syntax_plugin.mdwn | 5 + 9 files changed, 240 insertions(+), 18 deletions(-) create mode 100644 IkiWiki/Plugin/highlight.pm create mode 100644 doc/plugins/highlight.mdwn (limited to 'doc/todo') diff --git a/IkiWiki/Plugin/highlight.pm b/IkiWiki/Plugin/highlight.pm new file mode 100644 index 000000000..f43f18628 --- /dev/null +++ b/IkiWiki/Plugin/highlight.pm @@ -0,0 +1,118 @@ +#!/usr/bin/perl +package IkiWiki::Plugin::highlight; + +use warnings; +use strict; +use IkiWiki 3.00; +use highlight; + +# locations of highlight's files +my $filetypes="/etc/highlight/filetypes.conf"; +my $langdefdir="/usr/share/highlight/langDefs"; + +sub import { + hook(type => "getsetup", id => "highlight", call => \&getsetup); + hook(type => "checkconfig", id => "highlight", call => \&checkconfig); +} + +sub getsetup () { + return + plugin => { + safe => 1, + rebuild => 1, # format plugin + }, + tohighlight => { + type => "string", + example => ".c, .h, .cpp, .pl, .py, Makefile:make", + description => "source files to syntax highlight", + safe => 1, + rebuild => 1, + }, +} + +sub checkconfig () { + if (exists $config{tohighlight}) { + foreach my $file (split /, /, $config{tohighlight}) { + my @opts = $file=~s/^\.// ? + (keepextension => 1) : + (noextension => 1); + my $ext = $file=~s/:(.*)// ? $1 : $file; + + my $langfile=ext2langfile($ext); + if (! defined $langfile) { + error(sprintf(gettext( + "tohighlight contains unknown file type '%s'"), + $ext)); + } + + hook( + type => "htmlize", + id => $file, + call => sub { + my %params=@_; + highlight($langfile, $params{content}); + }, + longname => sprintf(gettext("Source code: %s"), $file), + @opts, + ); + } + } +} + +my %ext2lang; +my $filetypes_read=0; + +# Parse highlight's config file to get extension => language mappings. +sub read_filetypes () { + open (IN, $filetypes); + while () { + chomp; + if (/^\$ext\((.*)\)=(.*)$/) { + $ext2lang{$_}=$1 foreach $1, split ' ', $2; + } + } + close IN; + $filetypes_read=1; +} + +sub langfile ($) { + return "$langdefdir/$_[0].lang"; +} + +# Given a filename extension, determines the language definition to +# use to highlight it. +sub ext2langfile ($) { + my $ext=shift; + + read_filetypes() unless $filetypes_read; + if (exists $ext2lang{$ext}) { + return langfile($ext2lang{$ext}); + } + # If a language only has one common extension, it will not + # be listed in filetypes, so check the langfile. + elsif (-e langfile($ext)) { + return langfile($ext); + } + else { + return undef; + } +} + +# Interface to the highlight C library. +sub highlight ($$) { + my $langfile=shift; + my $input=shift; + + my $gen = highlightc::CodeGenerator_getInstance($highlightc::XHTML); + $gen->setFragmentCode(1); # generate html fragment + $gen->setHTMLEnclosePreTag(1); # include stylish
+	$gen->initLanguage($langfile);
+	$gen->initTheme("/dev/null"); # theme is not needed because CSS is not emitted
+	$gen->setEncoding("utf-8");
+
+	my $output=$gen->generateString($input);
+	highlightc::CodeGenerator_deleteInstance($gen);
+	return $output;
+}
+
+1
diff --git a/debian/changelog b/debian/changelog
index 71445ea71..db3e32cda 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,13 @@
+ikiwiki (3.14) UNRELEASED; urgency=low
+
+  * highlight: New plugin supporting syntax highlighting of pretty much
+    anything.
+  * debian/control: Add suggests for libhighlight-perl, although
+    that package is not yet created by Debian's highlight source package.
+    (See #529869)
+
+ -- Joey Hess   Fri, 22 May 2009 22:03:12 -0400
+
 ikiwiki (3.13) unstable; urgency=low
 
   * ikiwiki-transition: If passed a nonexistant srcdir, or one not
diff --git a/debian/control b/debian/control
index 57c5f917a..233de8f7c 100644
--- a/debian/control
+++ b/debian/control
@@ -35,7 +35,7 @@ Suggests: viewvc | gitweb | viewcvs, libsearch-xapian-perl,
   liblocale-gettext-perl (>= 1.05-1), libtext-typography-perl,
   libtext-csv-perl, libdigest-sha1-perl, graphviz, libnet-amazon-s3-perl,
   sparkline-php, texlive, dvipng, libtext-wikicreole-perl,
-  libsort-naturally-perl, libtext-textile-perl
+  libsort-naturally-perl, libtext-textile-perl, libhighlight-perl
 Conflicts: ikiwiki-plugin-table
 Replaces: ikiwiki-plugin-table
 Provides: ikiwiki-plugin-table
diff --git a/doc/plugins/highlight.mdwn b/doc/plugins/highlight.mdwn
new file mode 100644
index 000000000..07e888f36
--- /dev/null
+++ b/doc/plugins/highlight.mdwn
@@ -0,0 +1,72 @@
+[[!template id=plugin name=highlight author="[[Joey]]"]]
+[[!tag type/format]]
+
+This plugin allows ikiwiki to syntax highlight source files, using
+a fast syntax highlighter that supports over a hundred programming
+languages and file formats.
+
+## prerequisites
+
+You will need to install the perl bindings to the
+[highlight library](http://www.andre-simon.de/), which in Debian
+are in the [[!debpkg libhighlight-perl]] package.
+
+## configuration
+
+Nothing will be highlighted by default.
+To enable syntax highlighting, use the `tohighlight` setting in your
+setup file to control which files should be syntax highlighted.
+Here is a typical setting for it, enabling highlighting for files
+with the extensions .c, etc, and also for any files named "Makefile".
+
+	tohighlight => .c, .h, .cpp, .pl, .py, Makefile:make",
+
+It knows what language to use for most filename extensions (see
+`/etc/highlight/filetypes.conf` for a partial list), but if you want to
+bind an unusual filename extension, or any file without an extension
+(such as a Makefile), to a language, you can do so by appending a colon
+and the name of the language, as illustrated for Makefiles above.
+
+## embedding highlighted code
+
+To embed highlighted code on a page, you can use the
+[[ikiwiki/directive/format]] directive.
+
+For example:
+
+	\[[!format c """
+	void main () {
+		printf("hello, world!");
+	}
+	"""]]
+
+You can do this for any of the extensions/filenames enabled in
+`tohighlight`.
+
+## colors
+
+The colors etc used for the syntax highlighting are entirely configurable
+by CSS. See ikiwiki's [[style.css]] for the defaults.
+
+## limitations
+
+With this plugin enabled, source files become full-fledged ikiwiki pages,
+which means they can include [[WikiLinks|ikiwiki/wikilink]] and
+[[directives|ikiwiki/directive]] like any other page can, and are also
+affected by the [[smiley]] plugin, if it is enabled. This can be
+annoying if your code accidentially contains things that look like those.
+
+On the other hand, this also allows your syntax highlighed
+source code to contain markdown formatted comments and hyperlinks
+to other code files, like this:
+
+	/* \[[!format mdwn """
+		This comment will be formatted as *markdown*!
+
+		See [[bar.h]].
+	""]] */
+
+## security
+
+This lets anyone who can edit a page in your wiki also edit
+source code files that are in your wiki. Use appropriate caution.
diff --git a/doc/style.css b/doc/style.css
index 74d968ddf..e6512aed8 100644
--- a/doc/style.css
+++ b/doc/style.css
@@ -389,3 +389,21 @@ span.color {
 	border: 1px solid #aaa;
 	padding: 3px;
 }
+
+/* Used by the highlight plugin. */
+
+pre.hl { color:#000000; background-color:#ffffff; }
+.hl.num { color:#2928ff; }
+.hl.esc { color:#ff00ff; }
+.hl.str { color:#ff0000; }
+.hl.dstr { color:#818100; }
+.hl.slc { color:#838183; font-style:italic; }
+.hl.com { color:#838183; font-style:italic; }
+.hl.dir { color:#008200; }
+.hl.sym { color:#000000; }
+.hl.line { color:#555555; }
+.hl.mark { background-color:#ffffbb; }
+.hl.kwa { color:#000000; font-weight:bold; }
+.hl.kwb { color:#830000; }
+.hl.kwc { color:#000000; font-weight:bold; }
+.hl.kwd { color:#010181; }
diff --git a/doc/todo/automatic_use_of_syntax_plugin_on_source_code_files.mdwn b/doc/todo/automatic_use_of_syntax_plugin_on_source_code_files.mdwn
index cd5ff34de..71b4b88f0 100644
--- a/doc/todo/automatic_use_of_syntax_plugin_on_source_code_files.mdwn
+++ b/doc/todo/automatic_use_of_syntax_plugin_on_source_code_files.mdwn
@@ -12,3 +12,6 @@ this would allow the use of ikiwiki for [[!wikipedia literate programming]].
 * I have started something along these lines see [[plugins/contrib/sourcehighlight]].  For some reason I started with source-highlight [[DavidBremner]]
 
 * I wonder if this is similar to what you want: 
+
+> The new [[plugins/highlight]] plugin is in ikiwiki core and supports
+> source code files natively. [[done]] --[[Joey]] 
diff --git a/doc/todo/syntax_highlighting.mdwn b/doc/todo/syntax_highlighting.mdwn
index 81ba19bc8..01aa7b576 100644
--- a/doc/todo/syntax_highlighting.mdwn
+++ b/doc/todo/syntax_highlighting.mdwn
@@ -28,13 +28,17 @@ things easier for the user.
   also uses source-highlight, and operates on whole source files.
   Updated to work with the fix for [[bugs/multiple_pages_with_same_name]].  Untested with files with no extension, e.g. `Makefile`.
 * [[users/jasonblevins]]'s code plugin uses source-highlight, and supports both
-  while file and directive use.
+  whole file and directive use.
 
 * [hlsimple](http://pivot.cs.unb.ca/git/?p=ikiplugins.git;a=blob_plain;f=IkiWiki/Plugin/hlsimple.pm;hb=HEAD) is a wrapper for the the perl module [[!cpan Syntax::Highlight::Engine::Simple]].  This is pure perl, pretty simple, uses css. It ought to be pretty fast (according to the author, and just because it is not external).
 On the other hand, there are not many predefined languages yet.  Defining language syntaxes is about as much 
 work as source-highlight, but in perl.  I plan to package the base module for debian. Perhaps after the author 
 releases the 5 or 6 language definitions he has running on his web site, it might be suitable for inclusion in ikiwiki. [[DavidBremner]]
 
+* [[plugins/highlight]] uses [highlight](http://www.andre-simon.de) via
+  its swig bindings. It supports whole files only. It uses either
+  keepextension or noextension, as appropriate for the type of file.
+
 ## General problems / requirements
 
 * Using non-perl syntax highlighting backends is slower. All things equal,
@@ -56,7 +60,6 @@ releases the 5 or 6 language definitions he has running on his web site, it migh
   > it has a pass-through feature that I find very useful.  My memory is unfortunately a bit fuzzy as to how
   > well the swig bindings work. [[DavidBremner]]
 
-
 * Engines that already support a wide variety of file types are of
   course preferred. If the engine doesn't support a particular type
   of file, it could fall back to doing something simple like
@@ -105,20 +108,11 @@ releases the 5 or 6 language definitions he has running on his web site, it migh
 
   Perhaps the thing to do here is to use the new `longname` parameter to
   the format hook, to give them all names that will group together at or
-  near the end of the list. Ie: "Syntax: perl", "Syntax: C", etc.
-
-## format directive and comments
-
-Hmm, the [[ikiwiki/directive/format]] directive would also allow comments
-inside source files to have mdwn embedded in them, without making the use
-of mdwn a special case, or needing to postprocess the syntax highlighter
-output to find comments.
-
-	/* \[[!format mdwn """
-
-	This is a comment in my C file. You can use mdwn in here.
+  near the end of the list. Ie: "Syntax: perl", "Source code: c", etc.
 
-	"""]] */
+---
 
-Note that this assumes that directives are expanded in source files,
-which has its own set of problems.
+I'm calling this [[done]] since I added the [[plugins/highlight]]
+plugin. There are some unresolved issues touched on here,
+but they either have the own other bug reports, or are documented
+as semi-features in the docs to the plugin. --[[Joey]] 
diff --git a/doc/todo/syntax_highlighting/discussion.mdwn b/doc/todo/syntax_highlighting/discussion.mdwn
index 7a4095c65..27cb7084b 100644
--- a/doc/todo/syntax_highlighting/discussion.mdwn
+++ b/doc/todo/syntax_highlighting/discussion.mdwn
@@ -24,3 +24,5 @@ repository?  --[[JasonBlevins]]
 >> [[sourcecode|todo/automatic_use_of_syntax_plugin_on_source_code_files/discussion]]
 >> plugin only adds the file extensions listed in the config.  This shouldn't cause
 >> massive drop-down menu pollution.  -- [[Will]]
+
+>>> That seems to be the way to go! --[[Joey]] 
diff --git a/doc/todo/wiki-formatted_comments_with_syntax_plugin.mdwn b/doc/todo/wiki-formatted_comments_with_syntax_plugin.mdwn
index a5244c9ef..7a4a295d4 100644
--- a/doc/todo/wiki-formatted_comments_with_syntax_plugin.mdwn
+++ b/doc/todo/wiki-formatted_comments_with_syntax_plugin.mdwn
@@ -2,3 +2,8 @@
 wiki syntax within the comments of code pretty-printed with the
 [[plugins/contrib/syntax]] plugin.  This would allow the use of links and
 formatting in comments.
+
+> You can do this using the [[plugins/highlight]] plugin, but you have
+> to explicitly put a format directive in the comment to do it. Thus,
+> I'm leaving this open for now.. ideally, comments would be detected,
+> and formatted as markdown. --[[Joey]] 
-- 
cgit v1.2.3


From 47298b01c1921deff7e056406245a90f8371bd59 Mon Sep 17 00:00:00 2001
From: Joey Hess 
Date: Sat, 23 May 2009 05:17:26 -0400
Subject: allow format to use any language supported by highlight

format: Provide a htmlizefallback hook that other plugins can use to
handle formats that are not suitable for general-purpose htmlize hooks.

highlight: Use the hook to allow formatting of any language/extension,
without it needing to be enabled for standalone source files.

highlight: If the highlight perl binding is not available, fallback
safely to a passthrough mode.
---
 IkiWiki/Plugin/format.pm          | 28 +++++++++++-----
 IkiWiki/Plugin/highlight.pm       | 21 +++++++++++-
 debian/changelog                  |  3 ++
 doc/plugins/highlight.mdwn        | 67 ++++++++++++++++++++-------------------
 doc/todo/syntax_highlighting.mdwn |  6 ++--
 5 files changed, 82 insertions(+), 43 deletions(-)

(limited to 'doc/todo')

diff --git a/IkiWiki/Plugin/format.pm b/IkiWiki/Plugin/format.pm
index bbe3aa9fe..1513cbed7 100644
--- a/IkiWiki/Plugin/format.pm
+++ b/IkiWiki/Plugin/format.pm
@@ -10,21 +10,33 @@ sub import {
 }
 
 sub preprocess (@) {
-	my $format=$_[0];
-	shift; shift;
-	my $text=$_[0];
-	shift; shift;
 	my %params=@_;
+	my $format=shift;
+	shift;
+	my $text=IkiWiki::preprocess($params{page}, $params{destpage}, shift);
+	shift;
 
 	if (! defined $format || ! defined $text) {
 		error(gettext("must specify format and text"));
 	}
-	elsif (! exists $IkiWiki::hooks{htmlize}{$format}) {
-		error(sprintf(gettext("unsupported page format %s"), $format));
+	elsif (exists $IkiWiki::hooks{htmlize}{$format}) {
+		return IkiWiki::htmlize($params{page}, $params{destpage},
+		                        $format, $text);
 	}
+	else {
+		# Other plugins can register htmlizefallback
+		# hooks to add support for page types
+		# not suitable for htmlize. Try them until
+		# one succeeds.
+		my $ret;
+		IkiWiki::run_hooks(htmlizefallback => sub {
+			$ret=shift->($format, $text)
+				unless defined $ret;
+		});
+		return $ret if defined $ret;
 
-	return IkiWiki::htmlize($params{page}, $params{destpage}, $format,
-		IkiWiki::preprocess($params{page}, $params{destpage}, $text));
+		error(sprintf(gettext("unsupported page format %s"), $format));
+	}
 }
 
 1
diff --git a/IkiWiki/Plugin/highlight.pm b/IkiWiki/Plugin/highlight.pm
index 117ab5898..f116c41dd 100644
--- a/IkiWiki/Plugin/highlight.pm
+++ b/IkiWiki/Plugin/highlight.pm
@@ -4,7 +4,6 @@ package IkiWiki::Plugin::highlight;
 use warnings;
 use strict;
 use IkiWiki 3.00;
-use highlight;
 
 # locations of highlight's files
 my $filetypes="/etc/highlight/filetypes.conf";
@@ -13,6 +12,9 @@ my $langdefdir="/usr/share/highlight/langDefs";
 sub import {
 	hook(type => "getsetup", id => "highlight",  call => \&getsetup);
 	hook(type => "checkconfig", id => "highlight", call => \&checkconfig);
+	# this hook is used by the format plugin
+	hook(type => "htmlizefallback", id => "highlight", call =>
+		\&htmlizefallback);
 }
 
 sub getsetup () {
@@ -59,6 +61,17 @@ sub checkconfig () {
 	}
 }
 
+sub htmlizefallback {
+	my $format=lc shift;
+	my $langfile=ext2langfile($format);
+
+	if (! defined $langfile) {
+		return;
+	}
+
+	return highlight($langfile, shift);
+}
+
 my %ext2lang;
 my $filetypes_read=0;
 
@@ -103,6 +116,12 @@ sub highlight ($$) {
 	my $langfile=shift;
 	my $input=shift;
 
+	eval q{use highlight};
+	if ($@) {
+		print STDERR gettext("warning: highlight perl module not available; falling back to pass through");
+		return $input;
+	}
+
 	my $gen = highlightc::CodeGenerator_getInstance($highlightc::XHTML);
 	$gen->setFragmentCode(1); # generate html fragment
 	$gen->setHTMLEnclosePreTag(1); # include stylish 
diff --git a/debian/changelog b/debian/changelog
index db3e32cda..8088fa705 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,9 @@ ikiwiki (3.14) UNRELEASED; urgency=low
   * debian/control: Add suggests for libhighlight-perl, although
     that package is not yet created by Debian's highlight source package.
     (See #529869)
+  * format: Provide a htmlizefallback hook that other plugins
+    can use to handle formats that are not suitable for general-purpose
+    htmlize hooks. Used by highlight.
 
  -- Joey Hess   Fri, 22 May 2009 22:03:12 -0400
 
diff --git a/doc/plugins/highlight.mdwn b/doc/plugins/highlight.mdwn
index 5172af759..44ced80f7 100644
--- a/doc/plugins/highlight.mdwn
+++ b/doc/plugins/highlight.mdwn
@@ -1,7 +1,7 @@
 [[!template id=plugin name=highlight author="[[Joey]]"]]
 [[!tag type/format]]
 
-This plugin allows ikiwiki to syntax highlight source files, using
+This plugin allows ikiwiki to syntax highlight source code, using
 a fast syntax highlighter that supports over a hundred programming
 languages and file formats.
 
@@ -11,26 +11,10 @@ You will need to install the perl bindings to the
 [highlight library](http://www.andre-simon.de/), which in Debian
 are in the [[!debpkg libhighlight-perl]] package.
 
-## configuration
-
-Nothing will be highlighted by default.
-To enable syntax highlighting, use the `tohighlight` setting in your
-setup file to control which files should be syntax highlighted.
-Here is a typical setting for it, enabling highlighting for files
-with the extensions .c, etc, and also for any files named "Makefile".
-
-	tohighlight => ".c .h .cpp .pl .py Makefile:make",
-
-It knows what language to use for most filename extensions (see
-`/etc/highlight/filetypes.conf` for a partial list), but if you want to
-bind an unusual filename extension, or any file without an extension
-(such as a Makefile), to a language, you can do so by appending a colon
-and the name of the language, as illustrated for Makefiles above.
-
 ## embedding highlighted code
 
 To embed highlighted code on a page, you can use the
-[[ikiwiki/directive/format]] directive.
+[[format]] plugin.
 
 For example:
 
@@ -40,21 +24,36 @@ For example:
 	}
 	"""]]
 
-You can do this for any of the extensions/filenames enabled in
-`tohighlight`.
+	\[[!format diff """
+	-bar
+	+foo
+	"""]]
 
-## colors
+You can do this for any extension or language name supported by
+the [highlight library](http://www.andre-simon.de/) -- basically anything
+you can think of should work.
 
-The colors etc used for the syntax highlighting are entirely configurable
-by CSS. See ikiwiki's [[style.css]] for the defaults.
+## highlighting entire source files
 
-## limitations
+To enable syntax highlighting of entire standalone source files, use the
+`tohighlight` setting in your setup file to control which files should be
+syntax highlighted. Here is a typical setting for it, enabling highlighting
+for files with the extensions .c, etc, and also for any files named
+"Makefile".
 
-With this plugin enabled, source files become full-fledged ikiwiki pages,
-which means they can include [[WikiLinks|ikiwiki/wikilink]] and
-[[directives|ikiwiki/directive]] like any other page can, and are also
-affected by the [[smiley]] plugin, if it is enabled. This can be
-annoying if your code accidentially contains things that look like those.
+	tohighlight => ".c .h .cpp .pl .py Makefile:make",
+
+It knows what language to use for most filename extensions (see
+`/etc/highlight/filetypes.conf` for a partial list), but if you want to
+bind an unusual filename extension, or any file without an extension
+(such as a Makefile), to a language, you can do so by appending a colon
+and the name of the language, as illustrated for Makefiles above.
+
+With the plugin configured this way, source files become full-fledged
+wiki pages, which means they can include [[WikiLinks|ikiwiki/wikilink]]
+and [[directives|ikiwiki/directive]] like any other page can, and are also
+affected by the [[smiley]] plugin, if it is enabled. This can be annoying
+if your code accidentially contains things that look like those.
 
 On the other hand, this also allows your syntax highlighed
 source code to contain markdown formatted comments and hyperlinks
@@ -66,7 +65,11 @@ to other code files, like this:
 		See \[[bar.h]].
 	""]] */
 
-## security
+Finally, bear in mind that this lets anyone who can edit a page in your
+wiki also edit source code files that are in your wiki. Use appropriate
+caution.
+
+## colors
 
-This lets anyone who can edit a page in your wiki also edit
-source code files that are in your wiki. Use appropriate caution.
+The colors etc used for the syntax highlighting are entirely configurable
+by CSS. See ikiwiki's [[style.css]] for the defaults.
diff --git a/doc/todo/syntax_highlighting.mdwn b/doc/todo/syntax_highlighting.mdwn
index 01aa7b576..3d122829b 100644
--- a/doc/todo/syntax_highlighting.mdwn
+++ b/doc/todo/syntax_highlighting.mdwn
@@ -36,8 +36,10 @@ work as source-highlight, but in perl.  I plan to package the base module for de
 releases the 5 or 6 language definitions he has running on his web site, it might be suitable for inclusion in ikiwiki. [[DavidBremner]]
 
 * [[plugins/highlight]] uses [highlight](http://www.andre-simon.de) via
-  its swig bindings. It supports whole files only. It uses either
-  keepextension or noextension, as appropriate for the type of file.
+  its swig bindings. It optionally supports whole files, but also
+  integrates with the format directive to allow formatting of *any* of
+  highlight's supported formats. (For whole files, it uses either
+  keepextension or noextension, as appropriate for the type of file.)
 
 ## General problems / requirements
 
-- 
cgit v1.2.3


From 5c4d806f0146e9fc9ccc7f82cf9e70c8bb0b50eb Mon Sep 17 00:00:00 2001
From: "http://lj.rossia.org/users/imz/" 
Date: Mon, 25 May 2009 10:13:19 -0400
Subject: New wish.

---
 doc/todo/section-numbering.mdwn | 5 +++++
 1 file changed, 5 insertions(+)
 create mode 100644 doc/todo/section-numbering.mdwn

(limited to 'doc/todo')

diff --git a/doc/todo/section-numbering.mdwn b/doc/todo/section-numbering.mdwn
new file mode 100644
index 000000000..6f8c44a4c
--- /dev/null
+++ b/doc/todo/section-numbering.mdwn
@@ -0,0 +1,5 @@
+[[!tag wishlist]]
+
+Optional automatic section numbering would help reading: otherwise, a reader (like me) gets lost in the structure of a long page.
+
+I guess it is implementable with complex CSS... but one has first to compose this CSS in any case. So, this wish still has a todo status.
-- 
cgit v1.2.3


From 7d3b0018e600a2da44d572fd99634bd7d4371bc2 Mon Sep 17 00:00:00 2001
From: "http://lj.rossia.org/users/imz/" 
Date: Tue, 26 May 2009 08:14:37 -0400
Subject: Added a reason for this to be an ikiwiki's concern.

---
 doc/todo/section-numbering.mdwn | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

(limited to 'doc/todo')

diff --git a/doc/todo/section-numbering.mdwn b/doc/todo/section-numbering.mdwn
index 6f8c44a4c..3a2d232a8 100644
--- a/doc/todo/section-numbering.mdwn
+++ b/doc/todo/section-numbering.mdwn
@@ -2,4 +2,6 @@
 
 Optional automatic section numbering would help reading: otherwise, a reader (like me) gets lost in the structure of a long page.
 
-I guess it is implementable with complex CSS... but one has first to compose this CSS in any case. So, this wish still has a todo status.
+I guess it is implementable with complex CSS... but one has first to compose this CSS in any case. So, this wish still has a todo status. --Ivan Z.
+
+And another aspect why this is related to ikiwiki, not just authoring a CSS, is that the style of the numbers (genereated by CSS probably) should match the style of the numbers in ikiwiki's [[plugins/toc]]. --Ivan Z.
-- 
cgit v1.2.3


From df4cc4c16ca230ee99b80c80043ba54fb95f6e71 Mon Sep 17 00:00:00 2001
From: "http://lj.rossia.org/users/imz/" 
Date: Tue, 26 May 2009 11:34:35 -0400
Subject: One more suggestion for the wiki-synatx.

---
 doc/todo/matching_different_kinds_of_links.mdwn | 10 ++++++++++
 1 file changed, 10 insertions(+)

(limited to 'doc/todo')

diff --git a/doc/todo/matching_different_kinds_of_links.mdwn b/doc/todo/matching_different_kinds_of_links.mdwn
index b71d7cc5f..1d7c78d90 100644
--- a/doc/todo/matching_different_kinds_of_links.mdwn
+++ b/doc/todo/matching_different_kinds_of_links.mdwn
@@ -35,3 +35,13 @@ Besides pagespecs, the `rel=` attribute could be used for styles. --Ivan Z.
 > was not available, which is why I didn't make it differentiate from
 > normal links.) Might be better to go ahead and add the variable to
 > core though. --[[Joey]] 
+
+I saw somewhere else here soem suggestions for the wiki-syntax for specifying the relation name of a link. One more suggestion---[the syntax used in Semantic MediaWiki](http://en.wikipedia.org/wiki/Semantic_MediaWiki#Basic_usage), like this:
+
+
+... the capital city is \[[Has capital::Berlin]] ...
+
+ +So a part of the effect of `\[[!taglink TAG]]` could be represented as something like `\[[tag::TAG]]` or (more understandable relation name in what concerns the direction) `\[[tagged::TAG]]`. + +I don't have any opinion on this syntax (whether it's good or not)...--Ivan Z. -- cgit v1.2.3 From 9b4c83127fdef0ceb682c104db9bfb321b17022e Mon Sep 17 00:00:00 2001 From: "http://lj.rossia.org/users/imz/" Date: Tue, 26 May 2009 11:51:48 -0400 Subject: Added a wikilink (for connectivity). --- doc/todo/matching_different_kinds_of_links.mdwn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'doc/todo') diff --git a/doc/todo/matching_different_kinds_of_links.mdwn b/doc/todo/matching_different_kinds_of_links.mdwn index 1d7c78d90..26c5a072b 100644 --- a/doc/todo/matching_different_kinds_of_links.mdwn +++ b/doc/todo/matching_different_kinds_of_links.mdwn @@ -36,12 +36,12 @@ Besides pagespecs, the `rel=` attribute could be used for styles. --Ivan Z. > normal links.) Might be better to go ahead and add the variable to > core though. --[[Joey]] -I saw somewhere else here soem suggestions for the wiki-syntax for specifying the relation name of a link. One more suggestion---[the syntax used in Semantic MediaWiki](http://en.wikipedia.org/wiki/Semantic_MediaWiki#Basic_usage), like this: +I saw somewhere else here some suggestions for the wiki-syntax for specifying the relation name of a link. One more suggestion---[the syntax used in Semantic MediaWiki](http://en.wikipedia.org/wiki/Semantic_MediaWiki#Basic_usage), like this:
 ... the capital city is \[[Has capital::Berlin]] ...
 
-So a part of the effect of `\[[!taglink TAG]]` could be represented as something like `\[[tag::TAG]]` or (more understandable relation name in what concerns the direction) `\[[tagged::TAG]]`. +So a part of the effect of [[`\[[!taglink TAG\]\]`|plugins/tag]] could be represented as something like `\[[tag::TAG]]` or (more understandable relation name in what concerns the direction) `\[[tagged::TAG]]`. I don't have any opinion on this syntax (whether it's good or not)...--Ivan Z. -- cgit v1.2.3 From 86b67554c17dd9dc26142f02911ae07348b0c94b Mon Sep 17 00:00:00 2001 From: "http://lj.rossia.org/users/imz/" Date: Tue, 26 May 2009 12:47:46 -0400 Subject: A wish. --- doc/todo/target_filter_for_brokenlinks.mdwn | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 doc/todo/target_filter_for_brokenlinks.mdwn (limited to 'doc/todo') diff --git a/doc/todo/target_filter_for_brokenlinks.mdwn b/doc/todo/target_filter_for_brokenlinks.mdwn new file mode 100644 index 000000000..53347279d --- /dev/null +++ b/doc/todo/target_filter_for_brokenlinks.mdwn @@ -0,0 +1,11 @@ +[[!tag wishlist]] + +Currently, [[plugins/brokenlinks]] supports filtering by the place where a broken wikilink is used. + +Filtering by the target of the broken link would also be useful, e.g., + +
+\[[!brokenlinks matching="tagbase/*"]]
+
+ +would list the tags not yet "filled out". --Ivan Z. -- cgit v1.2.3 From b1695647f63d27103e078a5b546b746973148ef2 Mon Sep 17 00:00:00 2001 From: "http://lj.rossia.org/users/imz/" Date: Tue, 26 May 2009 12:52:40 -0400 Subject: minor invisible: I learned how to mark up code examples. --- doc/todo/target_filter_for_brokenlinks.mdwn | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'doc/todo') diff --git a/doc/todo/target_filter_for_brokenlinks.mdwn b/doc/todo/target_filter_for_brokenlinks.mdwn index 53347279d..137277c21 100644 --- a/doc/todo/target_filter_for_brokenlinks.mdwn +++ b/doc/todo/target_filter_for_brokenlinks.mdwn @@ -4,8 +4,6 @@ Currently, [[plugins/brokenlinks]] supports filtering by the place where a broke Filtering by the target of the broken link would also be useful, e.g., -
-\[[!brokenlinks matching="tagbase/*"]]
-
+ \[[!brokenlinks matching="tagbase/*"]] would list the tags not yet "filled out". --Ivan Z. -- cgit v1.2.3 From 67cdee214b67d6f178570ae3ee9bdd6c137a7fb1 Mon Sep 17 00:00:00 2001 From: "http://lj.rossia.org/users/imz/" Date: Tue, 26 May 2009 21:03:18 -0400 Subject: Added links to related work. --- doc/todo/latex.mdwn | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'doc/todo') diff --git a/doc/todo/latex.mdwn b/doc/todo/latex.mdwn index 604c5e87f..f374f332b 100644 --- a/doc/todo/latex.mdwn +++ b/doc/todo/latex.mdwn @@ -7,10 +7,14 @@ render via [HeVeA](http://pauillac.inria.fr/~maranget/hevea/index.html), similar. Useful for mathematics, as well as for stuff like the LaTeX version of the ikiwiki [[/logo]]. +> [[users/Jason Blevins]] has also a plugin for including [[LaTeX]] expressions (by means of `itex2MML`) -- [[plugins/mdwn_itex]] (look at his page for the link). --Ivan Z. + ---- ikiwiki could also support LaTeX as a document type, again rendering to HTML. +> [[users/Jason Blevins]] has also a [[plugins/pandoc]] plugin (look at his page for the link): in principle, [Pandoc](http://johnmacfarlane.net/pandoc/) can read and write [[LaTeX]]. --Ivan Z. + ---- Conversely, how about adding a plugin to support exporting to LaTeX? @@ -25,6 +29,8 @@ Conversely, how about adding a plugin to support exporting to LaTeX? >>>> Interesting, just yesterday I was playing with pandoc to make PDFs from my Markdown. Could someone advise me on how to embed these PDFs into ikiwiki? I need some guidance in implementing this. --[[JosephTurian]] +>>>> [[users/Jason Blevins]] has a [[plugins/pandoc]] plugin (look at his page for the link). --Ivan Z. + ---- [here](http://ng.l4x.org/gitweb/gitweb.cgi?p=ikiwiki.git/.git;a=blob;f=IkiWiki/Plugin/latex.pm) is a first stab at -- cgit v1.2.3 From d1553bd361dd6c87470618a82cce27dea670496b Mon Sep 17 00:00:00 2001 From: "http://lj.rossia.org/users/imz/" Date: Tue, 26 May 2009 21:07:18 -0400 Subject: Made the links to the userpage work in the prev.edit. --- doc/todo/latex.mdwn | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'doc/todo') diff --git a/doc/todo/latex.mdwn b/doc/todo/latex.mdwn index f374f332b..4363003c1 100644 --- a/doc/todo/latex.mdwn +++ b/doc/todo/latex.mdwn @@ -7,13 +7,13 @@ render via [HeVeA](http://pauillac.inria.fr/~maranget/hevea/index.html), similar. Useful for mathematics, as well as for stuff like the LaTeX version of the ikiwiki [[/logo]]. -> [[users/Jason Blevins]] has also a plugin for including [[LaTeX]] expressions (by means of `itex2MML`) -- [[plugins/mdwn_itex]] (look at his page for the link). --Ivan Z. +> [[users/JasonBlevins]] has also a plugin for including [[LaTeX]] expressions (by means of `itex2MML`) -- [[plugins/mdwn_itex]] (look at his page for the link). --Ivan Z. ---- ikiwiki could also support LaTeX as a document type, again rendering to HTML. -> [[users/Jason Blevins]] has also a [[plugins/pandoc]] plugin (look at his page for the link): in principle, [Pandoc](http://johnmacfarlane.net/pandoc/) can read and write [[LaTeX]]. --Ivan Z. +> [[users/JasonBlevins]] has also a [[plugins/pandoc]] plugin (look at his page for the link): in principle, [Pandoc](http://johnmacfarlane.net/pandoc/) can read and write [[LaTeX]]. --Ivan Z. ---- @@ -29,7 +29,7 @@ Conversely, how about adding a plugin to support exporting to LaTeX? >>>> Interesting, just yesterday I was playing with pandoc to make PDFs from my Markdown. Could someone advise me on how to embed these PDFs into ikiwiki? I need some guidance in implementing this. --[[JosephTurian]] ->>>> [[users/Jason Blevins]] has a [[plugins/pandoc]] plugin (look at his page for the link). --Ivan Z. +>>>> [[users/JasonBlevins]] has a [[plugins/pandoc]] plugin (look at his page for the link). --Ivan Z. ---- -- cgit v1.2.3 From 95e3e2d352b43e88a4ad87ef6d25ec53a7474422 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 3 Jun 2009 15:46:47 -0400 Subject: fix link, remove redirection page There was only one broken links. See plugins/brokenlinks for a list. --- doc/plugins/mailbox.mdwn | 3 --- doc/todo/mbox.mdwn | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) delete mode 100644 doc/plugins/mailbox.mdwn (limited to 'doc/todo') diff --git a/doc/plugins/mailbox.mdwn b/doc/plugins/mailbox.mdwn deleted file mode 100644 index d3646486c..000000000 --- a/doc/plugins/mailbox.mdwn +++ /dev/null @@ -1,3 +0,0 @@ -[[!meta redir=contrib/mailbox]] - -Redirecting to [[contrib/mailbox]]. diff --git a/doc/todo/mbox.mdwn b/doc/todo/mbox.mdwn index 31e4a9863..a6af0c3c5 100644 --- a/doc/todo/mbox.mdwn +++ b/doc/todo/mbox.mdwn @@ -3,7 +3,7 @@ I'd like to be able to drop an unmodified RFC2822 email message into ikiwiki, an > We're discussing doing just that (well, whole mailboxes, really) over in > [[comment_by_mail]] --[[Joey]] >> The ->> [[plugins/mailbox]] +>> [[plugins/contrib/mailbox]] >> plugin is roughly feature complete at this point. It can read mbox, maildir, and >> MH folders, does threading, and deals with MIME (now with >> pagespec based sanity checking). No doubt lots of things could be -- cgit v1.2.3 From e78883e07fc518cea2315b3765631d747550905a Mon Sep 17 00:00:00 2001 From: Lunar Date: Fri, 5 Jun 2009 13:22:03 +0200 Subject: Some thoughts on how to disable 'Preferences' link when irrelevant --- doc/todo/Allow_disabling_edit_and_preferences_links.mdwn | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'doc/todo') diff --git a/doc/todo/Allow_disabling_edit_and_preferences_links.mdwn b/doc/todo/Allow_disabling_edit_and_preferences_links.mdwn index a356c69df..5b9cc8742 100644 --- a/doc/todo/Allow_disabling_edit_and_preferences_links.mdwn +++ b/doc/todo/Allow_disabling_edit_and_preferences_links.mdwn @@ -52,3 +52,18 @@ Patch: >>> is not controlled by any plugin. It would be nice if it were; I am >>> trying to achieve a configuration where the only action supported >>> via CGI is blog-style comments. --[Zack](http://zwol.livejournal.com/) + +>>> Like [[puck]], I'd like to keep search available but I want to disable all +>>> login facitilities and thus disable the "Preferences" link. +>>> +>>> After digging a little bit in the source code, my first attempt was to make +>>> the "Preferences" link appear only if there is `sessioncgi` hooks +>>> registered. But this will not work as the [[plugins/inline]] plugin also +>>> defines it. +>>> +>>> Looking for `auth` hooks currently would not work as at least +>>> [[plugins/passwordauth]] does not register one. +>>> +>>> Adding a new `canlogin` hook looks like overkill to me. [[Joey]], how +>>> about making registration of the `auth` hook mandatory for all plugins +>>> making sense of the "Preferences" link? --[[Lunar]] -- cgit v1.2.3