3

We have sphinx documentation with 1000+ files and a single theme. In only one page (.rst file) I need to insert a javascript code, like that:

<script>
function myFunction() {
 alert("I am an alert box!");
}
</script>

<button onclick="myFunction()">Try it</button>

How could I do that? I tried a block and a directive so far.

3
  • Where you want to insert that script? Commented Nov 29, 2019 at 23:19
  • A file like this one: raw.githubusercontent.com/ArduPilot/ardupilot_wiki/master/… Commented Dec 17, 2019 at 1:20
  • The idea is to insert a simple script in a single file not in all pages through the theme. Commented Dec 17, 2019 at 1:21

1 Answer 1

2

Try this in your .rst file:

.. raw:: html

    <script>
    function myFunction() {
     alert("I am an alert box!");
    }
    </script>

    <button onclick="myFunction()">Try it</button>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.