Skip to content

Commit

Permalink
Added note seqjson converter
Browse files Browse the repository at this point in the history
  • Loading branch information
cohansen committed Jan 21, 2025
1 parent e04c9a0 commit f3455d7
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/utilities/sequence-editor/to-seq-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import type {
Load,
Metadata,
Model,
Note,
NumberArgument,
RepeatArgument,
Request,
Expand Down Expand Up @@ -144,6 +145,26 @@ function parseRequest(requestNode: SyntaxNode, text: string, commandDictionary:
};
}

function parseNote(stepNode: SyntaxNode, text: string): Note {
const time = parseTime(stepNode, text);

const noteValueNode = stepNode.getChild('NoteValue');
const noteValue = noteValueNode ? unquoteUnescape(text.slice(noteValueNode.from, noteValueNode.to)) : 'UNKNOWN';

const description = parseDescription(stepNode, text);
const metadata = parseMetadata(stepNode, text);
const models = parseModel(stepNode, text);

return {
description,
metadata,
models,
string_arg: noteValue,
time,
type: 'note',
};
}

function parseGroundBlockEvent(stepNode: SyntaxNode, text: string): GroundBlock | GroundEvent {
const time = parseTime(stepNode, text);

Expand Down Expand Up @@ -263,6 +284,8 @@ function parseStep(child: SyntaxNode, text: string, commandDictionary: CommandDi
case 'GroundBlock':
case 'GroundEvent':
return parseGroundBlockEvent(child, text);
case 'Note':
return parseNote(child, text);
}
// Standalone comment nodes (not descriptions of steps), are not supported in the seq.json schema
// Until a schema change is coordinated, comments will dropped while writing out seq.json.
Expand Down

0 comments on commit f3455d7

Please sign in to comment.