Add a new-tabbed variant for the Replite
directive, and allow customisation of its button text
#228
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This continues #165, #223, and #227 for the Replite directive. We do not subclass from the
BaseNotebookTab
class here since we need to construct a URL with quoted code that has been passed to the directive (similar to theTryExamples
directive).I was initially unsure about doing this as I mentioned in #227 (comment), but the implementation seems to be in line enough with that for other directives and felt straightforward to me. This PR shall bring feature parity for all four major directives, and all five directives can now have new-tabbed variants. As a plus, customisation is allowed for this directive's new-tab button text as well, either by a global
replite_button_text
value or on a per-directive basis.Changes made
RepliteTab
class that inherits fromdocutils.nodes.Element
. Here, we construct a URL for the REPL based on the input; and we return it when the:new_tab:
option is enabled; otherwise, we returnRepliteIframe
instead.replite_button_text
option forconf.py
, and a sample directive added to showcase Replite opening in a new tab.