├── .github └── FUNDING.yml ├── .gitignore ├── .travis.yml ├── 1.png ├── LICENSE ├── README.md ├── assets └── style.css ├── lib ├── entity.js ├── fn.js └── index.js ├── package.json └── test └── index.js /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | patreon: aleen42 3 | custom: ["http://paypal.me/aleen42", "https://www.buymeacoffee.com/aleen42"] 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | 11 | # Directory for instrumented libs generated by jscoverage/JSCover 12 | lib-cov 13 | 14 | # Coverage directory used by tools like istanbul 15 | coverage 16 | 17 | # nyc test coverage 18 | .nyc_output 19 | 20 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 21 | .grunt 22 | 23 | # node-waf configuration 24 | .lock-wscript 25 | 26 | # Compiled binary addons (http://nodejs.org/api/addons.html) 27 | build/Release 28 | 29 | # Dependency directories 30 | node_modules 31 | jspm_packages 32 | 33 | # Optional npm cache directory 34 | .npm 35 | 36 | # Optional REPL history 37 | .node_repl_history 38 | 39 | # IDEA 40 | .idea 41 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "13" 4 | script: npm test 5 | os: 6 | - linux 7 | -------------------------------------------------------------------------------- /1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aleen42/gitbook-treeview/028043c83f160b89e6e176819d5572d70ccfed4f/1.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Aleen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## page-treeview 2 | 3 |   [](#) [](https://github.com/aleen42/gitbook-treeview/issues) [](https://raw.githubusercontent.com/aleen42/gitbook-treeview/master/LICENSE) [](https://gitter.im/aleen42/gitbook-treeview?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) 4 | 5 | [](https://www.npmjs.com/package/gitbook-plugin-page-treeview) [](https://travis-ci.org/aleen42/gitbook-treeview) [](https://david-dm.org/aleen42/gitbook-treeview#info=devDependencies) [](https://www.npmjs.com/package/gitbook-plugin-page-treeview) 6 | 7 | a gitbook-plugin for generating a "Treeview" for each page. 8 | 9 |  10 | 11 | ### Installation 12 | 13 | add the following plugins to your `book.json` and run `gitbook install` 14 | 15 | ```json 16 | { 17 | "plugins": ["page-treeview"] 18 | } 19 | ``` 20 | 21 | ### Usage 22 | 23 | just find plugin on gitbook and install it on your gitbook project. 24 | 25 | configuration option can be set as an obj like, and of course you can use a default value shown as followed: 26 | 27 | ```json 28 | { 29 | "plugins": [ 30 | "page-treeview" 31 | ], 32 | "pluginsConfig": { 33 | "page-treeview": { 34 | "copyright": "Copyright © aleen42", 35 | "minHeaderCount": "2", 36 | "minHeaderDeep": "2" 37 | } 38 | } 39 | } 40 | ``` 41 | 42 | ### What Treeview looks like in Markdown? 43 | 44 | Treeview will only generate treeviews for headers between level 1 and 6. Here I'll list some cases with different structure (each number means the level a head tag, like 1 for <h1>): 45 | 46 | ##### 1-1-2-3-4-1 47 | 48 | - 1 49 | - 1 50 | - 2 51 | - 3 52 | - 4 53 | - 1 54 | 55 | ##### 3-4-2-3-4-5-1-2-3 56 | 57 | - 58 | - 59 | - 3 60 | - 4 61 | - 2 62 | - 3 63 | - 4 64 | - 5 65 | - 1 66 | - 2 67 | - 3 68 | 69 | 70 | 71 | 72 | 73 | ##### 1-2-3-1-3-4-5-1-2 74 | 75 | - 1 76 | - 2 77 | - 3 78 | - 1 79 | - 80 | - 3 81 | - 4 82 | - 5 83 | - 1 84 | - 2 85 | 86 | ### Tests 87 | 88 | ```bash 89 | npm test 90 | ``` 91 | 92 | ### Release History 93 | 94 | * ==================== **1.0.0 Initial release** ==================== 95 | * 1.5.7 release version 96 | * 1.5.8 fix bugs 97 | * 1.5.9 fix bugs of chinese 98 | * 1.6.1 fix bugs of text indent in markdown style 99 | * 1.6.9 fix bugs 100 | * 1.8.0 fix bugs 101 | * 1.8.3 fix bugs 102 | * ==================== **2.0.0 Style release** ==================== 103 | * 2.0.1 update style 104 | * 2.0.2 update style 105 | * 2.0.5 update style 106 | * 2.0.6 update style 107 | * 2.0.7 update readme 108 | * 2.1.3 fix bugs 109 | * 2.2.1 fix bugs 110 | * 2.2.2 fix bugs 111 | * 2.3.0 fix bugs 112 | * 2.3.4 fix bugs 113 | * 2.3.5 fix bugs 114 | * 2.3.7 fix bugs 115 | * 2.3.8 update readme 116 | * 2.4.0 update configuration 117 | * 2.4.1 restrict reading book 118 | * 2.4.3 fix bugs 119 | * 2.4.4 fix bugs 120 | * 2.4.5 update readme 121 | * 2.4.9 fix bugs 122 | * 2.5.0 update readme 123 | * 2.5.8 enhancement for issue [#2](https://github.com/aleen42/gitbook-treeview/issues/2) 124 | * 2.5.9 update default value 125 | * 2.6.1 fix bugs 126 | * 2.6.5 fix bugs 127 | * 2.6.7 fix bugs 128 | * 2.6.8 update readme 129 | * 2.6.9 update readme 130 | * 2.7.2 fix bugs 131 | * 2.7.3 update readme 132 | * 2.7.4 disable console 133 | * 2.7.7 fix bugs 134 | * 2.9.5 featuring collapsible lists 135 | * 2.9.6 update readme 136 | * 2.9.7 fix bugs 137 | * 2.9.8 fix the bug of stripping list leader when removing markdown of titles 138 | * ==================== **3.0.0 Refactor release** ==================== 139 | * 3.0.1 fix the bug when calculating headers' level 140 | * 3.0.2 support collapsed option (`false` by default) [#8](https://github.com/aleen42/gitbook-treeview/issues/8) 141 | * 3.0.3 use [marked](https://github.com/markedjs/marked) to convert markdown into plain text 142 | * 3.0.6 use gitbook-color to support light or dark theme 143 | 144 | ### :fuelpump: How to contribute 145 | 146 | Have an idea? Found a bug? See [how to contribute](https://aleen42.gitbooks.io/personalwiki/content/contribution.html). 147 | 148 | ### :scroll: License 149 | 150 | [MIT](https://aleen42.gitbooks.io/personalwiki/content/MIT.html) © aleen42 151 | 152 | *Note: if you like this project, feel free to buy me a swimming chance:* 153 | 154 | [](http://paypal.me/aleen42) [](https://www.patreon.com/aleen42) [](https://www.buymeacoffee.com/aleen42) 155 | -------------------------------------------------------------------------------- /assets/style.css: -------------------------------------------------------------------------------- 1 | .level__item { 2 | display: inline-block; 3 | } 4 | 5 | .level__parent::after { 6 | content: ""; 7 | width: 0; 8 | height: 0; 9 | border: 5px solid transparent; 10 | display: inline-block; 11 | margin-left: 0.5em; 12 | vertical-align: middle; 13 | cursor: pointer; 14 | } 15 | 16 | .level__parent--hidden::after { 17 | border-top: 5px solid var(--color-text-primary, #24292f); 18 | margin-top: 5px; 19 | } 20 | 21 | .level__parent--opened::after { 22 | border-bottom: 5px solid var(--color-text-primary, #24292f); 23 | margin-bottom: 5px; 24 | } 25 | 26 | .content { 27 | vertical-align: middle; 28 | } 29 | 30 | /** 31 | * treeview container 32 | */ 33 | 34 | .treeview__container { 35 | position: relative; 36 | margin-bottom: 80px; 37 | padding-bottom: 20px; 38 | } 39 | 40 | .treeview__container-title { 41 | position: absolute; 42 | right: 0; 43 | bottom: -35px; 44 | /* depends on: gitbook-plugin-color */ 45 | border-bottom: 1px solid var(--color-book-border, rgba(255, 255, 255, 0.2)); 46 | } 47 | 48 | .treeview__main-title { 49 | font-size: 20px; 50 | } 51 | 52 | .treeview__copyright { 53 | margin-left: 5px; 54 | color: #cdcdcd; 55 | font-size: 10px; 56 | } 57 | 58 | @media (max-width: 720px) { 59 | .treeview__copyright { 60 | display: none; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /lib/entity.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 34: 'quot', 3 | 38: 'amp', 4 | 39: 'apos', 5 | 60: 'lt', 6 | 62: 'gt', 7 | 160: 'nbsp', 8 | 161: 'iexcl', 9 | 162: 'cent', 10 | 163: 'pound', 11 | 164: 'curren', 12 | 165: 'yen', 13 | 166: 'brvbar', 14 | 167: 'sect', 15 | 168: 'uml', 16 | 169: 'copy', 17 | 170: 'ordf', 18 | 171: 'laquo', 19 | 172: 'not', 20 | 173: 'shy', 21 | 174: 'reg', 22 | 175: 'macr', 23 | 176: 'deg', 24 | 177: 'plusmn', 25 | 178: 'sup2', 26 | 179: 'sup3', 27 | 180: 'acute', 28 | 181: 'micro', 29 | 182: 'para', 30 | 183: 'middot', 31 | 184: 'cedil', 32 | 185: 'sup1', 33 | 186: 'ordm', 34 | 187: 'raquo', 35 | 188: 'frac14', 36 | 189: 'frac12', 37 | 190: 'frac34', 38 | 191: 'iquest', 39 | 192: 'Agrave', 40 | 193: 'Aacute', 41 | 194: 'Acirc', 42 | 195: 'Atilde', 43 | 196: 'Auml', 44 | 197: 'Aring', 45 | 198: 'AElig', 46 | 199: 'Ccedil', 47 | 200: 'Egrave', 48 | 201: 'Eacute', 49 | 202: 'Ecirc', 50 | 203: 'Euml', 51 | 204: 'Igrave', 52 | 205: 'Iacute', 53 | 206: 'Icirc', 54 | 207: 'Iuml', 55 | 208: 'ETH', 56 | 209: 'Ntilde', 57 | 210: 'Ograve', 58 | 211: 'Oacute', 59 | 212: 'Ocirc', 60 | 213: 'Otilde', 61 | 214: 'Ouml', 62 | 215: 'times', 63 | 216: 'Oslash', 64 | 217: 'Ugrave', 65 | 218: 'Uacute', 66 | 219: 'Ucirc', 67 | 220: 'Uuml', 68 | 221: 'Yacute', 69 | 222: 'THORN', 70 | 223: 'szlig', 71 | 224: 'agrave', 72 | 225: 'aacute', 73 | 226: 'acirc', 74 | 227: 'atilde', 75 | 228: 'auml', 76 | 229: 'aring', 77 | 230: 'aelig', 78 | 231: 'ccedil', 79 | 232: 'egrave', 80 | 233: 'eacute', 81 | 234: 'ecirc', 82 | 235: 'euml', 83 | 236: 'igrave', 84 | 237: 'iacute', 85 | 238: 'icirc', 86 | 239: 'iuml', 87 | 240: 'eth', 88 | 241: 'ntilde', 89 | 242: 'ograve', 90 | 243: 'oacute', 91 | 244: 'ocirc', 92 | 245: 'otilde', 93 | 246: 'ouml', 94 | 247: 'divide', 95 | 248: 'oslash', 96 | 249: 'ugrave', 97 | 250: 'uacute', 98 | 251: 'ucirc', 99 | 252: 'uuml', 100 | 253: 'yacute', 101 | 254: 'thorn', 102 | 255: 'yuml', 103 | 402: 'fnof', 104 | 913: 'Alpha', 105 | 914: 'Beta', 106 | 915: 'Gamma', 107 | 916: 'Delta', 108 | 917: 'Epsilon', 109 | 918: 'Zeta', 110 | 919: 'Eta', 111 | 920: 'Theta', 112 | 921: 'Iota', 113 | 922: 'Kappa', 114 | 923: 'Lambda', 115 | 924: 'Mu', 116 | 925: 'Nu', 117 | 926: 'Xi', 118 | 927: 'Omicron', 119 | 928: 'Pi', 120 | 929: 'Rho', 121 | 931: 'Sigma', 122 | 932: 'Tau', 123 | 933: 'Upsilon', 124 | 934: 'Phi', 125 | 935: 'Chi', 126 | 936: 'Psi', 127 | 937: 'Omega', 128 | 945: 'alpha', 129 | 946: 'beta', 130 | 947: 'gamma', 131 | 948: 'delta', 132 | 949: 'epsilon', 133 | 950: 'zeta', 134 | 951: 'eta', 135 | 952: 'theta', 136 | 953: 'iota', 137 | 954: 'kappa', 138 | 955: 'lambda', 139 | 956: 'mu', 140 | 957: 'nu', 141 | 958: 'xi', 142 | 959: 'omicron', 143 | 960: 'pi', 144 | 961: 'rho', 145 | 962: 'sigmaf', 146 | 963: 'sigma', 147 | 964: 'tau', 148 | 965: 'upsilon', 149 | 966: 'phi', 150 | 967: 'chi', 151 | 968: 'psi', 152 | 969: 'omega', 153 | 977: 'thetasym', 154 | 978: 'upsih', 155 | 982: 'piv', 156 | 8226: 'bull', 157 | 8230: 'hellip', 158 | 8242: 'prime', 159 | 8243: 'Prime', 160 | 8254: 'oline', 161 | 8260: 'frasl', 162 | 8472: 'weierp', 163 | 8465: 'image', 164 | 8476: 'real', 165 | 8482: 'trade', 166 | 8501: 'alefsym', 167 | 8592: 'larr', 168 | 8593: 'uarr', 169 | 8594: 'rarr', 170 | 8595: 'darr', 171 | 8596: 'harr', 172 | 8629: 'crarr', 173 | 8656: 'lArr', 174 | 8657: 'uArr', 175 | 8658: 'rArr', 176 | 8659: 'dArr', 177 | 8660: 'hArr', 178 | 8704: 'forall', 179 | 8706: 'part', 180 | 8707: 'exist', 181 | 8709: 'empty', 182 | 8711: 'nabla', 183 | 8712: 'isin', 184 | 8713: 'notin', 185 | 8715: 'ni', 186 | 8719: 'prod', 187 | 8721: 'sum', 188 | 8722: 'minus', 189 | 8727: 'lowast', 190 | 8730: 'radic', 191 | 8733: 'prop', 192 | 8734: 'infin', 193 | 8736: 'ang', 194 | 8743: 'and', 195 | 8744: 'or', 196 | 8745: 'cap', 197 | 8746: 'cup', 198 | 8747: 'int', 199 | 8756: 'there4', 200 | 8764: 'sim', 201 | 8773: 'cong', 202 | 8776: 'asymp', 203 | 8800: 'ne', 204 | 8801: 'equiv', 205 | 8804: 'le', 206 | 8805: 'ge', 207 | 8834: 'sub', 208 | 8835: 'sup', 209 | 8836: 'nsub', 210 | 8838: 'sube', 211 | 8839: 'supe', 212 | 8853: 'oplus', 213 | 8855: 'otimes', 214 | 8869: 'perp', 215 | 8901: 'sdot', 216 | 8968: 'lceil', 217 | 8969: 'rceil', 218 | 8970: 'lfloor', 219 | 8971: 'rfloor', 220 | 9001: 'lang', 221 | 9002: 'rang', 222 | 9674: 'loz', 223 | 9824: 'spades', 224 | 9827: 'clubs', 225 | 9829: 'hearts', 226 | 9830: 'diams', 227 | 338: 'OElig', 228 | 339: 'oelig', 229 | 352: 'Scaron', 230 | 353: 'scaron', 231 | 376: 'Yuml', 232 | 710: 'circ', 233 | 732: 'tilde', 234 | 8194: 'ensp', 235 | 8195: 'emsp', 236 | 8201: 'thinsp', 237 | 8204: 'zwnj', 238 | 8205: 'zwj', 239 | 8206: 'lrm', 240 | 8207: 'rlm', 241 | 8211: 'ndash', 242 | 8212: 'mdash', 243 | 8216: 'lsquo', 244 | 8217: 'rsquo', 245 | 8218: 'sbquo', 246 | 8220: 'ldquo', 247 | 8221: 'rdquo', 248 | 8222: 'bdquo', 249 | 8224: 'dagger', 250 | 8225: 'Dagger', 251 | 8240: 'permil', 252 | 8249: 'lsaquo', 253 | 8250: 'rsaquo', 254 | 8364: 'euro', 255 | }; 256 | -------------------------------------------------------------------------------- /lib/fn.js: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * _ 3 | * _____ _ ____ _ |_| 4 | * | _ |/ \ ____ ____ __ ___ / ___\/ \ __ _ ____ _ 5 | * | |_| || | / __ \/ __ \\ '_ \ _ / / | |___\ \ | |/ __ \| | 6 | * | _ || |__. ___/. ___/| | | ||_|\ \___ | _ | |_| |. ___/| | 7 | * |_/ \_|\___/\____|\____||_| |_| \____/|_| |_|_____|\____||_| 8 | * 9 | * ================================================================ 10 | * More than a coder, More than a designer 11 | * ================================================================ 12 | * 13 | * 14 | * - Document: fn.js 15 | * - Author: aleen42 16 | * - Description: base library 17 | * - Create Time: Feb 12nd, 2019 18 | * - Update Time: Feb 12nd, 2019 19 | * 20 | * 21 | **********************************************************************/ 22 | 23 | const isNullity = x => x == null; 24 | const TAG_NULL = []; 25 | const TAG_ARRAY = []; 26 | const TAG_OBJECT = ['[object Object]']; 27 | const TAG_STRING = ['[object String]']; 28 | const TAG_NUMBER = ['[object Number]']; 29 | // https://stackoverflow.com/questions/7656280/how-do-i-check-whether-an-object-is-an-arguments-object-in-javascript/7656333#7656333 30 | const TAG_ARGUMENTS = ['[object Arguments]']; 31 | const TAG_FUNCTION = ['[object Function]']; 32 | const tags = {}; 33 | [TAG_OBJECT, TAG_STRING, TAG_NUMBER, TAG_ARGUMENTS, TAG_FUNCTION].map(tag => { tags[tag[0]] = tag }); 34 | const getTag = x => isNullity(x) ? TAG_NULL : Array.isArray(x) ? TAG_ARRAY : tags[({}).toString.call(x)]; 35 | const is = TAG => x => getTag(x) === TAG; 36 | 37 | /** 38 | * [replaceAll: replace all match sub-string in a string] 39 | * @param {string} search [description] 40 | * @param {string} replacement [description] 41 | * @return {string} [description] 42 | */ 43 | String.prototype.replaceAll = function (search, replacement) { 44 | return this.split(search).join(replacement); 45 | }; 46 | 47 | /** 48 | * [leftTrim: trim left space] 49 | * @return {string} [description] 50 | */ 51 | String.prototype.leftTrim = function () { 52 | return this.replace(/^\s+/, ''); 53 | }; 54 | 55 | module.exports = { 56 | isOBJ: is(TAG_OBJECT), 57 | isSTR: is(TAG_STRING), 58 | isNUM: is(TAG_NUMBER), 59 | isFUN: is(TAG_FUNCTION), 60 | 61 | /** 62 | * [E2A: HTML entities to Ascii] 63 | * @param {string} str [description] 64 | * @returns {void | string | *} 65 | */ 66 | E2A: str => str.replace(/&([\S]+?);/g, value => { 67 | value = value.replace('&', ''); 68 | value = value.replace(';', ''); 69 | 70 | /** get the first key of a specific value */ 71 | const entity = Object.entries(require('./entity')).find(([, val]) => val === value); 72 | return !entity ? null : String.fromCharCode(entity[0]); 73 | }), 74 | 75 | /** 76 | * [A2U: convert ascii to unicode] 77 | * @param {string} str [description] 78 | * @returns {string} 79 | * @constructor 80 | */ 81 | A2U: str => str.split('').map(ch => `${ch.charCodeAt(0)};`).join(''), 82 | }; 83 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * _ 3 | * _____ _ ____ _ |_| 4 | * | _ |/ \ ____ ____ __ ___ / ___\/ \ __ _ ____ _ 5 | * | |_| || | / __ \/ __ \\ '_ \ _ / / | |___\ \ | |/ __ \| | 6 | * | _ || |__. ___/. ___/| | | ||_|\ \___ | _ | |_| |. ___/| | 7 | * |_/ \_|\___/\____|\____||_| |_| \____/|_| |_|_____|\____||_| 8 | * 9 | * ================================================================ 10 | * More than a coder, More than a designer 11 | * ================================================================ 12 | * 13 | * 14 | * - Document: index.js 15 | * - Author: aleen42 16 | * - Description: the main entrance for page-treeview 17 | * - Create Time: Apr 11st, 2016 18 | * - Update Time: Feb 12nd, 2019 19 | * 20 | * 21 | **********************************************************************/ 22 | 23 | const _ = require('./fn'); 24 | 25 | /** 26 | * [removeMarkdown: convert markdown into plain text] 27 | * @type {Function} 28 | */ 29 | const blockFn = x => `${x}\n`; 30 | const identity = x => x; 31 | const newlineFn = () => '\n'; 32 | const emptyFn = () => ''; 33 | 34 | const RemoveMarkdown = markdown => require('marked')(markdown, { 35 | gfm: true, 36 | pedantic: false, 37 | renderer: { 38 | // Block elements 39 | code: blockFn, 40 | blockquote: blockFn, 41 | html: emptyFn, 42 | heading: blockFn, 43 | hr: emptyFn, 44 | list: (body, ordered, start) => `${start}. ${blockFn(body)}`, // ignore list header 45 | listitem: text => blockFn(text), 46 | paragraph: blockFn, 47 | table: (header, body) => blockFn(header) + blockFn(body), 48 | tablerow: blockFn, 49 | tablecell: blockFn, 50 | // Inline elements 51 | strong: identity, 52 | em: identity, 53 | codespan: identity, 54 | br: newlineFn, 55 | del: identity, 56 | link: (_0, _1, text) => identity(text), 57 | image: (_0, _2, text) => identity(text), 58 | text: identity, 59 | }, 60 | }).trim(); 61 | 62 | /** 63 | * [remarkable: convert markdown into a html] 64 | * @type {Class} 65 | */ 66 | const Remarkable = require('remarkable'); 67 | 68 | /** 69 | * [generateContent: method for generating whole content] 70 | * @param {Object} configs [page configurations] 71 | * @param {string} [content] [page contents] 72 | * @return {string} [description] 73 | */ 74 | const generateContent = (configs, content = '') => { 75 | /** 76 | * [options: options for generating] 77 | * @type {Object} 78 | */ 79 | const options = Object.assign({ 80 | 'copyright': 'Copyright © aleen42', 81 | 'minHeaderCount': '1', 82 | 'minHeaderDeep': '1', 83 | 'collapsed': false, 84 | }, configs || {}); 85 | 86 | const renderContent = pageTreeview.initHeaders(content, options); 87 | 88 | /** check whether the option copyright is empty */ 89 | const copyRight = options.copyright ? (` 90 |