Hi Mark,

2013/7/7 Mark Elston <[email protected]>:
> I have been using sphinx to document some teaching notes and it has worked
> pretty well for my needs when I generate HTML.  I have been able to make use
> of the 'container' directive to style different kinds of text blocks in
> different ways since the HTML output adds a class attribute to the generated
> div block.
>
> However, I would like to do the same thing with latex output so I can
> generate PDF output with these text blocks as named environments (I have a
> custom style file with these environments already set up).
>
> However, the current latex translator/writer ignores container directives
> (the visit/depart methods just have 'pass').  My first thought is that I
> could create a subclass of LaTeXTranslator that simply implements these
> visitor methods as follows:
>
>     def visit_container(self, node):
>         self.out.append(r'\begin{')
>         self.out.append(node['name'])
>         self.out.append(r'}')
>
>     def depart_container(self, node):
>         self.out.append(r'\end{')
>         self.out.append(node['name'])
>         self.out.append(r'}')
>
> I don't know if this is sufficient for the translator or not.

I think the user is not a lot, but I think that it is sufficient and useful.
Please submit the request to the issue tracker ;)


> I have tried to create new translator/writer classes which seems to require
> a new builder class as well.  However, I am getting bogged down trying to
> understand how to write these classes and how to integrate them into my
> environment.
>
> Any help or pointers would be appreciated.

So if you want to register a new builder with a new name, then these
will be helpful:
- Reference: 
http://sphinx-doc.org/ext/appapi.html#sphinx.application.Sphinx.add_builder
- My builder extension:
https://bitbucket.org/shimizukawa/rst2textile/src/5590827/docutils_textile/__init__.py

Or if you want to override a part of function of built-in
LaTeXTranslator, you can use monkey patching.

Regards,
--
Takayuki SHIMIZUKAWA
http://about.me/shimizukawa

-- 
You received this message because you are subscribed to the Google Groups 
"sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sphinx-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to