dheerajturaga commented on code in PR #53657:
URL: https://github.com/apache/airflow/pull/53657#discussion_r2244301357


##########
airflow-core/src/airflow/ui/src/pages/TaskInstance/RenderedTemplates.tsx:
##########
@@ -16,14 +16,75 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import { Box, HStack, Table, Code } from "@chakra-ui/react";
+import { Box, HStack, Table } from "@chakra-ui/react";
 import { useParams } from "react-router-dom";
+import { PrismLight as SyntaxHighlighter } from "react-syntax-highlighter";
+import bash from "react-syntax-highlighter/dist/esm/languages/prism/bash";
+import json from "react-syntax-highlighter/dist/esm/languages/prism/json";
+import sql from "react-syntax-highlighter/dist/esm/languages/prism/sql";
+import yaml from "react-syntax-highlighter/dist/esm/languages/prism/yaml";
+import { oneLight, oneDark } from 
"react-syntax-highlighter/dist/esm/styles/prism";
 
 import { useTaskInstanceServiceGetMappedTaskInstance } from "openapi/queries";
 import { ClipboardRoot, ClipboardIconButton } from "src/components/ui";
+import { useColorMode } from "src/context/colorMode";
+
+SyntaxHighlighter.registerLanguage("json", json);
+SyntaxHighlighter.registerLanguage("yaml", yaml);
+SyntaxHighlighter.registerLanguage("sql", sql);
+SyntaxHighlighter.registerLanguage("bash", bash);
+
+const detectLanguage = (value: string): string => {
+  const trimmed = value.trim();
+
+  // Try to detect JSON
+  if (
+    (trimmed.startsWith("{") && trimmed.endsWith("}")) ||
+    (trimmed.startsWith("[") && trimmed.endsWith("]"))
+  ) {
+    try {
+      JSON.parse(trimmed);
+
+      return "json";
+    } catch {
+      // Not valid JSON, continue
+    }
+  }
+
+  // Try to detect YAML (basic heuristics)
+  if (trimmed.includes(":") && (trimmed.includes("\n") || trimmed.includes("- 
"))) {

Review Comment:
   Done!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to