You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit hard codes the matching patterns. Also it does not paste back the matched lines after formatting.
update: added a filter for python only and allow matching for multiple lines. kanghengliu@ca99f29
Provide background
When editing a markdown file, ipython magic commands and shell commands will prevent python formatters from functioning.
Example1:
%%timeprint("hello")
Example2:
!pipinstallrandomstuff
Black will break, since this is not a valid python chunk, however, modern linters will highlight the chunk just fine.
Both chunks are valid in jupyter notebook with IPython.
What is the significance of this feature?
strongly desired
Additional details
I've attempted to instruct the formatters to ignore certain patterns, however it is reasonably out of scope for code formatters to handle "broken" formats. Many formatters that i've found will not support this, and it makes sense for them to do so.
For additional use cases, see my issue at molten.nvim where I attempt to lint and format a chunk with cell magic.
The text was updated successfully, but these errors were encountered:
I would review a PR for this. I think I would prefer a more general approach, as expressing all of the possible changes someone might want to make as some key-value pattern-match DSL will be a challenge. We're already doing some modification of the text chunks; we could also pass them to a user-provided function for additional modification. This would likely happen around remove_surrounding and restore_surrounding
Did you check existing requests?
Describe the feature
For
injected
formatter, add a lua match pattern variable to match and filter out someinput_lines
, as they break formatter.Quick and dirty proof of concept:
kanghengliu@30568d6
This commit hard codes the matching patterns. Also it does not paste back the matched lines after formatting.update: added a filter for python only and allow matching for multiple lines.
kanghengliu@ca99f29
Provide background
When editing a markdown file, ipython magic commands and shell commands will prevent python formatters from functioning.
Example1:
Example2:
Black will break, since this is not a valid python chunk, however, modern linters will highlight the chunk just fine.
Both chunks are valid in jupyter notebook with IPython.
What is the significance of this feature?
strongly desired
Additional details
I've attempted to instruct the formatters to ignore certain patterns, however it is reasonably out of scope for code formatters to handle "broken" formats. Many formatters that i've found will not support this, and it makes sense for them to do so.
For additional use cases, see my issue at molten.nvim where I attempt to lint and format a chunk with cell magic.
The text was updated successfully, but these errors were encountered: