Code
Inline code
Monospace text formatting is typically used to represent text shown in computer terminals
or code editors
(often referred to as a codespan).
Like other inline text formatting, you can add multiple emphasis styles to monospace
text as long as the syntax
is placed
in the correct order
.
Code blocks
Basic code block (console)
A code block with [source,console].
Optional title
A code block with a title.
Language code block
{
"name": "module-name",
"version": "10.0.1",
"description": "An example module to illustrate the usage of package.json",
"author": "Author Name <author@example.com>",
"scripts": {
"test": "mocha",
"lint": "eslint"
}
}
Language code block w/ title
{
"name": "module-name",
"version": "10.0.1",
"description": "An example module to illustrate the usage of package.json",
"author": "Author Name <author@example.com>",
"scripts": {
"test": "mocha",
"lint": "eslint"
}
}
Language code block w/ hidden language
public class CurrentDateTime {
public static void main(String[] args) {
LocalDateTime current = LocalDateTime.now();
System.out.println("Current Date and Time is: " + current);
}
}
// Language code block with no title and hidden language name
public class CurrentDateTime {
public static void main(String[] args) {
LocalDateTime current = LocalDateTime.now();
System.out.println("Current Date and Time is: " + current);
}
}
Line wrapping
Line wrapping is turned off by default
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Code block w/ forced wrapping
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Callouts
vfs
.src('js/vendor/*.js', { cwd: 'src', cwdbase: true, read: false })
.pipe(tap((file) => { (1)
file.contents = browserify(file.relative, { basedir: 'src', detectGlobals: false }).bundle()
}))
.pipe(buffer()) (2)
.pipe(uglify())
.pipe(gulp.dest('build'))
1 | The tap function is used to wiretap the data in the pipe. |
2 | Wrap each streaming file in a buffer so the files can be processed by uglify. Uglify can only work with buffers, not streams. |
Listing and literal blocks
Listing blocks and literal blocks display the text you write exactly as you see it in the source. Literal text is treated as preformatted text. The text is presented in a fixed-width font and endlines are preserved. Only special characters and callouts are replaced when the document is converted. The only meaningful difference between a listing block and a literal block is that you can turn a listing block into a code block and apply syntax highlighting. |