Is it possible to disable underscore displayed as italic and bold?

I just use asterisks for italic and bold. As a programmer I write lots of names with underscore in it. Inline code could be a way but it’s kind of annoying.
It’s possible to disable underscore displayed as italic and bold forever?

I wish that underscores and asterisks in the middle of words had never been part of the Markdown spec. It was such a dumb idea.

Hi,

Don’t think it’s possible to disable it, but it’s possible to work around using underscores in normal text:

  • within_a_word shouldn’t be a problem
  • _at_start it can be prepended with \ to not render the italics
  • italics as per standard
  • in codeblocks it shouldn’t be _an issue_
-  within_a_word shouldn't be a problem
- \_at_start it can be prepended with `\` to _not_ render the italics
- _italics_ as per standard
- in codeblocks it shouldn't be `_an issue_`
  • Update: Within a paragraph you can also use not an issue. It does however render as code, so it might need some styling for display purposes, but then again in some cases like filename I kind of like the difference in styling.

Hope this helps,
Holroy

2 Likes

Underscores inside words don’t trigger italics on my system. If you’re seeing that, maybe it’s a theme issue or out-of-date installer or something?

I also wish for this. My Jekyll install writes filenames with underscores all over the place.

I am increasingly in favor of being able to alter or disable “_” as “italics”. I know there is a workaround of adding a backslash in front, or space, etc.

But here’s one reason not to.

Google Drive files often have underbars in the URL, (file[“alternativeLink”]) .

I am running a python script to make a (markdown) table of my Google Drive files, related to folder in my Obsidian vault.

But the “_” underscore character breaks the markdown-formatted table.

I have added a backslash in front of them in my script so the table works, but of course that breaks the URL to the GDrive file.

If I should post this on another thread, please let me know. I searched for it, but couldn’t find it again.

1 Like

Which theme are you using, where the underscore doesn’t auto-italicize? I disabled my themes and I still see the automatically-italics.

for example:

| file id | Name |
|---|---|
| 1W6lwbEq6s-_d5wdO_eLzb | zoo |
| 1W6lwbEq6s-d5wdOeLzb  | zoo |

doesn’t render as a markdown table in my Sandbox Vault:

When I remove the underscore character(s), or escape them out, it renders:

Note that ironically, this Forum markdown formatter renders my little snippet as I would hope Obsidian would do:

file id Name
1W6lwbEq6s-_d5wdO_eLzb zoo
1W6lwbEq6s-d5wdOeLzb zoo

I’m using the default theme. I’m not on the most current version of Obsidian, so that that could could account for the difference, tho I’m guessing it doesn’t.

In this particular case, I notice there’s a dash right before the underscore. I think Live Preview sees that as a word boundary. As an experiment, try deleting that dash (obviously this isn’t a solution, it’s just to confirm my guess).

Also, do you see the same behavior in Eeadinf View?

Yes, deleting the dash “fixes” it, as does adding a backslash before the _ character.

Adding a character is better for me, as if I delete something, I have no idea where it was, if I try to use the URL of the Google Drive file.

I think EEadinf View = Reading view, and the behavior is as I prefer there. But I don’t switch back and forth much.

Yes,

I don’t really use that view either, but it’s useful to check if you’re concerned about how your text will appear elsewhere, because it renders Markdown more accurately. Live Preview does its best but its hybrid nature sometimes leads to quirks. You can file a bug report, or if one already exists upvote it by clicking the heart at the bottom of the post.

One option I failed to mention in my previous list is to use <code> ... </code>, especially in conjunction with a table this could be a very good option, as in:

| file id | Name |
| --- | --- |
| <code>1W6lwbEq6s-_d5wdO_eLzb </code> | zoo  |
| <code>1W6lwbEq6s-d5wdOeLzb</code>    | zoo  |

Which in live-preview (with Minimal theme) renders as:
image

No extra italics or bold… And in this particular case, it could also be easier to style it if you don’t want it show as code. Now it’s inside a table, so something like td > code should be fairly precise to target use these cells (and not conflict with most other usages of <code>. (Or alternatively, one could even attach a class to the <code class="something"> and use that to inherit style from normal text, if so inclined)).

2 Likes

Thanks for the suggestions.

Regarding themes, here is how it renders in my Sandbox vault with the using “Default” Light theme and no other themes installed.

The td > code is something to consider. Thanks!

Not just code tags, but also backticks would work, like holroy originally mentioned in the 2nd reply to this thread. Just reminding you if you missed that, because you didn’t mention that workaround. (But it sounds like the tags do give you some extra class options)

| file id | Name |
|---|---|
| `1W6lwbEq6s-_d5wdO_eLzb` | zoo |
| `1W6lwbEq6s-d5wdOeLzb`  | zoo |
1 Like

Thanks! I tried that and I see what you mean. I wasn’t aware, so I am glad you mentioned it.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.