Skip to content
This repository has been archived by the owner on Dec 12, 2022. It is now read-only.

Add parse rule option #8

Merged
merged 6 commits into from
Jun 6, 2021
Merged

Add parse rule option #8

merged 6 commits into from
Jun 6, 2021

Conversation

kamiazya
Copy link
Member

@kamiazya kamiazya commented Jun 5, 2021

What was a problem

It was not possible to specify which object in the DOT language to parse.

How this PR fixes the problem

Add rule option for function parse.

import { Node } from 'ts-graphviz';
import { parse } from '@ts-graphviz/parser';

const node = parse(
  `test [
    style=filled;
    color=lightgrey;
    label = "example #1";
  ];`,
  { rule: 'node' },
);

console.log(node instanceof Node);
// true

Add rule option for function AST.parse .

import { AST } from '@ts-graphviz/parser';

const ast = AST.parse(
  `test [
    style=filled;
    color=lightgrey;
    label = "example #1";
  ];`,
  { rule: 'node' },
);

console.log(ast);
// {
//   type: 'node',
//   id: 'test',
//   attributes: [
//     { key: 'style', value: 'filled' },
//     { key: 'color', value: 'lightgrey' },
//     { key: 'label', value: 'example #1' }
//   ]
// }

Check lists (check x in [ ] of list items)

  • Test passed
  • Coding style (indentation, etc)

@kamiazya kamiazya marked this pull request as ready for review June 6, 2021 13:36
@kamiazya kamiazya merged commit 3a257b9 into main Jun 6, 2021
@kamiazya kamiazya changed the title Add AST.parse option Add parse rule option Jun 6, 2021
@kamiazya kamiazya deleted the add-paser-option branch June 6, 2021 13:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant