Skip to content

Commit

Permalink
Added support for TypoScript (#2505)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkern committed Aug 11, 2020
1 parent 388ad99 commit bf115f4
Show file tree
Hide file tree
Showing 14 changed files with 349 additions and 4 deletions.
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion components.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
"arduino": {
"title": "Arduino",
"require": "cpp",
"owner": "eisbehr-"
"owner": "dkern"
},
"arff": {
"title": "ARFF",
Expand Down Expand Up @@ -1142,6 +1142,14 @@
"alias": "ts",
"owner": "vkbansal"
},
"typoscript": {
"title": "TypoScript",
"alias": "tsconfig",
"aliasTitles": {
"tsconfig": "TSConfig"
},
"owner": "dkern"
},
"unrealscript": {
"title": "UnrealScript",
"alias": ["uscript", "uc"],
Expand Down
80 changes: 80 additions & 0 deletions components/prism-typoscript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
(function(Prism) {

var keywords = /\b(?:ACT|ACTIFSUB|CARRAY|CASE|CLEARGIF|COA|COA_INT|CONSTANTS|CONTENT|CUR|EDITPANEL|EFFECT|EXT|FILE|FLUIDTEMPLATE|FORM|FRAME|FRAMESET|GIFBUILDER|GMENU|GMENU_FOLDOUT|GMENU_LAYERS|GP|HMENU|HRULER|HTML|IENV|IFSUB|IMAGE|IMGMENU|IMGMENUITEM|IMGTEXT|IMG_RESOURCE|INCLUDE_TYPOSCRIPT|JSMENU|JSMENUITEM|LLL|LOAD_REGISTER|NO|PAGE|RECORDS|RESTORE_REGISTER|TEMPLATE|TEXT|TMENU|TMENUITEM|TMENU_LAYERS|USER|USER_INT|_GIFBUILDER|global|globalString|globalVar)\b/;

Prism.languages.typoscript = {
'comment': [
{
// multiline comments /* */
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
lookbehind: true
},
{
// double-slash comments - ignored when backslashes or colon is found in front
// also ignored whenever directly after an equal-sign, because it would probably be an url without protocol
pattern: /(^|[^\\:= \t]|(?:^|[^= \t])[ \t]+)\/\/.*/,
lookbehind: true,
greedy: true
},
{
// hash comments - ignored when leading quote is found for hex colors in strings
pattern: /(^|[^"'])#.*/,
lookbehind: true,
greedy: true
}
],
'function': [
{
// old include style
pattern: /<INCLUDE_TYPOSCRIPT:\s*source\s*=\s*(?:"[^"\r\n]*"|'[^'\r\n]*')\s*>/,
inside: {
'string': {
pattern: /"[^"\r\n]*"|'[^'\r\n]*'/,
inside: {
'keyword': keywords,
},
},
'keyword': {
pattern: /INCLUDE_TYPOSCRIPT/,
},
},
},
{
// new include style
pattern: /@import\s*(?:"[^"\r\n]*"|'[^'\r\n]*')/,
inside: {
'string': /"[^"\r\n]*"|'[^'\r\n]*'/,
},
}
],
'string': {
pattern: /^([^=]*=[< ]?)(?:(?!]\n).)*/,
lookbehind: true,
inside: {
'function': /{\$.*}/, // constants include
'keyword': keywords,
'number': /^[0-9]+$/,
'punctuation': /[,|:]/,
}
},
'keyword': keywords,
'number': {
// special highlighting for indexes of arrays in tags
pattern: /[0-9]+\s*[.{=]/,
inside: {
'operator': /[.{=]/,
}
},
'tag': {
pattern: /\.?[\w-\\]+\.?/,
inside: {
'punctuation': /\./,
}
},
'punctuation': /[{}[\];(),.:|]/,
'operator': /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
};

Prism.languages.tsconfig = Prism.languages.typoscript;

}(Prism));
1 change: 1 addition & 0 deletions components/prism-typoscript.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

95 changes: 95 additions & 0 deletions examples/prism-typoscript.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<h2>Typical TypoScript Setup File</h2>
<pre><code># import other files
@import 'EXT:fluid_styled_content/Configuration/TypoScript/setup.typoscript'
@import 'EXT:sitepackage/Configuration/TypoScript/Helper/DynamicContent.typoscript'

page = PAGE
page {
typeNum = 0

// setup templates
10 = FLUIDTEMPLATE
10 {
templateName = TEXT
templateName.stdWrap.cObject = CASE
templateName.stdWrap.cObject {
key.data = pagelayout

pagets__sitepackage_default = TEXT
pagets__sitepackage_default.value = Default

pagets__sitepackage_alternate = TEXT
pagets__sitepackage_alternate.value = Alternative

default = TEXT
default.value = Default
}

templateRootPaths {
0 = EXT:sitepackage/Resources/Private/Templates/Page/
1 = {$sitepackage.fluidtemplate.templateRootPath}
}

partialRootPaths {
0 = EXT:sitepackage/Resources/Private/Partials/Page/
1 = {$sitepackage.fluidtemplate.partialRootPath}
}

layoutRootPaths {
0 = EXT:sitepackage/Resources/Private/Layouts/Page/
1 = {$sitepackage.fluidtemplate.layoutRootPath}
}

dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
10 {
levels = 1
includeSpacer = 1
as = mainnavigation
}
}
}

// include css into head
includeCSS {
bootstrap = https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css
bootstrap.external = 1
website = EXT:sitepackage/Resources/Public/Css/styles.css
}

// include js into footer
includeJSFooter {
jquery = https://code.jquery.com/jquery-3.2.1.slim.min.js
jquery.external = 1
bootstrap = https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js
bootstrap.external = 1
website = EXT:sitepackage/Resources/Public/JavaScript/scripts.js
}
}

// global site configuration
config {
absRefPrefix = auto
cache_period = 86400
debug = 0
disablePrefixComment = 1
doctype = html5
extTarget =
index_enable = 1
index_externals = 1
index_metatags = 1
inlineStyle2TempFile = 1
intTarget =
linkVars = L
metaCharset = utf-8
no_cache = 0
pageTitleFirst = 1
prefixLocalAnchors = all
removeDefaultJS = 0
sendCacheHeaders = 1
compressCss = 0
compressJs = 0
concatenateCss = 0
concatenateJs = 0
}
</code></pre>
1 change: 1 addition & 0 deletions plugins/autoloader/prism-autoloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@
"t4": "t4-cs",
"trig": "turtle",
"ts": "typescript",
"tsconfig": "typoscript",
"uscript": "unrealscript",
"uc": "unrealscript",
"vb": "visual-basic",
Expand Down
2 changes: 1 addition & 1 deletion plugins/autoloader/prism-autoloader.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions plugins/show-language/prism-show-language.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
"toml": "TOML",
"trig": "TriG",
"ts": "TypeScript",
"tsconfig": "TSConfig",
"uscript": "UnrealScript",
"uc": "UnrealScript",
"vbnet": "VB.Net",
Expand Down
Loading

0 comments on commit bf115f4

Please sign in to comment.