Open platers opened 3 years ago
Looks like the following are the rules tat would be able to be fixable:
MD004 ul-style - Unordered list style MD005 list-indent - Inconsistent indentation for list items at the same level MD007 ul-indent - Unordered list indentation MD009 no-trailing-spaces - Trailing spaces MD010 no-hard-tabs - Hard tabs MD011 no-reversed-links - Reversed link syntax MD012 no-multiple-blanks - Multiple consecutive blank lines MD014 commands-show-output - Dollar signs used before commands without showing output MD018 no-missing-space-atx - No space after hash on atx style heading MD019 no-multiple-space-atx - Multiple spaces after hash on atx style heading MD020 no-missing-space-closed-atx - No space inside hashes on closed atx style heading MD021 no-multiple-space-closed-atx - Multiple spaces inside hashes on closed atx style heading MD022 blanks-around-headings/blanks-around-headers - Headings should be surrounded by blank lines MD023 heading-start-left/header-start-left - Headings must start at the beginning of the line MD026 no-trailing-punctuation - Trailing punctuation in heading MD027 no-multiple-space-blockquote - Multiple spaces after blockquote symbol MD030 list-marker-space - Spaces after list markers MD031 blanks-around-fences - Fenced code blocks should be surrounded by blank lines MD032 blanks-around-lists - Lists should be surrounded by blank lines MD034 no-bare-urls - Bare URL used MD037 no-space-in-emphasis - Spaces inside emphasis markers MD038 no-space-in-code - Spaces inside code span elements MD039 no-space-in-links - Spaces inside link text MD044 proper-names - Proper names should have the correct capitalization MD047 single-trailing-newline - Files should end with a single newline character MD049 emphasis-style - Emphasis style should be consistent MD050 strong-style - Strong style should be consistent
Thanks for compiling this. It would be great if we could leverage rules from existing linters instead of rewriting them. Would you be interested in looking into that?
Thanks for compiling this. It would be great if we could leverage rules from existing linters instead of rewriting them. Would you be interested in looking into that?
I can definitely take a look, but I am not sure to what extent the linters would be used the same way as this plugin works.
For example, markdownlint is not necessarily going to fix the issues for you. I can look into how the extension to VS Code works and get the rules implemented which is what I was hoping to do initially before I stumbled across this plugin.
Yeah, a while ago I was looking into remark which seemed promising. I believe its already installed in this project, but I never got around to using its plugins.
I like the idea of using something like remark to supply most of the rules or even get the linting framework setup to allow extensions as well. It looks like there is an example of it for remark-lint here. I will have to test it locally and see what happens. But it would help to not have to reinvent the wheel.
I got a simple example working, but I am not entirely sure how well it will work out since it may require dynamically building a couple of objects. I will try replacing an existing rule with the remark-lint plugin and see how well it works out. Hopefully it will not be too cumbersome, but if we did go this route we would probably need to go all in to make sure we had a consistent rule setup.
Here seems to be the current mapping: | Current Rule | Remark Lint |
---|---|---|
space-between-chinese-and-english-or-numbers | remark-lint-spaces-around-word and remark-lint-spaces-around-number | |
header-increment | remark-lint-heading-increment? | |
format-tags-in-yaml | I don't think this exists, so we would need to convert what we have to a remark-lint plugin | |
insert-yaml-attributes | I don't think this exists, so we would need to convert what we have to a remark-lint plugin | |
yaml-timestamp | I don't think this exists, so we would need to convert what we have to a remark-lint plugin | |
yaml-title | I don't think this exists, so we would need to convert what we have to a remark-lint plugin | |
file-name-heading | I don't think this exists, so we would need to convert what we have to a remark-lint plugin | |
capitalize-headings | I don't think this exists, so we would need to convert what we have to a remark-lint plugin | |
move-footnotes-to-the-bottom | I don't think this exists, so we would need to convert what we have to a remark-lint plugin | |
re-index-footnotes | I don't think this exists, so we would need to convert what we have to a remark-lint plugin | |
footnote-after-punctuation | I don't think this exists, so we would need to convert what we have to a remark-lint plugin | |
remove-multiple-spaces | I don't think this exists, so we would need to convert what we have to a remark-lint plugin | |
remove-hyphenated-line-breaks | I don't think this exists, so we would need to convert what we have to a remark-lint plugin | |
remove-consecutive-list-markers | I don't think this exists, so we would need to convert what we have to a remark-lint plugin | |
remove-empty-list-markers | I don't think this exists, so we would need to convert what we have to a remark-lint plugin | |
convert-bullet-list-markers | I don't think this exists, so we would need to convert what we have to a remark-lint plugin | |
proper-ellipsis | I don't think this exists, so we would need to convert what we have to a remark-lint plugin | |
trailing-spaces | I don't think this exists, so we would need to convert what we have to a remark-lint plugin | |
heading-blank-lines | I don't think this exists, so we would need to convert what we have to a remark-lint plugin | |
paragraph-blank-lines | I don't think this exists, so we would need to convert what we have to a remark-lint plugin | |
space-after-list-markers | kind of exists as a part of remark-lint-no-missing-blank-lines | |
compact-yaml | I don't think this exists, so we would need to convert what we have to a remark-lint plugin | |
consecutive-blank-lines | remark-lint-no-consecutive-blank-lines? | |
convert-spaces-to-tabs | I don't think this exists, so we would need to convert what we have to a remark-lint plugin | |
line-break-at-document-end | remark-lint-final-newline |
Looks like to convert over to remark would leave us with only a few existing rules and a conversion or setup for the others.
I'd like to have a mixture of remark rules and custom rules. It should still be easy to add a new rule by writing a little regex. We can use remark when we can.
I'd like to have a mixture of remark rules and custom rules. It should still be easy to add a new rule by writing a little regex. We can use remark when we can.
Good to know. That should be allow for an interesting way of setting things up. Are we also allowing markdownlint rules assuming they can be used to fix issues rather than just warn about them?
Sure, I'm open to most things as custom rules.
If we wanted to implement the fixable aliases here is what that looks like when using remark rules: | MarkdownLint Alias | Remark-Lint Rule |
---|---|---|
MD004 ul-style - Unordered list style | remark-lint-unordered-list-marker-style | |
MD005 list-indent - Inconsistent indentation for list items at the same level | Would need a custom rule or to use markdownlint if possible | |
MD007 ul-indent - Unordered list indentation | Would need a custom rule or to use markdownlint if possible | |
MD009 no-trailing-spaces - Trailing spaces | already exists as trailing-spaces and does not exist in remark lint | |
MD010 no-hard-tabs - Hard tabs | remark-lint-no-tabs | |
MD011 no-reversed-links - Reversed link syntax | Would need a custom addition to our rules or use of markdown lint if possible | |
MD012 no-multiple-blanks - Multiple consecutive blank lines | this is already taken care of | |
MD014 commands-show-output - Dollar signs used before commands without showing output | I am not sure if we want this, but it would require a custom addition or use of markdown lint if possible | |
MD018 no-missing-space-atx - No space after hash on atx style heading | Would need a custom addition to our rules or use of markdown lint if possible, but it would be risky to use given how tags work | |
MD019 no-multiple-space-atx - Multiple spaces after hash on atx style heading | We may still need something for this | |
MD020 no-missing-space-closed-atx - No space inside hashes on closed atx style heading | This would need to use a custom rule or markdown lint if possible | |
MD021 no-multiple-space-closed-atx - Multiple spaces inside hashes on closed atx style heading | This would need to use a custom rule or markdown lint if possible | |
MD022 blanks-around-headings/blanks-around-headers - Headings should be surrounded by blank lines | taken care of by heading-blank-lines | |
MD023 heading-start-left/header-start-left - Headings must start at the beginning of the line | Would need a custom rule or markdown lint if possible | |
MD026 no-trailing-punctuation - Trailing punctuation in heading | remark-lint-no-heading-punctuation is a partial replacement, but a custom rule or markdown lint if possible would be preferred if we want to cover the same functionality | |
MD027 no-multiple-space-blockquote - Multiple spaces after blockquote symbol | The closest I think I could find is remark-lint-blockquote-indentation, but it may not be an exact match | |
MD030 list-marker-space - Spaces after list markers | space-after-list-markers | |
MD031 blanks-around-fences - Fenced code blocks should be surrounded by blank lines | This would need a custom rule or markdownlint if possible | |
MD032 blanks-around-lists - Lists should be surrounded by blank lines | This would require a custom rule or markdownlint if possible | |
MD034 no-bare-urls - Bare URL used | this would require a custom rule or markdownlint if possible | |
MD037 no-space-in-emphasis - Spaces inside emphasis markers | this would require a custom rule or markdownlint if possible | |
MD038 no-space-in-code - Spaces inside code span elements | this would require a custom rule or markdownlint if possible | |
MD039 no-space-in-links - Spaces inside link text | this would require a custom rule or markdownlint if possible | |
MD044 proper-names - Proper names should have the correct capitalization | this is already accounted for by capitalize-headings | |
MD047 single-trailing-newline - Files should end with a single newline character | this is already accounted for by line-break-at-document-end | |
MD049 emphasis-style - Emphasis style should be consistent | remark-lint-emphasis-marker | |
MD050 strong-style - Strong style should be consistent | remark-lint-strong-marker |
@platers , do we want to implement MD018? Also, are there any of these we would not like to include? And would you like them added one at a time or all at once (I am guessing the former, but want to make sure since it is more testable)?
Lets skip MD018. Yeah lets add them one at a time, in order of convenience/utility. If we add too many more rules we'll have to update the settings page to be easier to find rules.
Sounds good, feel free to send PRs for new rules, no need to create issues for these.
Looks like we will not be able to use remark-lint as it seems to run things all at once. I am still checking, but it seems to run more than 1 rule at a time.
These are the rules that would try to run by default if my understanding is correct:
remark-lint-blockquote-indentation — warn when block quotes are either indented too much or too little
remark-lint-checkbox-character-style — warn when list item checkboxes violate a given style
remark-lint-checkbox-content-indent — warn when list item checkboxes are followed by too much whitespace
remark-lint-code-block-style — warn when code blocks do not adhere to a given style
remark-lint-definition-case — warn when definition labels are not lowercase
remark-lint-definition-spacing — warn when consecutive whitespace is used in a definition
remark-lint-emphasis-marker — warn when emphasis markers violate the given style
remark-lint-fenced-code-flag — warn when fenced code blocks occur without language flag
remark-lint-fenced-code-marker — warn when fenced code markers violate the given style
remark-lint-file-extension — warn when the file’s extension violates the given style
remark-lint-final-definition — warn when definitions are not placed at the end of the file
remark-lint-final-newline — warn when a newline at the end of a file is missing
remark-lint-first-heading-level — warn when the first heading has a level other than a specified value
remark-lint-hard-break-spaces — warn when too many spaces are used to create a hard break
remark-lint-heading-increment — warn when headings increment with more than 1 level at a time
remark-lint-heading-style — warn when heading style violates the given style
remark-lint-linebreak-style — warn when linebreaks violate a given or detected style
remark-lint-link-title-style — warn when link and definition titles occur with incorrect quotes
remark-lint-list-item-bullet-indent — warn when list item bullets are indented
remark-lint-list-item-content-indent — warn when the content of a list item has mixed indentation
remark-lint-list-item-indent — warn when the spacing between a list item’s bullet and its content violates a given style
remark-lint-list-item-spacing — warn when list looseness is incorrect
remark-lint-maximum-heading-length — warn when headings are too long
remark-lint-maximum-line-length — warn when lines are too long
remark-lint-no-blockquote-without-marker — warn when blank lines without markers (>
) are found in a block quote
remark-lint-no-consecutive-blank-lines — warn for too many consecutive blank lines
remark-lint-no-duplicate-defined-urls — warn on definitions that define the same urls
remark-lint-no-duplicate-definitions — warn on duplicate definitions
remark-lint-no-duplicate-headings — warn on duplicate headings
remark-lint-no-duplicate-headings-in-section — warn on duplicate headings in a section
remark-lint-no-emphasis-as-heading — warn when emphasis or importance is used instead of a heading
remark-lint-no-empty-url — warn on empty URLs in links and images
remark-lint-no-file-name-articles — warn when file name start with an article
remark-lint-no-file-name-consecutive-dashes — warn when file names contain consecutive dashes
remark-lint-no-file-name-irregular-characters — warn when file names contain irregular characters
remark-lint-no-file-name-mixed-case — warn when file names use mixed case
remark-lint-no-file-name-outer-dashes — warn when file names contain initial or final dashes
remark-lint-no-heading-content-indent — warn when heading content is indented
remark-lint-no-heading-indent — warn when headings are indented
remark-lint-no-heading-like-paragraph — for too many hashes (h7+ “headings”)
remark-lint-no-heading-punctuation — warn when headings end in illegal characters
remark-lint-no-html — warn when HTML nodes are used
remark-lint-no-inline-padding — warn when inline nodes are padded with spaces
remark-lint-no-literal-urls — warn when URLs without angle brackets are used
remark-lint-no-missing-blank-lines — warn when missing blank lines
remark-lint-no-multiple-toplevel-headings — warn when multiple top level headings are used
remark-lint-no-paragraph-content-indent — warn when the content in paragraphs are indented
remark-lint-no-reference-like-url — warn when URLs are also defined identifiers
remark-lint-no-shell-dollars — warn when shell code is prefixed by dollars
remark-lint-no-shortcut-reference-image — warn when shortcut reference images are used
remark-lint-no-shortcut-reference-link — warn when shortcut reference links are used
remark-lint-no-table-indentation — warn when tables are indented
remark-lint-no-tabs — warn when hard tabs are used instead of spaces
remark-lint-no-undefined-references — warn when references to undefined definitions are found
remark-lint-no-unneeded-full-reference-image — warn when full reference images are used if they can be collapsed
remark-lint-no-unneeded-full-reference-link — warn when full reference links are used if they can be collapsed
remark-lint-no-unused-definitions — warn when unused definitions are found
remark-lint-ordered-list-marker-style — warn when the markers of ordered lists violate a given style
remark-lint-ordered-list-marker-value — warn when the marker value of ordered lists violates a given style
remark-lint-rule-style — warn when horizontal rules violate a given style
remark-lint-strikethrough-marker — warn when strikethrough markers violate the given style
remark-lint-strong-marker — warn when importance (strong) markers violate the given style
remark-lint-table-cell-padding — warn when table cells are incorrectly padded
remark-lint-table-pipe-alignment — warn when table pipes are not aligned
remark-lint-table-pipes — warn when table rows are not fenced with pipes
remark-lint-unordered-list-marker-style — warn when markers of unordered lists violate a given style
Oh does remark only give warnings? I thought it could fix errors too :(
It can fix errors, but it does so using presets which include more than 1 rule at a time. We would need to build the whole set of remark rules at once from what I am gathering unless there is a good way to get the rule sets in use.
If I am understanding correctly how remark-lint does things, it uses remark-stringify to update the markdown. remark-stringify seems to be an all or nothing thing where you configure how you want all the rules run, then you run the update for all the rules.
It does not seem that it is feasible to use remark-lint with how we currently run the rules. They only allow disabling certain plugins, but you have to specify how you want certain things done or else the default will be used (default is NOT to do nothing).
For this issue, it is my understanding that the following rules would need to be added to obsidian-linter or rule modifications may be needed:
It looks like we have a good bit of work cut out for us if we want to get this completed, but it should be feasible to do so.
It may be easier to break this into several feature requests to make it seem less daunting and not have it sit in the swim lanes for the roadmap for the Linter for so long. I will think about whether to do that.
I may have been wrong about my initial assessment of whether or not we could use remark plugins that already exist to do some of the work for us. I am testing out whether they can actually be used. I think that if we dynamically add and remove plugins to use, we can probably use the plugins. I initially thought this was not allowed, but realized that it may very well be possible.
Well, it seems my initial assessment was correct. It is not possible to use remark rules to just update some of these values without accepting that some styling that may be disabled in the settings might have its equivalent run in remark-lint
/remark-stringify
. I thought it might be able to not auto format the other formats, but I was wrong.
Just wanted to chime in and say that I'm very glad to see markdownlint having played a role in this linter's design. I have markdownlint configured to my liking in VS Code and hope to translate it 1:1, if possible, over to Obsidian.
I'm using these markdownlint rules:
Implemented:
false
.Partially implemented:
"list_items": false
. Here false
should ensure blank lines around fences everywhere but when within a list.Unimplemented:
"indent": 4
.false
.false
."allowed_elements": [ "kbd" ]
.Some rules may not be relevant to obsidian-linter, or may controlled via Obsidian itself. The categories above are just based off your list above, I haven't tested them.
As a side note, Obsidian looks very broken in editing view when trying to handle somewhat complex lists, but renders them fine in reading view. Strange and unexpected. Maybe it's not ready for me to switch to yet...
MD027 is taken care of by the new rule that was merged for setting a blockquote style (#718). It is not an exact match, but setting the value to be the style of space
will make sure there is only 1 space after a blockquote indicator.
Hi! First: thanks a lot for this great plugin!
regarding MD007 ul-indent, I wanted to ask if there are any chances to get it done anytime soon 😅
I just now converted some text to markdown and was left with a lot of unordered lists having two spaces instead of 4. not a problem for the reading-mode, but in live-preview and source-mode it didn't look too well :D. I tried to use search-and-replace as possible, but a quick lint would have been much quicker 👍
Hi! First: thanks a lot for this great plugin!
regarding MD007 ul-indent, I wanted to ask if there are any chances to get it done anytime soon 😅
I just now converted some text to markdown and was left with a lot of unordered lists having two spaces instead of 4. not a problem for the reading-mode, but in live-preview and source-mode it didn't look too well :D. I tried to use search-and-replace as possible, but a quick lint would have been much quicker 👍
I am not sure where this falls on things. I am all over the place with when things get merged. I am currently working more on documenting things and some bug fixes, but I plan to shift focus a little once the documentation gets updated.
I would like to take another stab at remark lint and see if it is viable, but that will have to wait for now.
Any chance we could get a new push for MD007 ul-indent
? I just discovered a "bug" in Obsidian that doesn't consider indents at 2 or 3 spaces to actually be indents in editor mode. I don't want to manually edit every note to work around this issue to get indent guides back and was hoping the Linter would just have an option to automatically convert all my 2 space lists into 4 spaces.
Ideally this would be fixed at Obsidian's level but until then I'm fine using 4 spaces iff I can do it automatically without extra effort
I am not sure when ul-indent
will get implemented. I have thought about it several times, but I do not believe I have figured out a good way to handle the spacing before the unordered lists.
https://github.com/DavidAnson/markdownlint
Add rules that are automatically fixable.