diff --git a/packages/react-core/src/components/CodeBlock/examples/CodeBlock.md b/packages/react-core/src/components/CodeBlock/examples/CodeBlock.md index 4e0c7775ffa..ccc822baa9c 100644 --- a/packages/react-core/src/components/CodeBlock/examples/CodeBlock.md +++ b/packages/react-core/src/components/CodeBlock/examples/CodeBlock.md @@ -8,14 +8,20 @@ propComponents: ['CodeBlock', 'CodeBlockAction', 'CodeBlockCode'] import CopyIcon from '@patternfly/react-icons/dist/esm/icons/copy-icon'; import PlayIcon from '@patternfly/react-icons/dist/esm/icons/play-icon'; +**Important note:** to format code exactly as it is, you should use String.raw\`your code here\`. + +Using **String.raw\`\`** will keep all the special characters like `\n` or `\t`. + ## Examples ### Basic ```ts file="./CodeBlockBasic.tsx" + ``` ### Expandable ```ts file="./CodeBlockExpandable.tsx" + ``` diff --git a/packages/react-core/src/components/CodeBlock/examples/CodeBlockBasic.tsx b/packages/react-core/src/components/CodeBlock/examples/CodeBlockBasic.tsx index 49131aceb6c..e1e818af8bf 100644 --- a/packages/react-core/src/components/CodeBlock/examples/CodeBlockBasic.tsx +++ b/packages/react-core/src/components/CodeBlock/examples/CodeBlockBasic.tsx @@ -14,7 +14,7 @@ export const BasicCodeBlock: React.FunctionComponent = () => { setCopied(true); }; - const code = `apiVersion: helm.openshift.io/v1beta1/ + const code = String.raw`apiVersion: helm.openshift.io/v1beta1/ kind: HelmChartRepository metadata: name: azure-sample-repo0oooo00ooo diff --git a/packages/react-core/src/components/CodeBlock/examples/CodeBlockExpandable.tsx b/packages/react-core/src/components/CodeBlock/examples/CodeBlockExpandable.tsx index 1d068c18929..203f992c923 100644 --- a/packages/react-core/src/components/CodeBlock/examples/CodeBlockExpandable.tsx +++ b/packages/react-core/src/components/CodeBlock/examples/CodeBlockExpandable.tsx @@ -27,7 +27,7 @@ export const ExpandableCodeBlock: React.FunctionComponent = () => { setCopied(true); }; - const copyBlock = `apiVersion: helm.openshift.io/v1beta1/ + const copyBlock = String.raw`apiVersion: helm.openshift.io/v1beta1/ kind: HelmChartRepository metadata: name: azure-sample-repo @@ -35,11 +35,11 @@ spec: connectionConfig: url: https://raw.githubusercontent.com/Azure-Samples/helm-charts/master/docs`; - const code = `apiVersion: helm.openshift.io/v1beta1/ + const code = String.raw`apiVersion: helm.openshift.io/v1beta1/ kind: HelmChartRepository metadata: name: azure-sample-repo`; - const expandedCode = `spec: + const expandedCode = String.raw`spec: connectionConfig: url: https://raw.githubusercontent.com/Azure-Samples/helm-charts/master/docs`;