diff --git a/.vitepress/languages/index.ts b/.vitepress/languages/index.ts index bfca47efe..c422eb904 100644 --- a/.vitepress/languages/index.ts +++ b/.vitepress/languages/index.ts @@ -1,12 +1,26 @@ -import cds from './cds.tmLanguage.json' with {type:'json'} -import csv from './csv.tmLanguage.json' with {type:'json'} -import log from './log.tmLanguage.json' with {type:'json'} -import scsv from './scsv.tmLanguage.json' with {type:'json'} +import { bundledLanguages } from 'shiki' +import cds from './cds.tmLanguage.json' with { type: 'json' } +import csv from './csv.tmLanguage.json' with { type: 'json' } +import log from './log.tmLanguage.json' with { type: 'json' } +import scsv from './scsv.tmLanguage.json' with { type: 'json' } import type { LanguageInput } from 'shiki' + export default [ + { ...cds, aliases:['cds','cdl','dcl','cql'] }, { ...csv, aliases:['csv','csvc'] }, { ...scsv, aliases:['csvs'] }, { ...log, aliases:['log','logs'] }, + () => langAlias('php', 'httpc'), + ] as LanguageInput[] + +async function langAlias(targetLang: keyof typeof bundledLanguages, alias: string) { + const grammars = (await bundledLanguages[targetLang]()).default + const targetScope = `source.${targetLang}` + return grammars.map(g => g.scopeName === targetScope + ? { ...g, aliases: [...(g.aliases ?? []), alias] } + : g, + ) +} diff --git a/.vitepress/theme/components/cds-playground/highlighter.js b/.vitepress/theme/components/cds-playground/highlighter.js index 8f6fe37ad..5dce6261c 100644 --- a/.vitepress/theme/components/cds-playground/highlighter.js +++ b/.vitepress/theme/components/cds-playground/highlighter.js @@ -4,7 +4,10 @@ import languages from '../../../languages' const highlighter = await createHighlighter({ themes: ['github-dark', 'github-light'], langs: ['javascript', 'js', 'sql', 'typescript', 'vue', ...languages], - langAlias: Object.fromEntries( languages.map(l => l.aliases?.map(alias => [alias, l.name])) ) + langAlias: Object.fromEntries(languages.flatMap(l => { + if (!l || typeof l !== 'object' || !Array.isArray(l.aliases) || !l.name) return [] + return l.aliases.map(alias => [alias, l.name]) + })) }) export default highlighter diff --git a/guides/uis/fiori.md b/guides/uis/fiori.md index bfaa2224f..76b3e4215 100644 --- a/guides/uis/fiori.md +++ b/guides/uis/fiori.md @@ -306,7 +306,7 @@ Draft locks are not applied when creating drafts for new entities, as there is n The HTTP requests sent from Fiori clients that deal with drafts are as follows: -```php:line-numbers [Requests to draft data] +```httpc:line-numbers [Requests to draft data] POST /Foo/draftNew //> NEW POST /Foo(ID,IsActiveEntity=true)/draftEdit //> EDIT GET /Foo(ID,IsActiveEntity=false) //> READ @@ -347,7 +347,7 @@ Content-Type: application/json Add `IsActiveEntity=true` as a key parameter to your requests to address *active* data directly, bypassing potentially existing drafts, for example: -```php:line-numbers [Requests to active data] +```httpc:line-numbers [Requests to active data] POST /Books { IsActiveEntity:true, ... } //> CREATE PATCH /Books(ID=201,IsActiveEntity=true) {...} //> UPDATE DELETE /Books(ID=201,IsActiveEntity=true) //> DELETE @@ -362,7 +362,7 @@ While this was always possible in CAP Java before, it's available for CAP Node.j Going one step further, we assume `IsActiveEntity=true` by default, so that clients which don't know anything about drafts, or don't want to deal with them, can simply ignore any draft-specific requests and parameters: -```php:line-numbers [Draft-agnostic requests to active data] +```httpc:line-numbers [Draft-agnostic requests to active data] POST /Foo //> CREATE GET /Foo(ID) //> READ PATCH /Foo(ID) {...} //> UPDATE