Skip to content

Commit

Permalink
Merge pull request #177 from i-VRESSE/dotless-toml-table
Browse files Browse the repository at this point in the history
Do not treat `[topoaa.mol1]` as a module
  • Loading branch information
sverhoeven authored Oct 9, 2024
2 parents 03611d0 + 04fd2ad commit 929ef70
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## @i-vresse/wb-core 3.2.3 - 2024-10-09

### Fixed

- Do not treat `[topoaa.mol1]` as a module

## @i-vresse/wb-core 3.2.2 - 2024-10-09

### Added
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@i-vresse/wb-core",
"version": "3.2.2",
"version": "3.2.3",
"description": "React components to construct a workflow builder application",
"keywords": [
"react",
Expand Down
17 changes: 17 additions & 0 deletions packages/core/src/toml.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1112,4 +1112,21 @@ describe('lines2node()', () => {
const expected = [-1, -1, -1, -1, -1, 0, 0, 1]
expect(lookup).toEqual(expected)
})

it('given 2 sections', () => {
const workflow = [
'',
'molecules = [',
']',
'',
'[section1]',
'',
'[section1.mol1]'
].join('\n')

const lookup = lines2node(workflow)

const expected = [-1, -1, -1, -1, -1, 0, 0, 0]
expect(lookup).toEqual(expected)
})
})
5 changes: 3 additions & 2 deletions packages/core/src/toml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ export function dedupWorkflow (inp: string): string {
* For each line in the text, return the node index.
* -1 for global parameters.
*
* Ignores table with dots in the name.
*
* @param text The TOML text
* @returns
*/
Expand All @@ -317,10 +319,9 @@ export function lines2node (text: string): number[] {
// highlighter linenumber starts with 1 so add offset
const nodeLines: number[] = [-1]
let nodeIndex = -1
const isTable = /^\[/
for (let i = 0; i < lines.length; i++) {
const line = lines[i]
if (isTable.test(line)) {
if (line.startsWith('[') && !line.includes('.')) {
nodeIndex++
}
nodeLines.push(nodeIndex)
Expand Down

0 comments on commit 929ef70

Please sign in to comment.