Mis-formatted text after code block

Dear Obsidian guru,

I’m writing about miss-formatting of text occurring after a code-block, particularly with indents that should not be occurring. Having searched the forum, I found my issue to be similar to a past issue from another user: [Miss-format of Indented Plain Text after a Code Block](https://Miss-format of Indented Plain Text after a Code Block)

-Secondly, my Community plugins are disabled as I don’t use any 3rd party add-ons. Lastly, I’m not a programmer, and have I done any tinkering to obsidian’s code , and I may not understand any CS lingo you might use.

Steps to reproduce

  1. Create a note and paste the notes from step 2
"[ ]" represents multiple search patterns that will match any characters in the brackets
-  can be used to search a range letters within the alphabets. E.g., REGEXP '[a-h]e' will search records that have any alphabet from a-h preceding an e
- SYNTAX:
```SQL
	WHERE last_name REGEXP '[gim]e'
	--- searches for anyone whose last name contains "ge" OR "ie" OR "me"; meaning anything GIM preceding. Can reverse the order to 'e[gim]' to search "eg" OR "ei" OR "em"
```

 ######  IS NULL Operator:
	- Finds records where value for a column is null or is blank (i.e., no data present for a column). *IS NOT NULL* will return columns where the values is not null
	 - Great for: "Are there any records missing in this column?"

Expected result

I expect to see text neatly formatted in reading mode, where the code block formatting ends and is not carried over to the indented text below it. Image taken in reading mode

Actual result

The code block formatting carries over with the indented text below the code block, with the heading “IS NULL Operator” (note the light gray hue, instead of light blue hue in the reading mode)

Here’s the same screenshot in edit mode:

Environment

  • Operating system: Windows 11 Pro (Per my PC’s settings, Obsidian’s debug info below is incorrect!)
  • Debug info:
    SYSTEM INFO:
    Obsidian version: v1.1.9
    Installer version: v1.0.3
    Operating system: Windows 10 Pro 10.0.22621
    Login status: not logged in
    Insider build toggle: off
    Live preview: on
    Legacy editor: off
    Base theme: dark
    Community theme: Dracula + LYT v0.0.0
    Snippets enabled: 0
    Restricted mode: on

RECOMMENDATIONS:
Custom theme and snippets: for cosmetic issues, please first try updating your theme and disabling your snippets. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community theme and snippets.


Additional information

The code block formatting isn’t carrying over — you can see that there’s a heading in between that isn’t formatted as code.

In Markdown, indenting text by 1 tab or 4 spaces marks it as a code block. The fenced code block style (```) is a a third-party addition that has become popular. Because of it that format’s popularity, and because the indentation rule was a poor choice, people sometimes don’t know about the indentation rule.

If you indent your text by 3 or fewer spaces, it should be fine.

PS. You can make your code block part of the list item above it by indenting it.

Input:

* SYNTAX:

    ```
	WHERE last_name REGEXP '[gim]e'
	--- searches for anyone whose last name contains "ge" OR "ie" OR "me"; meaning anything GIM preceding. Can reverse the order to 'e[gim]' to search "eg" OR "ei" OR "em"
    ```

Result:

  • SYNTAX:

    WHERE last_name REGEXP '[gim]e'
    --- searches for anyone whose last name contains "ge" OR "ie" OR "me"; meaning anything GIM preceding. Can reverse the order to 'e[gim]' to search "eg" OR "ei" OR "em"
    

I’ve attempted to edit your post. If you want to show Markdown syntax, including some triple backtick codeblocks, you can surround the entire area with 4 backticks. I’ve attempted to put the backticks in the right place, as far as I can tell, so your syntax can be copied.

You’ve linked to a post where the answer was “that’s how Markdown works”. And as far as I can see from your explanations, the answer to you is, “that’s how Markdown works”.

I’m moving this to Help.

  • You have a space before your “IS NULL Operator:” heading. So it isn’t formatting as a valid header. Remove the space.
  • If you want to nest bullets, instead of making a code block, you need to have a bullet on the top. Indenting the first bullet just makes the paragraph indented, and it turns it into a code block.

No:

    - bullet 1
    - bullet 2

Yes:

- bullet 1
    - bullet 2
    - bullet 3
3 Likes

I didn’t know about the 4-backtick trick! I’ve been indenting the whole thing.

@CawlinTeffid, Keep increasing the number of backticks if you want show of another code block, or switch to tilde’s, ~~~. All legal as code fences.

2 Likes

Thank you @rigmarole and others for helping to troubleshoot this problem.

As an obsidian beginner, Markdown behaves oddly thinking indentation = code block sometimes and not at other times, which can be annoying to read.

Your suggestion on nesting bullets and how you presented (No vs Yes) was very helpful as a non-CS guy and I can see your point. Having tested it, I now know how to format text around code blocks which I didn’t come across before.

Would definitely endorse having your excellent explanation in the help.obsidian.md domain (specifically here: Format your notes - Obsidian Help), so new users can understand formatting after code-block.

Thank you! :slightly_smiling_face:

1 Like

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