How many lines have been parsed, counting every call.
Original G-code lines, in the order they were parsed.
Only populated when the parser was created with keepLines. Streaming
parses append to this, so it spans the whole input rather than just the
most recent chunk.
String input is split on '\n', so input ending in a newline yields one
final empty line here. That is the split's honest answer and is
deliberately not filtered out.
Metadata extracted from G-code comments, including thumbnails
Parses a single line of G-code into a command object.
Single line of G-code to parse
Whether to preserve comments in the parsed command (default: true)
Parsed GCodeCommand object or null if line is empty/invalid
Parses G-code input into commands and metadata
G-code to parse, either as a string or array of lines
Object containing parsed metadata and commands
Extracts metadata from G-code commands, particularly focusing on thumbnails.
Array of G-code commands containing metadata in comments
Object containing extracted metadata (currently only thumbnails)
This method processes special comments in the G-code that contain metadata. Currently, it focuses on extracting thumbnail data that some slicers embed in the G-code file. The thumbnail data is typically found between 'thumbnail begin' and 'thumbnail end' markers in the comments.
The method handles multi-line thumbnail data by accumulating characters until it encounters the end marker. Once complete, it validates the thumbnail data before storing it in the thumbnails record.
The in-progress thumbnail lives on the parser instance, so a block that spans multiple calls (a streaming parse hands each chunk to parseGCode separately) accumulates across them. Each call returns only the thumbnails completed during that call; a block still open at the end of a call carries into the next one.
A G-code parser that processes G-code commands and extracts metadata.
Remarks
This parser handles both single-line and multi-line G-code input, extracting commands, parameters, and metadata such as thumbnails. It preserves comments and, when created with
keepLines, retains the original source lines.Example