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

Viewports for markdown violate markdown lint MD022 #298

Open
NGenetzky opened this issue Aug 4, 2020 · 4 comments · May be fixed by #400
Open

Viewports for markdown violate markdown lint MD022 #298

NGenetzky opened this issue Aug 4, 2020 · 4 comments · May be fixed by #400

Comments

@NGenetzky
Copy link

MD022 - Headings should be surrounded by blank lines

Since the regexp for VIEWPORT['markdown'] requires "Header beginning" (Note, this is also a typo).

VIEWPORT = {
    'default':
    re.compile(
        r'^'                         # Starts at the begging of the line
        r'[=]+'                      # Heading begging
        r'(?P<name>[^=\|\[\{]*)'     # Name of the viewport, all before the | sign
                                     # Cannot include '[', '=', '|', and '{'
        r'\|'                        # Bar
        r'(?!\|)'                    # (But not two, that would be a preset)
        r'(?P<filter>[^=\|]*?)'      # Filter
        r'('                         # Optional defaults
          r'\|'                      # Bar
          r'(?P<defaults>[^=\|]+?)'  # Default attrs
        r')?'
        r'\s*'                       # Any whitespace
        r'(#(?P<source>[A-Z]))?'     # Optional source indicator
        r'\s*'                       # Any whitespace
        r'(\$(?P<sort>[A-Z]))?'      # Optional sort indicator
        r'\s*'                       # Any whitespace
        r'[=]+'                      # Header ending
    ),
    'markdown':
    re.compile(
        r'^'                         # Starts at the begging of the line
        r'[#]+'                      # Heading begging
        r'(?P<name>[^#\|\[\{]*)'     # Name of the viewport, all before the | sign
                                     # Cannot include '[', '#', '|', and '{'
        r'\|'                        # Bar
        r'(?!\|)'                    # (But not two, that would be a preset)
        r'(?P<filter>[^#\|]*?)'      # Filter
        r'('                         # Optional defaults
          r'\|'                      # Bar
          r'(?P<defaults>[^#\|]+?)'  # Default attrs
        r')?'
        r'\s*'                       # Any whitespace
        r'(#(?P<source>[A-Z]))?'     # Optional source indicator
        r'\s*'                       # Any whitespace
        r'(\$(?P<sort>[A-Z]))?'      # Optional sort indicator
        r'\s*'                       # Any whitespace
        r'$'                         # End of line
    )
}
@tbabej
Copy link
Collaborator

tbabej commented Aug 10, 2020

@NGenetzky do I understand correctly that adding a blank line below the viewport's heading (between the heading and the list of tasks) would suffice?

@NGenetzky
Copy link
Author

@tbabej , yes I believe that is all that is necessary.

@tmerse
Copy link

tmerse commented Dec 30, 2020

@NGenetzky do I understand correctly that adding a blank line below the viewport's heading (between the heading and the list of tasks) would suffice?

This should solve one of the problems you run into when autoformatting markdown-files in vim
e.g. via pandoc FILE.md -t markdown_strict or prettier FILE.md (I guess there are many other ways).

@pacien
Copy link

pacien commented Mar 3, 2022

taskwiki seems to behave strangely when blank line(s) are added between the
viewport header and an existing task list: it inserts a second copy of the list
instead of updating it. The parser should perhaps be more tolerant and accept
any number of blank lines under the viewport header.

For reference, vimwiki inserts a blank line between headers and automatically
generated blocks (TOC, tag list, link list) when using Markdown. This is set
through g:vimwiki_markdown_header_style, which defaults to 1 blank line.
Taskwiki should probably use that setting when inserting or updating a list.

pacien added a commit to pacien/taskwiki that referenced this issue Mar 4, 2022
This allows the presence of empty lines between the task list and the
header in a viewport, which is especially desirable to abide by standard
Markdown conventions.

The header spacing of existing viewports is preserved. For new Markdown
task lists, the spacing now follows the one configured in vimwiki with
`g:vimwiki_markdown_header_style`.

GitHub: closes tools-life#298
@pacien pacien linked a pull request Mar 4, 2022 that will close this issue
pacien added a commit to pacien/taskwiki that referenced this issue Apr 8, 2022
This allows the presence of empty lines between the task list and the
header in a viewport, which is especially desirable to abide by standard
Markdown conventions.

The header spacing of existing viewports is preserved. For new Markdown
task lists, the spacing now follows the one configured in vimwiki with
`g:vimwiki_markdown_header_style`.

GitHub: closes tools-life#298
fullstopslash pushed a commit to fullstopslash/taskwiki that referenced this issue Feb 7, 2024
This allows the presence of empty lines between the task list and the
header in a viewport, which is especially desirable to abide by standard
Markdown conventions.

The header spacing of existing viewports is preserved. For new Markdown
task lists, the spacing now follows the one configured in vimwiki with
`g:vimwiki_markdown_header_style`.

GitHub: closes tools-life#298
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants