@@ -155,6 +155,104 @@ hljs.registerLanguage("mlir",function(){"use strict";return function(e){
155155 className :"symbol" , variants :[ { begin :"%" + s + "([:#]\\d+)?" } , { begin :"\\^" + s } , {
156156 begin :"#" + s } ] } , e . C_NUMBER_MODE ] } } } ( ) ) ;
157157
158+ // https://www.renpy.org/doc/html/language_basics.html
159+ // https://github.com/renpy/vscode-language-renpy
160+ // Ren'Py script language support.
161+ hljs . registerLanguage ( "renpy" , ( hljs ) => {
162+ const IDENT = / [ A - Z a - z _ ] [ A - Z a - z 0 - 9 _ ] * / ;
163+ const INTERPOLATION = {
164+ className : "subst" ,
165+ begin : / \[ [ ^ \] \n ] + \] /
166+ } ;
167+ const TEXT_TAG = {
168+ className : "subst" ,
169+ begin : / \{ \/ ? [ A - Z a - z # ] [ ^ { } \n ] * \} /
170+ } ;
171+ const STRING_CONTAINS = [
172+ hljs . BACKSLASH_ESCAPE ,
173+ INTERPOLATION ,
174+ TEXT_TAG
175+ ] ;
176+ const QUOTE_STRING_MODE = {
177+ className : "string" ,
178+ begin : / " / ,
179+ end : / " / ,
180+ contains : STRING_CONTAINS
181+ } ;
182+ const APOS_STRING_MODE = {
183+ className : "string" ,
184+ begin : / ' / ,
185+ end : / ' / ,
186+ contains : STRING_CONTAINS
187+ } ;
188+ const BACKTICK_STRING_MODE = {
189+ className : "string" ,
190+ begin : / ` / ,
191+ end : / ` / ,
192+ contains : STRING_CONTAINS
193+ } ;
194+ const RENPY_KEYWORDS = [
195+ "add" , "at" , "behind" , "call" , "camera" , "centered" , "contains" ,
196+ "default" , "define" , "drag" , "draggroup" , "early" , "elif" , "else" ,
197+ "event" , "expression" , "extend" , "for" , "from" , "hide" , "hotspot" ,
198+ "if" , "image" , "init" , "jump" , "key" , "label" , "layeredimage" ,
199+ "menu" , "nvl" , "on" , "onlayer" , "pass" , "pause" , "play" , "python" ,
200+ "queue" , "repeat" , "return" , "scene" , "screen" , "set" , "show" ,
201+ "side" , "sound" , "spacing" , "stop" , "style" , "style_prefix" , "text" ,
202+ "textbutton" , "time" , "timer" , "transform" , "translate" , "use" ,
203+ "voice" , "while" , "with" , "window" , "zorder"
204+ ] . join ( " " ) ;
205+ const PYTHON_KEYWORDS = [
206+ "and" , "as" , "assert" , "async" , "await" , "break" , "class" ,
207+ "continue" , "def" , "del" , "except" , "False" , "finally" , "for" ,
208+ "from" , "global" , "import" , "in" , "is" , "lambda" , "None" ,
209+ "nonlocal" , "not" , "or" , "raise" , "True" , "try" , "yield"
210+ ] . join ( " " ) ;
211+
212+ return {
213+ name : "Ren'Py" ,
214+ aliases : [ "rpy" ] ,
215+ keywords : {
216+ keyword : `${ RENPY_KEYWORDS } ${ PYTHON_KEYWORDS } ` ,
217+ literal : "True False None yes no" ,
218+ built_in : "Character DynamicCharacter Solid Null Fade Dissolve MoveTransition Pause SetVariable ToggleVariable Show Hide Jump Call Return Function Play Queue Stop"
219+ } ,
220+ contains : [
221+ hljs . HASH_COMMENT_MODE ,
222+ QUOTE_STRING_MODE ,
223+ APOS_STRING_MODE ,
224+ BACKTICK_STRING_MODE ,
225+ hljs . NUMBER_MODE ,
226+ {
227+ className : "meta" ,
228+ begin : / ^ \s * \$ + / ,
229+ end : / $ / ,
230+ contains : [
231+ hljs . HASH_COMMENT_MODE ,
232+ QUOTE_STRING_MODE ,
233+ APOS_STRING_MODE ,
234+ BACKTICK_STRING_MODE ,
235+ hljs . NUMBER_MODE
236+ ]
237+ } ,
238+ {
239+ className : "section" ,
240+ begin : / ^ \s * ( l a b e l | s c r e e n | t r a n s f o r m | s t y l e | i m a g e | l a y e r e d i m a g e | t r a n s l a t e ) \s + / ,
241+ end : / : / ,
242+ keywords : "label screen transform style image layeredimage translate"
243+ } ,
244+ {
245+ className : "title" ,
246+ begin : new RegExp ( `^\\s*${ IDENT . source } (?=\\s+["'\`])` )
247+ } ,
248+ {
249+ className : "variable" ,
250+ begin : / \[ [ ^ \] \n ] + \] /
251+ }
252+ ]
253+ } ;
254+ } ) ;
255+
158256// https://github.com/siyuan-note/siyuan/pull/15345
159257hljs . registerLanguage ( 'template' , function ( hljs ) {
160258
0 commit comments