Hello, I'd like to add a role ``:foto:`` which in html simply inserts a clickable image to a remote image gallery.
Example:: :foto:`bar/123.jpg` would generate the following html:: <a href="http://foo.com/show/bar/123.jpg"> <img src="http://foo.com/thumb/bar/123.jpg"/> </a> latex would require a local mirror of the gallery and would generate something like:: \includepicture{/home/foo/fotos/bar/123.jpg} But latex is not (yet) my problem, I'd be glad to get the html build running. Here is what I've done so far. I admit that some parts are simply guess-and-try programming because I am a beginner with docutils extensions. Can somebody give me a hand to get this running? For the moment I get the following traceback:: File "l:\snapshots\sphinx\sphinx\environment.py", line 829, in read_doc pickle.dump(doctree, f, pickle.HIGHEST_PROTOCOL) PicklingError: Can't pickle <class 'foto_node'>: attribute lookup __builtin__.foto_node failed Here is what I added to my `conf.py`: from docutils import nodes from docutils import utils from docutils.parsers.rst.roles import set_classes class foto_node(nodes.General, nodes.Inline, nodes.Element): def astext(self): return self.get('alt', '') def visit_foto_node(self, node): print "visit_foto_node(%r, node)" % self self.visit_admonition(node) def depart_foto_node(self, node): self.depart_admonition(node) def foto_role(name, rawtext, text, lineno, inliner, options={}, content=[]): config = inliner.document.settings.env.config src = config.fotos_base_url_src + text href = config.fotos_base_url_href + text set_classes(options) img = foto_node(src=src,alt=text,title=text,**options) node = nodes.reference(rawtext, utils.unescape(text), img, refuri=href) return [node], [] def setup(app): app.add_config_value('fotos_base_url_src', "http://foo.com/thumb/", True) app.add_config_value('fotos_base_url_href', "http://foocom/show/", True) app.add_config_value('fotos_base_path', "/home/foo/fotos/", True) app.add_node(foto_node, html=(visit_foto_node, depart_foto_node), text=(visit_foto_node, depart_foto_node)) app.add_role('foto', foto_role) Luc -- You received this message because you are subscribed to the Google Groups "sphinx-dev" group. To post to this group, send email to sphinx-dev@googlegroups.com. To unsubscribe from this group, send email to sphinx-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sphinx-dev?hl=en.