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

fix(callouts): prevent newline after obsidian callouts title #1026

Closed

Conversation

saberzero1
Copy link
Collaborator

@saberzero1 saberzero1 commented Mar 23, 2024

Closes #1020

This change has the nice added benefit of more closely following Obsidian's callouts specification while not affecting GitHub's Alert Markdown.

Test set used:

---
title: test callouts
---

```markdown
> [!NOTE]
> Useful information that users should know, even when skimming content.

> [!TIP]
> Helpful advice for doing things better or more easily.

> [!IMPORTANT]
> Key information users need to know to achieve their goal.

> [!WARNING]
> Urgent info that needs immediate user attention to avoid problems.

> [!CAUTION]
> Advises about risks or negative outcomes of certain actions.
```

```md
> [!NOTE]
> Useful information that users should know, even when skimming content.

> [!TIP]
> Helpful advice for doing things better or more easily.

> [!IMPORTANT]
> Key information users need to know to achieve their goal.

> [!WARNING]
> Urgent info that needs immediate user attention to avoid problems.

> [!CAUTION]
> Advises about risks or negative outcomes of certain actions.
```

> [!NOTE]
> Useful information that users should know, even when skimming content.

> [!TIP]
> Helpful advice for doing things better or more easily.

> [!IMPORTANT]
> Key information users need to know to achieve their goal.

> [!WARNING]
> Urgent info that needs immediate user attention to avoid problems.

> [!CAUTION]
> Advises about risks or negative outcomes of certain actions.

@saberzero1 saberzero1 changed the title fix callout newline after callout title fix(callouts): prevent newline after obsidian callouts title Mar 23, 2024
@saberzero1 saberzero1 marked this pull request as ready for review March 23, 2024 19:24
@jackyzha0
Copy link
Owner

can you also test this with custom titles?

> [!NOTE] test title
> Useful information that users should know, even when skimming content.

we originally added this transform to handle this case

@saberzero1
Copy link
Collaborator Author

can you also test this with custom titles?

> [!NOTE] test title
> Useful information that users should know, even when skimming content.

we originally added this transform to handle this case

> [!NOTE] with a title
> This note has a title.

Results in:

<blockquote class="callout note" data-callout="note">
  <div class="callout-title">
    <div class="callout-icon"></div>
    <div class="callout-title-inner">
      <p>with a title </p>
    </div>

  </div>
  <p>This note has a title.</p>
</blockquote>

Which looks like:

image

Copy link
Owner

@jackyzha0 jackyzha0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry one more test for my sanity :)

> [!NOTE] with a title _and_ **formatting**
> This note has a title. yay

@saberzero1
Copy link
Collaborator Author

saberzero1 commented Mar 24, 2024

sorry one more test for my sanity :)

> [!NOTE] with a title _and_ **formatting**
> This note has a title. yay

Alright, one second.

EDIT:

<blockquote class="callout note" data-callout="note">
  <div class="callout-title">
    <div class="callout-icon"></div>
    <div class="callout-title-inner">
      <p>with a title <em>and</em> <strong>formatting</strong>
        This note has a title. yay</p>
    </div>

  </div>
</blockquote>

Changing the markdown to:

> [!NOTE] with a title _and_ **formatting**
>
> This note has a title. yay

Fixes that issue (this is basically the old behavior).

I'll look into a fix shortly.

@saberzero1
Copy link
Collaborator Author

I'll need some more time to implement an elegant fix.

Currently we check for newline \n characters in text value to split the title, but emphasis, strong, etc., type have children with a text value, instead of a text value themselves.

I'll let you know when I have properly addressed this. @jackyzha0

@aarnphm
Copy link
Collaborator

aarnphm commented Dec 3, 2024

Let's also include this in #1496

@aarnphm aarnphm closed this Dec 3, 2024
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 this pull request may close these issues.

Markdown Code in Code Block is Incorrectly Rendered
3 participants