sphinx-contrib/datatemplates

Use extra Jinja-Environment?

janbrohl opened this issue · 6 comments

Should we really use the Sphinx builder's Jinja Environment? At least escaping propably depends on the builder. Do we want that?

I'm not sure what you mean about escaping, can you elaborate?

Jinja supports auto-escaping potentially problematic strings ( https://jinja.palletsprojects.com/en/2.10.x/api/#autoescaping ) which may or may not be enabled depending on the environment (builder).
Using an independent environment would provide seperately defined template paths, defined auto-escape setting, more similarity to direct command line usage.

If each builder configures the environment with different escaping rules, don't we want those builder-specific settings? Or maybe not, since they are language-specific (HTML vs. RST)?

We would want ReST escaping as that is what we parse with sphinx.util.nodes.nested_parse_with_titles. Generating HTML is not our business, sphinx does that.

I could see escaping being useful, but I could also see it being useful to have embedded RST in the data that a user wants rendered. So it's fine if we make escaping the default, but there needs to be a way to turn it off.

As stated in #60 how to escape depends on context so not escaping by default but having escape functions or filters seems more doable.
So we just want autoescaping off, I think.