Comments (7)
Hey @AndreiSager . The Linter does not directly support this use case. However it does allow you to use custom regex for this situation. How familiar are you with regex?
from obsidian-linter.
Thanks for responding! I am not familiar with regex, but I have heard of it.
from obsidian-linter.
For those reading this, these are the steps necessary to make this happen:
- Open Settings > Linter > Custom
- Add new regex replacement, do the following:
- regex to find:
([^ \t\r\n\v\f])\n(#)
gm
- regex to replace:
$1\n\n$2
from obsidian-linter.
For those reading this, these are the steps necessary to make this happen:
- Open Settings > Linter > Custom
- Add new regex replacement, do the following:
- regex to find:
([^ \t\r\n\v\f])\n(#)
gm
- regex to replace:
$1\n\n$2
Thank you for your solution! I have tried it and it is not working. Am I supposed to disable or enable a setting to make it work?
from obsidian-linter.
The regex you need will be based on the following logic in the code:
text = text.replace(/^(#+\s.*)/gm, '\n\n$1\n\n'); // add blank line before and after headings
text = text.replace(/\n+(#+\s.*)/g, '\n\n$1'); // trim blank lines before headings
text = text.replace(/(^#+\s.*)\n+/gm, '$1\n\n'); // trim blank lines after headings
}
text = text.replace(/^\n+(#+\s.*)/, '$1'); // remove blank lines before first heading
text = text.replace(/(#+\s.*)\n+$/, '$1'); // remove blank lines after last heading
So if you want to make it so that all headings have something like /^(#+\s.*)/gm
and the \n\n\n$1
for the replace.
Then you need to trim blank lines before headings if they are too long: /\n{2,}(#+\s.*)/g
for find and \n\n\n$1
for replace.
Lastly, you nedd to remove the blank lines before the first heading:
^\n+(#+\s.*)
and the replace $1
and make sure it has no flags.
Thus it looks something like this:
Search | Flags | Replace |
---|---|---|
^(#+\s.*) |
gm |
\n\n\n$1 |
\n{2,}(#+\s.*) |
g |
\n\n\n$1 |
^\n+(#+\s.*) |
$1 |
Note: I have not tested this and cannot really do so at this time. But hopefully this gets you roughly to wherw you need to be.
from obsidian-linter.
@pjkaufman Thank you very much for helping solve my problem! The solution you gave works wonders!
from obsidian-linter.
I am glad that it works!
from obsidian-linter.
Related Issues (20)
- Bug: Indentations for math block removed from callouts or block quotes HOT 5
- Bug: auto “created” and “modified” date time in custom format. HOT 3
- FR: Lint selected files via the Files tab (similar to "Lint folder")
- Question: File Specific Rule Disabling in YAML Frontmatter - Hiding/Editing/Commenting Out rules HOT 4
- Bug: Linter deletes line beginnings and modifies front matter content in certain documents in edit mode HOT 8
- FR: Provide a button to ignore a custom regex replacement when linted.
- Bug: Lint on save doesn't lint on file write on mobile HOT 3
- Bug: numbered list markers all become "1." HOT 3
- Bug: preview mode lint of daily note funnnnnky results HOT 4
- Bug: Linter removes the # from the Share Note share_link URL HOT 1
- Bug: Unable to parse url correctly HOT 2
- Bug: i can't insert yaml by using linger HOT 5
- FR: improve YAML key sort to "at Start" and "at End" order
- Button to exclude file/folder from Linter HOT 2
- Question: Copy `复生吸芽 mAP\@.5` but the pasted text is `复生吸芽 mAP\@`. how to fix it? HOT 3
- FR: Enabling personal additions to auto-correction map HOT 3
- Bug: Smart quotes get applied in Markdown image links HOT 5
- Bug: random deletion of characters/words/line breaks throughout the note HOT 17
- Bug: footnote-after-punctuation fails if reference name contains hyphen
- Question: Custom Command: converting multiple single lines to bullet points HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from obsidian-linter.