Markdown: Mentions and timestamps not parsed in bullet lists #5561

Open
opened 2021-02-22 07:05:39 +01:00 by infinite-persistence · 0 comments
infinite-persistence commented 2021-02-22 07:05:39 +01:00 (Migrated from github.com)

(This is a known issue for a while, but documenting it since a recent plugin update caused a crashe.)

Issue

image

remark-lbry and remark-timestamps aren't working in lists and tables. It's either we are using remark incorrectly or there is a bug in remark (I think it's the latter).

Investigation

For both cases, when a bullet list is encountered, the "locator" hook behaved like this:

Current line being processed:

"* 11:11:11 Bad"

Data passed to our locator:

value: "11:11:11 Bad",
fromIndex: "1",

The parser should have given us a value without truncating the leading whitespace, or a fromIndex that is 0 to take into account the truncation.

  • For the case of remark-lbry, the locator simply returned -1 (not found)
  • For the case of remark-timestamp, the locator "correctly" returned 0 as it included some back-searching to handle timestamp corner-cases. If the returned value is smaller than fromIndex, the parser restarts, hence the infinite loop in #5557 Opening video makes app crash, build with latest source build

Assuming no mistakes in the Remark usage, there are various list-related parsing problems in Remark, such as https://github.com/remarkjs/remark/issues/517, which makes me think that remark v13 should fix things (we are currently on v8).
- v13 introduces a breaking change, and all plugins need to be tweaked.
- remark-attr, which we currently use, hasn't been updated yet (https://github.com/arobase-che/remark-attr/issues/22) so we can't go to v13.
- Going to v13 also seems to require some rework in remark-lbry.

(didn't use hyperlinks above as I didn't want to pollute their repo with "mentions")

(_This is a known issue for a while, but documenting it since a recent plugin update caused a crashe._) ## Issue ![image](https://user-images.githubusercontent.com/64950861/108667522-5ae9ce80-7514-11eb-8ec0-246513c4ff23.png) `remark-lbry` and `remark-timestamps` aren't working in lists and tables. It's either we are using remark incorrectly or there is a bug in remark (I think it's the latter). ## Investigation For both cases, when a bullet list is encountered, the "locator" hook behaved like this: Current line being processed: ``` "* 11:11:11 Bad" ``` Data passed to our locator: ``` value: "11:11:11 Bad", fromIndex: "1", ``` The parser should have given us a `value` without truncating the leading whitespace, or a `fromIndex` that is 0 to take into account the truncation. - For the case of `remark-lbry`, the locator simply returned `-1` (not found) - For the case of `remark-timestamp`, the locator "correctly" returned `0` as it included some back-searching to handle timestamp corner-cases. If the returned value is smaller than `fromIndex`, the parser restarts, hence the infinite loop in #5557 [Opening video makes app crash, build with latest source build](https://github.com/lbryio/lbry-desktop/issues/5557) ## Potentially related Assuming no mistakes in the Remark usage, there are various list-related parsing problems in Remark, such as `https://github.com/remarkjs/remark/issues/517`, which makes me think that `remark v13` should fix things (we are currently on `v8`). - `v13` introduces a breaking change, and all plugins need to be tweaked. - `remark-attr`, which we currently use, hasn't been updated yet (`https://github.com/arobase-che/remark-attr/issues/22`) so we can't go to `v13`. - Going to `v13` also seems to require some rework in `remark-lbry`. (_didn't use hyperlinks above as I didn't want to pollute their repo with "mentions"_)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
LBRYCommunity/lbry-desktop#5561
No description provided.