fraudTech commited on
Commit
db052aa
·
1 Parent(s): 5bf318a

fix matplotlib display

Browse files
Files changed (2) hide show
  1. web/src/App.css +21 -0
  2. web/src/App.tsx +41 -1
web/src/App.css CHANGED
@@ -982,6 +982,27 @@ details.tool-section[open] summary::before {
982
  word-break: break-word;
983
  }
984
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
985
  /* Horizontal scroll for collapsed input */
986
  .tool-input-scroll {
987
  white-space: pre;
 
982
  word-break: break-word;
983
  }
984
 
985
+ /* Style for tool output images (matplotlib plots) */
986
+ .tool-output img {
987
+ max-width: 100%;
988
+ height: auto;
989
+ border-radius: 6px;
990
+ border: 1px solid #3a342e;
991
+ margin: 1rem 0;
992
+ display: block;
993
+ }
994
+
995
+ /* Override monospace font for rendered markdown in tool output */
996
+ .tool-output > div {
997
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
998
+ }
999
+
1000
+ /* Keep code blocks in tool output with monospace */
1001
+ .tool-output pre,
1002
+ .tool-output code {
1003
+ font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Consolas', monospace;
1004
+ }
1005
+
1006
  /* Horizontal scroll for collapsed input */
1007
  .tool-input-scroll {
1008
  white-space: pre;
web/src/App.tsx CHANGED
@@ -696,7 +696,47 @@ function App() {
696
  {tool.output && (
697
  <div className="tool-section">
698
  <div className="tool-section-label">Output:</div>
699
- <pre className="tool-output">{tool.output}</pre>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
700
  </div>
701
  )}
702
  </div>
 
696
  {tool.output && (
697
  <div className="tool-section">
698
  <div className="tool-section-label">Output:</div>
699
+ <div className="tool-output">
700
+ <ReactMarkdown
701
+ remarkPlugins={[
702
+ [remarkMath, { singleDollarTextMath: true }],
703
+ remarkGfm
704
+ ]}
705
+ rehypePlugins={[rehypeKatex]}
706
+ components={{
707
+ code({ className, children, ...props }: any) {
708
+ const match = /language-(\w+)/.exec(className || '');
709
+ return match ? (
710
+ <SyntaxHighlighter
711
+ style={terminalTheme as any}
712
+ language={match[1]}
713
+ PreTag="div"
714
+ {...props}
715
+ >
716
+ {String(children).replace(/\n$/, '')}
717
+ </SyntaxHighlighter>
718
+ ) : (
719
+ <code className={className} {...props}>
720
+ {children}
721
+ </code>
722
+ );
723
+ },
724
+ // Ensure images are rendered properly
725
+ img({ src, alt, ...props }: any) {
726
+ return (
727
+ <img
728
+ src={src}
729
+ alt={alt || 'Plot'}
730
+ style={{ maxWidth: '100%', height: 'auto', margin: '1rem 0' }}
731
+ {...props}
732
+ />
733
+ );
734
+ },
735
+ }}
736
+ >
737
+ {tool.output}
738
+ </ReactMarkdown>
739
+ </div>
740
  </div>
741
  )}
742
  </div>