Closed empik-foto-it closed 2 years ago
What would be the use case?
espetialy tab
-> where is no Tab at all -> thera are spaces
Tabs are useful because I can use CSS Snippet which will help me to show level of intend in lists
For me this option could be synchronized or repleaced by reading the Obsidian parameters:
When I set Use tabs
it means that I prefer to have tabs
then `spaces'
Definitely open to a Pull Request since I'm not sure when I'd be able to get to this.
Instead of creating a new issue I'll tag onto this one. To me the List Indent
setting should only affect what's before the bullet character. It seems to be appropriately following what I have set in Obsidian regarding point 3 of @dariuszkowalski-com's comment above regarding inserting spaces instead of tabs when I have List Indent to tabs. However, the problem I'm running into is that it puts extra spaces after the bullet character. Regardless which option I have set for List Indent every line should always be [indent characters] [bullet] [ONE space] TEXT
Any plans to fix this one? 👀
Hi all,
I find this workaround solution. Just update runPrettifier
function in main.ts
runPrettifier() {
const view = this.app.workspace.activeLeaf.view;
if (view instanceof MarkdownView) {
// Do work here
const editor = view.sourceMode.cmEditor;
// Remember the cursor
const cursor = editor.getCursor();
editor.execCommand("selectAll");
let text = editor.getSelection();
prettifier(text, this.settings, { today: moment(), tags: [] })
.then((data) => {
let output = String(data || '');
// modify the output generated by remark
// support image link. ![[imagefile]]
//@ts-ignore
output = output.replaceAll('!\\[\\[', '![[');
// fix indentation issue
output = output.replace(/- {2,}/g, '- ');
//@ts-ignore
output = output.replaceAll(' ', '\t');
try {
// Calculate difference of lines and provide feedback
const n_before = String(data).split(/\r\n|\r|\n/).length;
const n_after = String(text).split(/\r\n|\r|\n/).length;
const lines_changed = n_before - n_after;
if (lines_changed != 0) {
if (lines_changed > 0) {
new Notice("Prettifier: added " + lines_changed + " lines.");
} else {
new Notice("Prettifier: removed " + lines_changed + " lines.");
}
}
// Update the cursor
if (cursor.line) {
cursor.line = cursor.line + lines_changed;
}
} catch (err) {
console.error(err);
}
editor.replaceSelection(output, "start");
editor.setCursor(cursor);
}).catch((err) => {
console.error(err);
if (err.message) {
new Notice(err.message);
}
});
}
}
@tuan3w Ohhh nice! What do you think of opening a Pull Request with this code?
@cristianvasquez I noticed that the code @tuan3w code was removed in the 0.1.0 release, breaking the indentation again. Do you have any plans to implement this fix again?
Please fix this again
I updated the plugin to accept one space or a tab :)
It doesn't work As espected: (Obsidian 0.10.2 plugin 0.0.6) (Obsidian 0.10.4 plugin 0.0.8)
afer
-
one space -> ok, but intend has two spaces (two dots)Expected results:
mixed
-
char , secound has 4 spaces which make an intend and 1 space after a-
Expected results:
tab
-
char , secound has 4 spaces which make an intend and 3 spaces after a-
. there is no a TAB char at allExpected results:
Originally posted by @dariuszkowalski-com in https://github.com/cristianvasquez/obsidian-prettify/issues/24#issuecomment-750026911