Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single Line Comments in Language Block Codes are hidden #69

Open
ebouchut opened this issue Nov 10, 2023 · 6 comments · May be fixed by #70
Open

Single Line Comments in Language Block Codes are hidden #69

ebouchut opened this issue Nov 10, 2023 · 6 comments · May be fixed by #70

Comments

@ebouchut
Copy link

ebouchut commented Nov 10, 2023

👏 First off thank you @HeroBlackInk for this useful plugin.

I noticed the following issue.

Summary

When editing a note with a single-line comment in a language code block, with Ultimate Todoist Sync for Obsidian plugin enabled, then the comment is not shown (whatever the value of Editing Mode (Live Preview or Source mode)).

Description of the Issue

When I type this in an Obsidian note:

```java
// Single-line comment
```

Then I expect, the // Single-line comment to be shown in the editor, like so

// Single-line comment

❌ Whereas it is not when Ultimate Todoist Sync for Obsidian is enabled whatever the value of Editing Mode (Live Preview or Source mode), and I get this instead.

FYI, the issue is the same for a single-line comment in a Ruby code block.

```ruby
# Single-line comment
```

✅ When I disable the Ultimate Todoist Sync for Obsidian plugin, the comment is shown as expected.

How to Reproduce this Issue?

  • Create a new Obsidian Vault
  • Install and enable the Ultimate Todoist Sync for Obsidian plugin
  • Create a new note and paste this
    ```java
    // Single-line comment
    ```
    
@MAWSpitau
Copy link

I do have the same problem, but with HTML-comments like:

<!-- Kommentar -->

This is what the hidden line looks like...

I would love to have this Bug fixed and see my comments again ;)

@MAWSpitau
Copy link

You can fix this with this workaround:

  • go to the styles.css of the plugin. (vault/.obsidian/plugins/ultimate-todoist-sync)

Change this:
.cm-line:not(:hover):not(.cm-active) span.cm-comment { display: none; }
to this:
/* .cm-line:not(:hover):not(.cm-active) span.cm-comment { display: none; } */

What it does:

  • The ID of the Todoist task is written down in %% %% Obsidians Comment syntax.
  • The author does not want to see us the id, so he hides it.
  • But ALL Comments are now hidden.
  • The change above is commenting this feature out.
  • Now you can see all your comments again. Even the ones in the todoist-Line, but that does not bother me.

@ebouchut
Copy link
Author

ebouchut commented Nov 16, 2023

👍 Thank you @MAWSpitau for this workaround.

@ebouchut
Copy link
Author

🧐 I will try to build a CSS selector to only target/hide the Todoist comments.

@ebouchut
Copy link
Author

ebouchut commented Nov 17, 2023

I have a CSS rule handy to hide the start and end Obsidian comment surrounding the todoist_id.

.cm-line:not(:hover):not(.cm-active) > .cm-comment.cm-comment-start:has(~ .dataview.inline-field > .dataview.inline-field-key[data-dv-key="todoist_id"]),
.cm-line:not(:hover):not(.cm-active) > .cm-comment.cm-comment-start:has(~ .dataview.inline-field > .dataview.inline-field-key[data-dv-key="todoist_id"]) ~ .cm-comment.cm-comment-end
{
    display: none;
}

✅ This fixed the issue for me, it:

  • hides the todoist_id start and end comment delimiters (%%) except when we hover over the line or edit the task.
  • 🎉 does not hide other types of comments (I tested Java HTML and Ruby)

It is brittle because it depends on the CSS classes of the Tasks Obsidian plugin.

@MAWSpitau and anyone else interested, let me know if this works for you.

@ebouchut ebouchut changed the title Single Line Comment in Language Block Codes are hidden Single Line Comments in Language Block Codes are hidden Nov 17, 2023
ebouchut added a commit to ebouchut/ultimate-todoist-sync-for-obsidian that referenced this issue Nov 17, 2023
Fixes an issue where non-Todist single line comments (Java, Ruby, HTML...)
were hidden.
See HeroBlackInk#69 (comment)
@ebouchut ebouchut linked a pull request Nov 17, 2023 that will close this issue
@Tejeev
Copy link

Tejeev commented Mar 28, 2024

I also see this, so I like having a fix. Thank you!
I've tried the fix, and it does not hide the todoist_id, so I've elected to just comment out the comment hiding CSS from styles.css for the time being. Either way, I'm grateful to have my comments back, so thank you guys :)

Regarding the final fix, I know my preferences are just that, mine, but I thought I'd share them just in case they are useful.

  • I would prefer it not to have more dependency on another tool, unless both projects are partnering (I've seen too many houses of cards come tumbling down because someone made a change, and these addons are becoming too important to my workflow)
  • The todoist_ID should be hidden, and no other comments. I like my comments :)
  • When on the line in edit mode, or mousing over the line, maybe todoist_id is visible

On a related note, I'm not sure if it's my mistake or some bug but I'm always able to see the todoist_id in edit mode, though the %% are hidden when not moused over or editing the line. I haven't had time to investigate this yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants