Editing
Code formatting examples
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Code === 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.<syntaxhighlight lang="javascript" line="1"> function add(a, b) { return a + b; } </syntaxhighlight>You can also create a link to code housed in GitLab, for example here is a link to the [https://gitlab.com/dao-governance-framework/science-publishing-dao/-/blob/main/forum-network/src/classes/reputation/reputation-token.js#L14 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 <code>// ...</code> to indicate where sections of code were removed. Enabling line numbers can help make the code easier to read, and to reference in prose.<syntaxhighlight lang="javascript" line="1"> 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} } // ... } </syntaxhighlight>Note that for referencing named elements of code in prose, such as <code>ReputationTokenContract</code>, the convention is to use <code>monospace</code> text. This is available from the formatting menu, in the same section as bold and italics, if you click More to expand that menu.
Summary:
Please note that all contributions to DAO Governance Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
DAO Governance Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
Edit source
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information