Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interleave example between other docs #7466

Draft
wants to merge 3 commits into
base: dev-2.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 20 additions & 22 deletions src/image/loading_displaying.js
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,26 @@ function loadingDisplaying(p5, fn){
* destination image's top left corner. See
* <a href="#/p5/imageMode">imageMode()</a> for other ways to position images.
*
* ```js example
* let img;
*
* // Load the image.
* function preload() {
* img = loadImage('assets/laDefense.jpg');
* }
*
* function setup() {
* createCanvas(100, 100);
*
* background(50);
*
* // Draw the image.
* image(img, 0, 0);
*
* describe('An image of the underside of a white umbrella with a gridded ceiling above.');
* }
* ```
*
* Here's a diagram that explains how optional parameters work in `image()`:
*
* <img src="assets/drawImage.png"></img>
Expand Down Expand Up @@ -907,28 +927,6 @@ function loadingDisplaying(p5, fn){
* background(50);
*
* // Draw the image.
* image(img, 0, 0);
*
* describe('An image of the underside of a white umbrella with a gridded ceiling above.');
* }
* </code>
* </div>
*
* <div>
* <code>
* let img;
*
* // Load the image.
* function preload() {
* img = loadImage('assets/laDefense.jpg');
* }
*
* function setup() {
* createCanvas(100, 100);
*
* background(50);
*
* // Draw the image.
* image(img, 10, 10);
*
* 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.');
Expand Down
13 changes: 13 additions & 0 deletions utils/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@ function descriptionString(node, parent) {
const content = node.children.map(n => descriptionString(n, node)).join('');
if (parent && parent.children.length === 1) return content;
return '<p>' + content + '</p>\n';
} else if (node.type === 'code') {
let classes = [];
let attrs = '';
if (node.lang) {
classes.push(`language-${node.lang}`);
}
if (node.meta) {
classes.push(node.meta);
}
if (classes.length > 0) {
attrs=` class="${classes.join(' ')}"`;
}
return `<pre><code${attrs}>${node.value}</code></pre>`;
} else if (node.type === 'inlineCode') {
return '<code>' + node.value + '</code>';
} else if (node.type === 'list') {
Expand Down
Loading