Ron,
On Thursday, September 23, 2021 at 10:37:45 AM UTC-4 Ron Stone wrote:
> Trying to combine sphinx-prompt (for standardized, non selectable prompts)
> and confluence-builder is resulting in no content appearing where code
> should be displayed in the output when the viewing the published confluence
> pages.
>
> Has anyone gotten them working together?
>
Unfortunately, the sphinx-prompt extension only generates raw HTML (or
LaTeX) nodes, which cannot be processed by
the sphinxcontrib-confluencebuilder extension (hence why the empty blocks).
A crude workaround if you wanted you target multiple builders (e.g. HTML
and Confluence), you could inject the following in your documentation's
configuration:
```
from docutils import nodes
import importlib
sphinx_prompt = importlib.import_module('sphinx-prompt')
class PromptDirectiveOverride(sphinx_prompt.PromptDirective):
def run(self):
text = '\n'.join(self.content)
lang = self.options.get('language') or 'text'
new_node = nodes.literal_block(text, text)
new_node['language'] = lang
return [ new_node ]
def setup(app):
app.connect('builder-inited', builder_inited)
def builder_inited(app):
if app.builder.name not in ('html', 'latex'):
app.add_directive('prompt', PromptDirectiveOverride, override=True)
```
Note that this only makes a simple literal block for this sections so
content can be processing by the translator (e.g. Confluence will generate
code blocks). You would not gain the advantage of non-selectable prompts in
Confluence; however, you will at least be able to see the content in
Confluence.
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/sphinx-users/563fb452-0eff-4751-bbf7-02bef57f127an%40googlegroups.com.