diff --git a/content/assets/css/prism-fhirpath.css b/content/assets/css/prism-fhirpath.css new file mode 100644 index 0000000..5c73bff --- /dev/null +++ b/content/assets/css/prism-fhirpath.css @@ -0,0 +1,38 @@ +/* Custom formatting for the code blocks */ +pre.language-fhirpath { + background-color: #eee; + text-shadow: unset; +} + +pre.language-fhirpath code.language-fhirpath { + white-space: pre-wrap; + text-shadow: unset; +} + +.token.operator, +.token.entity, +.token.url, +.language-css .token.string, +.style .token.string { + background: unset; +} + + +pre.language-fhirpath.stu { + margin-left: 20px; + overflow: unset; +} +pre.language-fhirpath.stu:after { + left: -16px; +} + +/* inline fhirpath code blocks used in examples */ +:not(pre) > code.fhirpath { + background-color: #eee; + padding: 1px 4px; + border: 1px solid #cccccc; + font-size: 1em; + display: inline-block; + margin: 2px 0; + text-shadow: unset; +} diff --git a/content/assets/js/prism-fhirpath.js b/content/assets/js/prism-fhirpath.js new file mode 100644 index 0000000..01d503d --- /dev/null +++ b/content/assets/js/prism-fhirpath.js @@ -0,0 +1,67 @@ +/* eslint-disable regexp/prefer-d */ +// https://hl7.org/fhirpath +Prism.languages.fhirpath = { + 'comment': { + pattern: /\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/, + greedy: true + }, + 'constant': [ + // This is where I'm going to put in the literals for datetime/date/time/quantity + /@[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9](:[0-9][0-9])?(\.[0-9]+)?(Z|[+\-][0-9][0-9]:[0-9][0-9])?/, + /@[0-9][0-9][0-9][0-9](-[0-9][0-9](-[0-9][0-9])?)?/, + /@T[0-9][0-9]:[0-9][0-9](:[0-9][0-9])?(\.[0-9]+)?/, + /\b\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b\s+(years|months|weeks|days|hours|minutes|seconds|milliseconds|year|month|week|day|hour|minute|second|millisecond)\b/ + ], + 'number': [ + /\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i, + /\b\d+(?:\.\d+)?L\b/i + ], + 'string': { + pattern: /(^|[^\\])'(?:\\.|[^\\'\r\n])*'(?!\s*:)/, + lookbehind: true, + greedy: true + }, + 'punctuation': /[()[\],.]/, + 'operator': /(>=|<=|!=|!~|[|\\+\-=<>~/*&])/, + 'keyword': [ + /\b(and|as|contains|day|days|div|hour|hours|implies|in|\$index|is|millisecond|milliseconds|minute|minutes|mod|month|months|or|second|seconds|\$this|\$total|week|weeks|xor|year|years)\b/, + /\{\s*\}/ + ], + 'boolean': /\b(?:false|true)\b/, + 'builtin': [ + // section 5.1 http://hl7.org/fhirpath/#existence + /\b(empty|exists|all|allTrue|anyTrue|allFalse|anyFalse|subsetOf|supersetOf|count|distinct|isDistinct)\b/, + // section 5.2 http://hl7.org/fhirpath/#filtering-and-projection + /\b(where|select|repeat|ofType)\b/, + // section 5.3 http://hl7.org/fhirpath/#subsetting + /\b(single|first|last|tail|skip|take|intersect|exclude)\b/, + // section 5.4 + /\b(union|combine)\b/, + // section 5.5 + /\b(iif|toBoolean|convertsToBoolean|toInteger|convertsToInteger|toDate|convertsToDate|toDateTime|convertsToDateTime|toDecimal|convertsToDecimal|toQuantity|convertsToQuantity|toString|convertsToString|toTime|convertsToTime)\b/, + // section 5.6 + /\b(indexOf|substring|startsWith|endsWith|contains|upper|lower|replace|matches|replaceMatches|length|toChars|split|join|encode|decode)\b/, + // section 5.7 + /\b(abs|ceiling|exp|floor|ln|log|power|round|sqrt|truncate)\b/, + // section 5.8 + /\b(children|descendants)\b/, + // section 5.9 (not is in section 6.5) + /\b(trace|now|timeOfDay|today|not)\b/, + // section 6.3 + /\b(as|is)\b/, + // section 7 + /\b(aggregate)\b/ + ], + 'variable': [ + /(%\w+)\b/, + /(%`(?:\w|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|[ \-\."\\\/fnrt])+`)/ // this isn;t quite right, but it's a start + ], + 'identifier': [ + { + pattern: /`(?:\w|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|[ \-\."\\\/fnrt])+`/, + // lookbehind: true, + greedy: true + }, + /\b([A-Za-z]|_)([A-Za-z0-9]|_)*\b/, + ] +};