diff --git a/autotests/folding/test.pbl.fold b/autotests/folding/test.pbl.fold new file mode 100644 --- /dev/null +++ b/autotests/folding/test.pbl.fold @@ -0,0 +1,101 @@ +# Wesnoth Markup Language + +#textdomain wesnoth-libs + +#define __GUI_WINDOW_HEIGHT +( + if(window_height = 0, 9999, window_height) +)#enddef + +#define __GUI_WINDOW_FUNCTIONS +def reevaluate_best_size(w, s) +( +[ + 0, +# + debug_print('window ', w), + debug_print('screen ', s) +# +][0] +); +#enddef + +# Don't highlight array indices as tags +stored_unit[1].moves +other[0][1][2] +other[foo][bar] + +foo[{MACRO}] +foo[$index] +foo[ 12 ] + +# Nested tags +[allow_undo][/allow_undo][not][true]text[/true][/not] +[foo][bar]text[/bar][/foo] + +[about] + title= _ "Campaign Designer" + text="Your Name" +[/about] + +[window] + id = "tooltip" + + [resolution] + definition = "tooltip" + automatic_placement = false + functions = "{__GUI_WINDOW_FUNCTIONS}" + + [grid] + + [row] + + [column] + + [label] + id = "label" + definition = "default_small" + + use_markup = true + wrap = true + [/label] + + [/column] + + [/row] + + [/grid] + + [/resolution] + +[/window] + +[event] + name = preload + first_time_only = no + [lua] + code = << + function narrator(t) + -- Behave like the [message] tag. + wesnoth.fire("message", + { speaker = "narrator", message = t.sentence }) + end + >> + [/lua] +[/event] + +[event] + name = turn 1 + [lua] + code = << narrator(...) >> + [args] + sentence = _ "Hello world!" + [/args] + [/lua] + [lua] + code = << narrator(...) >> + [args] + sentence = _ "How are you today?" + [/args] + [/lua] +[/event] diff --git a/autotests/html/test.pbl.html b/autotests/html/test.pbl.html new file mode 100644 --- /dev/null +++ b/autotests/html/test.pbl.html @@ -0,0 +1,108 @@ + + + +test.pbl + +
+# Wesnoth Markup Language
+
+#textdomain wesnoth-libs
+
+#define __GUI_WINDOW_HEIGHT
+(
+	if(window_height = 0, 9999, window_height)
+)#enddef
+
+#define __GUI_WINDOW_FUNCTIONS
+def reevaluate_best_size(w, s)
+(
+[
+	0,
+#
+	debug_print('window ', w),
+	debug_print('screen ', s)
+#
+][0]
+);
+#enddef
+
+# Don't highlight array indices as tags
+stored_unit[1].moves
+other[0][1][2]
+other[foo][bar]
+
+foo[{MACRO}]
+foo[$index]
+foo[  12 ]
+
+# Nested tags
+[allow_undo][/allow_undo][not][true]text[/true][/not]
+[foo][bar]text[/bar][/foo]
+
+[about]
+	title= _ "Campaign Designer"
+	text="Your Name"
+[/about]
+
+[window]
+	id = "tooltip"
+
+	[resolution]
+		definition = "tooltip"
+		automatic_placement = false
+		functions = "{__GUI_WINDOW_FUNCTIONS}"
+
+		[grid]
+
+			[row]
+
+				[column]
+
+					[label]
+						id = "label"
+						definition = "default_small"
+
+						use_markup = true
+						wrap = true
+					[/label]
+
+				[/column]
+
+			[/row]
+
+		[/grid]
+
+	[/resolution]
+
+[/window]
+
+[event]
+	name = preload
+	first_time_only = no
+	[lua]
+		code = <<
+			function narrator(t)
+				-- Behave like the [message] tag.
+				wesnoth.fire("message",
+				  { speaker = "narrator", message = t.sentence })
+			end
+		>>
+	[/lua]
+[/event]
+
+[event]
+	name = turn 1
+	[lua]
+		code = << narrator(...) >>
+		[args]
+			sentence = _ "Hello world!"
+		[/args]
+	[/lua]
+	[lua]
+		code = << narrator(...) >>
+		[args]
+			sentence = _ "How are you today?"
+		[/args]
+	[/lua]
+[/event]
+
diff --git a/autotests/input/test.pbl b/autotests/input/test.pbl new file mode 100644 --- /dev/null +++ b/autotests/input/test.pbl @@ -0,0 +1,101 @@ +# Wesnoth Markup Language + +#textdomain wesnoth-libs + +#define __GUI_WINDOW_HEIGHT +( + if(window_height = 0, 9999, window_height) +)#enddef + +#define __GUI_WINDOW_FUNCTIONS +def reevaluate_best_size(w, s) +( +[ + 0, +# + debug_print('window ', w), + debug_print('screen ', s) +# +][0] +); +#enddef + +# Don't highlight array indices as tags +stored_unit[1].moves +other[0][1][2] +other[foo][bar] + +foo[{MACRO}] +foo[$index] +foo[ 12 ] + +# Nested tags +[allow_undo][/allow_undo][not][true]text[/true][/not] +[foo][bar]text[/bar][/foo] + +[about] + title= _ "Campaign Designer" + text="Your Name" +[/about] + +[window] + id = "tooltip" + + [resolution] + definition = "tooltip" + automatic_placement = false + functions = "{__GUI_WINDOW_FUNCTIONS}" + + [grid] + + [row] + + [column] + + [label] + id = "label" + definition = "default_small" + + use_markup = true + wrap = true + [/label] + + [/column] + + [/row] + + [/grid] + + [/resolution] + +[/window] + +[event] + name = preload + first_time_only = no + [lua] + code = << + function narrator(t) + -- Behave like the [message] tag. + wesnoth.fire("message", + { speaker = "narrator", message = t.sentence }) + end + >> + [/lua] +[/event] + +[event] + name = turn 1 + [lua] + code = << narrator(...) >> + [args] + sentence = _ "Hello world!" + [/args] + [/lua] + [lua] + code = << narrator(...) >> + [args] + sentence = _ "How are you today?" + [/args] + [/lua] +[/event] diff --git a/autotests/reference/test.pbl.ref b/autotests/reference/test.pbl.ref new file mode 100644 --- /dev/null +++ b/autotests/reference/test.pbl.ref @@ -0,0 +1,101 @@ +# Wesnoth Markup Language
+
+#textdomain wesnoth-libs
+
+#define __GUI_WINDOW_HEIGHT
+(
+ if(window_height = 0, 9999, window_height)
+)#enddef
+
+#define __GUI_WINDOW_FUNCTIONS
+def reevaluate_best_size(w, s)
+(
+[
+ 0,
+#
+ debug_print('window ', w),
+ debug_print('screen ', s)
+#
+][0]
+);
+#enddef
+
+# Don't highlight array indices as tags
+stored_unit[1].moves
+other[0][1][2]
+other[foo][bar]
+
+foo[{MACRO}]
+foo[$index]
+foo[ 12 ]
+
+# Nested tags
+[allow_undo][/allow_undo][not][true]text[/true][/not]
+[foo][bar]text[/bar][/foo]
+
+[about]
+ title= _ "Campaign Designer"
+ text="Your Name"
+[/about]
+
+[window]
+ id = "tooltip"
+
+ [resolution]
+ definition = "tooltip"
+ automatic_placement = false
+ functions = "{__GUI_WINDOW_FUNCTIONS}"
+
+ [grid]
+
+ [row]
+
+ [column]
+
+ [label]
+ id = "label"
+ definition = "default_small"
+
+ use_markup = true
+ wrap = true
+ [/label]
+
+ [/column]
+
+ [/row]
+
+ [/grid]
+
+ [/resolution]
+
+[/window]
+
+[event]
+ name = preload
+ first_time_only = no
+ [lua]
+ code = <<
+ function narrator(t)
+ -- Behave like the [message] tag.
+ wesnoth.fire("message",
+ { speaker = "narrator", message = t.sentence })
+ end
+ >>
+ [/lua]
+[/event]
+
+[event]
+ name = turn 1
+ [lua]
+ code = << narrator(...) >>
+ [args]
+ sentence = _ "Hello world!"
+ [/args]
+ [/lua]
+ [lua]
+ code = << narrator(...) >>
+ [args]
+ sentence = _ "How are you today?"
+ [/args]
+ [/lua]
+[/event]
diff --git a/data/syntax/wml.xml b/data/syntax/wml.xml --- a/data/syntax/wml.xml +++ b/data/syntax/wml.xml @@ -5,6 +5,11 @@ Alternatively try the "normal" way: #kate@freenode, kwrite-devel@kde.org Changelog (0.35 and later): *************************** +* 0.42.1 + - 2019-01-01 + * Fix infinite loop between the "section" & "error" contexts. + * Only highlight tags with valid name format. + * Don't highlight array indices as tags. * 0.42 - 2011-11-15 : * Added preprocessor directives: #error, #warning @@ -54,8 +59,8 @@ * Made the new #ifndef directive be recognized (implemented on Wesnoth 1.3.11 and later) --> - + wmllint @@ -98,14 +103,17 @@ - - - + + + + + + @@ -152,18 +160,14 @@ - - - - - +