diff --git a/README.md b/README.md index 6657c0a..e514968 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ A TOC will be generated exactly on this place for the following headers. var toc = require('toc-md'); ``` -Provides the only function which inserts a TOC to a given source: +#### toc.insert **@param** *{String}* - a source where to insert a TOC (must contain the HTML comment ``)
**@param** *{Object}* - options:
@@ -31,6 +31,11 @@ Provides the only function which inserts a TOC to a given source: **@param** *{Function}* - callback +#### toc.clean + +**@param** *{String}* - a source whereof to clean a TOC
+**@param** *{Function}* - callback + #### Example ```js @@ -43,13 +48,23 @@ var options = { maxDepth: 6 }; -toc(source, options, function (err, res) { +toc.insert(source, options, function (err, res) { if (err) { console.log(err); } else { fs.writeFileSync('markdown-with-toc.md', res); } }); + +source = fs.readFileSync('markdown-with-toc.md', 'utf-8'); + +toc.clean(source, function (err, res) { + if (err) { + console.log(err); + } else { + fs.writeFileSync('markdown-without-toc.md', res); + } +}); ``` ### CLI @@ -65,18 +80,29 @@ Options: -h, --help : Help -v, --version : Shows the version number -m MAXDEPTH, --max-depth=MAXDEPTH : Uses headings whose depth is at most the specified value (default: 6) + -c, --clean : Cleans a TOC Arguments: SOURCE : Path to an input markdown file (it must contain the HTML comment ) (required) TARGET : Path to an output markdown file ``` -If argument `TARGET` is not specified, a TOC will be added to `SOURCE`. +If argument `TARGET` is not specified, a result will be written to `SOURCE`. #### Example +##### Insert + ```bash $ toc-md path/to/input/markdown path/to/output/markdown --max-depth=4 $ toc-md path/to/markdown -m 4 ``` + +##### Clean + +```bash +$ toc-md path/to/input/markdown path/to/output/markdown --clean + +$ toc-md path/to/markdown -c +``` diff --git a/README.ru.md b/README.ru.md index 758d01f..3667575 100644 --- a/README.ru.md +++ b/README.ru.md @@ -22,7 +22,7 @@ $ npm install toc-md var toc = require('toc-md'); ``` -Предоставляет единственную функцию, которая добавляет оглавление исходному тексту: +#### toc.insert **@param** *{String}* - исходный текст, в который необходимо добавить оглавление (обязательно должен содержать HTML-комментарий ``)
**@param** *{Object}* - опции:
@@ -31,6 +31,11 @@ var toc = require('toc-md'); **@param** *{Function}* - callback +#### toc.clean + +**@param** *{String}* - исходный текст, который необходимо очистить от оглавления
+**@param** *{Function}* - callback + #### Пример ```js @@ -43,13 +48,23 @@ var options = { maxDepth: 6 }; -toc(source, options, function (err, res) { +toc.insert(source, options, function (err, res) { if (err) { console.log(err); } else { fs.writeFileSync('markdown-с-оглавлением.md', res); } }); + +source = fs.readFileSync('markdown-с-оглавлением.md', 'utf-8'); + +toc.clean(source, function (err, res) { + if (err) { + console.log(err); + } else { + fs.writeFileSync('markdown-без-оглавления.md', res); + } +}); ``` ### CLI @@ -65,19 +80,29 @@ $ toc-md --help -h, --help : Помощь -v, --version : Показывает номер версии -m MAXDEPTH, --max-depth=MAXDEPTH : Использует заголовки, вложенность которых не больше указанного значения (по умолчанию: 6) + -c, --clean : Очищает оглавление Arguments: SOURCE : Путь к входному markdown-файлу (он должен содержать HTML-комментарий ) (обязательный аргумент) TARGET : Путь к выходному markdown-файлу ``` -Если аргумент `TARGET` не указан, то содержание будет добавлено в `SOURCE`. +Если аргумент `TARGET` не указан, то результат будет записан в `SOURCE`. - #### Пример +##### Добавление оглавления + ```bash $ toc-md путь/к/входному/markdown-файлу путь/к/выходному/markdown-файлу --max-depth=4 $ toc-md путь/к/markdown-файлу -m 4 ``` + +##### Очистка оглавления + +```bash +$ toc-md путь/к/входному/markdown-файлу путь/к/выходному/markdown-файлу --clean + +$ toc-md путь/к/markdown-файлу -c +```