From 24597b137be8f3479ae25a1bbd0d287c5c013a6a Mon Sep 17 00:00:00 2001 From: DavidCooperWCU Date: Wed, 3 Jun 2026 17:24:32 -0400 Subject: [PATCH 1/2] gdscript highlighting --- doc/guide/author/topics.xml | 6 ++ doc/guide/publisher/publication-file.xml | 1 + doc/guide/publisher/runestone.xml | 2 +- examples/sample-book/rune.xml | 90 ++++++++++++++++++++++++ schema/publication-schema.xml | 2 +- xsl/pretext-common.xsl | 1 + xsl/pretext-html.xsl | 40 +++++++++++ xsl/pretext-runestone.xsl | 1 + xsl/publisher-variables.xsl | 1 + 9 files changed, 142 insertions(+), 2 deletions(-) diff --git a/doc/guide/author/topics.xml b/doc/guide/author/topics.xml index 59dfe420b..58f2856ca 100644 --- a/doc/guide/author/topics.xml +++ b/doc/guide/author/topics.xml @@ -4067,6 +4067,12 @@ AC + IO + + GDScript + gdscript + + AC + Java java diff --git a/doc/guide/publisher/publication-file.xml b/doc/guide/publisher/publication-file.xml index 7c20f017d..5cf6cea6e 100644 --- a/doc/guide/publisher/publication-file.xml +++ b/doc/guide/publisher/publication-file.xml @@ -585,6 +585,7 @@
  • cpp (C++, Runestone server only)
  • java (Java, Runestone server only)
  • kotlin (Kotlin, Runestone server only)
  • +
  • gdscript (GDScript, Runestone server only)
  • python3 (Python 3, Runestone server only)
  • octave (Octave, Runestone server only)
  • none
  • diff --git a/doc/guide/publisher/runestone.xml b/doc/guide/publisher/runestone.xml index f68b2edd6..4c03b53d5 100644 --- a/doc/guide/publisher/runestone.xml +++ b/doc/guide/publisher/runestone.xml @@ -29,7 +29,7 @@
  • As much as possible, non-interactive versions of these problems will render in less-capable formats, like PDF, EPUB, and braille.
  • -
  • A program element with the attribute interactive set to activecode (even outside of a an exercise) will be realized as a Runestone ActiveCode interactive program, where programs can be edited, compiled, and run. In some cases a CodeLens interactive trace utility is also available. The language must be set. Supported values for the language when hosted at Runestone are: python, python3, c, cpp (C++), javascript, java, kotlin, octave (Matlab), sql, and html. When hosted on your own server, python, javascript, sql, and html, are supported with in-browser routines. So you do not need to configure anything server-side for this capability. See subsections of for details.
  • +
  • A program element with the attribute interactive set to activecode (even outside of a an exercise) will be realized as a Runestone ActiveCode interactive program, where programs can be edited, compiled, and run. In some cases a CodeLens interactive trace utility is also available. The language must be set. Supported values for the language when hosted at Runestone are: python, python3, c, cpp (C++), gdscript, javascript, java, kotlin, octave (Matlab), sql, and html. When hosted on your own server, python, javascript, sql, and html, are supported with in-browser routines. So you do not need to configure anything server-side for this capability. See subsections of for details.
  • Similarly, a program element with the attribute interactive set to codelens (even outside of a an exercise) will be realized as a Runestone CodeLens interactive program. This allows a reader to step through the program, much like in a debugger, but with more informative displays of the intermediate state of the program (and nothing like breakpoints or changing variable's values). This ability varies by language, and by hosting location. See subsections of for details.
  • diff --git a/examples/sample-book/rune.xml b/examples/sample-book/rune.xml index e78e94a6b..64496bb74 100644 --- a/examples/sample-book/rune.xml +++ b/examples/sample-book/rune.xml @@ -88,6 +88,7 @@ along with MathBook XML. If not, see . +

    Otherwise they are rendered as text with syntax coloring. Either way, if a language is not specified, docinfo/programs/@language will be checked to determine what language to assume the code is written in.

    @@ -116,6 +117,95 @@ along with MathBook XML. If not, see . +

    A GDScript program will only be interactive if hosted on a Runestone server.

    + + + + + An interactive GDScript program, using <pubtitle>Runestone</pubtitle> + + + var language : String = "GDScript" + print("Hello, " + language) + + class_name StateMachine + extends Node + ## Hierarchical State machine for the player. + ## + ## Initializes states and delegates engine callbacks ([method Node._physics_process], + ## [method Node._unhandled_input]) to the state. + + signal state_changed(previous, new) + + @export var initial_state: Node + var is_active = true: + set = set_is_active + + @onready var _state = initial_state: + set = set_state + @onready var _state_name = _state.name + + + func _init(): + add_to_group("state_machine") + + + func _enter_tree(): + print("this happens before the ready method!") + + + func _ready(): + state_changed.connect(_on_state_changed) + _state.enter() + + + func _unhandled_input(event): + _state.unhandled_input(event) + + + func _physics_process(delta): + _state.physics_process(delta) + + + func transition_to(target_state_path, msg={}): + if not has_node(target_state_path): + return + + var target_state = get_node(target_state_path) + assert(target_state.is_composite == false) + + _state.exit() + self._state = target_state + _state.enter(msg) + Events.player_state_changed.emit(_state.name) + + + func set_is_active(value): + is_active = value + set_physics_process(value) + set_process_unhandled_input(value) + set_block_signals(not value) + + + func set_state(value): + _state = value + _state_name = _state.name + + + func _on_state_changed(previous, new): + print("state changed") + state_changed.emit() + + + class State: + var foo = 0 + + func _init(): + print("Hello!") + + + +

    A Java program will only be interactive if hosted on a Runestone server.

    diff --git a/schema/publication-schema.xml b/schema/publication-schema.xml index ee81b6440..0db990161 100644 --- a/schema/publication-schema.xml +++ b/schema/publication-schema.xml @@ -388,7 +388,7 @@ Calculator = element calculator { attribute model { "geogebra-classic" | "geogebra-graphing" | "geogebra-geometry" | "geogebra-3d" | "none "}?, - attribute activecode { "python" | "javascript" | "html" | "sql" | "c" | "cpp" | "java" | "kotlin" | "python3" | "octave" | "none"}? + attribute activecode { "python" | "javascript" | "html" | "sql" | "c" | "cpp" | "gdscript" | "java" | "kotlin" | "python3" | "octave" | "none"}? } Crossreferences = diff --git a/xsl/pretext-common.xsl b/xsl/pretext-common.xsl index d81a9e242..f70eeead7 100644 --- a/xsl/pretext-common.xsl +++ b/xsl/pretext-common.xsl @@ -8026,6 +8026,7 @@ Book (with parts), "section" at level 3 + diff --git a/xsl/pretext-html.xsl b/xsl/pretext-html.xsl index b46a798d5..0035cbf24 100644 --- a/xsl/pretext-html.xsl +++ b/xsl/pretext-html.xsl @@ -13904,6 +13904,46 @@ TODO: + + + + + diff --git a/xsl/pretext-runestone.xsl b/xsl/pretext-runestone.xsl index 8b392bc5d..5553bb84c 100644 --- a/xsl/pretext-runestone.xsl +++ b/xsl/pretext-runestone.xsl @@ -2717,6 +2717,7 @@ along with PreTeXt. If not, see . browser jobeserver jobeserver + jobeserver jobeserver jobeserver jobeserver diff --git a/xsl/publisher-variables.xsl b/xsl/publisher-variables.xsl index b3e2541d4..8698f4a41 100644 --- a/xsl/publisher-variables.xsl +++ b/xsl/publisher-variables.xsl @@ -1912,6 +1912,7 @@ along with PreTeXt. If not, see .