Code formatting examples: Difference between revisions
m (Craig Calcaterra moved page Formatting Examples to Code Formatting Examples) |
m (→See Also) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 30: | Line 30: | ||
The default is to display only a thumbnail of the image, but you can instead display the image in a larger format. | The default is to display only a thumbnail of the image, but you can instead display the image in a larger format. | ||
[[File:Screenshot 2023-04-04 at 3.17.48 PM.png|alt=Sequence diagram|left| | [[File:Screenshot 2023-04-04 at 3.17.48 PM.png|alt=Sequence diagram|left|frame]] | ||
. | |||
== See Also == | |||
*[[Contributors guide]] | |||
*[[Author style guide]] | |||
*[[Guiding Principles|Guiding principles]] | |||
**[[Guiding principles#Individual code of conduct guidelines|Individual code of conduct]] | |||
**[[Guiding Principles#Group governance code of conduct|Group governance code of conduct]] | |||
* [[Transcendental values|Transcendental Values]] | |||
* [[Ethical Considerations|Ethical considerations]] | |||
*[[Governance Philosophy|Governance philosophy]] |
Latest revision as of 21:02, 6 April 2023
Code[edit | edit source]
In visual editing mode, you can use Insert > Code Block to format and syntax-highlight some code. You may need to click More to expand this menu.
Note that pressing escape while inputting text into the code block may cause you to lose unsaved work.
function add(a, b) {
return a + b;
}
You can also create a link to code housed in GitLab, for example here is a link to the reputation token prototype contract. Such a link can be obtained by navigating to the desired page and copying the URL, or by mousing over the number of a specific line, right-clicking and selecting "Copy Link".
You can copy and paste an excerpt of code into a code block. The syntax must be valid in order to highlight correctly, so note that curly braces for example must be closed. You can use a comment like // ...
to indicate where sections of code were removed.
Enabling line numbers can help make the code easier to read, and to reference in prose.
export class ReputationTokenContract extends ERC721 {
constructor() {
super('Reputation', 'REP');
this.histories = new Map(); // token id --> {increment, context (i.e. validation pool id)}
this.values = new Map(); // token id --> current value
this.locks = new Set(); // {tokenId, amount, start, duration}
}
// ...
}
Note that for referencing named elements of code in prose, such as ReputationTokenContract
, the convention is to use monospace
text. This is available from the formatting menu, in the same section as bold and italics, if you click More to expand that menu.
Screenshots[edit | edit source]
Screenshots can be inserted as images. Here is a screenshot uploaded as an image. In this case we have disabled text wrapping, so the image does not share horizontal space with the text that follows it.
Here is another example, this time with a larger image.
The default is to display only a thumbnail of the image, but you can instead display the image in a larger format.
.