Skip to content

Commit b0d1823

Browse files
RunDevelopmentmAAdhaTTah
authored andcommitted
Clean up Previewers' page (#1630)
This PR makes some changes to the [Previewers plugin's page](https://prismjs.com/plugins/previewers/). 1. Format the code examples to look nicer. 2. Fix the example of the 'Disabling a previewer' section. 3. Highlight API snippets as JavaScript.
1 parent e2f2fd1 commit b0d1823

File tree

1 file changed

+37
-36
lines changed

1 file changed

+37
-36
lines changed

plugins/previewers/index.html

+37-36
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,19 @@ <h1>Examples</h1>
4343

4444
<h2>CSS</h2>
4545
<pre class="language-css"><code>.example-gradient {
46-
background: -moz-linear-gradient(left, #cb60b3 0%, #c146a1 50%, #a80077 51%, #db36a4 100%); /* FF3.6+ */
47-
background: -webkit-linear-gradient(left, #cb60b3 0%,#c146a1 50%,#a80077 51%,#db36a4 100%); /* Chrome10+,Safari5.1+ */
48-
background: -o-linear-gradient(left, #cb60b3 0%,#c146a1 50%,#a80077 51%,#db36a4 100%); /* Opera 11.10+ */
49-
background: -ms-linear-gradient(left, #cb60b3 0%,#c146a1 50%,#a80077 51%,#db36a4 100%); /* IE10+ */
50-
background: linear-gradient(to right, #cb60b3 0%,#c146a1 50%,#a80077 51%,#db36a4 100%); /* W3C */
46+
background: -webkit-linear-gradient(left, #cb60b3 0%, #c146a1 50%, #a80077 51%, #db36a4 100%); /* Chrome10+, Safari5.1+ */
47+
background: -moz-linear-gradient(left, #cb60b3 0%, #c146a1 50%, #a80077 51%, #db36a4 100%); /* FF3.6+ */
48+
background: -ms-linear-gradient(left, #cb60b3 0%, #c146a1 50%, #a80077 51%, #db36a4 100%); /* IE10+ */
49+
background: -o-linear-gradient(left, #cb60b3 0%, #c146a1 50%, #a80077 51%, #db36a4 100%); /* Opera 11.10+ */
50+
background: linear-gradient(to right, #cb60b3 0%, #c146a1 50%, #a80077 51%, #db36a4 100%); /* W3C */
5151
}
5252
.example-angle {
5353
transform: rotate(10deg);
5454
}
5555
.example-color {
5656
color: rgba(255, 0, 0, 0.2);
5757
background: purple;
58-
border: 1px solid hsl(100,70%,40%);
58+
border: 1px solid hsl(100, 70%, 40%);
5959
}
6060
.example-easing {
6161
transition-timing-function: linear;
@@ -69,13 +69,13 @@ <h2>Markup attributes</h2>
6969
&lt;tr style="background: lightblue;"></code></pre>
7070

7171
<h2>Less</h2>
72-
<pre class="language-less"><code>@gradient: linear-gradient(135deg, #9dd53a 0%,#a1d54f 50%,#80c217 51%,#7cbc0a 100%);
72+
<pre class="language-less"><code>@gradient: linear-gradient(135deg, #9dd53a 0%, #a1d54f 50%, #80c217 51%, #7cbc0a 100%);
7373
.example-gradient {
74-
background: -moz-linear-gradient(-45deg, #9dd53a 0%, #a1d54f 50%, #80c217 51%, #7cbc0a 100%); /* FF3.6+ */
75-
background: -webkit-linear-gradient(-45deg, #9dd53a 0%,#a1d54f 50%,#80c217 51%,#7cbc0a 100%); /* Chrome10+,Safari5.1+ */
76-
background: -o-linear-gradient(-45deg, #9dd53a 0%,#a1d54f 50%,#80c217 51%,#7cbc0a 100%); /* Opera 11.10+ */
77-
background: -ms-linear-gradient(-45deg, #9dd53a 0%,#a1d54f 50%,#80c217 51%,#7cbc0a 100%); /* IE10+ */
78-
background: linear-gradient(135deg, #9dd53a 0%,#a1d54f 50%,#80c217 51%,#7cbc0a 100%); /* W3C */
74+
background: -webkit-linear-gradient(-45deg, #9dd53a 0%, #a1d54f 50%, #80c217 51%, #7cbc0a 100%); /* Chrome10+, Safari5.1+ */
75+
background: -moz-linear-gradient(-45deg, #9dd53a 0%, #a1d54f 50%, #80c217 51%, #7cbc0a 100%); /* FF3.6+ */
76+
background: -ms-linear-gradient(-45deg, #9dd53a 0%, #a1d54f 50%, #80c217 51%, #7cbc0a 100%); /* IE10+ */
77+
background: -o-linear-gradient(-45deg, #9dd53a 0%, #a1d54f 50%, #80c217 51%, #7cbc0a 100%); /* Opera 11.10+ */
78+
background: linear-gradient(135deg, #9dd53a 0%, #a1d54f 50%, #80c217 51%, #7cbc0a 100%); /* W3C */
7979
}
8080
@angle: 3rad;
8181
.example-angle {
@@ -85,7 +85,7 @@ <h2>Less</h2>
8585
.example-color {
8686
color: hsla(102, 53%, 42%, 0.4);
8787
}
88-
@easing: cubic-bezier(0.1,0.3,1,.4);
88+
@easing: cubic-bezier(0.1, 0.3, 1, .4);
8989
.example-easing {
9090
transition-timing-function: ease;
9191
}
@@ -95,20 +95,20 @@ <h2>Less</h2>
9595
}</code></pre>
9696

9797
<h2>Sass</h2>
98-
<pre class="language-sass"><code>$gradient: linear-gradient(135deg, #9dd53a 0%,#a1d54f 50%,#80c217 51%,#7cbc0a 100%)
98+
<pre class="language-sass"><code>$gradient: linear-gradient(135deg, #9dd53a 0%, #a1d54f 50%, #80c217 51%, #7cbc0a 100%)
9999
@mixin example-gradient
100-
background: -moz-radial-gradient(center, ellipse cover, #f2f6f8 0%, #d8e1e7 50%, #b5c6d0 51%, #e0eff9 100%)
101-
background: radial-gradient(ellipse at center, #f2f6f8 0%,#d8e1e7 50%,#b5c6d0 51%,#e0eff9 100%)
100+
background: -moz-radial-gradient(center, ellipse cover, #f2f6f8 0%, #d8e1e7 50%, #b5c6d0 51%, #e0eff9 100%)
101+
background: radial-gradient(ellipse at center, #f2f6f8 0%, #d8e1e7 50%, #b5c6d0 51%, #e0eff9 100%)
102102
$angle: 380grad
103103
@mixin example-angle
104104
transform: rotate(-120deg)
105105
.example-angle
106106
transform: rotate(18rad)
107107
$color: blue
108108
@mixin example-color
109-
color: rgba(147, 32, 34, 0.8)
109+
color: rgba(147, 32, 34, 0.8)
110110
.example-color
111-
color: pink
111+
color: pink
112112
$easing: ease-out
113113
.example-easing
114114
transition-timing-function: ease-in-out
@@ -120,32 +120,32 @@ <h2>Sass</h2>
120120
</code></pre>
121121

122122
<h2>Scss</h2>
123-
<pre class="language-scss"><code>$gradient: linear-gradient(135deg, #9dd53a 0%,#a1d54f 50%,#80c217 51%,#7cbc0a 100%);
123+
<pre class="language-scss"><code>$gradient: linear-gradient(135deg, #9dd53a 0%, #a1d54f 50%, #80c217 51%, #7cbc0a 100%);
124124
$attr: background;
125125
.example-gradient {
126-
#{$attr}-image: repeating-linear-gradient(10deg, rgba(255,0,0,0), rgba(255,0,0,1) 10px, rgba(255,0,0,0) 20px);
126+
#{$attr}-image: repeating-linear-gradient(10deg, rgba(255, 0, 0, 0), rgba(255, 0, 0, 1) 10px, rgba(255, 0, 0, 0) 20px);
127127
}
128128
$angle: 1.8turn;
129129
.example-angle {
130130
transform: rotate(-3rad)
131131
}
132132
$color: blue;
133133
.example-color {
134-
#{$attr}-color: rgba(255,255,0,0.75);
134+
#{$attr}-color: rgba(255, 255, 0, 0.75);
135135
}
136136
$easing: linear;
137137
.example-easing {
138-
transition-timing-function: cubic-bezier(0.9,0.1,.2,.4);
138+
transition-timing-function: cubic-bezier(0.9, 0.1, .2, .4);
139139
}
140140
$time: 1s;
141141
.example-time {
142142
transition-duration: 10s
143143
}</code></pre>
144144

145145
<h2>Stylus</h2>
146-
<pre class="language-stylus"><code>gradient = linear-gradient(135deg, #9dd53a 0%,#a1d54f 50%,#80c217 51%,#7cbc0a 100%)
146+
<pre class="language-stylus"><code>gradient = linear-gradient(135deg, #9dd53a 0%, #a1d54f 50%, #80c217 51%, #7cbc0a 100%)
147147
.example-gradient
148-
background-image: repeating-radial-gradient(circle, rgba(255,0,0,0), rgba(255,0,0,1) 10px, rgba(255,0,0,0) 20px)
148+
background-image: repeating-radial-gradient(circle, rgba(255, 0, 0, 0), rgba(255, 0, 0, 1) 10px, rgba(255, 0, 0, 0) 20px)
149149
angle = 357deg
150150
.example-angle
151151
transform: rotate(100grad)
@@ -166,15 +166,16 @@ <h1>Disabling a previewer</h1>
166166
can be added on a code block or any ancestor. Its value should be a space-separated list of previewers
167167
representing the subset.</p>
168168
<p>For example:</p>
169-
<pre class="language-markup"><code>&lt;pre class="language-css" data-previewers="color">&lt;code>div {
170-
/* Only the previewer for colors is enabled */
169+
<pre class="language-markup"><code>&lt;pre class="language-css" data-previewers="color time">&lt;code>div {
170+
/* Only the previewer for color and time are enabled */
171171
color: red;
172+
transition-duration: 1s;
172173
/* The previewer for angles is not enabled. */
173174
transform: rotate(10deg);
174175
}&lt;/code>&lt;/pre></code></pre>
175176
<p>will give the following result:</p>
176177
<pre class="language-css" data-previewers="color time"><code>div {
177-
/* Only the previewers color and time are enabled */
178+
/* Only the previewers for color and time are enabled */
178179
color: red;
179180
transition-duration: 1s;
180181
/* The previewer for angles is not enabled. */
@@ -184,30 +185,30 @@ <h1>Disabling a previewer</h1>
184185

185186
<section>
186187
<h1>API</h1>
187-
<p>This plugins provides a constructor that can be accessed through <code>Prism.plugins.Previewer</code>.</p>
188+
<p>This plugins provides a constructor that can be accessed through <code class="language-javascript">Prism.plugins.Previewer</code>.</p>
188189
<p>Once a previewer has been instantiated, an HTML element is appended to the document body.
189190
This element will appear when specific tokens are hovered.</p>
190191

191-
<h2><code>new Prism.plugins.Previewer(type, updater, supportedLanguages)</code></h2>
192+
<h2><code class="language-javascript">new Prism.plugins.Previewer(type, updater, supportedLanguages)</code></h2>
192193

193194
<ul>
194195
<li>
195-
<p><code>type</code>: the token type this previewer is associated to.
196+
<p><code class="language-javascript">type</code>: the token type this previewer is associated to.
196197
The previewer will be shown when hovering tokens of this type.</p>
197198
</li>
198199
<li>
199-
<p><code>updater</code>: the function that will be called each time an associated token is hovered.
200+
<p><code class="language-javascript">updater</code>: the function that will be called each time an associated token is hovered.
200201
This function takes the text content of the token as its only parameter.
201-
The previewer HTML element can be accessed through the keyword <code>this</code>.
202-
This function must return <code>true</code> for the previewer to be shown.</p>
202+
The previewer HTML element can be accessed through the keyword <code class="language-javascript">this</code>.
203+
This function must return <code class="language-javascript">true</code> for the previewer to be shown.</p>
203204
</li>
204205
<li>
205-
<p><code>supportedLanguages</code>: an optional array of supported languages.
206+
<p><code class="language-javascript">supportedLanguages</code>: an optional array of supported languages.
206207
The previewer will be available only for those.
207-
Defaults to <code>'*'</code>, which means every languages.</p>
208+
Defaults to <code class="language-javascript">'*'</code>, which means every languages.</p>
208209
</li>
209210
<li>
210-
<p><code>initializer</code>: an optional function.
211+
<p><code class="language-javascript">initializer</code>: an optional function.
211212
This function will be called when the previewer is initialized,
212213
right after the HTML element has been appended to the document body.</p>
213214
</li>

0 commit comments

Comments
 (0)