aboutsummaryrefslogtreecommitdiffstats
path: root/packages/dev-tools-pages/ts/highlight.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/dev-tools-pages/ts/highlight.tsx')
-rw-r--r--packages/dev-tools-pages/ts/highlight.tsx22
1 files changed, 20 insertions, 2 deletions
diff --git a/packages/dev-tools-pages/ts/highlight.tsx b/packages/dev-tools-pages/ts/highlight.tsx
index 8dff4c9e9..64c5f9a17 100644
--- a/packages/dev-tools-pages/ts/highlight.tsx
+++ b/packages/dev-tools-pages/ts/highlight.tsx
@@ -38,12 +38,30 @@ function diffHighlight(language: string, code: any, gutter: any) {
.join('\n');
}
-function highlight(language: string, code: string, diff: boolean, gutter: any) {
+interface highlightProps {
+ language: string;
+ code: string;
+ diff?: boolean;
+ gutter?: boolean;
+ etc?: boolean;
+}
+
+function highlight({ language, code, diff, gutter, etc }: highlightProps) {
if (diff) {
return diffHighlight(language, code, gutter);
}
- return hljs.highlight(language, code).value;
+ let hlCode = hljs.highlight(language, code).value;
+
+ if (!etc) {
+ return hlCode;
+ }
+
+ var hc = hlCode.split(/\r?\n/g);
+ hc.splice(1, 0, ' ...');
+ hc.splice(hc.length - 1, 0, ' ...');
+
+ return hc.join('\n');
}
export default highlight;