Cool!
I added syntaxify.addLanguages to do this, but I can see now that the
order of plugin loading is important.
The simple answer is to name your Haskell plugin something that comes
after the name of your syntaxify plugin ("Plugin: Syntaxify"). (And
call syntaxify.addLanguages with a data structure similar to that in the
plugin)
This is hardly satisfactory though. It would be very nice to have a
depends-on: qualifier of some sort. But that in turn requires some way
to identify the plugin that is independent of what you named the
tiddler. (Surely not everyone likes my choice of "Plugin: Syntaxify" --
I know lots of plugins named SomethingPlugin instead)
Anyone want to chime in on this? Perhaps it would be useful for plugin
writers to register themselves with the PluginManager?
Conal Elliott [conal....@gmail.com] wrote:
> I want to create a simple formatter that takes tiddler content like
>
> \begin{code}
> >my code goes here
> >\end{code}
> >
>
> and treats it exactly as
>
> {{haskell{
> >my code goes here
> >}}}
>
>
> The reason I want to enter the former instead of the latter is so that my
> tiddler content can be interpreted as a literate Haskell program (where text
> is treated as comments unless surrounded by \begin{code} and \end{code}).
>
> I'm guessing this sort of thing is trivial for someone who knows their way
> around the TW source, but I haven't been able to figure it out.
>
> I'm using ZiddlyWiki, and my html says version 2.0.11.
>
> I'd love some suggestions.
Another good question... (you don't hang out on axiom-developer, do you?
;)
Take a look at http://bob.mcelrath.org/tiddlyjsmath.html which creates
\begin{equation}...\end{equation}. I would be quite interested in a
faux-latex wikifier, if you want to work on that. But anyway the markup
is pretty trivial, the only non-trivial thing is that you really should
introduce the backslash as an escape character (as is done in that
plugin).
--
Cheers,
Bob McElrath [Univ. of California at Davis, Department of Physics]
"The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all progress
depends on the unreasonable man."
-- George Bernard Shaw, Maxims for Revolutionists
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFFlLOljwioWRGe9K0RAi1LAKCvyNUMd8jDLDy9H3O1YqJCmYl4vQCgxfOh
QIDjdmci/Bh+7NVz/SCMPq4=
=RpNx
-----END PGP SIGNATURE-----
As you've gathered, there's currently no decent way of doing this
apart from using the alphabetical ordering of tiddler titles, as Bob
suggests.
There is another approach I've considered that may solve the problem
quite neatly, though, and I'd be interested to see what people think.
The idea is to allow plugins to have a return value. Usually, the
return value will be something indicating "OK" (and indeed for
backwards compatibility, plugins that don't return a value would be
assumed to return "OK"). It is also possible for plugins to return the
value "NOTYET" which means "I haven't yet executed because something
I'm dependent upon hasn't happened yet". In that case, the plugin
framework will move onto the remaining plugins and try to execute
those before returning to the original plugin and trying again.
So, for example, your plugin could start with code like this:
if(!bobsPluginIsLoaded)
return NOTYET
// Do our processing here
return OK
This is pretty easy to implement - the only point to watch is that the
plugin framework should bail out if a complete cycle of plugins return
NOTYET.
Not sure if that makes sense, but it appears to allow for fairly
complex chains of dependency with reasonably robust deadlock recovery.
Cheers
Jeremy
--
Jeremy Ruston
mailto:jer...@osmosoft.com
http://www.tiddlywiki.com
That sounds like a great idea -- simple to code and understand, and
flexible enough for just about anything.
There's only two things it seems not to cover:
- plugin A wants to be loaded after plugin B, but only if plugin B is
present. If plugin B isn't there, then plugin A can still be loaded.
- plugin A wants to be loaded _before_ plugin B.
They're pretty obscure, just figured they should be out there. If
plugins had reliably unique identifiying strings, you could solve the
first case by providing each plugin with the list of plugins loaded
and plugins yet-to-load.
I think the deadlock detection will still hold true even if you're
passing plugins a plugin list.
And come to think of it, then you could solve the second situation by
the author of A asking the author of B to load after A, if A is
present.
I haven't really thought this through so maybe I've missed something..
;Daniel
--
Daniel Baird
http://tiddlyspot.com (free, effortless TiddlyWiki hosting)
http://danielbaird.com (TiddlyW;nks! :: Whiteboard Koala :: Blog ::
Things That Suck)
Given that several different versions of a plugin, slightly modified by
several different authors may exist... we also need a reliable way to
answer the question "is plugin X loaded".
I guess we want to use here
if(version.extensions.Syntaxify == undefined) {
return NOTYET;
}
if(version.extensions.Syntaxify.major != 1) {
return INCOMPATIBLE;
}
The scheme you suggest also needs a well-defined termination point.
That is, imagine you have plugins A and B both of which return NOTYET.
TW doesn't know whether A depends on B or vice-versa. It might run A,
then B, then A, then B... I suppose a good way to define the endpoint is
if the list of plugins loaded is the same after running all un-run
plugins, and having them return NOTYET. Of course this indicates some
dependency is simply not satisfied.
Any chance we can get this into the next 2.2 beta?
Cheers,
-- Bob
> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google Groups
> "TiddlyWiki" group.
> To post to this group, send email to Tiddl...@googlegroups.com
> To unsubscribe from this group, send email to
> TiddlyWiki-...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/TiddlyWiki?hl=en
> -~----------~----~----~----~------~----~------~--~---
That was what I reckoned too.
> The scheme you suggest also needs a well-defined termination point.
> That is, imagine you have plugins A and B both of which return NOTYET.
> TW doesn't know whether A depends on B or vice-versa. It might run A,
> then B, then A, then B... I suppose a good way to define the endpoint is
> if the list of plugins loaded is the same after running all un-run
> plugins, and having them return NOTYET. Of course this indicates some
> dependency is simply not satisfied.
I think that's the right approach: drop out after 'n' sweeps of the
un-run plugins if no plugin changes it's stage. As you say, 'n' must
be greater than 1; it seems as though n should be 2, what do you
reckon?
> Any chance we can get this into the next 2.2 beta?
Sure, I'll take patches in the usual way :)
Best wishes
Jeremy
> > > --
> Cheers,
> Bob McElrath [Univ. of California at Davis, Department of Physics]
>
> "The reasonable man adapts himself to the world; the unreasonable one
> persists in trying to adapt the world to himself. Therefore all progress
> depends on the unreasonable man."
> -- George Bernard Shaw, Maxims for Revolutionists
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
>
> iD8DBQFFlWWQjwioWRGe9K0RAjVmAJ0d9frdUJJowOnAkEv03L96gkn8JwCePIK9
> AQ2RAfjuFHltcoHfNWhQ3yE=
> =U8Wn
> -----END PGP SIGNATURE-----
I thought about that idea, but figured on a couple of factors:
- it requires that plugins have their official title; at the moment,
TW lets users rename their plugins quite freely. It's not so much that
renaming the plugins is a hugely useful feature, more that it's a
level of robustness that makes the overall system more forgiving.
- it changes the semantics of plugins by adding metadata (whether tags
or extended fields) outside of the plugin content itself.
- it restricts the dependencies that can be expressed. The beauty of
the NOTYET mechanism is that it very flexibly allows complex
dependencies (such as "install if pluginA OR pluginB is installed" or
"if we're on Windows, require pluginW"). Under the declarative
approach, each of these scenarios would need to be specifically
catered for in the syntax used in the tag or field.
- from an implementation perspective, detecting and dealing with
cyclic dependencies seems more complex under your proposal - one would
have to pre-compute some kind of dependency graph in order to figure
out where to start
Cheers
Jeremy
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
> I guess we want to use here
> if( version.extensions.Syntaxify == undefined) {
I think that's the right approach: drop out after 'n' sweeps of the
un-run plugins if no plugin changes it's stage. As you say, 'n' must
be greater than 1; it seems as though n should be 2, what do you
reckon?
- Suppose my plugin can work with "pluginA OR pluginB installed", but prefers pluginB. I don't know how it could decide when to settle for pluginA and when to hold out in hope of pluginB.
Mechanical: how can a plugin return NOTYET or any value at all? Isn't plugin code simply evaluated for its side-effect?
Somewhat off-topic, but TW explicitly loads StyleSheet last, after
StyleSheetLayout etc, so that you put your overriding CSS into
StyleSheet and it's guaranteed to override, if you get your
specificity right. Unfortunately CSS specificity is quite hard to get
right..
;D
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
I'm guessing you've confirmed that the Syntaxify plugin is actually
getting loaded properly itself.. maybe try looking for something you
know is in versions.extensions, to see if you are looking at the right
thing?
And is it version.extensions.Syntaxify or version.extensions.syntaxify
that you are checking?
Otherwise maybe post a URL so we can have a fiddle :)
;Daniel