4a99b8d234f653c806f9bcd3395e77df5761c25b
[Packages/TYPO3.CMS.git] / typo3 / sysext / t3editor / Resources / Public / JavaScript / parse_typoscript / tokenizetyposcript.js
1 /*
2 * This file is part of the TYPO3 CMS project.
3 *
4 * It is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU General Public License, either version 2
6 * of the License, or any later version.
7 *
8 * For the full copyright and license information, please read the
9 * LICENSE.txt file that was distributed with this source code.
10 *
11 * The TYPO3 project - inspiring people to share!
12 */
13
14 /* Tokenizer for TypoScript code
15 *
16 * based on tokenizejavascript.js by Marijn Haverbeke
17 */
18
19 // List of "reserved" word in typoscript and a css-class
20 var typoscriptWords = {
21 '_CSS_DEFAULT_STYLE': 'keyword',
22 '_DEFAULT_PI_VARS': 'keyword',
23 '_GIFBUILDER': 'keyword',
24 '_LOCAL_LANG': 'keyword',
25 '_offset': 'reserved',
26 'absRefPrefix': 'reserved',
27 'accessibility': 'reserved',
28 'accessKey': 'reserved',
29 'ACT': 'keyword3',
30 'ACTIFSUB': 'keyword3',
31 'ACTIFSUBRO': 'keyword',
32 'ACTRO': 'keyword3',
33 'addAttributes': 'reserved',
34 'addExtUrlsAndShortCuts': 'reserved',
35 'addItems': 'reserved',
36 'additionalHeaders': 'reserved',
37 'additionalParams': 'reserved',
38 'addParams': 'reserved',
39 'addQueryString': 'reserved',
40 'adjustItemsH': 'reserved',
41 'adjustSubItemsH': 'reserved',
42 'admPanel': 'keyword2',
43 'after': 'reserved',
44 'afterImg': 'reserved',
45 'afterImgLink': 'reserved',
46 'afterImgTagParams': 'reserved',
47 'afterROImg': 'reserved',
48 'afterWrap': 'reserved',
49 'age': 'reserved',
50 'alertPopups': 'reserved',
51 'align': 'reserved',
52 'all': 'keyword3',
53 'allow': 'reserved',
54 'allowCaching': 'reserved',
55 'allowedAttribs': 'reserved',
56 'allowedClasses': 'reserved',
57 'allowedCols': 'reserved',
58 'allowedNewTables': 'reserved',
59 'allowTags': 'reserved',
60 'allSaveFunctions': 'reserved',
61 'allStdWrap': 'reserved',
62 'allWrap': 'reserved',
63 'alt_print': 'keyword2',
64 'alternativeSortingField': 'reserved',
65 'alternativeTempPath': 'reserved',
66 'altIcons': 'reserved',
67 'altImgResource': 'reserved',
68 'altLabels': 'reserved',
69 'altTarget': 'reserved',
70 'altText': 'reserved',
71 'altUrl': 'reserved',
72 'altUrl_noDefaultParams': 'reserved',
73 'altWrap': 'reserved',
74 'always': 'reserved',
75 'alwaysActivePIDlist': 'reserved',
76 'alwaysLink': 'reserved',
77 'andWhere': 'reserved',
78 'angle': 'reserved',
79 'antiAlias': 'reserved',
80 'append': 'reserved',
81 'applyTotalH': 'reserved',
82 'applyTotalW': 'reserved',
83 'archive': 'reserved',
84 'ascii': 'keyword3',
85 'ATagAfterWrap': 'reserved',
86 'ATagBeforeWrap': 'reserved',
87 'ATagParams': 'reserved',
88 'ATagTitle': 'reserved',
89 'atLeast': 'keyword3',
90 'atMost': 'keyword3',
91 'attribute': 'reserved',
92 'auth': 'keyword2',
93 'autoLevels': 'reserved',
94 'autonumber': 'reserved',
95 'backColor': 'reserved',
96 'background': 'reserved',
97 'baseURL': 'reserved',
98 'BE': 'keyword3',
99 'be_groups': 'keyword3',
100 'be_users': 'keyword3',
101 'before': 'reserved',
102 'beforeImg': 'reserved',
103 'beforeImgLink': 'reserved',
104 'beforeImgTagParams': 'reserved',
105 'beforeROImg': 'reserved',
106 'beforeWrap': 'reserved',
107 'begin': 'reserved',
108 'beLoginLinkIPList': 'reserved',
109 'beLoginLinkIPList_login': 'reserved',
110 'beLoginLinkIPList_logout': 'reserved',
111 'bgCol': 'reserved',
112 'bgImg': 'reserved',
113 'blur': 'reserved',
114 'bm': 'reserved',
115 'bodyTag': 'reserved',
116 'bodyTagAdd': 'reserved',
117 'bodyTagCObject': 'reserved',
118 'bodyTagMargins': 'reserved',
119 'bodytext': 'reserved',
120 'border': 'reserved',
121 'borderCol': 'reserved',
122 'borderThick': 'reserved',
123 'bottomBackColor': 'reserved',
124 'bottomContent': 'reserved',
125 'bottomHeight': 'reserved',
126 'bottomImg': 'reserved',
127 'bottomImg_mask': 'reserved',
128 'BOX': 'keyword3',
129 'br': 'reserved',
130 'browse': 'keyword3',
131 'browser': 'keyword2',
132 'brTag': 'reserved',
133 'bullet': 'reserved',
134 'bulletlist': 'reserved',
135 'bullets': 'keyword3',
136 'bytes': 'reserved',
137 'cache': 'keyword2',
138 'cache_clearAtMidnight': 'reserved',
139 'cache_period': 'reserved',
140 'caption': 'reserved',
141 'caption_stdWrap': 'reserved',
142 'captionHeader': 'reserved',
143 'captionSplit': 'reserved',
144 'CARRAY': 'keyword',
145 'CASE': 'keyword',
146 'case': 'reserved',
147 'casesensitiveComp': 'reserved',
148 'cellpadding': 'reserved',
149 'cellspacing': 'reserved',
150 'char': 'reserved',
151 'charcoal': 'reserved',
152 'charMapConfig': 'reserved',
153 'CHECK': 'keyword2',
154 'check': 'reserved',
155 'class': 'reserved',
156 'classesAnchor': 'reserved',
157 'classesCharacter': 'reserved',
158 'classesImage': 'reserved',
159 'classesParagraph': 'reserved',
160 'clear': 'reserved',
161 'clearCache': 'reserved',
162 'clearCache_disable': 'reserved',
163 'clearCache_pageGrandParent': 'reserved',
164 'clearCache_pageSiblingChildren': 'reserved',
165 'clearCacheCmd': 'reserved',
166 'clearCacheLevels': 'reserved',
167 'clearCacheOfPages': 'reserved',
168 'clickTitleMode': 'reserved',
169 'clipboardNumberPads': 'reserved',
170 'cMargins': 'reserved',
171 'COA': 'keyword',
172 'COA_INT': 'keyword',
173 'cObj': 'keyword2',
174 'COBJ_ARRAY': 'keyword',
175 'cObject': 'keyword2',
176 'cObjNum': 'reserved',
177 'collapse': 'reserved',
178 'collections': 'reserved',
179 'color': 'reserved',
180 'color1': 'reserved',
181 'color2': 'reserved',
182 'color3': 'reserved',
183 'color4': 'reserved',
184 'colors': 'reserved',
185 'colour': 'reserved',
186 'colPos_list': 'reserved',
187 'colRelations': 'reserved',
188 'cols': 'reserved',
189 'colSpace': 'reserved',
190 'COMMENT': 'keyword2',
191 'comment_auto': 'reserved',
192 'commentWrap': 'reserved',
193 'compensateFieldWidth': 'reserved',
194 'compX': 'reserved',
195 'compY': 'reserved',
196 'conf': 'reserved',
197 'CONFIG': 'keyword',
198 'config': 'keyword2',
199 'CONSTANTS': 'keyword',
200 'constants': 'reserved',
201 'CONTENT': 'keyword',
202 'content': 'keyword2',
203 'content_from_pid_allowOutsideDomain': 'reserved',
204 'contextMenu': 'reserved',
205 'copy': 'keyword2',
206 'copyLevels': 'reserved',
207 'count_HMENU_MENUOBJ': 'reserved',
208 'count_menuItems': 'reserved',
209 'count_MENUOBJ': 'reserved',
210 'create': 'reserved',
211 'createFoldersInEB': 'reserved',
212 'crop': 'reserved',
213 'csConv': 'reserved',
214 'CSS_inlineStyle': 'keyword2',
215 'CType': 'keyword',
216 'CUR': 'keyword3',
217 'CURIFSUB': 'keyword3',
218 'CURIFSUBRO': 'keyword3',
219 'current': 'reserved',
220 'CURRO': 'keyword3',
221 'curUid': 'reserved',
222 'cut': 'keyword2',
223 'cWidth': 'reserved',
224 'data': 'reserved',
225 'dataArray': 'keyword2',
226 'dataWrap': 'reserved',
227 'date': 'reserved',
228 'date_stdWrap': 'reserved',
229 'datePrefix': 'reserved',
230 'dayofmonth': 'keyword2',
231 'dayofweek': 'keyword2',
232 'DB': 'keyword',
233 'db_list': 'keyword2',
234 'debug': 'reserved',
235 'debugData': 'reserved',
236 'debugFunc': 'reserved',
237 'debugItemConf': 'reserved',
238 'debugRenumberedObject': 'reserved',
239 'default': 'keyword3',
240 'defaultAlign': 'reserved',
241 'defaultCmd': 'reserved',
242 'defaultFileUploads': 'reserved',
243 'defaultHeaderType': 'reserved',
244 'defaultOutput': 'reserved',
245 'defaults': 'reserved',
246 'defaultType': 'reserved',
247 'delete': 'reserved',
248 'denyTags': 'reserved',
249 'depth': 'reserved',
250 'DESC': 'reserved',
251 'description': 'keyword3',
252 'dimensions': 'reserved',
253 'direction': 'reserved',
254 'directory': 'keyword3',
255 'directReturn': 'keyword3',
256 'disableAdvanced': 'reserved',
257 'disableAllHeaderCode': 'reserved',
258 'disableAltText': 'reserved',
259 'disableBodyTag': 'reserved',
260 'disableCacheSelector': 'reserved',
261 'disableCharsetHeader': 'reserved',
262 'disabled': 'reserved',
263 'disableDelete': 'reserved',
264 'disableDocSelector': 'reserved',
265 'disableHideAtCopy': 'reserved',
266 'disableIconLinkToContextmenu': 'reserved',
267 'disableItems': 'reserved',
268 'disableNewContentElementWizard': 'reserved',
269 'disableNoMatchingValueElement': 'reserved',
270 'disablePageExternalUrl': 'reserved',
271 'disablePrefixComment': 'reserved',
272 'disablePrependAtCopy': 'reserved',
273 'disableSearchBox': 'reserved',
274 'disableSingleTableView': 'reserved',
275 'disableTabInTextarea': 'reserved',
276 'displayContent': 'reserved',
277 'displayFieldIcons': 'reserved',
278 'displayIcons': 'reserved',
279 'displayMessages': 'reserved',
280 'displayRecord': 'reserved',
281 'displayTimes': 'reserved',
282 'distributeX': 'reserved',
283 'distributeY': 'reserved',
284 'div': 'keyword3',
285 'DIV': 'reserved',
286 'doctype': 'reserved',
287 'doctypeSwitch': 'reserved',
288 'DOCUMENT_BODY': 'keyword',
289 'doktype': 'reserved',
290 'doNotLinkIt': 'reserved',
291 'doNotShowLink': 'reserved',
292 'doNotStripHTML': 'reserved',
293 'dontCheckPid': 'reserved',
294 'dontLinkIfSubmenu': 'reserved',
295 'dontWrapInTable': 'reserved',
296 'doubleBrTag': 'reserved',
297 'dWorkArea': 'reserved',
298 'dynCSS': 'keyword2',
299 'edge': 'reserved',
300 'edit': 'keyword2',
301 'edit_access': 'keyword2',
302 'edit_docModuleUpload': 'reserved',
303 'edit_pageheader': 'keyword2',
304 'edit_RTE': 'reserved',
305 'editFieldsAtATime': 'reserved',
306 'editFormsOnPage': 'reserved',
307 'editIcons': 'reserved',
308 'editNoPopup': 'reserved',
309 'EDITPANEL': 'keyword',
310 'editPanel': 'reserved',
311 'EFFECT': 'keyword',
312 'elements': 'reserved',
313 'else': 'keyword3',
314 'email': 'keyword3',
315 'emailMeAtLogin': 'reserved',
316 'emailMess': 'reserved',
317 'emboss': 'reserved',
318 'enable': 'reserved',
319 'encapsLines': 'reserved',
320 'encapsLinesStdWrap': 'reserved',
321 'encapsTagList': 'reserved',
322 'end': 'keyword3',
323 'entryLevel': 'reserved',
324 'equalH': 'reserved',
325 'equals': 'keyword3',
326 'everybody': 'reserved',
327 'excludeDoktypes': 'reserved',
328 'excludeUidList': 'reserved',
329 'expAll': 'reserved',
330 'expand': 'reserved',
331 'explode': 'reserved',
332 'ext': 'reserved',
333 'external': 'keyword3',
334 'externalBlocks': 'reserved',
335 'extTarget': 'reserved',
336 'face': 'reserved',
337 'false': 'keyword3',
338 'FE': 'keyword3',
339 'fe_adminLib': 'reserved',
340 'fe_groups': 'keyword3',
341 'fe_users': 'keyword3',
342 'feadmin': 'keyword3',
343 'field': 'reserved',
344 'fieldName': 'reserved',
345 'fieldOrder': 'reserved',
346 'fieldRequired': 'reserved',
347 'fields': 'reserved',
348 'fieldWrap': 'reserved',
349 'FILE': 'keyword',
350 'file': 'reserved',
351 'file1': 'reserved',
352 'file2': 'reserved',
353 'file3': 'reserved',
354 'file4': 'reserved',
355 'file5': 'reserved',
356 'filelink': 'reserved',
357 'filelist': 'reserved',
358 'FILES': 'keyword',
359 'files': 'reserved',
360 'firstLabel': 'reserved',
361 'firstLabelGeneral': 'reserved',
362 'fixAttrib': 'reserved',
363 'flip': 'reserved',
364 'flop': 'reserved',
365 'folder': 'keyword2',
366 'folders': 'reserved',
367 'folderTree': 'keyword2',
368 'foldoutMenu': 'keyword2',
369 'fontColor': 'reserved',
370 'fontFile': 'reserved',
371 'fontOffset': 'reserved',
372 'fontSize': 'reserved',
373 'fontSizeMultiplicator': 'reserved',
374 'fontTag': 'reserved',
375 'forceDisplayFieldIcons': 'reserved',
376 'forceDisplayIcons': 'reserved',
377 'forceTemplateParsing': 'reserved',
378 'forceTypeValue': 'reserved',
379 'FORM': 'keyword',
380 'format': 'reserved',
381 'FRAME': 'keyword',
382 'frame': 'reserved',
383 'frameReloadIfNotInFrameset': 'reserved',
384 'FRAMESET': 'keyword',
385 'frameSet': 'reserved',
386 'ftu': 'reserved',
387 'function': 'reserved',
388 'Functions': 'keyword2',
389 'gamma': 'reserved',
390 'gapBgCol': 'reserved',
391 'gapLineCol': 'reserved',
392 'gapLineThickness': 'reserved',
393 'gapWidth': 'reserved',
394 'get': 'reserved',
395 'getBorder': 'reserved',
396 'getLeft': 'reserved',
397 'getRight': 'reserved',
398 'GIFBUILDER': 'keyword',
399 'global': 'keyword',
400 'globalNesting': 'reserved',
401 'globalString': 'keyword',
402 'globalVar': 'keyword',
403 'GMENU': 'keyword',
404 'GP': 'keyword',
405 'gray': 'reserved',
406 'group': 'reserved',
407 'groupBy': 'reserved',
408 'groupid': 'reserved',
409 'header': 'keyword3',
410 'header_layout': 'reserved',
411 'headerComment': 'reserved',
412 'headerData': 'reserved',
413 'headerSpace': 'reserved',
414 'headTag': 'reserved',
415 'height': 'reserved',
416 'helpText': 'reserved',
417 'hidden': 'reserved',
418 'hiddenFields': 'reserved',
419 'hide': 'reserved',
420 'hideButCreateMap': 'reserved',
421 'hidePStyleItems': 'reserved',
422 'hideRecords': 'reserved',
423 'highColor': 'reserved',
424 'history': 'reserved',
425 'HMENU': 'keyword',
426 'hostname': 'keyword2',
427 'hour': 'keyword2',
428 'HTML': 'keyword',
429 'html': 'keyword3',
430 'HTMLparser': 'reserved',
431 'HTMLparser_tags': 'reserved',
432 'htmlSpecialChars': 'reserved',
433 'htmlTag_dir': 'reserved',
434 'htmlTag_langKey': 'reserved',
435 'htmlTag_setParams': 'reserved',
436 'http': 'reserved',
437 'icon': 'reserved',
438 'icon_image_ext_list': 'reserved',
439 'icon_link': 'reserved',
440 'iconCObject': 'reserved',
441 'id': 'keyword3',
442 'IENV': 'keyword',
443 'if': 'keyword3',
444 'ifEmpty': 'keyword3',
445 'IFSUB': 'keyword3',
446 'IFSUBRO': 'keyword3',
447 'IMAGE': 'keyword',
448 'image': 'keyword3',
449 'image_frames': 'reserved',
450 'imageLinkWrap': 'reserved',
451 'imagePath': 'reserved',
452 'images': 'reserved',
453 'imageWrapIfAny': 'reserved',
454 'IMG_RESOURCE': 'keyword',
455 'imgList': 'keyword2',
456 'imgMap': 'reserved',
457 'imgMapExtras': 'reserved',
458 'imgMax': 'reserved',
459 'IMGMENU': 'keyword',
460 'IMGMENUITEM': 'keyword',
461 'imgNameNotRandom': 'reserved',
462 'imgNamePrefix': 'reserved',
463 'imgObjNum': 'reserved',
464 'imgParams': 'reserved',
465 'imgPath': 'reserved',
466 'imgResource': 'keyword2',
467 'imgStart': 'reserved',
468 'IMGTEXT': 'keyword',
469 'imgText': 'keyword2',
470 'import': 'reserved',
471 'inBranch': 'keyword3',
472 'inc': 'reserved',
473 'INCLUDE_TYPOSCRIPT': 'keyword',
474 'includeCSS': 'reserved',
475 'includeLibrary': 'reserved',
476 'includeNotInMenu': 'reserved',
477 'index': 'reserved',
478 'index_descrLgd': 'reserved',
479 'index_enable': 'reserved',
480 'index_externals': 'reserved',
481 'info': 'keyword2',
482 'inlineStyle2TempFile': 'reserved',
483 'innerStdWrap': 'reserved',
484 'innerStdWrap_all': 'reserved',
485 'innerWrap': 'reserved',
486 'innerWrap2': 'reserved',
487 'input': 'reserved',
488 'inputLevels': 'reserved',
489 'insertClassesFromRTE': 'reserved',
490 'insertData': 'reserved',
491 'intensity': 'reserved',
492 'intTarget': 'reserved',
493 'intval': 'reserved',
494 'invert': 'reserved',
495 'IP': 'keyword2',
496 'IProcFunc': 'reserved',
497 'isFalse': 'keyword3',
498 'isGreaterThan': 'keyword3',
499 'isInList': 'keyword3',
500 'isLessThan': 'keyword3',
501 'isPositive': 'keyword3',
502 'isTrue': 'keyword3',
503 'itemArrayProcFunc': 'reserved',
504 'itemH': 'reserved',
505 'items': 'reserved',
506 'itemsProcFunc': 'reserved',
507 'iterations': 'reserved',
508 'join': 'reserved',
509 'JSMENU': 'keyword',
510 'jsmenu': 'keyword2',
511 'JSMENUITEM': 'keyword',
512 'JSwindow': 'keyword2',
513 'JSWindow': 'reserved',
514 'JSwindow_params': 'reserved',
515 'keep': 'reserved',
516 'keepEntries': 'reserved',
517 'keepNonMatchedTags': 'reserved',
518 'key': 'reserved',
519 'keyword3': 'keyword3',
520 'LABEL': 'keyword2',
521 'label': 'reserved',
522 'labelStdWrap': 'reserved',
523 'labelWrap': 'reserved',
524 'lang': 'reserved',
525 'language': 'keyword3',
526 'language_alt': 'reserved',
527 'languageField': 'reserved',
528 'layout': 'keyword2',
529 'left': 'reserved',
530 'leftjoin': 'reserved',
531 'levels': 'reserved',
532 'leveltitle': 'keyword3',
533 'leveluid': 'reserved',
534 'lib': 'keyword2',
535 'limit': 'reserved',
536 'line': 'reserved',
537 'lineColor': 'reserved',
538 'lineThickness': 'reserved',
539 'linkPrefix': 'reserved',
540 'linkTitleToSelf': 'reserved',
541 'linkVars': 'reserved',
542 'linkWrap': 'reserved',
543 'list': 'keyword3',
544 'listNum': 'reserved',
545 'listOnlyInSingleTableView': 'reserved',
546 'LIT': 'keyword',
547 'lm': 'reserved',
548 'LOAD_REGISTER': 'keyword',
549 'locale_all': 'reserved',
550 'localNesting': 'reserved',
551 'locationData': 'reserved',
552 'lockFilePath': 'reserved',
553 'lockToIP': 'reserved',
554 'login': 'keyword3',
555 'loginUser': 'keyword2',
556 'longdescURL': 'reserved',
557 'lowColor': 'reserved',
558 'lower': 'reserved',
559 'LR': 'reserved',
560 'mailform': 'keyword3',
561 'mailto': 'reserved',
562 'main': 'reserved',
563 'mainScript': 'reserved',
564 'makelinks': 'reserved',
565 'markerWrap': 'reserved',
566 'marks': 'keyword2',
567 'mask': 'reserved',
568 'max': 'reserved',
569 'maxAge': 'reserved',
570 'maxChars': 'reserved',
571 'maxH': 'reserved',
572 'maxHeight': 'reserved',
573 'maxItems': 'reserved',
574 'maxW': 'reserved',
575 'maxWidth': 'reserved',
576 'maxWInText': 'reserved',
577 'media': 'keyword3',
578 'menu': 'keyword3',
579 'menu_type': 'reserved',
580 'menuHeight': 'reserved',
581 'menuName': 'reserved',
582 'menuOffset': 'reserved',
583 'menuWidth': 'reserved',
584 'message_page_is_being_generated': 'reserved',
585 'message_preview': 'reserved',
586 'META': 'keyword',
587 'meta': 'reserved',
588 'metaCharset': 'reserved',
589 'method': 'reserved',
590 'min': 'reserved',
591 'minH': 'reserved',
592 'minItems': 'reserved',
593 'minute': 'keyword2',
594 'minW': 'reserved',
595 'mod': 'keyword3',
596 'mode': 'reserved',
597 'module': 'keyword2',
598 'month': 'keyword2',
599 'move_wizard': 'keyword2',
600 'MP_defaults': 'reserved',
601 'MP_disableTypolinkClosestMPvalue': 'reserved',
602 'MP_mapRootPoints': 'reserved',
603 'MULTIMEDIA': 'keyword',
604 'multimedia': 'keyword3',
605 'name': 'reserved',
606 'negate': 'keyword3',
607 'nesting': 'reserved',
608 'neverHideAtCopy': 'reserved',
609 'new': 'keyword2',
610 'NEW': 'keyword3',
611 'new_wizard': 'keyword2',
612 'newPageWiz': 'reserved',
613 'newRecordFromTable': 'reserved',
614 'newWindow': 'reserved',
615 'newWizards': 'reserved',
616 'next': 'reserved',
617 'niceText': 'reserved',
618 'nicetext': 'reserved',
619 'NO': 'keyword3',
620 'no_cache': 'reserved',
621 'no_search': 'reserved',
622 'noAttrib': 'reserved',
623 'noCache': 'reserved',
624 'noCreateRecordsLink': 'reserved',
625 'noLink': 'reserved',
626 'noMatchingValue_label': 'reserved',
627 'nonCachedSubst': 'reserved',
628 'none': 'keyword3',
629 'nonTypoTagStdWrap': 'reserved',
630 'nonTypoTagUserFunc': 'reserved',
631 'nonWrappedTag': 'reserved',
632 'noOrderBy': 'reserved',
633 'noPageTitle': 'reserved',
634 'noResultObj': 'keyword2',
635 'noThumbsInEB': 'reserved',
636 'noThumbsInRTEimageSelect': 'reserved',
637 'noTrimWrap': 'reserved',
638 'noValueInsert': 'reserved',
639 'numRows': 'keyword2',
640 'obj': 'reserved',
641 'offset': 'reserved',
642 'onlineWorkspaceInfo': 'reserved',
643 'onlyCurrentPid': 'reserved',
644 'opacity': 'reserved',
645 'options': 'keyword2',
646 'orderBy': 'reserved',
647 'outerWrap': 'reserved',
648 'outline': 'reserved',
649 'outputLevels': 'reserved',
650 'override': 'reserved',
651 'overrideAttribs': 'reserved',
652 'overrideId': 'reserved',
653 'overridePageModule': 'reserved',
654 'overrideWithExtension': 'reserved',
655 'PAGE': 'keyword',
656 'page': 'keyword2',
657 'PAGE_TARGET': 'keyword',
658 'PAGE_TSCONFIG_ID': 'keyword',
659 'PAGE_TSCONFIG_IDLIST': 'keyword',
660 'PAGE_TSCONFIG_STR': 'keyword',
661 'pageFrameObj': 'reserved',
662 'pageGenScript': 'reserved',
663 'pages': 'keyword3',
664 'pages_language_overlay': 'keyword3',
665 'pageTitleFirst': 'reserved',
666 'pageTree': 'keyword2',
667 'parameter': 'reserved',
668 'params': 'reserved',
669 'parseFunc': 'reserved',
670 'parseFunc_RTE': 'keyword3',
671 'parser': 'reserved',
672 'password': 'reserved',
673 'paste': 'keyword2',
674 'path': 'reserved',
675 'permissions': 'reserved',
676 'perms': 'keyword2',
677 'pid': 'keyword3',
678 'pid_list': 'reserved',
679 'pidInList': 'reserved',
680 'PIDinRootline': 'keyword2',
681 'PIDupinRootline': 'keyword2',
682 'pixelSpaceFontSizeRef': 'reserved',
683 'plaintextLib': 'reserved',
684 'plainTextStdWrap': 'reserved',
685 'plugin': 'keyword2',
686 'postCObject': 'reserved',
687 'postLineBlanks': 'reserved',
688 'postLineChar': 'reserved',
689 'postLineLen': 'reserved',
690 'postUserFunc': 'reserved',
691 'postUserFuncInt': 'reserved',
692 'preBlanks': 'reserved',
693 'preCObject': 'reserved',
694 'prefix': 'reserved',
695 'prefixComment': 'reserved',
696 'prefixLocalAnchors': 'reserved',
697 'prefixRelPathWith': 'reserved',
698 'preIfEmptyListNum': 'reserved',
699 'preLineBlanks': 'reserved',
700 'preLineChar': 'reserved',
701 'preLineLen': 'reserved',
702 'prepend': 'reserved',
703 'preserveEntities': 'reserved',
704 'preUserFunc': 'reserved',
705 'prev': 'reserved',
706 'preview': 'keyword2',
707 'previewBorder': 'reserved',
708 'prevnextToSection': 'reserved',
709 'prioriCalc': 'reserved',
710 'proc': 'reserved',
711 'processor_allowUpscaling': 'reserved',
712 'properties': 'reserved',
713 'protect': 'reserved',
714 'protectLvar': 'reserved',
715 'publish': 'keyword2',
716 'publish_levels': 'reserved',
717 'QEisDefault': 'reserved',
718 'quality': 'reserved',
719 'RADIO': 'keyword2',
720 'radio': 'reserved',
721 'radioWrap': 'reserved',
722 'range': 'reserved',
723 'rawUrlEncode': 'reserved',
724 'recipient': 'reserved',
725 'RECORDS': 'keyword',
726 'recursive': 'reserved',
727 'recursiveDelete': 'reserved',
728 'redirect': 'reserved',
729 'redirectToURL': 'reserved',
730 'reduceColors': 'reserved',
731 'references': 'reserved',
732 'register': 'reserved',
733 'relPathPrefix': 'reserved',
734 'remap': 'reserved',
735 'remapTag': 'reserved',
736 'REMOTE_ADDR': 'keyword',
737 'removeBadHTML': 'reserved',
738 'removeDefaultJS': 'reserved',
739 'removeIfEquals': 'reserved',
740 'removeIfFalse': 'reserved',
741 'removeItems': 'reserved',
742 'removeObjectsOfDummy': 'reserved',
743 'removePrependedNumbers': 'reserved',
744 'removeTags': 'reserved',
745 'removeWrapping': 'reserved',
746 'renderObj': 'keyword2',
747 'renderWrap': 'reserved',
748 'REQ': 'keyword2',
749 'required': 'keyword3',
750 'reset': 'reserved',
751 'resources': 'reserved',
752 'RESTORE_REGISTER': 'keyword',
753 'resultObj': 'reserved',
754 'returnLast': 'reserved',
755 'returnUrl': 'reserved',
756 'rightjoin': 'reserved',
757 'rm': 'reserved',
758 'rmTagIfNoAttrib': 'reserved',
759 'RO': 'keyword3',
760 'rootline': 'keyword3',
761 'rotate': 'reserved',
762 'rows': 'reserved',
763 'rowSpace': 'reserved',
764 'RTE': 'keyword2',
765 'RTE_compliant': 'keyword2',
766 'RTEfullScreenWidth': 'reserved',
767 'rules': 'reserved',
768 'sample': 'reserved',
769 'saveClipboard': 'reserved',
770 'saveDocNew': 'reserved',
771 'script': 'keyword3',
772 'search': 'keyword3',
773 'SEARCHRESULT': 'keyword',
774 'secondRow': 'reserved',
775 'section': 'reserved',
776 'sectionIndex': 'reserved',
777 'select': 'keyword2',
778 'selectFields': 'reserved',
779 'separator': 'reserved',
780 'set': 'reserved',
781 'setContentToCurrent': 'reserved',
782 'setCurrent': 'reserved',
783 'setfixed': 'reserved',
784 'setOnly': 'reserved',
785 'setup': 'keyword2',
786 'shadow': 'reserved',
787 'SHARED': 'keyword',
788 'sharpen': 'reserved',
789 'shear': 'reserved',
790 'short': 'reserved',
791 'shortcut': 'keyword3',
792 'shortcutFrame': 'reserved',
793 'shortcutIcon': 'reserved',
794 'show': 'reserved',
795 'showAccessRestrictedPages': 'reserved',
796 'showActive': 'reserved',
797 'showClipControlPanelsDespiteOfCMlayers': 'reserved',
798 'showFirst': 'reserved',
799 'showHiddenPages': 'reserved',
800 'showHiddenRecords': 'reserved',
801 'showHistory': 'reserved',
802 'showPageIdWithTitle': 'reserved',
803 'showTagFreeClasses': 'reserved',
804 'simulateDate': 'reserved',
805 'simulateUserGroup': 'reserved',
806 'singlePid': 'reserved',
807 'site_author': 'reserved',
808 'site_reserved': 'reserved',
809 'sitemap': 'keyword3',
810 'sitetitle': 'reserved',
811 'siteUrl': 'reserved',
812 'size': 'reserved',
813 'solarize': 'reserved',
814 'sorting': 'reserved',
815 'source': 'reserved',
816 'space': 'reserved',
817 'spaceAfter': 'reserved',
818 'spaceBefore': 'reserved',
819 'spaceBelowAbove': 'reserved',
820 'spaceLeft': 'reserved',
821 'spaceRight': 'reserved',
822 'spacing': 'reserved',
823 'spamProtectEmailAddresses': 'reserved',
824 'spamProtectEmailAddresses_atSubst': 'reserved',
825 'spamProtectEmailAddresses_lastDotSubst': 'reserved',
826 'SPC': 'keyword3',
827 'special': 'reserved',
828 'split': 'keyword2',
829 'splitChar': 'reserved',
830 'splitRendering': 'reserved',
831 'src': 'reserved',
832 'stdheader': 'reserved',
833 'stdWrap': 'keyword2',
834 'stdWrap2': 'reserved',
835 'strftime': 'reserved',
836 'stripHtml': 'reserved',
837 'styles': 'reserved',
838 'stylesheet': 'reserved',
839 'submenuObjSuffixes': 'reserved',
840 'subMenuOffset': 'reserved',
841 'submit': 'reserved',
842 'subparts': 'keyword2',
843 'subst_elementUid': 'reserved',
844 'substMarksSeparately': 'reserved',
845 'substring': 'reserved',
846 'swirl': 'reserved',
847 'sword': 'reserved',
848 'sword_noMixedCase': 'reserved',
849 'SWORD_PARAMS': 'reserved',
850 'sword_standAlone': 'reserved',
851 'sys_dmail': 'keyword3',
852 'sys_domain': 'keyword3',
853 'sys_filemounts': 'keyword3',
854 'sys_language_mode': 'reserved',
855 'sys_language_overlay': 'reserved',
856 'sys_language_uid': 'reserved',
857 'sys_note': 'keyword3',
858 'sys_template': 'keyword3',
859 'system': 'keyword2',
860 'table': 'keyword3',
861 'tableCellColor': 'reserved',
862 'tableParams': 'reserved',
863 'tables': 'reserved',
864 'tableStdWrap': 'reserved',
865 'tableWidth': 'reserved',
866 'tags': 'reserved',
867 'target': 'reserved',
868 'TCAdefaults': 'keyword',
869 'TCEFORM': 'keyword',
870 'TCEMAIN': 'keyword',
871 'TDparams': 'reserved',
872 'temp': 'keyword2',
873 'TEMPLATE': 'keyword',
874 'template': 'keyword2',
875 'templateContent': 'reserved',
876 'templateFile': 'reserved',
877 'TEXT': 'keyword',
878 'text': 'keyword3',
879 'textarea': 'reserved',
880 'textMargin': 'reserved',
881 'textMargin_outOfText': 'reserved',
882 'textMaxLength': 'reserved',
883 'textObjNum': 'reserved',
884 'textpic': 'keyword3',
885 'textPos': 'reserved',
886 'thickness': 'reserved',
887 'this': 'keyword3',
888 'thumbnailsByDefault': 'reserved',
889 'tile': 'reserved',
890 'time_stdWrap': 'reserved',
891 'tipafriendLib': 'reserved',
892 'title': 'reserved',
893 'titleLen': 'reserved',
894 'titleTagFunction': 'reserved',
895 'titleText': 'reserved',
896 'tm': 'reserved',
897 'TMENU': 'keyword',
898 'TMENUITEM': 'keyword',
899 'token': 'reserved',
900 'top': 'keyword3',
901 'totalWidth': 'reserved',
902 'transparentBackground': 'reserved',
903 'transparentColor': 'reserved',
904 'treeLevel': 'keyword2',
905 'trim': 'reserved',
906 'true': 'keyword3',
907 'tsdebug': 'keyword2',
908 'tsdebug_tree': 'reserved',
909 'TSFE': 'keyword',
910 'type': 'reserved',
911 'typeNum': 'reserved',
912 'types': 'reserved',
913 'typolink': 'keyword2',
914 'typolinkCheckRootline': 'reserved',
915 'uid': 'keyword3',
916 'uidInList': 'reserved',
917 'uniqueGlobal': 'keyword3',
918 'uniqueLocal': 'keyword3',
919 'unset': 'reserved',
920 'unsetEmpty': 'keyword3',
921 'updated': 'keyword3',
922 'uploadFieldsInTopOfEB': 'reserved',
923 'uploads': 'keyword3',
924 'upper': 'reserved',
925 'url': 'keyword2',
926 'us': 'keyword3',
927 'useCacheHash': 'reserved',
928 'useLargestItemX': 'reserved',
929 'useLargestItemY': 'reserved',
930 'USER': 'keyword',
931 'user': 'reserved',
932 'USER_INT': 'keyword',
933 'user_task': 'keyword3',
934 'useragent': 'keyword2',
935 'USERDEF1': 'keyword3',
936 'USERDEF1RO': 'keyword3',
937 'USERDEF2': 'keyword3',
938 'USERDEF2RO': 'keyword3',
939 'userdefined': 'reserved',
940 'userFunc': 'keyword2',
941 'userfunction': 'reserved',
942 'usergroup': 'keyword3',
943 'userid': 'reserved',
944 'USERNAME_substToken': 'reserved',
945 'userProc': 'reserved',
946 'USR': 'keyword3',
947 'USRRO': 'keyword3',
948 'value': 'reserved',
949 'valueArray': 'reserved',
950 'version': 'keyword2',
951 'view': 'keyword2',
952 'wave': 'reserved',
953 'web_func': 'keyword3',
954 'web_info': 'keyword3',
955 'web_layout': 'keyword3',
956 'web_list': 'keyword3',
957 'web_ts': 'keyword',
958 'where': 'reserved',
959 'width': 'reserved',
960 'wiz': 'reserved',
961 'wordSpacing': 'reserved',
962 'workArea': 'reserved',
963 'workOnSubpart': 'keyword2',
964 'wrap': 'reserved',
965 'wrap1': 'reserved',
966 'wrap2': 'reserved',
967 'wrap3': 'reserved',
968 'wrapAfterTags': 'reserved',
969 'wrapAlign': 'reserved',
970 'wrapFieldName': 'reserved',
971 'wrapItemAndSub': 'reserved',
972 'wrapNonWrappedLines': 'reserved',
973 'wraps': 'reserved',
974 'xhtml_cleaning': 'reserved',
975 'xhtml_strict': 'keyword3',
976 'xhtml_trans': 'keyword3',
977 'xmlprologue': 'reserved',
978 'XY': 'keyword3',
979 };
980
981 var tokenizeTypoScript = function() {
982
983 // Some helper regexp matchers.
984 var isOperatorChar = matcher(/[\+\-\*\&\%\/=<>!\?]/);
985 var isDigit = matcher(/[0-9]/);
986 var isHexDigit = matcher(/[0-9A-Fa-f]/);
987 var isWordChar = matcher(/[\w\$_]/);
988
989 function isWhiteSpace(ch) {
990 // Unfortunately, IE's regexp matcher thinks non-breaking spaces
991 // aren't whitespace. Also, in our scheme newlines are no
992 // whitespace (they are another special case).
993 return ch != "\n" && (ch == nbsp || /\s/.test(ch));
994 }
995
996 // This function produces a MochiKit-style iterator that tokenizes
997 // the output of the given stringstream (see stringstream.js).
998 // Tokens are objects with a type, style, and value property. The
999 // value contains the textual content of the token. Because this may
1000 // include trailing whitespace (for efficiency reasons), some
1001 // tokens, such a variable names, also have a name property
1002 // containing their actual textual value.
1003 return function(source) {
1004 // Produce a value to return. Automatically skips and includes any
1005 // whitespace. The base argument is prepended to the value
1006 // property and assigned to the name property -- this is used when
1007 // the caller has already extracted the text from the stream
1008 // himself.
1009 function result(type, style, base) {
1010 // nextWhile(isWhiteSpace); - comment thats line because needed for autocomplete
1011 var value = {
1012 type: type,
1013 style: style,
1014 value: (base ? base + source.get() : source.get())
1015 };
1016 if (base) {
1017 value.name = base;
1018 }
1019 return value;
1020 }
1021
1022 // Advance the text stream over characters for which test returns
1023 // true. (The characters that are 'consumed' like this can later
1024 // be retrieved by calling source.get()).
1025 function nextWhile(test) {
1026 var next;
1027 while ((next = source.peek()) && test(next)) {
1028 source.next();
1029 }
1030 }
1031
1032 // Advance the stream until the given character (not preceded by a
1033 // backslash) is encountered (or a newline is found).
1034 function nextUntilUnescaped(end) {
1035 var escaped = false;
1036 var next;
1037 while ((next = source.peek()) && next != "\n") {
1038 source.next();
1039 if (next == end && !escaped) {
1040 break;
1041 }
1042 escaped = next == "\\";
1043 }
1044 }
1045
1046 function readHexNumber() {
1047 source.next();
1048 // skip the 'x'
1049 nextWhile(isHexDigit);
1050 return result("number", "atom");
1051 }
1052
1053 function readNumber() {
1054 nextWhile(isDigit);
1055 return result("number", "atom");
1056 }
1057
1058 // Read a word, look it up in keywords. If not found, it is a
1059 // variable, otherwise it is a keyword of the type found.
1060 function readWord() {
1061 nextWhile(isWordChar);
1062 var word = source.get();
1063 var known = typoscriptWords.hasOwnProperty(word) && {
1064 type: 'keyword',
1065 style: typoscriptWords[word]
1066 };
1067 return known ?
1068 result(known.type, known.style, word) :
1069 result("variable", "other", word);
1070 }
1071
1072 function readRegexp() {
1073 nextUntilUnescaped("/");
1074 nextWhile(matcher(/[gi]/));
1075 return result("regexp", "string");
1076 }
1077
1078 // Mutli-line comments are tricky. We want to return the newlines
1079 // embedded in them as regular newline tokens, and then continue
1080 // returning a comment token for every line of the comment. So
1081 // some state has to be saved (inComment) to indicate whether we
1082 // are inside a /* */ sequence.
1083 function readMultilineComment(start) {
1084 this.inComment = true;
1085 var maybeEnd = (start == "*");
1086 while (true) {
1087 var next = source.peek();
1088 if (next == "\n") {
1089 break;
1090 }
1091 source.next();
1092 if (next == "/" && maybeEnd) {
1093 this.inComment = false;
1094 break;
1095 }
1096 maybeEnd = (next == "*");
1097 }
1098
1099 return result("comment", "ts-comment");
1100 }
1101
1102 // Fetch the next token. Dispatches on first character in the
1103 // stream, or first two characters when the first is a slash. The
1104 // || things are a silly trick to keep simple cases on a single
1105 // line.
1106 function next() {
1107 var token = null;
1108 var ch = source.next();
1109 if (ch == "\n") {
1110 token = {
1111 type: "newline",
1112 style: "whitespace",
1113 value: source.get()
1114 };
1115 this.inValue = false;
1116
1117 } else if (!this.inValue && this.inComment) {
1118 token = readMultilineComment.call(this, ch);
1119
1120 /*
1121 } else if (this.inValue) {
1122 token = nextUntilUnescaped(null) || {
1123 type: "value",
1124 style: "ts-value",
1125 value: source.get()
1126 };
1127 this.inValue = false;
1128 */
1129
1130 } else if (isWhiteSpace(ch)) {
1131 token = nextWhile(isWhiteSpace) || result("whitespace", "whitespace");
1132
1133 } else if (!this.inValue && (ch == "\"" || ch == "'")) {
1134 token = nextUntilUnescaped(ch) || result("string", "string");
1135
1136 } else if (
1137 (ch == "<" ||
1138 ch == ">" ||
1139 ch == "." ||
1140 (ch == "=" && source.peek() != "<")
1141 )
1142 && source.peek() != "\n" ) { // there must be some value behind the operator!
1143 this.inValue = true;
1144 token = result(ch, "ts-operator");
1145
1146 } else if (!this.inValue && ch == "[") {
1147 token = nextUntilUnescaped("]") || result("condition", "ts-condition");
1148
1149 // with punctuation, the type of the token is the symbol itself
1150 } else if (!this.inValue && /[\[\]\(\),;\:\.\<\>\=]/.test(ch)) {
1151 token = result(ch, "ts-operator");
1152
1153 } else if (!this.inValue && (ch == "{" || ch == "}")) {
1154 token = result(ch, "ts-operator curly-bracket");
1155
1156 } else if (!this.inValue && ch == "0" && (source.peek() == "x" || source.peek() == "X")) {
1157 token = readHexNumber();
1158
1159 } else if (!this.inValue && isDigit(ch)) {
1160 token = readNumber();
1161
1162 } else if (!this.inValue && ch == "/") {
1163 next = source.peek();
1164
1165 if (next == "*") {
1166 token = readMultilineComment.call(this, ch);
1167
1168 } else if (next == "/") {
1169 token = nextUntilUnescaped(null) || result("comment", "ts-comment");
1170
1171 } else if (this.regexp) {
1172 token = readRegexp();
1173
1174 } else {
1175 token = nextWhile(isOperatorChar) || result("operator", "ts-operator");
1176 }
1177
1178 } else if (!this.inValue && ch == "#") {
1179 token = nextUntilUnescaped(null) || result("comment", "ts-comment");
1180
1181 } else if (!this.inValue && isOperatorChar(ch)) {
1182 token = nextWhile(isOperatorChar) || result("operator", "ts-operator");
1183
1184 } else {
1185 token = readWord();
1186 if (this.inValue) {
1187 token.style += ' ts-value';
1188 }
1189 }
1190
1191 // JavaScript's syntax rules for when a slash might be the start
1192 // of a regexp and when it is just a division operator are kind
1193 // of non-obvious. This decides, based on the current token,
1194 // whether the next token could be a regular expression.
1195 if (token.style != "whitespace" && token != "comment") {
1196 this.regexp = token.type == "operator" || token.type == "keyword c" || token.type.match(/[\[{}\(,;:]/);
1197 }
1198 return token;
1199 }
1200
1201 // Wrap it in an iterator. The state (regexp and inComment) is
1202 // exposed because a parser will need to save it when making a
1203 // copy of its state.
1204 return {
1205 next: next,
1206 regexp: true,
1207 inComment: false,
1208 inValue: false
1209 };
1210 }
1211 } ();