Skip to content

Commit d17c3ee

Browse files
authored
Merge pull request #7466 from processing/interleaved-examples
Interleave example between other docs
2 parents e955799 + 83e7c45 commit d17c3ee

File tree

2 files changed

+33
-22
lines changed

2 files changed

+33
-22
lines changed

src/image/loading_displaying.js

+20-22
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,26 @@ function loadingDisplaying(p5, fn){
854854
* destination image's top left corner. See
855855
* <a href="#/p5/imageMode">imageMode()</a> for other ways to position images.
856856
*
857+
* ```js example
858+
* let img;
859+
*
860+
* // Load the image.
861+
* function preload() {
862+
* img = loadImage('assets/laDefense.jpg');
863+
* }
864+
*
865+
* function setup() {
866+
* createCanvas(100, 100);
867+
*
868+
* background(50);
869+
*
870+
* // Draw the image.
871+
* image(img, 0, 0);
872+
*
873+
* describe('An image of the underside of a white umbrella with a gridded ceiling above.');
874+
* }
875+
* ```
876+
*
857877
* Here's a diagram that explains how optional parameters work in `image()`:
858878
*
859879
* <img src="assets/drawImage.png"></img>
@@ -907,28 +927,6 @@ function loadingDisplaying(p5, fn){
907927
* background(50);
908928
*
909929
* // Draw the image.
910-
* image(img, 0, 0);
911-
*
912-
* describe('An image of the underside of a white umbrella with a gridded ceiling above.');
913-
* }
914-
* </code>
915-
* </div>
916-
*
917-
* <div>
918-
* <code>
919-
* let img;
920-
*
921-
* // Load the image.
922-
* function preload() {
923-
* img = loadImage('assets/laDefense.jpg');
924-
* }
925-
*
926-
* function setup() {
927-
* createCanvas(100, 100);
928-
*
929-
* background(50);
930-
*
931-
* // Draw the image.
932930
* image(img, 10, 10);
933931
*
934932
* describe('An image of the underside of a white umbrella with a gridded ceiling above. The image has dark gray borders on its left and top.');

utils/convert.js

+13
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,19 @@ function descriptionString(node, parent) {
3939
const content = node.children.map(n => descriptionString(n, node)).join('');
4040
if (parent && parent.children.length === 1) return content;
4141
return '<p>' + content + '</p>\n';
42+
} else if (node.type === 'code') {
43+
let classes = [];
44+
let attrs = '';
45+
if (node.lang) {
46+
classes.push(`language-${node.lang}`);
47+
}
48+
if (node.meta) {
49+
classes.push(node.meta);
50+
}
51+
if (classes.length > 0) {
52+
attrs=` class="${classes.join(' ')}"`;
53+
}
54+
return `<pre><code${attrs}>${node.value}</code></pre>`;
4255
} else if (node.type === 'inlineCode') {
4356
return '<code>' + node.value + '</code>';
4457
} else if (node.type === 'list') {

0 commit comments

Comments
 (0)