Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Linter breaks callout with table inside #597

Closed
1 of 2 tasks
meskill opened this issue Jan 25, 2023 · 18 comments · Fixed by #694
Closed
1 of 2 tasks

Bug: Linter breaks callout with table inside #597

meskill opened this issue Jan 25, 2023 · 18 comments · Fixed by #694
Assignees
Labels
bug Something isn't working markdown General Markdown or Markdown related issue or feature reproducible resolution/update-made A change has been made that should resolve this issue or request

Comments

@meskill
Copy link

meskill commented Jan 25, 2023

Describe the Bug

If there is a callout block with the table inside after linting, it will separate table and blockquotes and will indefinitely add new lines between callout and table.

How to Reproduce

Example to reproduce issue with

> [!warning]- Test
>
> | column1 | column2 |
> | ------ | ------- |
> |   test1     |   test2      |
>
Linter Logs
Running linter
Running Insert YAML attributes
Running Header Increment
Running Footnote after Punctuation
Running Convert Bullet List Markers
Running Emphasis Style
Running Ordered List Style
Running Remove Empty List Markers
Running Unordered List Style
Running Compact YAML
Running Consecutive blank lines
Running Empty Line Around Code Fences
Running Empty Line Around Tables
Running Heading blank lines
Running Paragraph blank lines
Running Space after list markers
Running Custom Regex
Running Custom Lint Commands
Linter Config
{
  "ruleConfigs": {
    "Escape YAML Special Characters": {
      "Escapes colons with a space after them (: ), single quotes ('), and double quotes (\") in YAML.": false,
      "Try to Escape Single Line Arrays": false
    },
    "Format Tags in YAML": {
      "Remove Hashtags from tags in the YAML frontmatter, as they make the tags there invalid.": false
    },
    "Format Yaml Array": {
      "Allows for the formatting of regular yaml arrays as either multi-line or single-line and `tags` and `aliases` are allowed to have some Obsidian specific yaml formats. Note that single string to single-line goes from a single string entry to a single-line array if more than 1 entry is present. The same is true for single string to multi-line except it becomes a multi-line array.": false,
      "Format yaml aliases section": true,
      "Format yaml tags section": true,
      "Default yaml array section style": "single-line",
      "Format yaml array sections": true,
      "Force key values to be single-line arrays": "",
      "Force key values to be multi-line arrays": ""
    },
    "Insert YAML attributes": {
      "Inserts the given YAML attributes into the YAML frontmatter. Put each attribute on a single line.": true,
      "Text to insert": "tags: "
    },
    "Move Tags to Yaml": {
      "Move all tags to Yaml frontmatter of the document.": false,
      "Body tag operation": "Nothing"
    },
    "Remove YAML Keys": {
      "Removes the YAML keys specified": false,
      "YAML Keys to Remove": ""
    },
    "YAML Key Sort": {
      "Sorts the YAML keys based on the order and priority specified. Note: may remove blank lines as well.": false,
      "YAML Key Priority Sort Order": "",
      "Priority Keys at Start of YAML": true,
      "YAML Sort Order for Other Keys": "None",
      "Sorts the YAML keys based on the order and priority specified. Note: removes blank lines as well.": false
    },
    "YAML Timestamp": {
      "Keep track of the date the file was last edited in the YAML front matter. Gets dates from file metadata.": false,
      "Date Created": true,
      "Date Created Key": "date created",
      "Date Modified": true,
      "Date Modified Key": "date modified",
      "Format": "dddd, MMMM Do YYYY, h:mm:ss a"
    },
    "YAML Title": {
      "Inserts the title of the file into the YAML frontmatter. Gets the title from the first H1 or filename if there is no H1.": false,
      "Title Key": "title",
      "Inserts the title of the file into the YAML frontmatter. Gets the title from the first H1 or filename.": false
    },
    "YAML Title Alias": {
      "Inserts the title of the file into the YAML frontmatter's aliases section. Gets the title from the first H1 or filename.": false,
      "Preserve existing aliases section style": true,
      "Keep alias that matches the filename": false,
      "Use the YAML key `linter-yaml-title-alias` to help with filename and heading changes": true
    },
    "Capitalize Headings": {
      "Headings should be formatted with capitalization": false,
      "Style": "First letter",
      "Ignore Cased Words": true,
      "Ignore Words": "macOS, iOS, iPhone, iPad, JavaScript, TypeScript, AppleScript",
      "Lowercase Words": "via, a, an, the, and, or, but, for, nor, so, yet, at, by, in, of, on, to, up, as, is, if, it, for, to, with, without, into, onto, per"
    },
    "File Name Heading": {
      "Inserts the file name as a H1 heading if no H1 heading exists.": false
    },
    "Header Increment": {
      "Heading levels should only increment by one level at a time": true
    },
    "Footnote after Punctuation": {
      "Ensures that footnote references are placed after punctuation, not before.": true
    },
    "Move Footnotes to the bottom": {
      "Move all footnotes to the bottom of the document.": false
    },
    "Re-Index Footnotes": {
      "Re-indexes footnote keys and footnote, based on the order of occurrence (NOTE: This rule deliberately does *not* preserve the relation between key and footnote, to be able to re-index duplicate keys.)": false,
      "Re-indexes footnote keys and footnote, based on the order of occurence (NOTE: This rule deliberately does *not* preserve the relation between key and footnote, to be able to re-index duplicate keys.)": false
    },
    "Convert Bullet List Markers": {
      "Converts common bullet list marker symbols to markdown list markers.": true
    },
    "Emphasis Style": {
      "Makes sure the emphasis style is consistent.": true,
      "Style": "underscore"
    },
    "No Bare URLs": {
      "Encloses bare URLs with angle brackets except when enclosed in back ticks, square braces, or single or double quotes.": false
    },
    "Ordered List Style": {
      "Makes sure that ordered lists follow the style specified.": true,
      "Number Style": "ascending",
      "Ordered List Indicator End Style": ".",
      "Makes sure that ordered lists follow the style specified. Note that 2 spaces or 1 tab is considered to be an indentation level.": true
    },
    "Proper Ellipsis": {
      "Replaces three consecutive dots with an ellipsis.": false
    },
    "Remove Consecutive List Markers": {
      "Removes consecutive list markers. Useful when copy-pasting list items.": false
    },
    "Remove Empty List Markers": {
      "Removes empty list markers, i.e. list items without content.": true
    },
    "Remove Hyphenated Line Breaks": {
      "Removes hyphenated line breaks. Useful when pasting text from textbooks.": false
    },
    "Remove Multiple Spaces": {
      "Removes two or more consecutive spaces. Ignores spaces at the beginning and ending of the line. ": false
    },
    "Strong Style": {
      "Makes sure the strong style is consistent.": false,
      "Style": "consistent"
    },
    "Two Spaces Between Lines with Content": {
      "Makes sure that two spaces are added to the ends of lines with content continued on the next line for paragraphs, blockquotes, and list items": false
    },
    "Compact YAML": {
      "Removes leading and trailing blank lines in the YAML front matter.": true,
      "Inner New Lines": false
    },
    "Consecutive blank lines": {
      "There should be at most one consecutive blank line.": true
    },
    "Convert Spaces to Tabs": {
      "Converts leading spaces to tabs.": false,
      "Tabsize": "4"
    },
    "Empty Line Around Code Fences": {
      "Ensures that there is an empty line around code fences unless they start or end a document.": true
    },
    "Empty Line Around Tables": {
      "Ensures that there is an empty line around github flavored tables unless they start or end a document.": true
    },
    "Heading blank lines": {
      "All headings have a blank line both before and after (except where the heading is at the beginning or end of the document).": true,
      "Bottom": true,
      "Empty Line Between Yaml and Header": true
    },
    "Line Break at Document End": {
      "Ensures that there is exactly one line break at the end of a document.": false
    },
    "Paragraph blank lines": {
      "All paragraphs should have exactly one blank line both before and after.": true
    },
    "Remove Empty Lines Between List Markers and Checklists": {
      "There should not be any empty lines between list markers and checklists.": false
    },
    "Remove link spacing": {
      "Removes spacing around link text.": false
    },
    "Remove Space around Fullwidth Characters": {
      "Ensures that fullwidth characters are not followed by whitespace (either single spaces or a tab). Note that this may causes issues with markdown format in some cases.": false,
      "Ensures that fullwidth characters are not followed by whitespace (either single spaces or a tab)": false
    },
    "Space after list markers": {
      "There should be a single space after list markers and checkboxes.": true
    },
    "Trailing spaces": {
      "Removes extra spaces after every line.": false,
      "Two Space Linebreak": false
    },
    "Space between Chinese Japanese or Korean and English or numbers": {
      "Ensures that Chinese, Japanese, or Korean and English or numbers are separated by a single space. Follows these [guidelines](https://github.com/sparanoid/chinese-copywriting-guidelines)": false
    },
    "Force YAML Escape": {
      "Escapes the values for the specified YAML keys.": false,
      "Force YAML Escape on Keys": ""
    },
    "Headings Start Line": {
      "Headings that do not start a line will have their preceding whitespace removed to make sure they get recognized as headers.": false
    },
    "Remove Trailing Punctuation in Heading": {
      "Removes the specified punctuation from the end of headings making sure to ignore the semicolon at the end of [HTML entity references](https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references).": false,
      "Trailing Punctuation": ".,;:!。,;:!"
    },
    "Unordered List Style": {
      "Makes sure that unordered lists follow the style specified.": true,
      "List item style": "-"
    },
    "Empty Line Around Blockquotes": {
      "Ensures that there is an empty line around blockquotes unless they start or end a document. **Note that an empty line is either one less level of nesting for blockquotes or a newline character.**": false
    },
    "Empty Line Around Math Blocks": {
      "Ensures that there is an empty line around math blocks using `Number of Dollar Signs to Indicate a Math Block` to determine how many dollar signs indicates a math block for single-line math.": false
    },
    "Move Math Block Indicators to Their Own Line": {
      "Move all starting and ending math block indicators to their own lines using `Number of Dollar Signs to Indicate a Math Block` to determine how many dollar signs indicates a math block for single-line math.": false
    },
    "Remove Space around Characters": {
      "Ensures that certain characters are not surrounded by whitespace (either single spaces or a tab). Note that this may causes issues with markdown format in some cases.": false,
      "Include Fullwidth Forms": true,
      "Include CJK Symbols and Punctuation": true,
      "Include Dashes": true,
      "Other symbols": ""
    },
    "Add Blockquote Indentation on Paste": {
      "Adds blockquotes to all but the first line, when the cursor is in a blockquote/callout line during pasting": false
    },
    "Prevent Double Checklist Indicator on Paste": {
      "Removes starting checklist indicator from the text to paste if the line the cursor is on in the file has a checklist indicator": false
    },
    "Prevent Double List Item Indicator on Paste": {
      "Removes starting list indicator from the text to paste if the line the cursor is on in the file has a list indicator": false
    },
    "Proper Ellipsis on Paste": {
      "Replaces three consecutive dots with an ellipsis even if they have a space between them in the text to paste": false
    },
    "Remove Hyphens on Paste": {
      "Removes hyphens from the text to paste": false
    },
    "Remove Leading or Trailing Whitespace on Paste": {
      "Removes any leading non-tab whitespace and all trailing whitespace for the text to paste": false
    },
    "Remove Leftover Footnotes from Quote on Paste": {
      "Removes any leftover footnote references for the text to paste": false
    },
    "Remove Multiple Blank Lines on Paste": {
      "Condenses multiple blank lines down into one blank line for the text to paste": false
    },
    "Auto-correct Common Misspellings": {
      "Uses a dictionary of common misspellings to automatically convert them to their proper spellings. See [auto-correct map](https://github.com/platers/obsidian-linter/tree/master/src/utils/auto-correct-misspellings.ts) for the full list of auto-corrected words.": false,
      "Ignore Words": ""
    }
  },
  "lintOnSave": true,
  "recordLintOnSaveLogs": false,
  "displayChanged": false,
  "foldersToIgnore": [],
  "linterLocale": "system-default",
  "logLevel": 4,
  "lintCommands": [],
  "customRegexes": [],
  "commonStyles": {
    "aliasArrayStyle": "single-line",
    "tagArrayStyle": "single-line",
    "minimumNumberOfDollarSignsToBeAMathBlock": 2,
    "escapeCharacter": "\""
  }
}

Expected Behavior

The linter should not break the callout block

Screenshots

demonstration

Device

  • Desktop
  • Mobile
@meskill meskill added the bug Something isn't working label Jan 25, 2023
@pjkaufman
Copy link
Collaborator

Thanks for reporting this. This sounds like when it recognizes the table it might not be recognizing it correctly. I will have to take a look at this as I whittle down the existing bugs.

@Beau-Yang
Copy link

Beau-Yang commented Feb 6, 2023

The same thing happens when using a math formula in display math mode in a callout or using two callouts in succession and the former one ends with a nested callout or a blockquote in it.

e.g.

Case 1:

> [!note]
> $$\frac{1}{2}$$

will turn to

> [!note]  
>
> $$

\frac{1}{2}

$$

Case 2:

> [!note]  
> 123
> > 456

> [!info]
> abc

will turn to

> [!note]  
> 123
>
> > 456

>
> [!info]  
> abc

@grantx2016
Copy link

grantx2016 commented Mar 16, 2023

@pjkaufman, I am seeing similar behaviour with just normal tables (ie outside of callouts). With Linter configured to surround tables with a blank row, the blank row is actually inserted under the table header row, when the header row is blank (the blank row should placed be above the header row):

Before linting:
Screenshot 2023-03-16 at 1 31 23 pm

After linting:
Screenshot 2023-03-16 at 1 31 55 pm

I think the underlying cause is the same so won't raise another issue.

@pjkaufman
Copy link
Collaborator

This definitely looks similar to some things I have worked on before, but they are also a little different.

@Beau-Yang , case 1 should be fixed on master now. I just merged in a change for that which was reported last year on #560 . The other cases are a little different, so I will have to evaluate them on a case by case basis.

@pjkaufman
Copy link
Collaborator

@pjkaufman, I am seeing similar behaviour with just normal tables (ie outside of callouts). With Linter configured to surround tables with a blank row, the blank row is actually inserted under the table header row, when the header row is blank (the blank row should placed be above the header row):

Before linting: Screenshot 2023-03-16 at 1 31 23 pm

After linting: Screenshot 2023-03-16 at 1 31 55 pm

I think the underlying cause is the same so won't raise another issue.

This could be due to how the table regex works, but I am not sure there is a really good way to fix this. So far all of the options I have seen mean that I either get really accurate table identifications with poor performance for large files (something like 70 minutes to parse a single file) or pretty accurate table identification so long as it is standard and fills out the table parts. I have yet to find a good medium, but maybe that will be something that can be found yet.

@pjkaufman
Copy link
Collaborator

I am going to take another look at this. Some of these examples look like they should not be too bad to fix. However some of them look like they may not be easily done without redoing the table parser. I will see what I can do. If there is a need to update the table regex/table parsing for some of the examples, I will go ahead and break them into a separate ticket as that will be a lot of work and should not be grouped with some of the other fixes that are smaller.

@pjkaufman
Copy link
Collaborator

pjkaufman commented Apr 8, 2023

The same thing happens when using a math formula in display math mode in a callout or using two callouts in succession and the former one ends with a nested callout or a blockquote in it.

e.g.

Case 1:

> [!note]
> $$\frac{1}{2}$$

will turn to

> [!note]  
>
> $$

\frac{1}{2}

$$

Case 2:

> [!note]  
> 123
> > 456

> [!info]
> abc

will turn to

> [!note]  
> 123
>
> > 456

>
> [!info]  
> abc

For the cases provided here, it looks like a separate change I made fixed them or at least altered them, @Beau-Yang . Here are the new results which look fine to me.

Case 1

before:

> [!note]
> $$\frac{1}{2}$$

after:

> [!note]
>
> $$
> \frac{1}{2}
> $$

Case 2

before:

> [!note]  
> 123
> > 456

> [!info]
> abc

after:

> [!note]
> 123
>
> > 456

> [!info]
> abc

Please let me know if for some reason the output is not valid as it looks valid to me. I made a change in the last release that seems to have fixed this (#658).

@pjkaufman
Copy link
Collaborator

pjkaufman commented Apr 8, 2023

Describe the Bug

If there is a callout block with the table inside after linting, it will separate table and blockquotes and will indefinitely add new lines between callout and table.

How to Reproduce

Example to reproduce issue with

> [!warning]- Test
>
> | column1 | column2 |
> | ------ | ------- |
> |   test1     |   test2      |
>

Linter Logs
Linter Config

Expected Behavior

The linter should not break the callout block

Screenshots

demonstration demonstration

Device

  • Desktop
  • Mobile

I am still seeing this issue with the tables so I will go ahead and check it to see if there is something I can do about that n particular.

Edit: Actually, I may not be seeing this issue anymore.

@pjkaufman pjkaufman self-assigned this Apr 8, 2023
@pjkaufman pjkaufman added markdown General Markdown or Markdown related issue or feature reproducible labels Apr 8, 2023
@pjkaufman pjkaufman moved this from Backlog to In Progress in Obsidian Linter Apr 8, 2023
@pjkaufman
Copy link
Collaborator

@pjkaufman, I am seeing similar behaviour with just normal tables (ie outside of callouts). With Linter configured to surround tables with a blank row, the blank row is actually inserted under the table header row, when the header row is blank (the blank row should placed be above the header row):

Before linting: Screenshot 2023-03-16 at 1 31 23 pm

After linting: Screenshot 2023-03-16 at 1 31 55 pm

I think the underlying cause is the same so won't raise another issue.

I am not seeing this issue using the following markdown:

|  |  |
| ------ | ------- |
|   test1     |   test2      |

If you could provide me with your data.json and a sample markdown table, that would help me determine if this is truly fixed with the latest version or if it is just a fluke that it is working for me.

@pjkaufman
Copy link
Collaborator

pjkaufman commented Apr 8, 2023

I have noticed that the following keeps getting a blank line added if you run the Linter by Move Math Block Indicator to Its Own Line:

> [!note]
> $$
> \frac{1}{2}
> $$

becomes

> [!note]
> $$
> \frac{1}{2}
> 
> $$

@pjkaufman
Copy link
Collaborator

@meskill , @grantx2016 , @Beau-Yang , if any of you can still reproduce this issue on the latest version of the Linter please let me know and include an example with your data.json contents so I can attempt to reproduce the issue. So far it looks like all of the issues mentioned here have been fixed.

So barring any feedback, I plan to close this issue on next Saturday, the 15th. Thanks for helping us improve this plugin!

@meskill
Copy link
Author

meskill commented Apr 11, 2023

@pjkaufman I'm still facing the issue with excessive an empty line after callout block.

See gif below
demonstration

My data.json:
data.txt

@grantx2016
Copy link

if any of you can still reproduce this issue on the latest version of the Linter please let me know

I have retested with the latest version and no longer experience the issue I mentioned earlier whereby the blank line is inserted into the second row of a table, when Linter is configured to surround a table with a blank row.

@pjkaufman
Copy link
Collaborator

Thanks! I can now reproduce this issue.

@pjkaufman
Copy link
Collaborator

The rule causing the issue is "Paragraph Blank Lines" for adding empty lines around the table:

> [!warning]- Test
>
> | column1 | column2 |
> | ------ | ------- |
> |   test1     |   test2      |
>

@pjkaufman
Copy link
Collaborator

This seems to be a bug with how the Table is escaped leading to it not knowing if the table is a part of the blockquote or not. Thus blank lines get added. I need to think of a solution to this because it looks like fixing this breaks other things.

@pjkaufman
Copy link
Collaborator

I may have a fix for this, I just need to double check its results to make sure it is valid. So far it seems to work as intended. But I need to run it against a larger dataset to be sure that it does not mess things up somewhere.

@github-project-automation github-project-automation bot moved this from In Progress to Releasing in Obsidian Linter Apr 21, 2023
@pjkaufman
Copy link
Collaborator

This should be fixed on master and in the next release. Please let us know if that is not the case.

@pjkaufman pjkaufman added the resolution/update-made A change has been made that should resolve this issue or request label Apr 21, 2023
@pjkaufman pjkaufman moved this from Releasing to Done in Obsidian Linter May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working markdown General Markdown or Markdown related issue or feature reproducible resolution/update-made A change has been made that should resolve this issue or request
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants