[education/rkward/mr-origin-23] rkward/syntax: Highlighting of Floats in R Output

Thomas Friedrichsmeier null at kde.org
Wed Oct 18 17:24:53 BST 2023


Git commit 86ad923d39711fd7a8b1a5889b97811ccccabfac by Thomas Friedrichsmeier, on behalf of Pierre de Villemereuil.
Committed on 18/10/2023 at 18:21.
Pushed by tfry into branch 'mr-origin-23'.

Highlighting of Floats in R Output

Detects and highlight numbers in the R output in a robust way.

M  +3    -0    rkward/syntax/rkward.xml

https://invent.kde.org/education/rkward/-/commit/86ad923d39711fd7a8b1a5889b97811ccccabfac

diff --git a/rkward/syntax/rkward.xml b/rkward/syntax/rkward.xml
index 0c7dbf2e9..61d04d9b2 100644
--- a/rkward/syntax/rkward.xml
+++ b/rkward/syntax/rkward.xml
@@ -72,6 +72,8 @@ SPDX-License-Identifier: GPL-2.0-or-later
 		<context name="OutputRules" attribute="Output" >
 			<!-- Strings = no highlights -->
 			<DetectChar attribute="Output String" context="outputstring" char="""/>
+			<!-- Floats are hard to catch in R Output -->
+			<RegExpr attribute="Output Float" context="#stay" String="(?<=<|>|\(|\[| |^)-?([1-9][0-9]*|0)(\.[0-9]*)?i?(e[-+]?[ ]{0,3}[0-9]+)?(?![0-9a-zA-Z/_\~\-\]]|[.,;:][^ \t])"/>
 		</context>
 		<!-- This context is not really used, but meant to be included. It checks whether a new line is a continuation of a command. If so, it eats the "+ " at the line start. Else it tries to pop back to the top level. (NOTE: An output line starting with "+" will be considered a command line!) -->
 		<context attribute="Output" name="OutputContinuationCheck" lineEndContext="#stay">
@@ -191,6 +193,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
 		<itemData name="Output" defStyleNum="dsOthers"/>
 		<itemData name="Output String" defStyleNum="dsOthers"/>
 		<itemData name="Output String Char" defStyleNum="dsOthers"/>
+		<itemData name="Output Float" defStyleNum="dsChar"/>
 		<itemData name="Prompt" defStyleNum="dsNormal"/>
 		<itemData name="Normal Text" defStyleNum="dsNormal"/>
 		<itemData name="Symbol" defStyleNum="dsNormal"/>



More information about the rkward-tracker mailing list