obsidian-linter: Bug: Malformed Table Hangs Linter
Describe the Bug
Malformed tables (e.g. incorrect header syntax) cause linter to hang indefinitely.
How to Reproduce
Lint the attached example markdown file which contains a malformed table: “Malformed Table Hangs Linter.md”
Please make sure to include logs and the rule(s) that cause the issue if applicable. You can include logs by going to the debug tab of the Linter and setting the log level to debug. Then enable the capturing of logs and either lint on save or lint the current file. Then go back to the debug tab and you can grab Linter logs from the last run. > Logs are not produced so unable to provide them.
If you are not sure which rule(s) may cause the issue, please attach the data.json file located at <vault>/.obsidian/plugins/obsidian-linter/ or copy the config from the debug tab.
data.json attached. I am unclear which rule causes the issue.
Expected Behavior
Linting is not expected to transform malformed tables, so it should just ignore them in that case.
Screenshots
NA
Device
- Desktop
- Mobile
Additional Context
This bug makes it very difficult to bulk lint large folders since only one malformed table causes linter to hang and very difficult to find the troublesome file.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 19
I believe that this is fixed now on master and will go out in the next release. Please let us know if this is not true on master or in the next release.
Also, the Linter does not try to fix the table. Trying to determine if a table is present in the file is what is causing the issue in this case.
I tried looking for a way to kill the regex processing if it took more than a minute or 2 to run and then log the error, but it seems that is not really feasible. I am not sure what is causing the regex to hang exactly and there is no good way of doing that from what I can tell. Since I have little experience diagnosing problems with regex except via trial and error, I am not sure I can do much on that front. I may have to shift to another package and see if it alleviates this issue without creating another performance issue.
Dev Note: Take a look at the following links and see if any of them help with this performance issue: https://github.com/tgrosinger/advanced-tables-obsidian/blob/main/src/table-editor.ts https://github.com/aidenlx/table-extended https://www.npmjs.com/package/@gerhobbelt/markdown-it-regexp https://www.npmjs.com/package/markdown-it-multimd-table https://github.com/tgrosinger/advanced-tables-obsidian
@grantx2016 , what you are requesting here is a lot harder said than done. Parsing tables is already super difficult in markdown and creates problems. If I were to force the use of a specific markdown table format, then the performance could be greatly improved, but as of right now, I have been unable to find a good way to parse tables.
I have used a markdown parser, but long files caused issues https://github.com/platers/obsidian-linter/issues/458 and now it seems that the regex that is more performant, but may not be as accurate is also having performant is also having issues. I am not sure I can fix this as it stands, but I do appreciate the notice about the issue.