links-notation 0.21.2 → 0.22.0

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/README.md CHANGED
@@ -85,7 +85,7 @@ import { Parser, Link, FormatOptions } from 'links-notation';
85
85
  // TypeScript provides full type checking and autocomplete
86
86
  const parser = new Parser({
87
87
  maxInputSize: 10 * 1024 * 1024,
88
- maxDepth: 1000,
88
+ maxDepth: 64,
89
89
  });
90
90
 
91
91
  const links: Link[] = parser.parse('(source: type target)');
@@ -200,7 +200,7 @@ import {
200
200
  // Create parser with options
201
201
  const parser = new Parser({
202
202
  maxInputSize: 5 * 1024 * 1024,
203
- maxDepth: 500,
203
+ maxDepth: 32,
204
204
  });
205
205
 
206
206
  // Parse with full type safety
@@ -334,6 +334,11 @@ Main parser class for converting strings to links.
334
334
 
335
335
  - `constructor(options)` - Create a parser; `options.comments` set to `false`
336
336
  reads `#` as an ordinary character instead of the start of a comment
337
+ - `options.maxInputSize` - Maximum input size in bytes (default: 10MB)
338
+ - `options.maxDepth` - How deep links may nest (default: `DEFAULT_MAX_DEPTH`,
339
+ 64). Every parenthesized group and every indentation level is one level,
340
+ and a document nested deeper is refused with a `ParseError` rather than
341
+ recursed into until the stack runs out
337
342
  - `initialize()` - Initialize the parser (async)
338
343
  - `parse(input)` - Parse a Lino string and return links
339
344
 
@@ -359,7 +364,7 @@ EventEmitter-based streaming parser for incremental parsing.
359
364
 
360
365
  - `constructor(options)` - Create a new streaming parser
361
366
  - `options.maxInputSize` - Maximum input size in bytes (default: 10MB)
362
- - `options.maxDepth` - Maximum nesting depth (default: 1000)
367
+ - `options.maxDepth` - How deep links may nest (default: 64)
363
368
  - `write(chunk)` - Feed a chunk of data to the parser
364
369
  - `end()` - Finish parsing and return all parsed links
365
370
  - `position()` - Get current parsing position (line, column, offset)
@@ -397,6 +402,17 @@ Syntax error at line 2, column 12: Expected "(", [ \t], [\r\n], or [^ \t\n\r(:)]
397
402
  - `snippet` - The offending line with a caret under the offending column
398
403
  - `location` - The position as the generated parser reports it
399
404
  - `cause` - The error the generated parser threw
405
+ - `maxDepth` - The deepest nesting allowed, when the document is nested deeper;
406
+ `null` for any other error
407
+
408
+ A document nested deeper than `maxDepth` is refused at the group or the line
409
+ that is one level too deep:
410
+
411
+ ```text
412
+ Nesting too deep at line 1, column 4: nesting depth exceeds the maximum of 3
413
+ 1 | ((((a))))
414
+ | ^
415
+ ```
400
416
 
401
417
  ## Project Structure
402
418
 
package/README.ru.md CHANGED
@@ -235,6 +235,12 @@ console.log(formatLinks(plain.parse('# a b\n'))); // (# a b)
235
235
 
236
236
  - `constructor(options)` - Создать парсер; `options.comments` со значением
237
237
  `false` читает `#` как обычный символ, а не как начало комментария
238
+ - `options.maxInputSize` - Максимальный размер входных данных в байтах
239
+ (по умолчанию: 10MB)
240
+ - `options.maxDepth` - Насколько глубоко могут быть вложены связи
241
+ (по умолчанию: `DEFAULT_MAX_DEPTH`, 64). Каждая группа в скобках и каждый
242
+ уровень отступа - это один уровень; документ с более глубокой вложенностью
243
+ отклоняется с `ParseError`, а не разбирается рекурсивно, пока не кончится стек
238
244
  - `initialize()` - Инициализация парсера (асинхронно)
239
245
  - `parse(input)` - Парсинг строки Lino и возвращение связей
240
246
 
@@ -285,6 +291,17 @@ Syntax error at line 2, column 12: Expected "(", [ \t], [\r\n], or [^ \t\n\r(:)]
285
291
  - `snippet` - Сломанная строка с указателем под нужным столбцом
286
292
  - `location` - Позиция в том виде, в каком ее сообщает сгенерированный парсер
287
293
  - `cause` - Ошибка, которую выбросил сгенерированный парсер
294
+ - `maxDepth` - Наибольшая допустимая вложенность, если документ вложен глубже;
295
+ `null` для любой другой ошибки
296
+
297
+ Документ, вложенный глубже `maxDepth`, отклоняется на той группе или строке,
298
+ которая на один уровень глубже допустимого:
299
+
300
+ ```text
301
+ Nesting too deep at line 1, column 4: nesting depth exceeds the maximum of 3
302
+ 1 | ((((a))))
303
+ | ^
304
+ ```
288
305
 
289
306
  ## Структура проекта
290
307