@zhongqian97-code/ecode 0.5.62 → 0.5.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -802,7 +802,7 @@ if (rawArgs[0] === "web") {
802
802
  webAutoApprove = true;
803
803
  }
804
804
  }
805
- const { buildServer, generateAccessToken } = await import("./web-N7JFJIBC.js");
805
+ const { buildServer, generateAccessToken } = await import("./web-JSKN3U25.js");
806
806
  const token = finalConfig.webToken ?? generateAccessToken();
807
807
  const manager = new SessionManager(finalConfig);
808
808
  const __webDirname = dirname(fileURLToPath(import.meta.url));
@@ -670,20 +670,45 @@ function generateAdminHtml(version) {
670
670
 
671
671
  // Basic markdown \u2192 HTML (no libs)
672
672
  function renderMarkdown(text) {
673
- // Escape HTML first
674
- let s = text
675
- .replace(/&/g, '&')
676
- .replace(/</g, '&lt;')
677
- .replace(/>/g, '&gt;');
678
- // Code blocks (use highlightCode for syntax coloring)
679
- s = s.replace(/\`\`\`([\\s\\S]*?)\`\`\`/g, (_, code) =>
680
- '<pre><code>' + highlightCode(code.trim()) + '</code></pre>');
681
- // Inline code
682
- s = s.replace(/\`([^\`]+)\`/g, '<code>$1</code>');
683
- // Bold
673
+ // Protect fenced/inline code BEFORE escaping (highlightCode/escHtml escape internally)
674
+ const codeBlocks = [];
675
+ let s = String(text).replace(/\`\`\`([\\s\\S]*?)\`\`\`/g, (_, code) => {
676
+ codeBlocks.push('<pre><code>' + highlightCode(code.replace(/^\\n+/, '').replace(/\\n+$/, '')) + '</code></pre>');
677
+ return '\\u0001CB' + (codeBlocks.length - 1) + '\\u0001';
678
+ });
679
+ const inlineCode = [];
680
+ s = s.replace(/\`([^\`]+)\`/g, (_, code) => {
681
+ inlineCode.push('<code>' + escHtml(code) + '</code>');
682
+ return '\\u0001IC' + (inlineCode.length - 1) + '\\u0001';
683
+ });
684
+ // Escape remaining text
685
+ s = escHtml(s);
686
+ // Inline: links, bold, italic, strikethrough
687
+ s = s.replace(/\\[([^\\]]+)\\]\\(([^)\\s]+)\\)/g, '<a href="$2" target="_blank" rel="noopener">$1</a>');
684
688
  s = s.replace(/\\*\\*([^*]+)\\*\\*/g, '<strong>$1</strong>');
689
+ s = s.replace(/(^|[^*])\\*([^*\\n]+)\\*/g, '$1<em>$2</em>');
690
+ s = s.replace(/~~([^~]+)~~/g, '<del>$1</del>');
691
+ // Block: headers + lists, line by line
692
+ const lines = s.split('\\n');
693
+ const out = [];
694
+ let listType = null;
695
+ const closeList = () => { if (listType) { out.push('</' + listType + '>'); listType = null; } };
696
+ for (const line of lines) {
697
+ const h = line.match(/^(#+)\\s+(.*)$/);
698
+ const ul = line.match(/^\\s*[-*]\\s+(.*)$/);
699
+ const ol = line.match(/^\\s*\\d+\\.\\s+(.*)$/);
700
+ if (h) { closeList(); const lvl = Math.min(h[1].length, 6); out.push('<h' + lvl + '>' + h[2] + '</h' + lvl + '>'); }
701
+ else if (ul) { if (listType !== 'ul') { closeList(); out.push('<ul>'); listType = 'ul'; } out.push('<li>' + ul[1] + '</li>'); }
702
+ else if (ol) { if (listType !== 'ol') { closeList(); out.push('<ol>'); listType = 'ol'; } out.push('<li>' + ol[1] + '</li>'); }
703
+ else { closeList(); out.push(line); }
704
+ }
705
+ closeList();
706
+ s = out.join('\\n');
685
707
  // Paragraph breaks
686
708
  s = s.replace(/\\n\\n+/g, '</p><p>');
709
+ // Restore code placeholders
710
+ s = s.replace(/\\u0001CB(\\d+)\\u0001/g, (_, i) => codeBlocks[+i]);
711
+ s = s.replace(/\\u0001IC(\\d+)\\u0001/g, (_, i) => inlineCode[+i]);
687
712
  return '<p>' + s + '</p>';
688
713
  }
689
714
 
@@ -834,7 +859,10 @@ function generateAdminHtml(version) {
834
859
  function finalizeStreamingMsg() {
835
860
  if (state.streamingMsgEl) {
836
861
  const body = state.streamingMsgEl.querySelector('.msg-body');
837
- if (body) body.classList.remove('cursor-blink');
862
+ if (body) {
863
+ body.classList.remove('cursor-blink');
864
+ body.innerHTML = renderMarkdown(body.textContent);
865
+ }
838
866
  state.streamingMsgEl = null;
839
867
  }
840
868
  state.streamingThinkEl = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhongqian97-code/ecode",
3
- "version": "0.5.62",
3
+ "version": "0.5.63",
4
4
  "description": "A minimal Claude Code clone with REPL interface and bash tool calling",
5
5
  "type": "module",
6
6
  "author": "zhongqian97-code",