Enteee / plantuml-parser

Parse PlantUML with JavaScript or TypeScript
https://duckpond.ch/category/plantuml-parser
Apache License 2.0
136 stars 33 forks source link

Support `@startuml name` #93

Closed tobiashochguertel closed 1 year ago

tobiashochguertel commented 1 year ago

VS Code shows a hint, when the name is not set. It looks like that this @startuml name Syntax is officially supported but not documented. Example and more informations can be found in the following issue of vscode repository.

@startuml System Context of Project Collector System
!include https://raw.githubusercontent.com/adrianvlupu/C4-PlantUML/latest/C4_Context.puml

grafik

yarn run v1.22.19
$ node src/plantuml-helper.js
/Users/tobiashochgurtel/work-dev/project-collector/plantuml-c4-analytic/node_modules/plantuml-parser/dist/plantuml.js:11669
        throw peg$buildStructuredError(peg$maxFailExpected, peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, peg$maxFailPos < input.length
        ^

Error [SyntaxError]: Expected "(", "\n", "\r\n", or [ ,\t] but "S" found.
    at peg$buildStructuredError (/Users/tobiashochgurtel/work-dev/project-collector/plantuml-c4-analytic/node_modules/plantuml-parser/dist/plantuml.js:704:16)
    at peg$parse (/Users/tobiashochgurtel/work-dev/project-collector/plantuml-c4-analytic/node_modules/plantuml-parser/dist/plantuml.js:11669:15)
    at parseSync (/Users/tobiashochgurtel/work-dev/project-collector/plantuml-c4-analytic/node_modules/plantuml-parser/dist/index.js:64:12)
    at file:///Users/tobiashochgurtel/work-dev/project-collector/plantuml-c4-analytic/src/plantuml-helper.js:18:18
    at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3) {
  expected: [
    {
      type: 'class',
      parts: [ ' ', '\t' ],
      inverted: false,
      ignoreCase: false
    },
    { type: 'literal', text: '(', ignoreCase: false },
    {
      type: 'class',
      parts: [ ' ', '\t' ],
      inverted: false,
      ignoreCase: false
    },
    { type: 'literal', text: '\n', ignoreCase: false },
    { type: 'literal', text: '\r\n', ignoreCase: false }
  ],
  found: 'S',
  location: {
    start: { offset: 10, line: 1, column: 11 },
    end: { offset: 11, line: 1, column: 12 }
  }
}

Node.js v19.7.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Enteee commented 1 year ago

Thank you for raising this issue, this is a duplicate of #24 . But since you are now the second person to raise this, i will keep this open and extend the parser with support for this.