From a9da85d3001b967242026a33d248856a199c30c9 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Wed, 27 Jan 2021 15:11:08 -0300 Subject: [PATCH 1/4] Add language prop to HighlightCode component --- src/core/components/highlight-code.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/components/highlight-code.jsx b/src/core/components/highlight-code.jsx index 2d888c75699..718883d4d79 100644 --- a/src/core/components/highlight-code.jsx +++ b/src/core/components/highlight-code.jsx @@ -39,7 +39,7 @@ export default class HighlightCode extends Component { } render () { - let { value, className, downloadable, getConfigs, canCopy } = this.props + let { value, className, downloadable, getConfigs, canCopy, language } = this.props const config = getConfigs ? getConfigs() : {syntaxHighlight: {activated: true, theme: "agate"}} @@ -47,6 +47,7 @@ export default class HighlightCode extends Component { const codeBlock = get(config, "syntaxHighlight.activated") ? Date: Wed, 27 Jan 2021 15:13:56 -0300 Subject: [PATCH 2/4] Use language prop for JSON HighlightCode responses --- src/core/components/response-body.jsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/components/response-body.jsx b/src/core/components/response-body.jsx index 013425e1992..2425a1e8e76 100644 --- a/src/core/components/response-body.jsx +++ b/src/core/components/response-body.jsx @@ -94,13 +94,15 @@ export default class ResponseBody extends React.PureComponent { // Anything else (CORS) } else if (/json/i.test(contentType)) { // JSON + let language = null try { body = JSON.stringify(JSON.parse(content), null, " ") + language = "json" } catch (error) { body = "can't parse JSON. Raw result:\n\n" + content } - bodyEl = + bodyEl = // XML } else if (/xml/i.test(contentType)) { From 60c32266e22277c48ac375688328ef9b75bf059e Mon Sep 17 00:00:00 2001 From: Nicolas Date: Wed, 27 Jan 2021 15:27:35 -0300 Subject: [PATCH 3/4] Add missing language prop type in HighlightCode --- src/core/components/highlight-code.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/components/highlight-code.jsx b/src/core/components/highlight-code.jsx index 718883d4d79..414180cb94a 100644 --- a/src/core/components/highlight-code.jsx +++ b/src/core/components/highlight-code.jsx @@ -12,6 +12,7 @@ export default class HighlightCode extends Component { className: PropTypes.string, downloadable: PropTypes.bool, fileName: PropTypes.string, + language: PropTypes.string, canCopy: PropTypes.bool } @@ -47,7 +48,7 @@ export default class HighlightCode extends Component { const codeBlock = get(config, "syntaxHighlight.activated") ? Date: Wed, 27 Jan 2021 15:27:39 -0300 Subject: [PATCH 4/4] Update response-body.jsx --- src/core/components/response-body.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/components/response-body.jsx b/src/core/components/response-body.jsx index 2425a1e8e76..88587321261 100644 --- a/src/core/components/response-body.jsx +++ b/src/core/components/response-body.jsx @@ -102,7 +102,7 @@ export default class ResponseBody extends React.PureComponent { body = "can't parse JSON. Raw result:\n\n" + content } - bodyEl = + bodyEl = // XML } else if (/xml/i.test(contentType)) {