|
1 | 1 | 'use strict' |
2 | 2 |
|
3 | 3 | const { NodeHtmlMarkdown } = require('node-html-markdown') |
4 | | -const nhm = new NodeHtmlMarkdown() |
| 4 | + |
| 5 | +let nhm |
| 6 | +const customTranslators = { |
| 7 | + DIV: ({ visitor }) => ({ |
| 8 | + surroundingNewlines: 2, |
| 9 | + postprocess: ({ nodeMetadata, node }) => { |
| 10 | + // <div class="admonitionblock note"> |
| 11 | + if (node.classList.contains('admonitionblock')) { |
| 12 | + |
| 13 | + const type = (node |
| 14 | + .classList.values(). |
| 15 | + find(v => v != 'admonitionblock') |
| 16 | + .toUpperCase()) |
| 17 | + |
| 18 | + const content = ( |
| 19 | + nhm.translate( |
| 20 | + node.querySelector('td:nth-child(2)') |
| 21 | + .innerHTML |
| 22 | + ).replace(/^/mg, '> ')) |
| 23 | + |
| 24 | + return `> [!${type}]\n${content}` |
| 25 | + } |
| 26 | + } |
| 27 | + }) |
| 28 | +} |
| 29 | +nhm = new NodeHtmlMarkdown({}, customTranslators) |
5 | 30 |
|
6 | 31 | const File = require('vinyl') |
7 | 32 |
|
@@ -84,13 +109,17 @@ module.exports.register = function ({ playbook, config }) { |
84 | 109 | output+=`# Couchbase |
85 | 110 |
|
86 | 111 | > This is the official documentation for Couchbase, a leading NoSQL distributed database platform |
87 | | -> designed for high performance, scalability, and flexibility. The documentation covers comprehensive |
88 | | -> guides for developers and operations teams, including installation and configuration, development |
89 | | -> tutorials, API references, administration, security, cloud deployment, and integration with various |
90 | | -> programming languages and frameworks. Couchbase enables applications to handle massive data volumes |
91 | | -> and high concurrency with its memory-first architecture and flexible JSON document model.\n\n` |
| 112 | +> designed for high performance, scalability, and flexibility. |
| 113 | +> The documentation covers comprehensive guides for developers and operations |
| 114 | +> teams, including installation and configuration, development tutorials, API |
| 115 | +> references, administration, security, cloud deployment, and integration with |
| 116 | +> various programming languages and frameworks. |
| 117 | +> Couchbase enables applications to handle massive data volumes and high |
| 118 | +> concurrency with its memory-first architecture and flexible JSON document |
| 119 | +> model. |
| 120 | +
|
92 | 121 |
|
93 | | - output+=`\n## Docs\n` |
| 122 | +## Docs\n` |
94 | 123 |
|
95 | 124 | for (const c of navObj) { |
96 | 125 | const v = c.versions[0] |
|
0 commit comments