MCPcopy Create free account
hub / github.com/ashawkey/camera_viewer / extractNameFromBlock

Method extractNameFromBlock

js/poseParser.js:68–100  ·  view source on GitHub ↗

* Extract trajectory name from a # comment line at the start of a block * @param {string} block - The block content * @param {number} index - Block index for default naming * @returns {Object} - { name: string, content: string }

(block, index)

Source from the content-addressed store, hash-verified

66 * @returns {Object} - { name: string, content: string }
67 */
68 static extractNameFromBlock(block, index) {
69 const lines = block.split('\n');
70 let name = `Trajectory ${index + 1}`;
71 let contentStartIndex = 0;
72
73 // Look for # comment lines at the start of the block
74 for (let i = 0; i < lines.length; i++) {
75 const trimmed = lines[i].trim();
76
77 if (trimmed === '') {
78 // Skip empty lines at the start
79 contentStartIndex = i + 1;
80 continue;
81 }
82
83 if (trimmed.startsWith('#')) {
84 // Found a name comment - extract the name
85 const extractedName = trimmed.substring(1).trim();
86 if (extractedName) {
87 name = extractedName;
88 }
89 contentStartIndex = i + 1;
90 } else {
91 // First non-comment, non-empty line - start of actual content
92 break;
93 }
94 }
95
96 // Return the content without the name comment lines
97 const content = lines.slice(contentStartIndex).join('\n');
98
99 return { name, content };
100 }
101
102 /**
103 * Split input into separate trajectory blocks

Callers 1

parseMultipleMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected