Commits

Gregg Lind committed bfc9819

togglePygmentsGenericAnnotation, making it easier to cut and paste (see issue 267)

Uses jQuery to toggle all Pygments generics.

Initial code by Taggnostr.

  • Participants
  • Parent commits dd46f48

Comments (0)

Files changed (1)

sphinx/themes/basic/static/doctools.js

   });
 };
 
+
+/**
+ * Every code block gets a toggle switch for Pygments Generics
+ */
+togglePygmentsGenericAnnotation = function() {
+    // future TODO... only add click box if a pygments generic is present
+    $('<input type="button" value="plain/fancy" class="showPygmentsGenericAnnotation" \
+        style="background-color: transparent; border: 0 dotted black; margin: 10px 0 0 0; font-size: smaller;" \
+        >').
+        appendTo($('.highlight pre'));
+    $('.showPygmentsGenericAnnotation').click(function() { 
+            // generics from pygments/token.py
+            $(this).parent().find('.g, .gd, .ge, .gr, .gh, .gi, .go, .gp, .gs, .gu, .gt').toggle();
+        });
+};
+
 /**
  * Small JavaScript module for the documentation.
  */
 
 $(document).ready(function() {
   Documentation.init();
+  togglePygmentsGenericAnnotation();
 });