MCPcopy Create free account
hub / github.com/microsoft/Webwright / parseMarkdownSections

Function parseMarkdownSections

assets/compare_trajectory/app.js:736–780  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

734}
735
736function parseMarkdownSections(text) {
737 const lines = String(text || '').split(/\r?\n/);
738 const sections = [];
739 let pendingTime = '';
740 let index = 0;
741 while (index < lines.length) {
742 const line = lines[index];
743 const timeMatch = line.match(/^<sub>.*?⏱️\s*([^<]+)<\/sub>$/);
744 if (timeMatch) {
745 pendingTime = timeMatch[1].trim();
746 index += 1;
747 continue;
748 }
749 const headingMatch = line.match(/^###\s+(ℹ️ Info|👤 User|💬 Copilot|✅\s+`([^`]+)`)\s*$/);
750 if (!headingMatch) {
751 index += 1;
752 continue;
753 }
754 const tool = headingMatch[2] || '';
755 let type = 'info';
756 if (tool) {
757 type = 'tool';
758 } else if (/User/.test(headingMatch[1])) {
759 type = 'user';
760 } else if (/Copilot/.test(headingMatch[1])) {
761 type = 'copilot';
762 }
763 let cursor = index + 1;
764 const bodyLines = [];
765 while (cursor < lines.length) {
766 if (lines[cursor].match(/^<sub>.*?⏱️/)) {
767 break;
768 }
769 if (lines[cursor].match(/^###\s+(ℹ️ Info|👤 User|💬 Copilot|✅\s+`[^`]+`)\s*$/)) {
770 break;
771 }
772 bodyLines.push(lines[cursor]);
773 cursor += 1;
774 }
775 sections.push({ type, tool, timeLabel: pendingTime || 'n/a', body: bodyLines.join('\n').trim() });
776 pendingTime = '';
777 index = cursor;
778 }
779 return sections;
780}
781
782function parseSessionToolSection(section, side, commandOrder, eventOrder) {
783 const body = section.body || '';

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected