question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

markdownlint takes absurdly long to parse a 27,000 line table due to work for each inline incorrectly processing the entire table

See original GitHub issue

STR:

  1. Install both Text Power Tools (TPT) and markdownlint.
  2. Open a long MD document. I was viewing this one.
  3. Ctrl+P, and choose any of the TPT commands. I use “filter lines including a string”

*Note: I see this bug even without opening an MD file. But a long MD file is what makes it easier to reproduce.

Expected a popup from TPT to ask you to input query

Observed It shows “activating extensions…” at status bar for a while, then nothing happens. No popup. If I click “activating extensions” during the time, it shows mardownlint is “unresponsive”.

Afterwards, markdownlint freezes (no longer recognize lighting errors) until restarting.

Tested on newest stable VS Code and Insiders

Version: 1.62.2 (system setup)
Commit: 3a6960b964327f0e3882ce18fcebd07ed191b316
Date: 2021-11-11T20:56:38.428Z
Electron: 13.5.2
Chrome: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Windows_NT x64 6.1.7601
----------------
Version: 1.63.0-insider
Commit: 4e303fcc52269ab578affa6cb1eb455eacab445f
Date: 2021-11-22T05:28:15.683Z
Electron: 13.5.2
Chromium: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Windows_NT x64 6.1.7601

See also: https://github.com/qcz/vscode-text-power-tools/issues/29

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
DavidAnsoncommented, Nov 24, 2021

Thanks! Your trace shows an unreasonable amount of time being spent in markdownlint’s helpers.emphasisMarkersInContent function which is used exclusively by MD037/no-space-in-emphasis. It doesn’t seem to be stuck, but rather spending all its time in the “search code spans” phase splitting code with newLineRe and running emphasisMarkersRe.

Interestingly, if I weren’t looking at your issue, I was going to be looking at this function anyway because it relates to a commit I did yesterday. I’ll see if I can reproduce the issue using the file you link to above.

0reactions
DavidAnsoncommented, Nov 24, 2021

Oh no… The pattern of calling forEachInlineCodeSpan(tokenLines.join("\n"), ...) is very problematic at the moment. In this case, token corresponds to one of the cells of the table and tokenLines includes all 26695 lines of the table. Each line contains 2-4 tokens depending on the scenario, and the entire table is re-scanned for every token. Not good. This is fixable, but it’s an issue with the library and I’ll transfer the issue there.

Read more comments on GitHub >

github_iconTop Results From Across the Web

markdownlint/RULES.md at main - GitHub
This document contains a description of all rules, what they are checking for, as well as an examples of documents that break the...
Read more >
How to handle wide markdown tables and line-length checks ...
Approach I. First I tried to include a ignore MD013 (line length check) in the relevant section of the Markdown table, however, Markdown...
Read more >
Markdownlint - Visual Studio Marketplace
Introduction. The Markdown markup language is designed to be easy to read, write, and understand. It succeeds - and its flexibility is both ......
Read more >
Linting Markdown And Documentation - Earthly Blog
Many linting, code formatting, and static analysis tools exist for code. You can use eslint, gofmt, or many other static analysis tools, ...
Read more >
New Feature: Table Support - Meta Stack Exchange
All sites across Stack Exchange are now able to use tables. Thanks for all the feedback. We'll keep monitoring this question and we'll...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found