From 2949585ac62a3f710b5b30a72238edf49f7e2783 Mon Sep 17 00:00:00 2001 From: ThirtySomething Date: Sat, 12 Jun 2021 15:38:06 +0200 Subject: [PATCH 1/6] Added converter for PlantUML builtin functions --- src/plantuml/diagram/builtinfunctions.ts | 77 ++++++++++++++++++++++++ src/plantuml/diagram/title.ts | 3 + 2 files changed, 80 insertions(+) create mode 100644 src/plantuml/diagram/builtinfunctions.ts diff --git a/src/plantuml/diagram/builtinfunctions.ts b/src/plantuml/diagram/builtinfunctions.ts new file mode 100644 index 0000000..4c330b7 --- /dev/null +++ b/src/plantuml/diagram/builtinfunctions.ts @@ -0,0 +1,77 @@ +interface regReplaceBF { + find: RegExp; + replace: string; +} + +const regs: regReplaceBF[] = [ + // PlantUML Builtin functions + // https://plantuml.com/de/preprocessing#291cabbe982ff775 + // Replace %darken("red", 20) + { find: /(\%darken\(.+?(?=\))\))/mg, replace: '' }, + // Replace %date("yyyy.MM.dd' at 'HH:mm") + { find: /(\%date\(.+?(?=\))\))/mg, replace: (function () { let today = new Date().toLocaleDateString(); return today; }()) }, + // Replace %dirpath() + // Not working in VSCode preview in title tag + // { find: /(\%dirpath\(\))/mg, replace: 'dirpath' }, + // Replace %feature("theme") + { find: /(\%feature\(.+?(?=\))\))/mg, replace: 'feature' }, + // Replace %false() + { find: /(\%false\(\))/mg, replace: 'false' }, + // Replace %file_exists("c:/foo/dummy.txt") + { find: /(\%file_exists\(.+?(?=\))\))/mg, replace: 'file_exists' }, + // Replace %filename() + { find: /(\%filename\(\))/mg, replace: 'filename' }, + // Replace %function_exists("$some_function") + { find: /(\%function_exists\(.+?(?=\))\))/mg, replace: 'function_exists' }, + // Replace %get_variable_value("$my_variable") + // Not working in VSCode preview in title tag + // { find: /(\%get_variable_value\(.+?(?=\))\))/mg, replace: 'get_variable_value' }, + // Replace %getenv("OS") + { find: /(\%getenv\(.+?(?=\))\))/mg, replace: 'getenv' }, + // Replace %intval("42") + { find: /(\%intval\(.+?(?=\))\))/mg, replace: 'intval' }, + // Replace %is_dark("#000000") + { find: /(\%is_dark\(.+?(?=\))\))/mg, replace: 'is_dark' }, + // Replace %is_light("#000000") + { find: /(\%is_light\(.+?(?=\))\))/mg, replace: 'is_light' }, + // Replace %lighten("red", 20) + { find: /(\%lighten\(.+?(?=\))\))/mg, replace: 'lighten' }, + // Replace %lower("Hello") + { find: /(\%lower\(.+?(?=\))\))/mg, replace: 'lower' }, + // Replace %newline() + // Not working in VSCode preview in title tag + // { find: /(\%newline\(\))/mg, replace: ' ' }, + // Replace %not(2+2==4) + { find: /(\%not\(.+?(?=\))\))/mg, replace: 'not' }, + // Replace %reverse_color("#FF7700") + { find: /(\%reverse_color\(.+?(?=\))\))/mg, replace: 'reverse_color' }, + // Replace %reverse_hsluv_color("#FF7700") + { find: /(\%reverse_hsluv_color\(.+?(?=\))\))/mg, replace: 'reverse_hsluv_color' }, + // Replace %set_variable_value("$my_variable", "some_value") + // Not working in VSCode preview in title tag + // { find: /(\%set_variable_value\(.+?(?=\))\))/mg, replace: 'set_variable_value' }, + // Replace %string(1 + 2) + { find: /(\%string\(.+?(?=\))\))/mg, replace: 'string' }, + // Replace %strlen("foo") + { find: /(\%strlen\(.+?(?=\))\))/mg, replace: 'strlen' }, + // Replace %strpos("abcdef", "ef") + { find: /(\%strpos\(.+?(?=\))\))/mg, replace: 'strpos' }, + // Replace %substr("abcdef", 3, 2) + { find: /(\%substr\(.+?(?=\))\))/mg, replace: 'substr' }, + // Replace %true() + { find: /(\%true\(\))/mg, replace: 'true' }, + // Replace %upper("Hello") + { find: /(\%upper\(.+?(?=\))\))/mg, replace: 'upper' }, + // Replace %variable_exists("$my_variable") + { find: /(\%variable_exists\(.+?(?=\))\))/mg, replace: 'variable_exists' }, + // Replace %version() + { find: /(\%version\(\))/mg, replace: 'version' }, +] + +export function Deal(instring: string): string { + let workstring = instring; + for (let rp of regs) { + workstring = workstring.replace(rp.find, rp.replace).trim(); + } + return workstring; +} \ No newline at end of file diff --git a/src/plantuml/diagram/title.ts b/src/plantuml/diagram/title.ts index be28581..1d21935 100644 --- a/src/plantuml/diagram/title.ts +++ b/src/plantuml/diagram/title.ts @@ -1,3 +1,5 @@ +import * as builtinfunctions from './builtinfunctions'; + interface regReplace { find: RegExp; replace: string; @@ -36,5 +38,6 @@ export function Deal(value: string): string { for (let rp of regs){ title=title.replace(rp.find,rp.replace).trim(); } + title = builtinfunctions.Deal(title); return title; } \ No newline at end of file From 8074e78583ce08cf54b7e377b2da8fc46df0c0bb Mon Sep 17 00:00:00 2001 From: ThirtySomething Date: Sat, 19 Jun 2021 16:50:37 +0200 Subject: [PATCH 2/6] Re-write of preprocessor as class. Fixed call of preprocessing. --- src/plantuml/diagram/builtinfunctions.ts | 379 ++++++++++++++++++----- src/plantuml/diagram/diagram.ts | 9 +- src/plantuml/diagram/title.ts | 3 - 3 files changed, 310 insertions(+), 81 deletions(-) diff --git a/src/plantuml/diagram/builtinfunctions.ts b/src/plantuml/diagram/builtinfunctions.ts index 4c330b7..390a0ad 100644 --- a/src/plantuml/diagram/builtinfunctions.ts +++ b/src/plantuml/diagram/builtinfunctions.ts @@ -1,77 +1,304 @@ -interface regReplaceBF { - find: RegExp; - replace: string; -} +// PlantUML Builtin functions +// https://plantuml.com/de/preprocessing#291cabbe982ff775 + +// 001: How to enable extension to use 'ts-expression-evaluator' +// import evaluate, { registerFunction } from 'ts-expression-evaluator' + +export class BuiltinFunctionsPreprocessor { + private _builtinFunctionRegularExpression = /%([a-z_]+)\(([^\)]+)?\)/ig; + private _quotesRegularExpression = /"/ig; + + private _filename: string = undefined; + private _pathname: string = undefined; + private _buildinfunction: string = undefined; + private _functionname: string = undefined; + private _functionarguments: string = undefined; + + constructor(fullQualifiedFilename: string) { + let i = fullQualifiedFilename.lastIndexOf("\\"); + this._filename = fullQualifiedFilename.substr(i + 1); + this._pathname = fullQualifiedFilename.substr(0, i); + } + + public ProcessBuiltinFunctions(titleRaw: string): string { + let workstring = titleRaw; + + workstring = workstring.replace(this._builtinFunctionRegularExpression, (...args) => { + let result = args[0]; + this._buildinfunction = args[0]; + this._functionname = args[1]; + this._functionarguments = this.stripQuotes(args[2]); + console.log(`pathname: ${this._pathname}, filename: ${this._filename}, titlestring: ${titleRaw}, buildinfunction: ${this._buildinfunction}, functionname: ${this._functionname}, functionarguments: ${this._functionarguments}`) + switch (this._functionname) { + // Process %darken("red", 20) + case "darken": + result = this.processDarken(); + break; + // Process %date("yyyy.MM.dd' at 'HH:mm") + case "date": + result = this.processDate(); + break; + // Process %dirpath() + case "dirpath": + result = this.processDirpath(); + break; + // Process %feature("theme") + case "feature": + result = this.processFeature(); + break; + // Process %false() + case "false": + result = this.processFalse(); + break; + // Process %file_exists("c:/foo/dummy.txt") + case "file_exists": + result = this.processFileExists(); + break; + // Process %filename() + case "filename": + result = this.processFilename(); + break; + // Process %function_exists("$some_function") + case "function_exists": + result = this.processFunctionExists(); + break; + // Process %get_variable_value("$my_variable") + case "get_variable_value": + result = this.processGetVariableValue(); + break; + // Process %getenv("OS") + case "getenv": + result = this.processGetenv(); + break; + // Process %intval("42") + case "intval": + result = this.processIntval(); + break; + // Process %is_dark("#000000") + case "is_dark": + result = this.processIsDark(); + break; + // Process %is_light("#000000") + case "is_light": + result = this.processIsLight(); + break; + // Process %lighten("red", 20) + case "lighten": + result = this.processLighten(); + break; + // Process %lower("Hello") + case "lower": + result = this.processLower(); + break; + // Process %newline() + case "newline": + result = this.processNewline(); + break; + // Process %not(2+2==4) + case "not": + result = this.processNot(); + break; + // Process %reverse_color("#FF7700") + case "reverse_color": + result = this.processReverseColor(); + break; + // Process %reverse_hsluv_color("#FF7700") + case "reverse_hsluv_color": + result = this.processReverseHsluvColor(); + break; + // Process %set_variable_value("$my_variable", "some_value") + case "set_variable_value": + result = this.processSetVariableValue(); + break; + // Process %string(1 + 2) + case "string": + result = this.processString(); + break; + // Process %strlen("foo") + case "strlen": + result = this.processStrlen(); + break; + // Process %strpos("abcdef", "ef") + case "strpos": + result = this.processStrpos(); + break; + // Process %substr("abcdef", 3, 2) + case "substr": + result = this.processSubstr(); + break; + // Process %true() + case "true": + result = this.processTrue(); + break; + // Process %upper("Hello") + case "upper": + result = this.processUpper(); + break; + // Process %variable_exists("$my_variable") + case "variable_exists": + result = this.processVariableExists(); + break; + // Process %version() + case "version": + result = this.processVersion(); + break; + // ... + default: + break; + } + return result; + }); + + return workstring; + } + + private splitString(stringToSplit: string): string[] { + let parts = stringToSplit.split(","); + return parts; + } + + private stripQuotes(stringwithquotes: string): string { + return stringwithquotes.replace(this._quotesRegularExpression, ""); + } + + private processDarken(): string { + return "darken"; + } + + private processDate(): string { + let today = new Date().toLocaleDateString(); + return today; + } + + private processDirpath(): string { + return this._pathname; + } + + private processFeature(): string { + return "feature"; + } + + private processFalse(): string { + return "false"; + } + + private processFileExists(): string { + return "file_exists"; + } + + private processFilename(): string { + return this._filename; + } + + private processFunctionExists(): string { + return "function_exists"; + } + + private processGetVariableValue(): string { + return "get_variable_value"; + } + + private processGetenv(): string { + let result = "undefined"; + let env = process.env; + + if (env[this._functionarguments]) { + result = env[this._functionarguments]; + } + + return result; + } -const regs: regReplaceBF[] = [ - // PlantUML Builtin functions - // https://plantuml.com/de/preprocessing#291cabbe982ff775 - // Replace %darken("red", 20) - { find: /(\%darken\(.+?(?=\))\))/mg, replace: '' }, - // Replace %date("yyyy.MM.dd' at 'HH:mm") - { find: /(\%date\(.+?(?=\))\))/mg, replace: (function () { let today = new Date().toLocaleDateString(); return today; }()) }, - // Replace %dirpath() - // Not working in VSCode preview in title tag - // { find: /(\%dirpath\(\))/mg, replace: 'dirpath' }, - // Replace %feature("theme") - { find: /(\%feature\(.+?(?=\))\))/mg, replace: 'feature' }, - // Replace %false() - { find: /(\%false\(\))/mg, replace: 'false' }, - // Replace %file_exists("c:/foo/dummy.txt") - { find: /(\%file_exists\(.+?(?=\))\))/mg, replace: 'file_exists' }, - // Replace %filename() - { find: /(\%filename\(\))/mg, replace: 'filename' }, - // Replace %function_exists("$some_function") - { find: /(\%function_exists\(.+?(?=\))\))/mg, replace: 'function_exists' }, - // Replace %get_variable_value("$my_variable") - // Not working in VSCode preview in title tag - // { find: /(\%get_variable_value\(.+?(?=\))\))/mg, replace: 'get_variable_value' }, - // Replace %getenv("OS") - { find: /(\%getenv\(.+?(?=\))\))/mg, replace: 'getenv' }, - // Replace %intval("42") - { find: /(\%intval\(.+?(?=\))\))/mg, replace: 'intval' }, - // Replace %is_dark("#000000") - { find: /(\%is_dark\(.+?(?=\))\))/mg, replace: 'is_dark' }, - // Replace %is_light("#000000") - { find: /(\%is_light\(.+?(?=\))\))/mg, replace: 'is_light' }, - // Replace %lighten("red", 20) - { find: /(\%lighten\(.+?(?=\))\))/mg, replace: 'lighten' }, - // Replace %lower("Hello") - { find: /(\%lower\(.+?(?=\))\))/mg, replace: 'lower' }, - // Replace %newline() - // Not working in VSCode preview in title tag - // { find: /(\%newline\(\))/mg, replace: ' ' }, - // Replace %not(2+2==4) - { find: /(\%not\(.+?(?=\))\))/mg, replace: 'not' }, - // Replace %reverse_color("#FF7700") - { find: /(\%reverse_color\(.+?(?=\))\))/mg, replace: 'reverse_color' }, - // Replace %reverse_hsluv_color("#FF7700") - { find: /(\%reverse_hsluv_color\(.+?(?=\))\))/mg, replace: 'reverse_hsluv_color' }, - // Replace %set_variable_value("$my_variable", "some_value") - // Not working in VSCode preview in title tag - // { find: /(\%set_variable_value\(.+?(?=\))\))/mg, replace: 'set_variable_value' }, - // Replace %string(1 + 2) - { find: /(\%string\(.+?(?=\))\))/mg, replace: 'string' }, - // Replace %strlen("foo") - { find: /(\%strlen\(.+?(?=\))\))/mg, replace: 'strlen' }, - // Replace %strpos("abcdef", "ef") - { find: /(\%strpos\(.+?(?=\))\))/mg, replace: 'strpos' }, - // Replace %substr("abcdef", 3, 2) - { find: /(\%substr\(.+?(?=\))\))/mg, replace: 'substr' }, - // Replace %true() - { find: /(\%true\(\))/mg, replace: 'true' }, - // Replace %upper("Hello") - { find: /(\%upper\(.+?(?=\))\))/mg, replace: 'upper' }, - // Replace %variable_exists("$my_variable") - { find: /(\%variable_exists\(.+?(?=\))\))/mg, replace: 'variable_exists' }, - // Replace %version() - { find: /(\%version\(\))/mg, replace: 'version' }, -] - -export function Deal(instring: string): string { - let workstring = instring; - for (let rp of regs) { - workstring = workstring.replace(rp.find, rp.replace).trim(); - } - return workstring; -} \ No newline at end of file + private processIntval(): string { + return this._functionarguments; + } + + private processIsDark(): string { + return "is_dark"; + } + + private processIsLight(): string { + return "is_light"; + } + + private processLighten(): string { + return "lighten"; + } + + private processLower(): string { + return this._functionarguments.toLowerCase(); + } + + private processNewline(): string { + return "newline"; + } + + private processNot(): string { + let result = "false"; + // 001: How to enable extension to use 'ts-expression-evaluator' + // let check = evaluate(this._functionarguments); + let check = eval(this._functionarguments); + if (check === true) { + result == "true"; + } + return result; + } + + private processReverseColor(): string { + return "reverse_color"; + } + + private processReverseHsluvColor(): string { + return "reverse_hsluv_color"; + } + + private processSetVariableValue(): string { + return "set_variable_value"; + } + + private processString(): string { + // 001: How to enable extension to use 'ts-expression-evaluator' + // let result = evaluate(this._functionarguments); + let result = eval(this._functionarguments); + return String(result); + } + + private processStrlen(): string { + return String(this._functionarguments.length); + } + + private processStrpos(): string { + let parts = this.splitString(this._functionarguments); + return String(parts[0].indexOf(parts[1])); + } + + private processSubstr(): string { + let result = undefined; + let parts = this._functionarguments.split(","); + switch (parts.length) { + case 3: + result = parts[0].substr(Number(parts[1]), Number(parts[2])); + break; + default: + result = parts[0].substr(Number(parts[1])); + break; + } + return result; + } + + private processTrue(): string { + return "true"; + } + + private processUpper(): string { + return this._functionarguments.toUpperCase(); + } + + private processVariableExists(): string { + return "variable_exists"; + } + + private processVersion(): string { + return "version"; + } +} diff --git a/src/plantuml/diagram/diagram.ts b/src/plantuml/diagram/diagram.ts index 51f03c9..591f27b 100644 --- a/src/plantuml/diagram/diagram.ts +++ b/src/plantuml/diagram/diagram.ts @@ -3,6 +3,7 @@ import * as path from 'path'; import * as title from './title'; import { DiagramType, getType } from './type'; +import { BuiltinFunctionsPreprocessor } from './builtinfunctions'; import { getContentWithInclude } from './include'; export const diagramStartReg = /@start(\w+)/i; @@ -24,6 +25,7 @@ export class Diagram { private _index: number = undefined; private _pageCount: number = undefined; private _contentWithInclude: string = undefined; + private _builtinFunctions: BuiltinFunctionsPreprocessor = undefined; constructor(content: string); constructor(content: string, document: vscode.TextDocument, start: vscode.Position, end: vscode.Position); @@ -41,6 +43,7 @@ export class Diagram { if (i >= 0) this.fileName = this.fileName.substr(0, i); this.dir = path.dirname(this.path); if (!path.isAbsolute(this.dir)) this.dir = ""; + this._builtinFunctions = new BuiltinFunctionsPreprocessor(this.path); } public get index(): number { if (this._index !== undefined) { @@ -97,7 +100,8 @@ export class Diagram { let matches: RegExpMatchArray;; if (matches = this.lines[0].match(RegFName)) { this._titleRaw = matches[2]; - this._title = title.Deal(this._titleRaw); + let tempTitle = this._builtinFunctions.ProcessBuiltinFunctions(this._titleRaw); + this._title = title.Deal(tempTitle); return; } let inlineTitle = /^\s*title\s+(.+?)\s*$/i; @@ -109,7 +113,8 @@ export class Diagram { } } if (this._titleRaw) { - this._title = title.Deal(this._titleRaw); + let tempTitle = this._builtinFunctions.ProcessBuiltinFunctions(this._titleRaw); + this._title = title.Deal(tempTitle); } else if (this.start && this.end) { // this.title = `${this.fileName}@${this.start.line + 1}-${this.end.line + 1}`; if (this.index) diff --git a/src/plantuml/diagram/title.ts b/src/plantuml/diagram/title.ts index 1d21935..be28581 100644 --- a/src/plantuml/diagram/title.ts +++ b/src/plantuml/diagram/title.ts @@ -1,5 +1,3 @@ -import * as builtinfunctions from './builtinfunctions'; - interface regReplace { find: RegExp; replace: string; @@ -38,6 +36,5 @@ export function Deal(value: string): string { for (let rp of regs){ title=title.replace(rp.find,rp.replace).trim(); } - title = builtinfunctions.Deal(title); return title; } \ No newline at end of file From 5e0553385dd39bde38ff267d97c3b1909add8ae4 Mon Sep 17 00:00:00 2001 From: ThirtySomething Date: Sat, 19 Jun 2021 17:04:57 +0200 Subject: [PATCH 3/6] Use language setting for date format. --- src/plantuml/diagram/builtinfunctions.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plantuml/diagram/builtinfunctions.ts b/src/plantuml/diagram/builtinfunctions.ts index 390a0ad..8cc4a21 100644 --- a/src/plantuml/diagram/builtinfunctions.ts +++ b/src/plantuml/diagram/builtinfunctions.ts @@ -1,6 +1,8 @@ // PlantUML Builtin functions // https://plantuml.com/de/preprocessing#291cabbe982ff775 +import * as vscode from 'vscode'; + // 001: How to enable extension to use 'ts-expression-evaluator' // import evaluate, { registerFunction } from 'ts-expression-evaluator' @@ -166,7 +168,8 @@ export class BuiltinFunctionsPreprocessor { } private processDate(): string { - let today = new Date().toLocaleDateString(); + let tmplocale = vscode.env.language; + let today = new Date().toLocaleDateString(tmplocale); return today; } From f54354984664f8b5552093b6ca3d429baf06d666 Mon Sep 17 00:00:00 2001 From: ThirtySomething Date: Sun, 20 Jun 2021 18:10:43 +0200 Subject: [PATCH 4/6] Get path with trailing slash, get filename without extension. --- src/plantuml/diagram/builtinfunctions.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/plantuml/diagram/builtinfunctions.ts b/src/plantuml/diagram/builtinfunctions.ts index 8cc4a21..293e227 100644 --- a/src/plantuml/diagram/builtinfunctions.ts +++ b/src/plantuml/diagram/builtinfunctions.ts @@ -19,7 +19,7 @@ export class BuiltinFunctionsPreprocessor { constructor(fullQualifiedFilename: string) { let i = fullQualifiedFilename.lastIndexOf("\\"); this._filename = fullQualifiedFilename.substr(i + 1); - this._pathname = fullQualifiedFilename.substr(0, i); + this._pathname = fullQualifiedFilename.substr(0, i + 1); } public ProcessBuiltinFunctions(titleRaw: string): string { @@ -190,7 +190,12 @@ export class BuiltinFunctionsPreprocessor { } private processFilename(): string { - return this._filename; + let result = this._filename; + let parts = result.split("."); + if (parts.length > 0) { + result = parts[0]; + } + return result; } private processFunctionExists(): string { From 86190322dc0bfdcdf7b5cf26a89d2a6c2a226b9b Mon Sep 17 00:00:00 2001 From: ThirtySomething Date: Wed, 30 Jun 2021 20:56:06 +0200 Subject: [PATCH 5/6] Set dependency, revert changes to %filename --- package-lock.json | 217 ++--------------------- package.json | 1 + src/plantuml/diagram/builtinfunctions.ts | 26 ++- 3 files changed, 26 insertions(+), 218 deletions(-) diff --git a/package-lock.json b/package-lock.json index ec0ec21..47c6788 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,209 +1,14 @@ { "name": "plantuml", - "version": "2.14.4", - "lockfileVersion": 2, + "version": "2.14.5", + "lockfileVersion": 1, "requires": true, - "packages": { - "": { - "name": "plantuml", - "version": "2.14.4", - "license": "SEE LICENSE IN LICENSE.txt", - "dependencies": { - "linq-collections": "*", - "vscode-nls": "^2.0.2" - }, - "devDependencies": { - "@types/mocha": "^2.2.32", - "@types/node": "^6.0.40", - "@types/vscode": "^1.39.0", - "js-yaml": "^3.13.1", - "markdown-it": "^8.3.2", - "plist": "^3.0.2", - "typescript": "^3.7.2" - }, - "engines": { - "vscode": "^1.39.0" - } - }, - "node_modules/@types/mocha": { - "version": "2.2.32", - "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-2.2.32.tgz", - "integrity": "sha1-3aDabq8hldL/gI9CoXJbGhnn7Wk=", - "dev": true - }, - "node_modules/@types/node": { - "version": "6.0.46", - "resolved": "https://registry.npmjs.org/@types/node/-/node-6.0.46.tgz", - "integrity": "sha1-jZ5IVygx8FsRzEx5N1TUNDchnWI=", - "dev": true - }, - "node_modules/@types/vscode": { - "version": "1.52.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.52.0.tgz", - "integrity": "sha512-Kt3bvWzAvvF/WH9YEcrCICDp0Z7aHhJGhLJ1BxeyNP6yRjonWqWnAIh35/pXAjswAnWOABrYlF7SwXR9+1nnLA==", - "dev": true - }, - "node_modules/argparse": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.9.tgz", - "integrity": "sha1-c9g7wmP4bpf4zE9rrhsOkKfSLIY=", - "dev": true, - "dependencies": { - "sprintf-js": "~1.0.2" - } - }, - "node_modules/base64-js": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", - "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] - }, - "node_modules/entities": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.1.tgz", - "integrity": "sha1-blwtClYhtdra7O+AuQ7ftc13cvA=", - "dev": true - }, - "node_modules/esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true, - "bin": { - "esparse": "bin/esparse.js", - "esvalidate": "bin/esvalidate.js" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/js-yaml": { - "version": "3.13.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", - "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", - "dev": true, - "dependencies": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, - "node_modules/linkify-it": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-2.0.3.tgz", - "integrity": "sha1-2UpGSPmxwXnWT6lykSaL22zpQ08=", - "dev": true, - "dependencies": { - "uc.micro": "^1.0.1" - } - }, - "node_modules/linq-collections": { - "version": "1.0.254", - "resolved": "https://registry.npmjs.org/linq-collections/-/linq-collections-1.0.254.tgz", - "integrity": "sha512-SGg0LG+sNfAYm5c3QRPJhAi9I/MtY8e0TjfftsSlsqNKDJPTH22Bcsaq6vlTitgZEfXbY1yn9U9YgwoyGGH2PA==" - }, - "node_modules/markdown-it": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-8.3.2.tgz", - "integrity": "sha1-30uGUw0Xw7yb7sO2jXcLkuoXrpY=", - "dev": true, - "dependencies": { - "argparse": "^1.0.7", - "entities": "~1.1.1", - "linkify-it": "^2.0.0", - "mdurl": "^1.0.1", - "uc.micro": "^1.0.3" - }, - "bin": { - "markdown-it": "bin/markdown-it.js" - } - }, - "node_modules/mdurl": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz", - "integrity": "sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4=", - "dev": true - }, - "node_modules/plist": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/plist/-/plist-3.0.2.tgz", - "integrity": "sha512-MSrkwZBdQ6YapHy87/8hDU8MnIcyxBKjeF+McXnr5A9MtffPewTs7G3hlpodT5TacyfIyFTaJEhh3GGcmasTgQ==", - "dev": true, - "dependencies": { - "base64-js": "^1.5.1", - "xmlbuilder": "^9.0.7", - "xmldom": "^0.5.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", - "dev": true - }, - "node_modules/typescript": { - "version": "3.7.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.2.tgz", - "integrity": "sha512-ml7V7JfiN2Xwvcer+XAf2csGO1bPBdRbFCkYBczNZggrBZ9c7G3riSUeJmqEU5uOtXNPMhE3n+R4FA/3YOAWOQ==", - "dev": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } - }, - "node_modules/uc.micro": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.3.tgz", - "integrity": "sha1-ftUNXg+an7ClczeSWfKndFjVAZI=", - "dev": true - }, - "node_modules/vscode-nls": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/vscode-nls/-/vscode-nls-2.0.2.tgz", - "integrity": "sha1-gIUiOAhEuK0VNJmvXDsDkhrqAto=" - }, - "node_modules/xmlbuilder": { - "version": "9.0.7", - "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", - "integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=", - "dev": true, - "engines": { - "node": ">=4.0" - } - }, - "node_modules/xmldom": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.5.0.tgz", - "integrity": "sha512-Foaj5FXVzgn7xFzsKeNIde9g6aFBxTPi37iwsno8QvApmtg7KYrr+OPyRHcJF7dud2a5nGRBXK3n0dL62Gf7PA==", - "dev": true, - "engines": { - "node": ">=10.0.0" - } - } - }, "dependencies": { + "@babel/parser": { + "version": "7.14.7", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.14.7.tgz", + "integrity": "sha512-X67Z5y+VBJuHB/RjwECp8kSl5uYi0BvRbNeWqkaJCVh+LiTPl19WBUfG627psSgp9rSf6ojuXghQM3ha6qHHdA==" + }, "@types/mocha": { "version": "2.2.32", "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-2.2.32.tgz", @@ -309,6 +114,14 @@ "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, + "ts-expression-evaluator": { + "version": "1.3.14", + "resolved": "https://registry.npmjs.org/ts-expression-evaluator/-/ts-expression-evaluator-1.3.14.tgz", + "integrity": "sha512-V4AfZi7J91u0cIdiGH3ha6j4DwII4KHLdTS49TciQR+d2n0m53We7akAcHyUyxEIHXK7TEvG8Ue2uWTLjtTYKg==", + "requires": { + "@babel/parser": "^7.0.0" + } + }, "typescript": { "version": "3.7.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.2.tgz", diff --git a/package.json b/package.json index dc5afc5..dd0b27f 100755 --- a/package.json +++ b/package.json @@ -368,6 +368,7 @@ }, "dependencies": { "linq-collections": "*", + "ts-expression-evaluator": "^1.3.14", "vscode-nls": "^2.0.2" } } diff --git a/src/plantuml/diagram/builtinfunctions.ts b/src/plantuml/diagram/builtinfunctions.ts index 293e227..815b69c 100644 --- a/src/plantuml/diagram/builtinfunctions.ts +++ b/src/plantuml/diagram/builtinfunctions.ts @@ -2,9 +2,7 @@ // https://plantuml.com/de/preprocessing#291cabbe982ff775 import * as vscode from 'vscode'; - -// 001: How to enable extension to use 'ts-expression-evaluator' -// import evaluate, { registerFunction } from 'ts-expression-evaluator' +import evaluate, { registerFunction } from 'ts-expression-evaluator' export class BuiltinFunctionsPreprocessor { private _builtinFunctionRegularExpression = /%([a-z_]+)\(([^\)]+)?\)/ig; @@ -30,7 +28,12 @@ export class BuiltinFunctionsPreprocessor { this._buildinfunction = args[0]; this._functionname = args[1]; this._functionarguments = this.stripQuotes(args[2]); - console.log(`pathname: ${this._pathname}, filename: ${this._filename}, titlestring: ${titleRaw}, buildinfunction: ${this._buildinfunction}, functionname: ${this._functionname}, functionarguments: ${this._functionarguments}`) + console.log(`pathname: ${this._pathname}`); + console.log(`filename: ${this._filename}`); + console.log(`titlestring: ${titleRaw}`); + console.log(`buildinfunction: ${this._buildinfunction}`); + console.log(`functionname: ${this._functionname}`); + console.log(`functionarguments: ${this._functionarguments}`); switch (this._functionname) { // Process %darken("red", 20) case "darken": @@ -190,12 +193,7 @@ export class BuiltinFunctionsPreprocessor { } private processFilename(): string { - let result = this._filename; - let parts = result.split("."); - if (parts.length > 0) { - result = parts[0]; - } - return result; + return this._filename; } private processFunctionExists(): string { @@ -243,9 +241,7 @@ export class BuiltinFunctionsPreprocessor { private processNot(): string { let result = "false"; - // 001: How to enable extension to use 'ts-expression-evaluator' - // let check = evaluate(this._functionarguments); - let check = eval(this._functionarguments); + let check = evaluate(this._functionarguments); if (check === true) { result == "true"; } @@ -265,9 +261,7 @@ export class BuiltinFunctionsPreprocessor { } private processString(): string { - // 001: How to enable extension to use 'ts-expression-evaluator' - // let result = evaluate(this._functionarguments); - let result = eval(this._functionarguments); + let result = evaluate(this._functionarguments); return String(result); } From e11a381ada466c664afd742ef820639ede3bc8f5 Mon Sep 17 00:00:00 2001 From: ThirtySomething Date: Sun, 21 Aug 2022 12:44:05 +0200 Subject: [PATCH 6/6] Updated dependencies, don't use Title as name --- package-lock.json | 292 +++++--------------------------- package.json | 14 +- src/plantuml/diagram/diagram.ts | 31 ++-- 3 files changed, 65 insertions(+), 272 deletions(-) diff --git a/package-lock.json b/package-lock.json index 37a09b3..ba41f7e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,209 +1,8 @@ { "name": "plantuml", - "version": "2.15.1", - "lockfileVersion": 2, + "version": "2.16.0", + "lockfileVersion": 1, "requires": true, - "packages": { - "": { - "name": "plantuml", - "version": "2.15.1", - "license": "SEE LICENSE IN LICENSE.txt", - "dependencies": { - "linq-collections": "*", - "ts-expression-evaluator": "^1.3.14", - "vscode-nls": "^2.0.2" - }, - "devDependencies": { - "@types/mocha": "^2.2.32", - "@types/node": "^6.0.40", - "@types/vscode": "^1.57.0", - "js-yaml": "^3.13.1", - "markdown-it": "^8.3.2", - "plist": "^3.0.2", - "typescript": "^3.7.2" - }, - "engines": { - "vscode": "^1.57.0" - } - }, - "node_modules/@types/mocha": { - "version": "2.2.32", - "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-2.2.32.tgz", - "integrity": "sha1-3aDabq8hldL/gI9CoXJbGhnn7Wk=", - "dev": true - }, - "node_modules/@types/node": { - "version": "6.0.46", - "resolved": "https://registry.npmjs.org/@types/node/-/node-6.0.46.tgz", - "integrity": "sha1-jZ5IVygx8FsRzEx5N1TUNDchnWI=", - "dev": true - }, - "node_modules/@types/vscode": { - "version": "1.57.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.57.0.tgz", - "integrity": "sha512-FeznBFtIDCWRluojTsi9c3LLcCHOXP5etQfBK42+ixo1CoEAchkw39tuui9zomjZuKfUVL33KZUDIwHZ/xvOkQ==", - "dev": true - }, - "node_modules/argparse": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.9.tgz", - "integrity": "sha1-c9g7wmP4bpf4zE9rrhsOkKfSLIY=", - "dev": true, - "dependencies": { - "sprintf-js": "~1.0.2" - } - }, - "node_modules/base64-js": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", - "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] - }, - "node_modules/entities": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.1.tgz", - "integrity": "sha1-blwtClYhtdra7O+AuQ7ftc13cvA=", - "dev": true - }, - "node_modules/esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true, - "bin": { - "esparse": "bin/esparse.js", - "esvalidate": "bin/esvalidate.js" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/js-yaml": { - "version": "3.13.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", - "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", - "dev": true, - "dependencies": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, - "node_modules/linkify-it": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-2.0.3.tgz", - "integrity": "sha1-2UpGSPmxwXnWT6lykSaL22zpQ08=", - "dev": true, - "dependencies": { - "uc.micro": "^1.0.1" - } - }, - "node_modules/linq-collections": { - "version": "1.0.254", - "resolved": "https://registry.npmjs.org/linq-collections/-/linq-collections-1.0.254.tgz", - "integrity": "sha512-SGg0LG+sNfAYm5c3QRPJhAi9I/MtY8e0TjfftsSlsqNKDJPTH22Bcsaq6vlTitgZEfXbY1yn9U9YgwoyGGH2PA==" - }, - "node_modules/markdown-it": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-8.3.2.tgz", - "integrity": "sha1-30uGUw0Xw7yb7sO2jXcLkuoXrpY=", - "dev": true, - "dependencies": { - "argparse": "^1.0.7", - "entities": "~1.1.1", - "linkify-it": "^2.0.0", - "mdurl": "^1.0.1", - "uc.micro": "^1.0.3" - }, - "bin": { - "markdown-it": "bin/markdown-it.js" - } - }, - "node_modules/mdurl": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz", - "integrity": "sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4=", - "dev": true - }, - "node_modules/plist": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/plist/-/plist-3.0.2.tgz", - "integrity": "sha512-MSrkwZBdQ6YapHy87/8hDU8MnIcyxBKjeF+McXnr5A9MtffPewTs7G3hlpodT5TacyfIyFTaJEhh3GGcmasTgQ==", - "dev": true, - "dependencies": { - "base64-js": "^1.5.1", - "xmlbuilder": "^9.0.7", - "xmldom": "^0.5.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", - "dev": true - }, - "node_modules/typescript": { - "version": "3.7.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.2.tgz", - "integrity": "sha512-ml7V7JfiN2Xwvcer+XAf2csGO1bPBdRbFCkYBczNZggrBZ9c7G3riSUeJmqEU5uOtXNPMhE3n+R4FA/3YOAWOQ==", - "dev": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } - }, - "node_modules/uc.micro": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.3.tgz", - "integrity": "sha1-ftUNXg+an7ClczeSWfKndFjVAZI=", - "dev": true - }, - "node_modules/vscode-nls": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/vscode-nls/-/vscode-nls-2.0.2.tgz", - "integrity": "sha1-gIUiOAhEuK0VNJmvXDsDkhrqAto=" - }, - "node_modules/xmlbuilder": { - "version": "9.0.7", - "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", - "integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=", - "dev": true, - "engines": { - "node": ">=4.0" - } - }, - "node_modules/xmldom": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.5.0.tgz", - "integrity": "sha512-Foaj5FXVzgn7xFzsKeNIde9g6aFBxTPi37iwsno8QvApmtg7KYrr+OPyRHcJF7dud2a5nGRBXK3n0dL62Gf7PA==", - "dev": true, - "engines": { - "node": ">=10.0.0" - } - } - }, "dependencies": { "@babel/parser": { "version": "7.14.7", @@ -211,27 +10,27 @@ "integrity": "sha512-X67Z5y+VBJuHB/RjwECp8kSl5uYi0BvRbNeWqkaJCVh+LiTPl19WBUfG627psSgp9rSf6ojuXghQM3ha6qHHdA==" }, "@types/mocha": { - "version": "2.2.32", - "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-2.2.32.tgz", - "integrity": "sha1-3aDabq8hldL/gI9CoXJbGhnn7Wk=", + "version": "2.2.48", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-2.2.48.tgz", + "integrity": "sha512-nlK/iyETgafGli8Zh9zJVCTicvU3iajSkRwOh3Hhiva598CMqNJ4NcVCGMTGKpGpTYj/9R8RLzS9NAykSSCqGw==", "dev": true }, "@types/node": { - "version": "6.0.46", - "resolved": "https://registry.npmjs.org/@types/node/-/node-6.0.46.tgz", - "integrity": "sha1-jZ5IVygx8FsRzEx5N1TUNDchnWI=", + "version": "6.14.13", + "resolved": "https://registry.npmjs.org/@types/node/-/node-6.14.13.tgz", + "integrity": "sha512-J1F0XJ/9zxlZel5ZlbeSuHW2OpabrUAqpFuC2sm2I3by8sERQ8+KCjNKUcq8QHuzpGMWiJpo9ZxeHrqrP2KzQw==", "dev": true }, "@types/vscode": { - "version": "1.57.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.57.0.tgz", - "integrity": "sha512-FeznBFtIDCWRluojTsi9c3LLcCHOXP5etQfBK42+ixo1CoEAchkw39tuui9zomjZuKfUVL33KZUDIwHZ/xvOkQ==", + "version": "1.70.0", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.70.0.tgz", + "integrity": "sha512-3/9Fz0F2eBgwciazc94Ien+9u1elnjFg9YAhvAb3qDy/WeFWD9VrOPU7CIytryOVUdbxus8uzL4VZYONA0gDtA==", "dev": true }, "argparse": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.9.tgz", - "integrity": "sha1-c9g7wmP4bpf4zE9rrhsOkKfSLIY=", + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "~1.0.2" @@ -244,9 +43,9 @@ "dev": true }, "entities": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.1.tgz", - "integrity": "sha1-blwtClYhtdra7O+AuQ7ftc13cvA=", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz", + "integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==", "dev": true }, "esprima": { @@ -256,9 +55,9 @@ "dev": true }, "js-yaml": { - "version": "3.13.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", - "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", "dev": true, "requires": { "argparse": "^1.0.7", @@ -266,9 +65,9 @@ } }, "linkify-it": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-2.0.3.tgz", - "integrity": "sha1-2UpGSPmxwXnWT6lykSaL22zpQ08=", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-2.2.0.tgz", + "integrity": "sha512-GnAl/knGn+i1U/wjBz3akz2stz+HrHLsxMwHQGofCDfPvlf+gDKN58UtfmUquTY4/MXeE2x7k19KQmeoZi94Iw==", "dev": true, "requires": { "uc.micro": "^1.0.1" @@ -280,39 +79,38 @@ "integrity": "sha512-SGg0LG+sNfAYm5c3QRPJhAi9I/MtY8e0TjfftsSlsqNKDJPTH22Bcsaq6vlTitgZEfXbY1yn9U9YgwoyGGH2PA==" }, "markdown-it": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-8.3.2.tgz", - "integrity": "sha1-30uGUw0Xw7yb7sO2jXcLkuoXrpY=", + "version": "8.4.2", + "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-8.4.2.tgz", + "integrity": "sha512-GcRz3AWTqSUphY3vsUqQSFMbgR38a4Lh3GWlHRh/7MRwz8mcu9n2IO7HOh+bXHrR9kOPDl5RNCaEsrneb+xhHQ==", "dev": true, "requires": { "argparse": "^1.0.7", "entities": "~1.1.1", "linkify-it": "^2.0.0", "mdurl": "^1.0.1", - "uc.micro": "^1.0.3" + "uc.micro": "^1.0.5" } }, "mdurl": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz", - "integrity": "sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4=", + "integrity": "sha512-/sKlQJCBYVY9Ers9hqzKou4H6V5UWc/M59TH2dvkt+84itfnq7uFOMLpOiOS4ujvHP4etln18fmIxA5R5fll0g==", "dev": true }, "plist": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/plist/-/plist-3.0.2.tgz", - "integrity": "sha512-MSrkwZBdQ6YapHy87/8hDU8MnIcyxBKjeF+McXnr5A9MtffPewTs7G3hlpodT5TacyfIyFTaJEhh3GGcmasTgQ==", + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/plist/-/plist-3.0.6.tgz", + "integrity": "sha512-WiIVYyrp8TD4w8yCvyeIr+lkmrGRd5u0VbRnU+tP/aRLxP/YadJUYOMZJ/6hIa3oUyVCsycXvtNRgd5XBJIbiA==", "dev": true, "requires": { "base64-js": "^1.5.1", - "xmlbuilder": "^9.0.7", - "xmldom": "^0.5.0" + "xmlbuilder": "^15.1.1" } }, "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", "dev": true }, "ts-expression-evaluator": { @@ -324,15 +122,15 @@ } }, "typescript": { - "version": "3.7.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.2.tgz", - "integrity": "sha512-ml7V7JfiN2Xwvcer+XAf2csGO1bPBdRbFCkYBczNZggrBZ9c7G3riSUeJmqEU5uOtXNPMhE3n+R4FA/3YOAWOQ==", + "version": "3.9.10", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", + "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", "dev": true }, "uc.micro": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.3.tgz", - "integrity": "sha1-ftUNXg+an7ClczeSWfKndFjVAZI=", + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz", + "integrity": "sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==", "dev": true }, "vscode-nls": { @@ -341,15 +139,9 @@ "integrity": "sha1-gIUiOAhEuK0VNJmvXDsDkhrqAto=" }, "xmlbuilder": { - "version": "9.0.7", - "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", - "integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=", - "dev": true - }, - "xmldom": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.5.0.tgz", - "integrity": "sha512-Foaj5FXVzgn7xFzsKeNIde9g6aFBxTPi37iwsno8QvApmtg7KYrr+OPyRHcJF7dud2a5nGRBXK3n0dL62Gf7PA==", + "version": "15.1.1", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-15.1.1.tgz", + "integrity": "sha512-yMqGBqtXyeN1e3TGYvgNgDVZ3j84W4cwkOXQswghol6APgZWaff9lnbvN7MHYJOiXsvGPXtjTYJEiC9J2wv9Eg==", "dev": true } } diff --git a/package.json b/package.json index d659acb..e4b4747 100755 --- a/package.json +++ b/package.json @@ -365,13 +365,13 @@ "buildsyntax": "node ./scripts/build-syntax.js" }, "devDependencies": { - "@types/mocha": "^2.2.32", - "@types/node": "^6.0.40", - "@types/vscode": "^1.57.0", - "js-yaml": "^3.13.1", - "markdown-it": "^8.3.2", - "plist": "^3.0.2", - "typescript": "^3.7.2" + "@types/mocha": "^2.2.48", + "@types/node": "^6.14.13", + "@types/vscode": "^1.70.0", + "js-yaml": "^3.14.1", + "markdown-it": "^8.4.2", + "plist": "^3.0.6", + "typescript": "^3.9.10" }, "dependencies": { "linq-collections": "*", diff --git a/src/plantuml/diagram/diagram.ts b/src/plantuml/diagram/diagram.ts index bd99144..1e5e7dc 100644 --- a/src/plantuml/diagram/diagram.ts +++ b/src/plantuml/diagram/diagram.ts @@ -100,23 +100,24 @@ export class Diagram { let matches: RegExpMatchArray;; if (matches = this.lines[0].match(RegFName)) { this._nameRaw = matches[2]; - let tempTitle = this._builtinFunctions.ProcessBuiltinFunctions(this._nameRaw); - this._name = title.Deal(tempTitle); + let tempName = this._builtinFunctions.ProcessBuiltinFunctions(this._nameRaw); + this._name = title.Deal(tempName); return; } - // // don't use title as diagram name, #438, #400, #409 - // let inlineTitle = /^\s*title\s+(.+?)\s*$/i; - // let multLineTitle = /^\s*title\s*$/i; - // for (let text of this.lines) { - // if (inlineTitle.test(text)) { - // let matches = text.match(inlineTitle); - // this._titleRaw = matches[1]; - // } - // } - // if (this._titleRaw) { - // this._title = title.Deal(this._titleRaw); - // return - // } + // don't use title as diagram name, #438, #400, #409 + let inlineName = /^\s*title\s+(.+?)\s*$/i; + let multLineName = /^\s*title\s*$/i; + for (let text of this.lines) { + if (inlineName.test(text)) { + let matches = text.match(inlineName); + this._nameRaw = matches[1]; + } + } + if (this._nameRaw) { + let tempName = this._builtinFunctions.ProcessBuiltinFunctions(this._nameRaw); + this._name = title.Deal(tempName); + return + } if (this.start && this.end) { // this.title = `${this.fileName}@${this.start.line + 1}-${this.end.line + 1}`; if (this.index)