Skip to content

Allow specifying custom check icon svg #203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sphinx_copybutton/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def add_to_context(app, config):
config.copybutton_image_svg = path.read_text()

config.html_context.update({"copybutton_image_svg": config.copybutton_image_svg})
config.html_context.update({"checkbutton_image_svg": config.checkbutton_image_svg})
config.html_context.update({"copybutton_selector": config.copybutton_selector})
config.html_context.update(
{
Expand Down Expand Up @@ -80,6 +81,8 @@ def setup(app):
app.add_config_value("copybutton_line_continuation_character", "", "html")
app.add_config_value("copybutton_here_doc_delimiter", "", "html")
app.add_config_value("copybutton_image_svg", "", "html")
app.add_config_value("checkbutton_image_svg", "", "html")
app.add_config_value("c", "", "html")
app.add_config_value("copybutton_selector", "div.highlight pre", "html")
app.add_config_value("copybutton_exclude", ".linenos", "html")

Expand Down
8 changes: 6 additions & 2 deletions sphinx_copybutton/_static/copybutton.js_t
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,17 @@ if (doc_url_root == '#') {
}

/**
* SVG files for our copy buttons
* SVG files for our icons, if the user specified their own SVG use that, otherwise use the default
*/
let iconCheck = `<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-check" width="44" height="44" viewBox="0 0 24 24" stroke-width="2" stroke="#22863a" fill="none" stroke-linecap="round" stroke-linejoin="round">

let iconCheck = `{{ checkbutton_image_svg }}`;
if (!iconCheck) {
iconCopy = `<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-check" width="44" height="44" viewBox="0 0 24 24" stroke-width="2" stroke="#22863a" fill="none" stroke-linecap="round" stroke-linejoin="round">
<title>${messages[locale]['copy_success']}</title>
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
<path d="M5 12l5 5l10 -10" />
</svg>`
}

// If the user specified their own SVG use that, otherwise use the default
let iconCopy = `{{ copybutton_image_svg }}`;
Expand Down