@mtcute/markdown-parser 0.25.0 → 0.25.1

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.
Files changed (3) hide show
  1. package/index.cjs +9 -1
  2. package/index.js +9 -1
  3. package/package.json +2 -2
package/index.cjs CHANGED
@@ -364,7 +364,15 @@ function parse(strings, ...sub) {
364
364
  if (prevBlockquote) entities.push(prevBlockquote);
365
365
  function adjustOffsets(from, by) {
366
366
  for (const ent of entities) {
367
- if (ent.offset >= from) ent.offset += by;
367
+ if (ent.offset < from) continue;
368
+ if (by >= 0) {
369
+ ent.offset += by;
370
+ continue;
371
+ }
372
+ const adjustTotal = Math.min(ent.offset, Math.abs(by));
373
+ const adjustInternal = Math.max(Math.abs(by) - ent.offset, 0);
374
+ ent.offset -= adjustTotal;
375
+ ent.length -= adjustInternal;
368
376
  }
369
377
  for (const stack of Object.values(stacks)) {
370
378
  for (const ent of stack) {
package/index.js CHANGED
@@ -357,7 +357,15 @@ function parse(strings, ...sub) {
357
357
  if (prevBlockquote) entities.push(prevBlockquote);
358
358
  function adjustOffsets(from, by) {
359
359
  for (const ent of entities) {
360
- if (ent.offset >= from) ent.offset += by;
360
+ if (ent.offset < from) continue;
361
+ if (by >= 0) {
362
+ ent.offset += by;
363
+ continue;
364
+ }
365
+ const adjustTotal = Math.min(ent.offset, Math.abs(by));
366
+ const adjustInternal = Math.max(Math.abs(by) - ent.offset, 0);
367
+ ent.offset -= adjustTotal;
368
+ ent.length -= adjustInternal;
361
369
  }
362
370
  for (const stack of Object.values(stacks)) {
363
371
  for (const ent of stack) {
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@mtcute/markdown-parser",
3
3
  "type": "module",
4
- "version": "0.25.0",
4
+ "version": "0.25.1",
5
5
  "description": "Markdown entities parser for mtcute",
6
6
  "license": "MIT",
7
7
  "dependencies": {
8
- "@mtcute/core": "^0.25.0",
8
+ "@mtcute/core": "^0.25.1",
9
9
  "long": "5.2.3"
10
10
  },
11
11
  "exports": {