The code component

Displays one or many blocks of code from a programming language or formated text as XML or JSON.

Introduced in SQLPage v0.19.0.

Top-level parameters

class

class attribute added to the container in HTML. It can be used to apply custom styling to this item through css. Added in v0.18.0.

id

id attribute added to the container in HTML. It can be used to target this item through css or for scrolling to this item through links (use "#id" in link url).

Row-level parameters

contents

REQUIRED. A block of code.

description

Description of the snipet of code.

description_md

Rich text in the markdown format. Among others, this allows you to write bold text using **bold**, italics using *italics*, and links using [text](https://example.com).

language

Set the programming language name.

title

Set the heading level (default level is 1)

Example 1

Displays a block of HTML code.

select 
    'code' as component;
select 
    'A HTML5 example' as title,
    'html'            as language,
    'Here’s the very minimum that an HTML document should contain, assuming it has CSS and JavaScript linked to it.' as description,
    '<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8">
		<title>title</title>
		<link rel="stylesheet" href="style.css">
		<script src="script.js"></script>
	</head>
	<body>
		<!-- page content -->
	</body>
</html>' as contents;

Result

A HTML5 example

Here’s the very minimum that an HTML document should contain, assuming it has CSS and JavaScript linked to it.

<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8">
		<title>title</title>
		<link rel="stylesheet" href="style.css">
		<script src="script.js"></script>
	</head>
	<body>
		<!-- page content -->
	</body>
</html>

See also: other components