Rappresentare il Codice
Rappresentare il codice per blocchi
Per rappresentare una o più righe o paragrafi come codice scrivere il seguente codice:
---- righe o paragrafi da rappresentare come codice ----
Quindi per esempio se scriviamo il seguente codice:
---- #!/bin/bash sudo apt-get update sudo apt-get clean sudo apt-get autoclean sudo apt-get autoremove exit ----
Produrremo:
#!/bin/bash sudo apt-get update sudo apt-get clean sudo apt-get autoclean sudo apt-get autoremove exit
Rappresentare il codice con la sintassi colorata
Per rappresentare una o più righe o paragrafi come codice scrivere il seguente codice:
---- .Titolo opzionale (possiamo ometterlo) [source,codice_da_rappresentare] righe o paragrafi da rappresentare come codice ----
Rappresentare codice CSS
Per rappresentare una o più righe di codice CSS scrivere il seguente codice:
.codice CSS da inserire
[source,css]
----
/* unvisited link */
a:link {
color: red;
}
/* visited link */
a:visited {
color: green;
}
/* mouse over link */
a:hover {
color: hotpink;
}
/* selected link */
a:active {
color: blue;
}
----
Produrrà il seguente risultato:
/* unvisited link */
a:link {
color: red;
}
/* visited link */
a:visited {
color: green;
}
/* mouse over link */
a:hover {
color: hotpink;
}
/* selected link */
a:active {
color: blue;
}
Rappresentare codice HTML
Per rappresentare una o più righe di codice HTML scrivere il seguente codice:
.codice html da inserire [source,html] ---- <!-- The text field --> <input type="text" value="Inserisci il testo da copiare" id="myInput"> <!-- The button used to copy the text --> <button onclick="myFunction()">Copia il testo</button> ----
Produrrà il seguente risultato:
<!-- The text field -->
<input type="text" value="Inserisci il testo da copiare" id="myInput">
<!-- The button used to copy the text -->
<button onclick="myFunction()">Copia il testo</button>
Rappresentare codice Javascript
Per rappresentare una o più righe di codice HTML scrivere il seguente codice:
.Inserire codice javascript
[source,javascript]
----
function myFunction() {
/* Get the text field */
var copyText = document.getElementById("myInput");
/* Select the text field */
copyText.select();
/* Copy the text inside the text field */
document.execCommand("copy");
/* Alert the copied text */
alert("Copied the text: " + copyText.value);
}
----
Produrrà il seguente risultato:
function myFunction() {
/* Get the text field */
var copyText = document.getElementById("myInput");
/* Select the text field */
copyText.select();
/* Copy the text inside the text field */
document.execCommand("copy");
/* Alert the copied text */
alert("Copied the text: " + copyText.value);
}
Rappresentare il codice evidenziando il testo
Per rappresentare del codice è possibile usare un blocco di testo è possibile anche mettere la parola o frase tra accenti a sinistra (backtick). Scrivendo il seguente codice:
`blocco di testo rappresentato come codice`
Si otterrà una rappresentazione del codice evidenziando il testo nella riga:
blocco di testo rappresentato come codice evidenziando il testo nella riga