-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.html
62 lines (62 loc) · 2.88 KB
/
example.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Example for the showsource library</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/default.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/highlight.min.js"></script>
<style>
html, body {
padding: 20px;
}
.example {
border: 1px solid #ccc;
padding: 20px;
margin-bottom: 20px;
}
</style>
</head>
<body>
<h1>Example for the showsource library</h1>
<p>The purpose for this library es to extract the code from a existing portion of a web page to show it as a new part in the web page.</p>
<p>(*) The origin of the library is to ease the creation of examples of existing libraries.</p>
<div class="example" data-showsource>
<h2>Simple example</h2>
<p><span class="fw-bold">hint:</span> add the <span class="fw-bold">data-showsource</span> attribute to the element that we want to extract the html content and to add the result after it.</p>
<div class="d-flex">
<img src="https://picsum.photos/400/200" class="mx-auto">
</div>
</div>
<div class="example" data-showsource data-showsource-hide-plugin="false" data-showsource-remove="" data-showsource-max-attributes-per-line="2">
<h2>Extended simple example</h2>
<p>This is almost the same example than before, but we are overridding some default options.
<ul>
<li>We want to show the data attributes related to this plugin, so we added <span class="fw-bold">data-showsource-no-hide-plugin</span>.</li>
</ul>
</p>
<div class="d-flex">
<img src="https://picsum.photos/400/200" class="mx-auto">
</div>
</div>
<div class="example" data-showsource data-showsource-skip-selector="h1,h2,h3,h4,h5,p">
<h2>Enhancing readability</h2>
<p><span class="fw-bold">hint:</span> to improve readability of some examples, add <span class="fw-bold">data-showsource-skip-selector="h1,h2,h3,h4,h5,p"</span> to remove titles and paragraphs.</p>
<div class="d-flex">
<img src="https://picsum.photos/400/200" class="mx-auto">
</div>
</div>
</body>
<script src="js/showsource.js"></script>
<script>
showsource.defaults.maxAttributesPerLine = 1;
console.log(showsource.defaults);
if (document.addEventListener) {
document.addEventListener("DOMContentLoaded", function() {
hljs.highlightAll();
});
}
</script>
</html>