Skip to content

Commit b0659b6

Browse files
author
Alice Koreman
committed
add syntax highlighting example line wrapping page
1 parent 33411cc commit b0659b6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pages/code-view/with-line-wrapping.page.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
import { SpaceBetween } from "@cloudscape-design/components";
55

66
import { CodeView } from "../../lib/components";
7+
import cppHighlight from "../../lib/components/code-view/highlight/cpp";
78
import { ScreenshotArea } from "../screenshot-area";
9+
810
export default function CodeViewPage() {
911
return (
1012
<ScreenshotArea>
@@ -30,10 +32,12 @@ export default function CodeViewPage() {
3032
lineNumbers={true}
3133
content={`Hello this is a short line.\nHello this is a long line. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.\nHello this is another short line.`}
3234
/>
35+
Full example with indentation and code highlighting
3336
<CodeView
3437
lineWrapping={true}
3538
lineNumbers={true}
36-
content={`public class HelloWorld {\n public static void main(String[] args) {\n System.out.println("Hello, World!");\n }\n}`}
39+
highlight={cppHighlight}
40+
content={`void UserQuery(map<string, vector<string> > &svmap) {\n string queryName;\n cout << "Please enter a family name you want to query: ";\n cin >> queryName;\n int i = 0;\n for (map<string, vector<string> >::iterator itr = svmap.begin(), mapEnd = svmap.end(); itr != mapEnd; ++itr) {\n i++;\n if (itr->first == queryName) {\n cout << "The " << itr->first << " family has " << itr->second.size() << " children: ";\n for (vector<string>::iterator itrvec = itr->second.begin(), vecEnd = itr->second.end(); itrvec != vecEnd; ++itrvec)\n cout << *itrvec << " ";\n break;\n }\n }\n if (i >= svmap.size())\n cout << "Sorry, the " << queryName << " family is not found." << endl;\n}`}
3741
/>
3842
</SpaceBetween>
3943
</ScreenshotArea>

0 commit comments

Comments
 (0)