Skip to content

Commit 41899b4

Browse files
authored
Merge pull request microsoft#162 from Microsoft/alihamud-syntaxHighlighter
Syntax highlighter to make code colorful
2 parents 44f7953 + 78687da commit 41899b4

13 files changed

Lines changed: 4082 additions & 11 deletions

File tree

NOTICE.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Microsoft.PowerBI.JavaScript
2+
3+
THIRD-PARTY SOFTWARE NOTICES AND INFORMATION
4+
Do Not Translate or Localize
5+
6+
This project incorporates components from the projects listed below. The original copyright notices and the licenses under which Microsoft received such components are set forth below. Microsoft reserves all rights not expressly granted herein, whether by implication, estoppel or otherwise.
7+
8+
1. SyntaxHighlighter (https://github.com/syntaxhighlighter/syntaxhighlighter)
9+
10+
Copyright (c) 2004-2013, Alex Gorbatchev
11+
12+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

demo/LICENSE.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Microsoft.PowerBI.JavaScript
2+
3+
Copyright (c) Microsoft Corporation
4+
5+
All rights reserved.
6+
7+
MIT License
8+
9+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

demo/NOTICE.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Microsoft.PowerBI.JavaScript
2+
3+
THIRD-PARTY SOFTWARE NOTICES AND INFORMATION
4+
Do Not Translate or Localize
5+
6+
This project incorporates components from the projects listed below. The original copyright notices and the licenses under which Microsoft received such components are set forth below. Microsoft reserves all rights not expressly granted herein, whether by implication, estoppel or otherwise.
7+
8+
1. SyntaxHighlighter (https://github.com/syntaxhighlighter/syntaxhighlighter)
9+
10+
Copyright (c) 2004-2013, Alex Gorbatchev
11+
12+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

demo/code-demo/code_area.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
<div class="editorTitle">Code</div>
33
<div class="textAreaControls">
44
<button id="btnRunCode" class="textAreaControl">
5-
<img src="images\run.png"/> Run
5+
<img src="images\run.png" /> Run
66
</button>
77
<button id="btnCopyCode" class="textAreaControl" onclick="CopyCode();">
8-
<img src="images\copy.png"/> Copy
8+
<img src="images\copy.png" /> Copy
99
</button>
1010
</div>
11-
<textarea id="txtCode" readonly />
11+
12+
<div id="highlighter">
13+
</div>

demo/code-demo/index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1">
77

88
<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.css" />
9+
<link type="text/css" rel="stylesheet" href="syntaxhighlighter/theme.css">
910
<link rel="stylesheet" type="text/css" href="style/style.css">
1011
<link rel="stylesheet" type="text/css" href="style/layout.css">
12+
<link rel="stylesheet" type="text/css" href="style/syntaxHighlighterOverride.css">
13+
1114
</head>
1215

1316
<body>
@@ -48,7 +51,7 @@
4851
<script src="../node_modules/jquery/dist/jquery.js"></script>
4952
<script src="../node_modules/es6-promise/dist/es6-promise.js"></script>
5053
<script src="../node_modules/powerbi-client/dist/powerbi.js"></script>
51-
54+
5255
<script src="scripts/codesamples.js"></script>
5356

5457
<script src="scripts/index.js"></script>

demo/code-demo/scripts/utils.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ function LoadLogWindow(divSelector) {
5050
}
5151

5252
function SetCode(func) {
53-
$("#txtCode").val(BodyCodeOfFunction(func));
53+
var codeHtml = '<pre id="txtCode" class="brush: js; gutter: false;">';
54+
codeHtml = codeHtml + BodyCodeOfFunction(func) + '</pre><script type="text/javascript" src="syntaxhighlighter/syntaxhighlighter.js"></script>';
55+
$("#highlighter").html(codeHtml);
5456

5557
var runFunc = mapFunc(func);
5658

demo/code-demo/step_authorize.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!DOCTYPE html>
22
<div id="authStepDiv">
3-
<div id="sampleReport" class="line">
3+
<div id="sampleReport" class="pbi-line">
44
<div class="pageTitle">
55
<h3>Sample Report</h3>
66
<h8>You can embed a sample report and interact with Power BI Embedded firsthand by clicking below.</h8>

demo/code-demo/style/style.css

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ a {
134134
width: 100%;
135135
}
136136

137-
.line {
137+
.pbi-line {
138138
display: inline-block;
139139
width: 100%;
140140
}
@@ -509,10 +509,12 @@ a {
509509
width: 100%;
510510
height: 300px;
511511
border: none;
512-
padding-top: 40px;
512+
padding: 20px;
513513
position: relative;
514514
top: -30px;
515-
padding-left: 20px;
515+
background: #FFFFFF;
516+
overflow: auto;
517+
white-space: pre-wrap;
516518
}
517519

518520
#GoToEmbedStepButton {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.syntaxhighlighter {
2+
overflow: hidden !important;
3+
margin: 0em !important;
4+
padding: 0em !important;
5+
top: -98px !important;
6+
}
7+
8+
.syntaxhighlighter .line {
9+
white-space: pre-wrap !important;
10+
}

0 commit comments

Comments
 (0)