Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions doc/guide/author/topics.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4067,6 +4067,12 @@
<cell></cell>
<cell>AC + IO</cell>
</row>
<row>
<cell>GDScript</cell>
<cell><c>gdscript</c></cell>
<cell></cell>
<cell>AC</cell>
</row>
<row>
<cell>Java</cell>
<cell><c>java</c></cell>
Expand Down
1 change: 1 addition & 0 deletions doc/guide/publisher/publication-file.xml
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@
<li><c>cpp</c> (C++, Runestone server only)</li>
<li><c>java</c> (Java, Runestone server only)</li>
<li><c>kotlin</c> (Kotlin, Runestone server only)</li>
<li><c>gdscript</c> (GDScript, Runestone server only)</li>
<li><c>python3</c> (Python 3, Runestone server only)</li>
<li><c>octave</c> (Octave, Runestone server only)</li>
<li><c>none</c></li>
Expand Down
2 changes: 1 addition & 1 deletion doc/guide/publisher/runestone.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

<li>As much as possible, non-interactive versions of these problems will render in less-capable formats, like <init>PDF</init>, <init>EPUB</init>, and braille.</li>

<li>A <tag>program</tag> element with the attribute <attr>interactive</attr> set to <c>activecode</c> (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 <attr>language</attr> must be set. Supported values for the language when hosted at Runestone are: <c>python</c>, <c>python3</c>, <c>c</c>, <c>cpp</c> (C++), <c>javascript</c>, <c>java</c>, <c>kotlin</c>, <c>octave</c> (Matlab), <c>sql</c>, and <c>html</c>. When hosted on your own server, <c>python</c>, <c>javascript</c>, <c>sql</c>, and <c>html</c>, are supported with in-browser routines. So you do not need to configure <em>anything</em> server-side for this capability. See subsections of <xref ref="interactive-program-activecode"/> for details.</li>
<li>A <tag>program</tag> element with the attribute <attr>interactive</attr> set to <c>activecode</c> (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 <attr>language</attr> must be set. Supported values for the language when hosted at Runestone are: <c>python</c>, <c>python3</c>, <c>c</c>, <c>cpp</c> (C++), <c>gdscript</c>, <c>javascript</c>, <c>java</c>, <c>kotlin</c>, <c>octave</c> (Matlab), <c>sql</c>, and <c>html</c>. When hosted on your own server, <c>python</c>, <c>javascript</c>, <c>sql</c>, and <c>html</c>, are supported with in-browser routines. So you do not need to configure <em>anything</em> server-side for this capability. See subsections of <xref ref="interactive-program-activecode"/> for details.</li>

<li>Similarly, a <tag>program</tag> element with the attribute <attr>interactive</attr> set to <c>codelens</c> (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 <xref ref="interactive-program-codelens"/> for details.</li>

Expand Down
16 changes: 16 additions & 0 deletions examples/sample-book/rune.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
</program>
</listing>


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

Expand Down Expand Up @@ -116,6 +117,21 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
</program>
</listing>

<p>A GDScript program will only be interactive if hosted on a Runestone server.</p>
<!-- Note: It may be possible to embed a mini ActiveCode Style IDE for GDScript -->
<!-- on the web page, but it's not implemented yet. -->

<listing xml:id="program-activecode-gdscript">
<title>An interactive GDScript program, using <pubtitle>Runestone</pubtitle></title>
<program xml:id="gdscript-hello-world" interactive='activecode' language="gdscript" label="gd-hello-world">
<code>
var language : String = "GDScript"
print("Hello, " + language)

</code>
</program>
</listing>

<p>A Java program will only be interactive if hosted on a Runestone server.</p>

<listing xml:id="program-activecode-java">
Expand Down
2 changes: 1 addition & 1 deletion schema/publication-schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
1 change: 1 addition & 0 deletions xsl/pretext-common.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -8026,6 +8026,7 @@ Book (with parts), "section" at level 3
<language ptx="basic" active="" listings="Basic" prism="basic"/>
<language ptx="c" active="c" listings="C" prism="c"/>
<language ptx="cpp" active="cpp" listings="C++" prism="cpp"/>
<language ptx="gdscript" active="gdscript" listings="Python" prism="gdscript"/>
<language ptx="go" active="" listings="C" prism="go"/>
<language ptx="java" active="java" listings="Java" prism="java"/>
<language ptx="javascript" active="javascript" listings="" prism="javascript"/>
Expand Down
40 changes: 40 additions & 0 deletions xsl/pretext-html.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -13918,6 +13918,46 @@ TODO:
<xsl:if test="$b-has-program and not($b-debug-react)">
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.26.0/components/prism-core.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.26.0/plugins/autoloader/prism-autoloader.min.js"></script>

<!-- INJECT GDSCRIPT 2 GRAMMAR VIA PRISM HOOKS -->
<script type="text/javascript">
<![CDATA[
(function() {
if (!window.Prism) return;

// Define grammar using safe string-based RegExp constructors
var gdscript2Grammar = {
'comment': new RegExp('#.*'),
'string': {
pattern: new RegExp('(?:r|f|b)?(?:"(?:\\\\.|[^"\\\\])*"|\'(?:\\\\.|[^\'\\\\])*\')', 'i'),
greedy: true
},
'annotation': {
pattern: new RegExp('@\\w+'),
alias: 'builtin'
},
'keyword': new RegExp('\\b(?:as|assert|await|break|breakpoint|class|class_name|const|continue|enum|export|extends|for|func|if|elif|else|in|is|match|onready|pass|preload|return|self|setget|signal|static|super|tool|var|void|while|yield)\\b'),
'function': new RegExp('\\b[a-z_]\\w*(?=\\s*\\()', 'i'),
'number': new RegExp('\\b(?:0b+|0x[\\da-fA-F]+|\\d+(?:\\.\\d+)?(?:e[+-]?\\d+)?)\\b'),
'boolean': new RegExp('\\b(?:true|false)\\b'),
'operator': new RegExp('->|:=|&&|\\|\\||[-+*/%&|^!=<>]=?|~'),
'punctuation': new RegExp('[{}[\\];(),.:]')
};

// Hook into Prism's token initialization pipeline
Prism.hooks.add('before-tokenize', function(env) {
if (env.language === 'gdscript') {
Prism.languages.gdscript = gdscript2Grammar;
}
});

// Pre-register it globally
Prism.languages.gdscript = gdscript2Grammar;
})();
]]>
</script>


<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.26.0/plugins/line-numbers/prism-line-numbers.min.js" integrity="sha512-dubtf8xMHSQlExGRQ5R7toxHLgSDZ0K7AunqPWHXmJQ8XyVIG19S1T95gBxlAeGOK02P4Da2RTnQz0Za0H0ebQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.26.0/plugins/line-highlight/prism-line-highlight.min.js" integrity="sha512-93uCmm0q+qO5Lb1huDqr7tywS8A2TFA+1/WHvyiWaK6/pvsFl6USnILagntBx8JnVbQH5s3n0vQZY6xNthNfKA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<xsl:if test="$b-html-theme-legacy or $b-reveal-build" >
Expand Down
1 change: 1 addition & 0 deletions xsl/pretext-runestone.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -2717,6 +2717,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
<xsl:when test="$language = 'sql'"> <xsl:text>browser</xsl:text></xsl:when>
<xsl:when test="$language = 'c'"> <xsl:text>jobeserver</xsl:text></xsl:when>
<xsl:when test="$language = 'cpp'"> <xsl:text>jobeserver</xsl:text></xsl:when>
<xsl:when test="$language = 'gdscript'"> <xsl:text>jobeserver</xsl:text></xsl:when>
<xsl:when test="$language = 'java'"> <xsl:text>jobeserver</xsl:text></xsl:when>
<xsl:when test="$language = 'kotlin'"> <xsl:text>jobeserver</xsl:text></xsl:when>
<xsl:when test="$language = 'python2'"> <xsl:text>jobeserver</xsl:text></xsl:when>
Expand Down
1 change: 1 addition & 0 deletions xsl/publisher-variables.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -1912,6 +1912,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
<!-- languages only available on a Runestone server -->
<xsl:when test="($entered-lang = 'c') or
($entered-lang = 'cpp') or
($entered-lang = 'gdscript') or
($entered-lang = 'java') or
($entered-lang = 'kotlin') or
($entered-lang = 'python3') or
Expand Down