Enforce Script Highlighter – Extension
Jump to navigation
Jump to search
Lou Montana (talk | contribs) (Add more description and examples) |
Lou Montana (talk | contribs) (Add noLinks, Add game possible values, Add examples) |
||
Line 26: | Line 26: | ||
* [[:Category:Arma_Reforger/Modding/Guidelines/Scripting|Enforce Script Syntax]] support | * [[:Category:Arma_Reforger/Modding/Guidelines/Scripting|Enforce Script Syntax]] support | ||
** Links to game classes using {{hl|enfusion://}} link | ** Links to game classes using {{hl|enfusion://}} link | ||
** Auto-detects class/enum declarations in script snippet e.g <enforce inline>class ABC {} | ** Auto-detects class/enum declarations in script snippet e.g <enforce inline>class ABC {} ABC.MyMethod();</enforce> | ||
** Slight styling for {{hl|m_}}/{{hl|s_}} variables, {{hl|ALL_CAPS}} constants | ** Slight styling for {{hl|m_}}/{{hl|s_}} variables, {{hl|ALL_CAPS}} constants | ||
* "Copy code to clipboard" button on hover | * "Copy code to clipboard" button on hover | ||
Line 33: | Line 33: | ||
** {{hl|inline}} for inline code | ** {{hl|inline}} for inline code | ||
** {{hl|notrim}} to remove the auto trim (lines themselves will always be rtrimmed) | ** {{hl|notrim}} to remove the auto trim (lines themselves will always be rtrimmed) | ||
** {{hl|1= game="armaR"}} ( | ** {{hl|1= game="armaR"}} (default per wiki namespace, case-insensitive) used to force which game links should be used - can be one of {{hl|dayz}}, {{hl|armaR}}, {{hl|arma4}} | ||
** {{hl|1= classes="SCR_ClassA SCR_ClassB"}} (case-sensitive) additional classes to be declared (if outside the example) | ** {{hl|1= classes="SCR_ClassA SCR_ClassB"}} (case-sensitive) additional classes to be declared (if outside the example) | ||
** {{hl|noGuess}} to disable guessing unknown token as classes as false positives can happen - use {{hl|classes}} in that case<br><!-- | ** {{hl|noGuess}} to disable guessing unknown token as classes as false positives can happen - use {{hl|classes}} in that case<br><!-- | ||
-->Class guess regex: {{hl|^([A-Z][A-Z0-9]{1,7}_)?E?[A-Z][a-z][A-Za-z0-9_]*$}} as per {{Link|Arma Reforger:Scripting: Conventions#Tag|script tag guidelines}} | -->Class guess regex: {{hl|^([A-Z][A-Z0-9]{1,7}_)?E?[A-Z][a-z][A-Za-z0-9_]*$}} as per {{Link|Arma Reforger:Scripting: Conventions#Tag|script tag guidelines}} | ||
** {{hl|noLinks}} to disable class-linking | |||
Line 131: | Line 132: | ||
|- | |- | ||
| <syntaxhighlight lang="html"> | | <syntaxhighlight lang="html"> | ||
<enforce> | <enforce game="ofp">string text = "It's OK!"; int a = 42; PlayerBase pb = NULL; RplComponent comp = null;</enforce> | ||
<enforce | <enforce game="dayz">string text = "It's OK!"; int a = 42; PlayerBase pb = NULL; RplComponent comp = null;</enforce> | ||
<enforce game="armaR">string text = "It's OK!"; int a = 42; PlayerBase pb = NULL; RplComponent comp = null;</enforce> | |||
<enforce game="arma4">string text = "It's OK!"; int a = 42; PlayerBase pb = NULL; RplComponent comp = null;</enforce> | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| <enforce> | | <enforce game="ofp">string text = "It's OK!"; int a = 42; PlayerBase pb = NULL; RplComponent comp = null;</enforce> | ||
<enforce | <enforce game="dayz">string text = "It's OK!"; int a = 42; PlayerBase pb = NULL; RplComponent comp = null;</enforce> | ||
<enforce game="armaR">string text = "It's OK!"; int a = 42; PlayerBase pb = NULL; RplComponent comp = null;</enforce> | |||
<enforce game="arma4">string text = "It's OK!"; int a = 42; PlayerBase pb = NULL; RplComponent comp = null;</enforce> | |||
|- | |- | ||
| <syntaxhighlight lang="html"> | | <syntaxhighlight lang="html"> | ||
Line 151: | Line 156: | ||
SCR_jkl v4; | SCR_jkl v4; | ||
</enforce> | </enforce> | ||
|- | |||
| <syntaxhighlight lang="html"> | |||
<enforce>MyClass.Test</enforce> | |||
<enforce noGuess>MyClass.MyMethod</enforce> | |||
</syntaxhighlight> | |||
| <enforce>MyClass.MyMethod</enforce> | |||
<enforce noGuess>MyClass.MyMethod</enforce> | |||
|- | |||
| <syntaxhighlight lang="html"> | |||
<enforce>RplComponent</enforce> | |||
<enforce noLinks>RplComponent</enforce> | |||
</syntaxhighlight> | |||
| <enforce>RplComponent</enforce> | |||
<enforce noLinks>RplComponent</enforce> | |||
|} | |} | ||
Revision as of 02:27, 17 June 2023
Enforce Script Highlighter | |
---|---|
Description | Highlights Enforce Script code. |
Author | Lou Montana |
Project Start | 2022-07-30: Project start |
Release Date |
|
Version | 0.95 |
This extension highlights Enforce Script Syntax using Script Editor's theme.
Features
- Enforce Script Syntax support
- Links to game classes using enfusion:
/ / link - Auto-detects class/enum declarations in script snippet e.g class ABC {} ABC.MyMethod();
- Slight styling for m_/s_ variables, ALL_CAPS constants
- Links to game classes using enfusion:
- "Copy code to clipboard" button on hover
- Enforce Script tag button in the wiki edit toolbar (next to B and I)
- Options:
- inline for inline code
- notrim to remove the auto trim (lines themselves will always be rtrimmed)
- game="armaR" (default per wiki namespace, case-insensitive) used to force which game links should be used - can be one of dayz, armaR, arma4
- classes="SCR_ClassA SCR_ClassB" (case-sensitive) additional classes to be declared (if outside the example)
- noGuess to disable guessing unknown token as classes as false positives can happen - use classes in that case
Class guess regex: ^([A-Z][A-Z0-9]{1,7}_)?E?[A-Z][a-z][A-Za-z0-9_]*$ as per script tag guidelines - noLinks to disable class-linking
Installation
- Unzip the directory to wiki
/extensions /EnforceScriptHighlighter - Add
wfLoadExtension( 'EnforceScriptHighlighter' );
to LocalSettings.php - Settings can be found in extension.json:
- Game-Namespace relationship
- Game class-link pairs
- keywords, native types, preprocessor commands, etc.
Usage
Using <enforce>
tags will auto-generate syntax highlighting.
Code | Result |
---|---|
<enforce/>
|
-no code provided-
|
<enforce></enforce>
|
-no code provided-
|
<enforce> </enforce>
|
-no code provided-
|
<enforce>int i = 3;</enforce>
|
|
<enforce>
#ifdef WORKBENCH
class ABC
{
}
class DEF : ABC
{
// unreachable
protected static void Print(string text)
{
Print(text + 42, LogLevel.NORMAL);
}
}
#endif
</enforce>
|
|
This is <enforce inline>int i = 0; i++;</enforce> absolutely inline.<br>
And here comes another one <enforce inline>float value = 0.001;</enforce> inline text.<br>
And another one <enforce inline>array<string> = {};</enforce>
|
This is int i = 0; i++; absolutely inline. |
<enforce notrim>
Print("Hello there");
</enforce>
|
Print("Hello there");
|
<enforce game="ofp">string text = "It's OK!"; int a = 42; PlayerBase pb = NULL; RplComponent comp = null;</enforce>
<enforce game="dayz">string text = "It's OK!"; int a = 42; PlayerBase pb = NULL; RplComponent comp = null;</enforce>
<enforce game="armaR">string text = "It's OK!"; int a = 42; PlayerBase pb = NULL; RplComponent comp = null;</enforce>
<enforce game="arma4">string text = "It's OK!"; int a = 42; PlayerBase pb = NULL; RplComponent comp = null;</enforce>
|
string text = "It's OK!"; int a = 42; PlayerBase pb = NULL; RplComponent comp = null; string text = "It's OK!"; int a = 42; PlayerBase pb = NULL; RplComponent comp = null; |
<enforce classes="SCR_abc SCR_jkl v2">
SCR_abc v1;
SCR_def v2;
SCR_ghi v3;
SCR_jkl v4;
</enforce>
|
SCR_abc v1;
SCR_def v2;
SCR_ghi v3;
SCR_jkl v4; |
<enforce>MyClass.Test</enforce>
<enforce noGuess>MyClass.MyMethod</enforce>
|
MyClass.MyMethod MyClass.MyMethod |
<enforce>RplComponent</enforce>
<enforce noLinks>RplComponent</enforce>
|
RplComponent |
Known Issues
Version | Issue | Report Date | Fix Date |
---|---|---|---|
0.00a | N/A | ||
0.95 | N/A |