javalent / admonitions

Adds admonition block-styled content to Obsidian.md
MIT License
1.08k stars 72 forks source link

Line breaks not showing correctly in editing preview #266

Closed shayyya1 closed 1 year ago

shayyya1 commented 1 year ago

When writing an admonition, lines seperated by line breaks in the code will not be seperated in the editing preview 2022-10-15 15_05_20-4 Conditional probability - uni - Obsidian v1 0 0 Results in image

rotem443 commented 1 year ago

Happens to me as well since obsidian 1.0

KeiyuKensei commented 1 year ago

Please implement this plugin for version 1.0.0 as soon as possible. Thank you very much

nosas commented 1 year ago

This is expected behavior from a markdown point-of-view, but unexpected for Obsidian.

rootless69 commented 1 year ago

I also have this issue. Seems like removing a selector in assets/main.css is a quick fix: https://github.com/valentine195/obsidian-admonition/blob/2fb38ccc0b39ada8d3d0a4476e9ff3333c52c3ae/src/assets/main.css#L304-L306

The selector right before can also be removed: https://github.com/valentine195/obsidian-admonition/blob/2fb38ccc0b39ada8d3d0a4476e9ff3333c52c3ae/src/assets/main.css#L299-L302

This makes line paddings in live preview look almost identical to read mode.

For admonition:

`````````ad-info
title: Title
First line.
After a single line break comes a second line.

Two line breaks to a third line, followed by a multi line math block:
$$
z=re^{i \theta}
$$
A line break after the math block comes a fourth line.
Then comes some a long text without line-breaks that repeats. Then comes some a long text without line-breaks that repeats. Then comes some a long text without line-breaks that repeats.

Last line.


Before (Live-Preview):
![image](https://user-images.githubusercontent.com/6492687/199980566-70e0b467-52a6-4001-93e5-160f2bd62510.png)

After (Live-Preview):
![image](https://user-images.githubusercontent.com/6492687/199980798-3803310b-18cb-4295-9f36-d313e4bf99ac.png)

Read Mode:
![image](https://user-images.githubusercontent.com/6492687/199981439-7be550f5-078e-4cc6-81a1-21c6e7006fa7.png)
nousernameavailableanymore commented 1 year ago

Puh, crisis averted. Thank you @rootless69 !

For everyone wondering how this works: remove the two CSS snippets @rootless69 posted above from the styles.css in your .obsidian\plugins\obsidian-admonition folder and restart Obisidan.

im-richard commented 1 year ago

I know this is late, but I love you @rootless69 I was writing a few of these today and noticed that the line breaks were completely messed up. I sometimes write a few notes in one box and not having line breaks was making them hard to read.

Appreciate the fix.

Pedroespecial commented 1 year ago

Wonderful - worked a treat. For anyone that might be as 'green' as me: the styles.css file was not formatted and was just a mass of text. I opened it in Visual Studio Code and did a Alt+Shift+F and it all looked nice again and ready to edit :-)

valentine195 commented 1 year ago

Hi, I’ll remove these lines when I get a chance, but you should not edit plugin css directly. Use a CSS snippet. Otherwise the changes will be overwritten on a plugin update.

wlnirvana commented 1 year ago

Look forward to the fix to be released

wlnirvana commented 1 year ago

A sample css snippet that worked for me:

/* See https://github.com/valentine195/obsidian-admonition/issues/266#issuecomment-1303527540 */
.is-live-preview .admonition-content > * br {
    display: inline;
}

.is-live-preview .admonition-content > * {
    margin: revert;
}
sigrunixia commented 1 year ago

Hello everyone.

The PR should fix this issue and the Mathjax issue with spacing as well. If you experience any issues further, please make a new issue.