Feature Request: Comment Formatting

Instead of creating yet another custom syntax, I‘d suggest to support CriticMarkup. CriticMarkup is supported already by quite a few apps, and it‘s well designed & thought thru (so that it doesn‘t clash with any other syntax, yet is still easily recognizable).

With CriticMarkup syntax,

{==this would be highlighted text==}
{>>this would be a comment which would be left out in preview<<}

Here‘s a somewhat contrived example:

4 Likes

Some other people have shown their solution, but additionally, if you are just working in obsidian, if you use the LaTeX format for commenting, it also hides it from the preview mode.

For example: $% this is a comment$

I think it works as you wish, the only thing you have to pay attention is that the last letter should attached to the second “$” sign.

1 Like

It’s quite convoluted. Ideally there wouldn’t be more than 4 symbols (2 before, 2 after - or 3 before 1 closing).

Personally, I don’t think so. On the contrary, I think that by choosing a three-character markup this greatly increases chances that there’s no clashes with any other use case. And, at the same time, this allows to choose semantically meaningful characters (like ++ or -- for additions/deletions etc) which helps to memorize/recognize them.

In addition, if the app supports adding highlight/comment markup via a keyboard/menu command and subdues the markup visually via appropriate syntax coloring, then there shouldn’t be an issue with this.

Here’s another (more real-world) example how this could look:

1 Like

Another thing to consider is how this might impact publish and export (e.g. to PDF). I don’t think tools like pandoc can deal with the CriticMarkup syntax in particular, but it seems that the one suggested by @ryanjamurphy plays well with it (albeit with some caveats for the YAML metadata).

1 Like

Is anyone aware of any current comment format that works for putting a [[llinked note]] while still being able to click on it.

My main purpose is to be able to embed notes in other notes, without [[links]] showing in embed preview

I tried the following:

/* [[new note]] */
<!-- [[new note]] -->
$% [[new note]]$
[//]: # ([[new note]])

None of them seem to succesfully comment out while still making it clickable.

I suspect this might not be possible

The perfect solution to this problem is in here:

Remove Yaml Front Matter from embeds

Meta Post - Common CSS Hacks

unfortuntaly it doesn’t work with v.0.9.3 anymore

Interesting challenge. If you don’t usually use code (backticks) or highlight (equals signs) syntaxes in your markdown, you could probably achieve this with some custom CSS. Hide the unused syntax in preview (display: none;) and it should remain clickable in edit but hidden in preview.

1 Like

That’s a nice solution, what would it look like if I where to use (equal signs) for instance?

how do I determine == (equal signs) in combination with { display: none; } ?

Thanks, I think this might be what I’m looking for

In Obsidian, this markdown ==some text== becomes this HTML <mark>some text</mark>; i.e., highlighted text.

If you don’t use <mark> normally, you should be able to add something like this to obsidian.css to hide <mark>’d text in Preview:

mark {
    display: none;
}
2 Likes

got you, that makes sense, I’ll be playing with it! I appreciate the help!

2 Likes

Nothing to add but I just want to say I love these forums bc it feels like I snuck into a super secret club of really smart people and content creators for free.

I clicked on this link, gained a cool insight about commenting (something I had wondered before). And it turns out… CGPgrey is here, casually asking a question. Also saw Curtis Mccale the other day who is another one of my fav content creators.

I love it

5 Likes

If Obsidian Publish is to one day allow users to utilize their own custom CSS, then it may make sense that Obsidian adopt the ability to specify a CSS class for a block elements like many Markdown flavors already do.

Given that, rather than introduce another Obsidian-specific markup, one could turn any block element into a ‘comment’ simply by adding a CSS class to it that included display: none;.

This entire paragraph could be visible in the editor and hidden in preview mode, without adding whitespace, and without creating new markup, just by adding a class.{.my-hidden-class}

4 Likes

Super happy with this community as well, @ishgunacar by far my favorite community online, you comment made my day!

1 Like

@0x4A I don’t know why I didn’t think of that, that’s a genius approach!
I understand obsidian publish doesn’t allow for custom css yet, but is this approach already possible in a local vault by specifiying this in obsidian.css?
Or is this something that’s not possible yet?

Currently only using the method @ryanjamurphy described above, by hijacking an already existing markup.

There’s a decent argument for it eventually being included though, as it already has an adopted syntax in Pandoc and at least two Markdown flavors, maybe more.

1 Like

@santi @0x4A Oh, good point, though. Arguably you can just do:

Some text in a paragraph. <span style=“display:none;”>some more text including a [[link]].</span> Et cetera.

Without needing to highjack markdown. Not as clean, but saves you from losing e.g., the ability to highlight stuff.

2 Likes

thanks @ryanjamurphy I just tried it and it only works if I remove the double quotes around display:none

Some text in a paragraph. <span style=display:none>some more text including a [[link]].</span> Et cetera.

I agree, it might not be as clean as <mark> but it’s definetly a good idea to have something like this to not interfere with <mark>


Would it be possible to integrate this with .markdown-embed-content
so that it shows in note preview, but not in ![[a note embed]]

I got note embed working with <mark>
now preview in a note shows noramlly, but when wrapped in <mark> a highligh, </mark>
and on a note embed the highlight is hidden. This is exactly what I was looking for thanks @ryanjamurphy and @0x4A for all the help

thisis what I got on my obsidian.css

  .markdown-embed-content mark {
      display: none;

It doesn’t seem to show previews with [[links]] in order to fix this
what I’d love to be able to do is make it work with <span style=display:none> so that I don’t have to interfere with <mark> and solve [[links]]

I’d like to bump this if possible. Currently, as far as I can tell, there’s no formatting which will hide a comment both when previewed in Obsidian and when a vault is Published to the standard theme. Publish doesn’t have custom CSS yet.

I think this trick works without regard to CSS. But custom CSS in Publish is out: Obsidian Release v0.9.4 (Insider build)