@mgks/docmd 0.3.7 → 0.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +61 -63
- package/bin/docmd.js +13 -16
- package/bin/postinstall.js +4 -4
- package/package.json +12 -10
- package/src/assets/css/docmd-highlight-dark.css +86 -1
- package/src/assets/css/docmd-highlight-light.css +86 -1
- package/src/assets/css/docmd-main.css +544 -464
- package/src/assets/css/docmd-theme-retro.css +105 -106
- package/src/assets/css/docmd-theme-ruby.css +92 -92
- package/src/assets/css/docmd-theme-sky.css +63 -64
- package/src/assets/favicon.ico +0 -0
- package/src/assets/images/docmd-logo-dark.png +0 -0
- package/src/assets/images/docmd-logo-light.png +0 -0
- package/src/assets/js/docmd-image-lightbox.js +2 -2
- package/src/assets/js/docmd-main.js +1 -1
- package/src/assets/js/docmd-mermaid.js +1 -1
- package/src/assets/js/docmd-search.js +1 -1
- package/src/commands/build.js +71 -370
- package/src/commands/dev.js +141 -80
- package/src/commands/init.js +107 -132
- package/src/commands/live.js +145 -0
- package/src/core/asset-manager.js +72 -0
- package/src/core/config-loader.js +2 -2
- package/src/core/config-validator.js +1 -1
- package/src/core/file-processor.js +13 -9
- package/src/core/fs-utils.js +40 -0
- package/src/core/html-formatter.js +97 -0
- package/src/core/html-generator.js +61 -65
- package/src/core/icon-renderer.js +1 -1
- package/src/core/logger.js +1 -1
- package/src/core/markdown/containers.js +1 -1
- package/src/core/markdown/renderers.js +1 -1
- package/src/core/markdown/rules.js +1 -2
- package/src/core/markdown/setup.js +1 -1
- package/src/core/navigation-helper.js +1 -1
- package/src/index.js +12 -0
- package/src/live/core.js +5 -1
- package/src/live/index.html +16 -1
- package/src/live/live.css +157 -68
- package/src/plugins/analytics.js +1 -1
- package/src/plugins/seo.js +26 -36
- package/src/plugins/sitemap.js +2 -2
- package/src/templates/layout.ejs +50 -81
- package/src/templates/navigation.ejs +23 -76
- package/src/templates/no-style.ejs +115 -129
- package/src/templates/partials/theme-init.js +1 -1
- package/src/templates/toc.ejs +6 -35
- package/dist/assets/css/docmd-highlight-dark.css +0 -1
- package/dist/assets/css/docmd-highlight-light.css +0 -1
- package/dist/assets/css/docmd-main.css +0 -1627
- package/dist/assets/css/docmd-theme-retro.css +0 -868
- package/dist/assets/css/docmd-theme-ruby.css +0 -629
- package/dist/assets/css/docmd-theme-sky.css +0 -618
- package/dist/assets/favicon.ico +0 -0
- package/dist/assets/images/docmd-logo-dark.png +0 -0
- package/dist/assets/images/docmd-logo-light.png +0 -0
- package/dist/assets/images/docmd-logo.png +0 -0
- package/dist/assets/js/docmd-image-lightbox.js +0 -74
- package/dist/assets/js/docmd-main.js +0 -222
- package/dist/assets/js/docmd-mermaid.js +0 -205
- package/dist/assets/js/docmd-search.js +0 -218
- package/dist/assets/js/mermaid.min.js +0 -2811
- package/dist/assets/js/minisearch.js +0 -2013
- package/dist/docmd-live.js +0 -30748
- package/dist/index.html +0 -201
- package/dist/live.css +0 -167
- package/docmd.config.js +0 -175
- package/scripts/build-live.js +0 -157
- package/scripts/failsafe.js +0 -37
- package/scripts/test-live.js +0 -54
- package/src/assets/images/docmd-logo.png +0 -0
- package/src/live/templates.js +0 -9
|
@@ -1,180 +1,166 @@
|
|
|
1
|
+
<%# Source file from the docmd project — https://github.com/docmd-io/docmd %>
|
|
2
|
+
|
|
1
3
|
<!DOCTYPE html>
|
|
2
4
|
<html lang="en">
|
|
3
5
|
<head>
|
|
4
6
|
<meta charset="UTF-8">
|
|
5
7
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
-
|
|
7
8
|
<% if (frontmatter.components?.meta !== false) { %>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
<%- metaTagsHtml || '' %>
|
|
10
|
+
<title><%= pageTitle %><% if (frontmatter.components?.siteTitle !== false) { %> : <%= siteTitle %><% } %></title>
|
|
11
|
+
<% if (description && !(metaTagsHtml && metaTagsHtml.includes('name="description"'))) { %>
|
|
12
|
+
<meta name="description" content="<%= description %>">
|
|
13
|
+
<% } %>
|
|
13
14
|
<% } %>
|
|
14
|
-
|
|
15
15
|
<% if (frontmatter.components?.favicon !== false) { %>
|
|
16
|
-
|
|
16
|
+
<%- faviconLinkHtml || '' %>
|
|
17
17
|
<% } %>
|
|
18
|
-
|
|
19
18
|
<% if (frontmatter.components?.themeMode !== false) { %>
|
|
20
|
-
|
|
19
|
+
<script>window.DOCMD_DEFAULT_MODE = "<%= defaultMode %>";</script>
|
|
21
20
|
<% } %>
|
|
22
|
-
|
|
23
21
|
<% if (frontmatter.components?.css !== false) { %>
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
<link rel="stylesheet" href="<%= relativePathToRoot %>assets/css/docmd-main.css">
|
|
23
|
+
<% if (frontmatter.components?.highlight !== false) { %>
|
|
24
|
+
<link rel="stylesheet" href="<%= relativePathToRoot %>assets/css/docmd-highlight-<%= defaultMode === 'dark' ? 'dark' : 'light' %>.css" id="highlight-theme">
|
|
25
|
+
<% } %>
|
|
28
26
|
<% } %>
|
|
29
|
-
|
|
30
27
|
<% if (frontmatter.components?.themeMode !== false) { %>
|
|
31
|
-
|
|
28
|
+
<%- themeInitScript %>
|
|
32
29
|
<% } %>
|
|
33
|
-
|
|
34
30
|
<% if (frontmatter.components?.theme !== false) { %>
|
|
35
|
-
|
|
31
|
+
<%- themeCssLinkHtml || '' %>
|
|
36
32
|
<% } %>
|
|
37
|
-
|
|
38
33
|
<% if (frontmatter.components?.customCss !== false && customCssFiles && customCssFiles.length > 0) { %>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
34
|
+
<% customCssFiles.forEach(cssFile => { %>
|
|
35
|
+
<link rel="stylesheet" href="<%= relativePathToRoot %><%- cssFile.startsWith('/') ? cssFile.substring(1) : cssFile %>">
|
|
36
|
+
<% }); %>
|
|
42
37
|
<% } %>
|
|
43
|
-
|
|
44
38
|
<% if (frontmatter.components?.pluginStyles !== false) { %>
|
|
45
|
-
|
|
39
|
+
<%- pluginStylesHtml || '' %>
|
|
46
40
|
<% } %>
|
|
47
|
-
|
|
48
41
|
<% if (frontmatter.components?.pluginHeadScripts !== false) { %>
|
|
49
|
-
|
|
42
|
+
<%- pluginHeadScriptsHtml || '' %>
|
|
50
43
|
<% } %>
|
|
51
|
-
|
|
52
44
|
<% if (frontmatter.customHead) { %>
|
|
53
|
-
|
|
45
|
+
<%- frontmatter.customHead %>
|
|
54
46
|
<% } %>
|
|
55
47
|
</head>
|
|
56
|
-
<body
|
|
57
|
-
<%
|
|
58
|
-
if (frontmatter.components?.theme !== false) {
|
|
59
|
-
%> data-theme="<%= defaultMode %>"<%
|
|
60
|
-
}
|
|
61
|
-
%><%
|
|
62
|
-
if (frontmatter.bodyClass) {
|
|
63
|
-
%> class="<%= frontmatter.bodyClass %>"<%
|
|
64
|
-
}
|
|
65
|
-
%> data-copy-code-enabled="<%= config.copyCode === true %>">
|
|
48
|
+
<body<% if (frontmatter.components?.theme !== false) { %> data-theme="<%= defaultMode %>"<% } %><% if (frontmatter.bodyClass) { %> class="<%= frontmatter.bodyClass %>"<% } %> data-copy-code-enabled="<%= config.copyCode === true %>">
|
|
66
49
|
<% if (frontmatter.components?.layout === true || frontmatter.components?.layout === 'full') { %>
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
<% } %>
|
|
73
|
-
</header>
|
|
50
|
+
<div class="main-content-wrapper">
|
|
51
|
+
<% if (frontmatter.components?.header !== false) { %>
|
|
52
|
+
<header class="page-header">
|
|
53
|
+
<% if (frontmatter.components?.pageTitle !== false) { %>
|
|
54
|
+
<h1><%= pageTitle %></h1>
|
|
74
55
|
<% } %>
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
56
|
+
</header>
|
|
57
|
+
<% } %>
|
|
58
|
+
<main class="content-area">
|
|
59
|
+
<div class="content-layout">
|
|
60
|
+
<div class="main-content"><%- content %></div>
|
|
61
|
+
<% if (frontmatter.components?.toc !== false && headings && headings.length > 0) { %>
|
|
62
|
+
<div class="toc-sidebar">
|
|
63
|
+
<%- include('toc', { content, headings, navigationHtml, isActivePage }) %>
|
|
80
64
|
</div>
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
</div>
|
|
92
|
-
<% } %>
|
|
93
|
-
</div>
|
|
94
|
-
</footer>
|
|
95
|
-
<% } %>
|
|
96
|
-
</div>
|
|
97
|
-
<% } else if (frontmatter.components?.sidebar === true) { %>
|
|
98
|
-
<aside class="sidebar">
|
|
99
|
-
<% if (frontmatter.components?.logo !== false && logo && logo.light && logo.dark) { %>
|
|
100
|
-
<div class="sidebar-header">
|
|
101
|
-
<a href="<%= logo.href || (relativePathToRoot + 'index.html') %>" class="logo-link">
|
|
102
|
-
<img src="<%= relativePathToRoot %><%- logo.light.startsWith('/') ? logo.light.substring(1) : logo.light %>" alt="<%= logo.alt || siteTitle %>" class="logo-light" <% if (logo.height) { %>style="height: <%= logo.height %>;"<% } %>>
|
|
103
|
-
<img src="<%= relativePathToRoot %><%- logo.dark.startsWith('/') ? logo.dark.substring(1) : logo.dark %>" alt="<%= logo.alt || siteTitle %>" class="logo-dark" <% if (logo.height) { %>style="height: <%= logo.height %>;"<% } %>>
|
|
104
|
-
</a>
|
|
65
|
+
<% } %>
|
|
66
|
+
</div>
|
|
67
|
+
</main>
|
|
68
|
+
<% if (frontmatter.components?.footer !== false) { %>
|
|
69
|
+
<footer class="page-footer">
|
|
70
|
+
<div class="footer-content">
|
|
71
|
+
<div class="user-footer"><%- footerHtml || '' %></div>
|
|
72
|
+
<% if (frontmatter.components?.branding !== false) { %>
|
|
73
|
+
<div class="branding-footer">
|
|
74
|
+
Build with <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z"></path><path d="M12 5 9.04 7.96a2.17 2.17 0 0 0 0 3.08c.82.82 2.13.85 3 .07l2.07-1.9a2.82 2.82 0 0 1 3.79 0l2.96 2.66"></path><path d="m18 15-2-2"></path><path d="m15 18-2-2"></path></svg> <a href="https://docmd.io" target="_blank" rel="noopener">docmd.</a>
|
|
105
75
|
</div>
|
|
76
|
+
<% } %>
|
|
77
|
+
</div>
|
|
78
|
+
</footer>
|
|
79
|
+
<% } %>
|
|
80
|
+
</div>
|
|
81
|
+
<% } else if (frontmatter.components?.sidebar === true) { %>
|
|
82
|
+
<aside class="sidebar">
|
|
83
|
+
<% if (frontmatter.components?.logo !== false && logo && logo.light && logo.dark) { %>
|
|
84
|
+
<div class="sidebar-header">
|
|
85
|
+
<a href="<%= logo.href || (relativePathToRoot + 'index.html') %>" class="logo-link">
|
|
86
|
+
<img src="<%= relativePathToRoot %><%- logo.light.startsWith('/') ? logo.light.substring(1) : logo.light %>" alt="<%= logo.alt || siteTitle %>" class="logo-light" <% if (logo.height) { %>style="height: <%= logo.height %>;"<% } %>>
|
|
87
|
+
<img src="<%= relativePathToRoot %><%- logo.dark.startsWith('/') ? logo.dark.substring(1) : logo.dark %>" alt="<%= logo.alt || siteTitle %>" class="logo-dark" <% if (logo.height) { %>style="height: <%= logo.height %>;"<% } %>>
|
|
88
|
+
</a>
|
|
89
|
+
</div>
|
|
90
|
+
<% } %>
|
|
91
|
+
<% if (frontmatter.components?.navigation !== false) { %>
|
|
92
|
+
<%- navigationHtml %>
|
|
93
|
+
<% } %>
|
|
94
|
+
<% if (frontmatter.components?.themeToggle !== false && theme && theme.enableModeToggle) { %>
|
|
95
|
+
<button id="theme-toggle-button" aria-label="Toggle theme" class="theme-toggle-button">
|
|
96
|
+
<%- renderIcon('sun', { class: 'icon-sun' }) %> <%- renderIcon('moon', { class: 'icon-moon' }) %>
|
|
97
|
+
</button>
|
|
98
|
+
<% } %>
|
|
99
|
+
</aside>
|
|
100
|
+
<div class="main-content-wrapper">
|
|
101
|
+
<% if (frontmatter.components?.header !== false) { %>
|
|
102
|
+
<header class="page-header">
|
|
103
|
+
<% if (frontmatter.components?.pageTitle !== false) { %>
|
|
104
|
+
<h1><%= pageTitle %></h1>
|
|
106
105
|
<% } %>
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
<
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
<% } %>
|
|
116
|
-
</aside>
|
|
117
|
-
<div class="main-content-wrapper">
|
|
118
|
-
<% if (frontmatter.components?.header !== false) { %>
|
|
119
|
-
<header class="page-header">
|
|
120
|
-
<% if (frontmatter.components?.pageTitle !== false) { %>
|
|
121
|
-
<h1><%= pageTitle %></h1>
|
|
122
|
-
<% } %>
|
|
123
|
-
</header>
|
|
124
|
-
<% } %>
|
|
125
|
-
<main class="content-area">
|
|
126
|
-
<div class="content-layout">
|
|
127
|
-
<div class="main-content">
|
|
128
|
-
<%- content %>
|
|
129
|
-
</div>
|
|
130
|
-
<% if (frontmatter.components?.toc !== false && headings && headings.length > 0) { %>
|
|
131
|
-
<div class="toc-sidebar">
|
|
132
|
-
<%- include('toc', { content, headings, navigationHtml, isActivePage }) %>
|
|
133
|
-
</div>
|
|
134
|
-
<% } %>
|
|
106
|
+
</header>
|
|
107
|
+
<% } %>
|
|
108
|
+
<main class="content-area">
|
|
109
|
+
<div class="content-layout">
|
|
110
|
+
<div class="main-content"><%- content %></div>
|
|
111
|
+
<% if (frontmatter.components?.toc !== false && headings && headings.length > 0) { %>
|
|
112
|
+
<div class="toc-sidebar">
|
|
113
|
+
<%- include('toc', { content, headings, navigationHtml, isActivePage }) %>
|
|
135
114
|
</div>
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
115
|
+
<% } %>
|
|
116
|
+
</div>
|
|
117
|
+
</main>
|
|
118
|
+
<% if (frontmatter.components?.footer !== false) { %>
|
|
119
|
+
<footer class="page-footer">
|
|
120
|
+
<div class="footer-content">
|
|
121
|
+
<div class="user-footer"><%- footerHtml || '' %></div>
|
|
122
|
+
<% if (frontmatter.components?.branding !== false) { %>
|
|
123
|
+
<div class="branding-footer">
|
|
124
|
+
Build with <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z"></path><path d="M12 5 9.04 7.96a2.17 2.17 0 0 0 0 3.08c.82.82 2.13.85 3 .07l2.07-1.9a2.82 2.82 0 0 1 3.79 0l2.96 2.66"></path><path d="m18 15-2-2"></path><path d="m15 18-2-2"></path></svg> <a href="https://docmd.io" target="_blank" rel="noopener">docmd.</a>
|
|
125
|
+
</div>
|
|
126
|
+
<% } %>
|
|
127
|
+
</div>
|
|
128
|
+
</footer>
|
|
129
|
+
<% } %>
|
|
130
|
+
</div>
|
|
152
131
|
<% } else { %>
|
|
153
|
-
|
|
132
|
+
<%- content %>
|
|
154
133
|
<% } %>
|
|
155
134
|
|
|
156
135
|
<% if (frontmatter.components?.scripts === true) { %>
|
|
157
136
|
<% if (frontmatter.components?.mainScripts === true) { %>
|
|
158
|
-
|
|
137
|
+
<script>window.DOCMD_ROOT = "<%= relativePathToRoot %>";</script>
|
|
138
|
+
<script src="<%= relativePathToRoot %>assets/js/docmd-main.js"></script>
|
|
159
139
|
<% } %>
|
|
160
140
|
|
|
161
141
|
<% if (frontmatter.components?.lightbox === true && frontmatter.components?.mainScripts === true) { %>
|
|
162
|
-
|
|
142
|
+
<script src="<%= relativePathToRoot %>assets/js/docmd-image-lightbox.js"></script>
|
|
163
143
|
<% } %>
|
|
164
144
|
|
|
145
|
+
<!-- Mermaid & MiniSearch from CDN -->
|
|
146
|
+
<script src="https://cdn.jsdelivr.net/npm/mermaid@11.12.2/dist/mermaid.min.js"></script>
|
|
147
|
+
<script src="<%= relativePathToRoot %>assets/js/docmd-mermaid.js"></script>
|
|
148
|
+
|
|
149
|
+
<script src="https://cdn.jsdelivr.net/npm/minisearch@7.2.0/dist/umd/index.min.js"></script>
|
|
150
|
+
<script src="<%= relativePathToRoot %>assets/js/docmd-search.js"></script>
|
|
151
|
+
|
|
165
152
|
<% if (frontmatter.components?.customJs === true && customJsFiles && customJsFiles.length > 0) { %>
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
153
|
+
<% customJsFiles.forEach(jsFile => { %>
|
|
154
|
+
<script src="<%= relativePathToRoot %><%- jsFile.startsWith('/') ? jsFile.substring(1) : jsFile %>"></script>
|
|
155
|
+
<% }); %>
|
|
169
156
|
<% } %>
|
|
170
157
|
|
|
171
158
|
<% if (frontmatter.components?.pluginBodyScripts === true) { %>
|
|
172
|
-
|
|
159
|
+
<%- pluginBodyScriptsHtml || '' %>
|
|
173
160
|
<% } %>
|
|
174
161
|
<% } %>
|
|
175
|
-
|
|
176
162
|
<% if (frontmatter.customScripts) { %>
|
|
177
|
-
|
|
163
|
+
<%- frontmatter.customScripts %>
|
|
178
164
|
<% } %>
|
|
179
165
|
</body>
|
|
180
|
-
</html>
|
|
166
|
+
</html>
|
package/src/templates/toc.ejs
CHANGED
|
@@ -1,56 +1,28 @@
|
|
|
1
|
-
<%#
|
|
1
|
+
<%# Source file from the docmd project — https://github.com/docmd-io/docmd %>
|
|
2
|
+
|
|
2
3
|
<%
|
|
3
|
-
// Helper function to decode HTML entities
|
|
4
4
|
function decodeHtmlEntities(html) {
|
|
5
|
-
return html
|
|
6
|
-
.replace(/&/g, '&')
|
|
7
|
-
.replace(/</g, '<')
|
|
8
|
-
.replace(/>/g, '>')
|
|
9
|
-
.replace(/"/g, '"')
|
|
10
|
-
.replace(/'/g, "'")
|
|
11
|
-
.replace(/ /g, ' ');
|
|
5
|
+
return html.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, "'").replace(/ /g, ' ');
|
|
12
6
|
}
|
|
13
|
-
|
|
14
|
-
// Use the isActivePage flag if provided, otherwise fall back to checking navigationHtml
|
|
15
7
|
const shouldShowToc = typeof isActivePage !== 'undefined' ? isActivePage :
|
|
16
8
|
(typeof navigationHtml !== 'undefined' && navigationHtml && navigationHtml.includes('class="active"'));
|
|
17
9
|
|
|
18
10
|
if (shouldShowToc && !frontmatter?.toc || frontmatter?.toc !== 'false') {
|
|
19
|
-
// If direct headings aren't available, we'll try to extract them from the content
|
|
20
11
|
let tocHeadings = [];
|
|
21
12
|
if (headings && headings.length > 0) {
|
|
22
|
-
// Use provided headings if available
|
|
23
13
|
tocHeadings = headings.filter(h => h.level >= 2 && h.level <= 4);
|
|
24
14
|
} else if (content) {
|
|
25
|
-
// Basic regex to extract headings from HTML content
|
|
26
15
|
const headingRegex = /<h([2-4])[^>]*?(?:id="([^"]*)")?[^>]*?>([\s\S]*?)<\/h\1>/g;
|
|
27
16
|
let match;
|
|
28
17
|
let contentStr = content.toString();
|
|
29
|
-
|
|
30
18
|
while ((match = headingRegex.exec(contentStr)) !== null) {
|
|
31
19
|
const level = parseInt(match[1], 10);
|
|
32
|
-
// Use ID if available, or generate one from the text
|
|
33
20
|
let id = match[2];
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
// Decode HTML entities
|
|
37
|
-
const text = decodeHtmlEntities(textWithTags);
|
|
38
|
-
|
|
39
|
-
if (!id) {
|
|
40
|
-
// Generate an ID from the heading text if none exists
|
|
41
|
-
id = text
|
|
42
|
-
.toLowerCase()
|
|
43
|
-
.replace(/\s+/g, '-')
|
|
44
|
-
.replace(/[^\w-]/g, '')
|
|
45
|
-
.replace(/--+/g, '-')
|
|
46
|
-
.replace(/^-+|-+$/g, '');
|
|
47
|
-
}
|
|
48
|
-
|
|
21
|
+
const text = decodeHtmlEntities(match[3].replace(/<\/?\w+[^>]*>/g, '')); // Stripped tags
|
|
22
|
+
if (!id) id = text.toLowerCase().replace(/\s+/g, '-').replace(/[^\w-]/g, '').replace(/--+/g, '-').replace(/^-+|-+$/g, '');
|
|
49
23
|
tocHeadings.push({ id, level, text });
|
|
50
24
|
}
|
|
51
25
|
}
|
|
52
|
-
|
|
53
|
-
// Only show TOC if there are enough headings
|
|
54
26
|
if (tocHeadings.length > 1) {
|
|
55
27
|
%>
|
|
56
28
|
<div class="toc-container">
|
|
@@ -63,5 +35,4 @@ if (shouldShowToc && !frontmatter?.toc || frontmatter?.toc !== 'false') {
|
|
|
63
35
|
<% }); %>
|
|
64
36
|
</ul>
|
|
65
37
|
</div>
|
|
66
|
-
<% }
|
|
67
|
-
} %>
|
|
38
|
+
<% } } %>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#abb2bf;background:#282c34}.hljs-comment,.hljs-quote{color:#5c6370;font-style:italic}.hljs-doctag,.hljs-formula,.hljs-keyword{color:#c678dd}.hljs-deletion,.hljs-name,.hljs-section,.hljs-selector-tag,.hljs-subst{color:#e06c75}.hljs-literal{color:#56b6c2}.hljs-addition,.hljs-attribute,.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#98c379}.hljs-attr,.hljs-number,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-pseudo,.hljs-template-variable,.hljs-type,.hljs-variable{color:#d19a66}.hljs-bullet,.hljs-link,.hljs-meta,.hljs-selector-id,.hljs-symbol,.hljs-title{color:#61aeee}.hljs-built_in,.hljs-class .hljs-title,.hljs-title.class_{color:#e6c07b}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}.hljs-link{text-decoration:underline}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#383a42;background:#fafafa}.hljs-comment,.hljs-quote{color:#a0a1a7;font-style:italic}.hljs-doctag,.hljs-formula,.hljs-keyword{color:#a626a4}.hljs-deletion,.hljs-name,.hljs-section,.hljs-selector-tag,.hljs-subst{color:#e45649}.hljs-literal{color:#0184bb}.hljs-addition,.hljs-attribute,.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#50a14f}.hljs-attr,.hljs-number,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-pseudo,.hljs-template-variable,.hljs-type,.hljs-variable{color:#986801}.hljs-bullet,.hljs-link,.hljs-meta,.hljs-selector-id,.hljs-symbol,.hljs-title{color:#4078f2}.hljs-built_in,.hljs-class .hljs-title,.hljs-title.class_{color:#c18401}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}.hljs-link{text-decoration:underline}
|