mugiwara85/CodeblockCustomizer

doc comment rendering & linenumber scrolling

Closed this issue · 14 comments

Thanks for your excellent job!It's almost the best codeblock plugin of Obsidian now. Howerver I still find 2 bugs as following:

1. doc comment rendering

1.1 enabling CodeblockCustomizer

image-20230524180813823

<div class="codeblock-customizer-RVline">
  <div class="codeblock-customizer-RVline-number" style="--codeblock-customizer-RVline-number-color:#2B2B2F; --codeblock-customizer-RVline-number-textColor:#6C6C6C;">7</div>
  <div class="codeblock-customizer-RVline-text"> * <span class="token keyword">@param</span> <span class="token class-name"><span class="token punctuation">{</span>number<span class="token punctuation">}</span></span> <span class="token parameter">key</span></div>
</div>

The doc-comment token of line 7-11 is rendered as common text

1.2 disableing CodeblockCustomizer

image-20230524180924999

<span class="token doc-comment comment">/** 
 * <span class="token keyword">@param</span> <span class="token class-name"><span class="token punctuation">{</span>number<span class="token punctuation">}</span></span> <span class="token parameter">key</span>

    ...

</span>

The doc-comment token is rendered right (because it is in a span that has class doc-comment and comment)

2. linenumber scrolling

image-20230524181231267

Only almost the best? :) If you have ideas for new features, or how to make it better, feel free to tell me.
Regarding the problems:

  1. --> I will look into this this week.
  2. --> What exactly is the problem there? That it displayed a scrollbar? If yes, should it have broken the line into a new line?

I hope it would work like :
line-number-fixed
This is the way that "Better CodeBlock" plugin use to render linenumber. I think it's better to read.

So, it's not the scrolling that is problematic, but rather that when you scroll the line number is not displayed, because it is scrolled with the text, and is not visible? This is what you mean?

Exactly.

Ok, I just wanted to be sure, that I understood the problem. But you are right, that shouldn't be that way. I will look into this as well.

Thanks for your reply! Keep up the good work.

Quick question. Is the vertical scrollbar really necessary? Wouldn't it be better if the text would wrap like this:
image
In editing view it works this way already, so it would make sense to do the same in reading view.

Since whether to wrap line is also an option in IDE settings, I think it's a matter of personal preference. I treat line-wrap (which depends on the width of page) as a damage to indentation style of my code, as following:
image

Which setting is that? This one?
image
This has no effect on my machine. I found regarding this problem 1-2 smaller problems as well. And your bug with the comment is a good catch!

I mean the setting of IDE like Intelli J. It has an option about line-wrap like following:
soft-wrap

Wouldn't it be better if the text would wrap like this

Since you asked if line-wrap is better, I want to use the conditon that IDE makes wrap-line as an option to prove that it's a matter of personal perference.

ok, I understand, however, I am not yet sure if it is possible. Obsidian works a little different unfortunately. I am having a little trouble regarding this, but I do what I can :)

Thanks for this amazing plugin! Finally codeblocks can be styled nicely! I too would be very interested in maintaining the line number to the side whilst scrolling. Could this be done via css position absolute and some margin?

With regards to line wrap vs no line wrap, I prefer to read code with no line wrap and edit with line wrap so in reading mode, it would be very preferable to be able to have a scrollable agnostic line numbering.

The next release will contain the fix for the line numbers and comment rendering as well. I am having a little trouble to get all the things fixed, because now if I fix something it breaks something else. Unfortunately, CSS is not my strength. I think in the worst case I can release the next version with the fixes. It will also include a new feature where you can override line numbering behavior with ln:true or ln:false for specific code blocks. Hang in there a little :)

Both problem should be fixed in v1.2.0. Sorry it took this long. Try out the current version, and report back if you experience any other problems. Please also read the README.