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

Newlines without > break callouts (Obsidian inconsistency) #1628

Open
Tracked by #1496
MaxWolf-01 opened this issue Dec 1, 2024 · 0 comments
Open
Tracked by #1496

Newlines without > break callouts (Obsidian inconsistency) #1628

MaxWolf-01 opened this issue Dec 1, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@MaxWolf-01
Copy link

Describe the bug

In Obsidian, both of the below ways of defining a callout with multiple lines work, not in quartz:

> [!note]
Line
Anotherone

> [!note]
>Line
>Anotherone

Expected behavior

The callout should only stop after an empty newline, not requiring > on every line.
The same goes for nested callouts:

> [!note] Outer 
Outer
> > [!note] Inner 
> > Inner
>Inner 
>
>Outer

image

It would be nice to have a core plugin to enable this Obsidian markdown feature, even if it is not markdown standard, as with other features.

Desktop (please complete the following information):

  • Quartz Version: v4@latest
  • node Version: v22.11.0
  • npm version: 10.9.0
  • OS: Ubuntu 22.04
  • Browser Firefox

Additional context

The following transformer fixes it (not extensively tested yet):

import { QuartzTransformerPlugin } from "../types"

export const CalloutNewlineFix: QuartzTransformerPlugin = () => {
  return {
    name: "CalloutNewlineFix",
    textTransform(_ctx, src) {
      if (typeof src !== "string") {
        src = src.toString()
      }

      return src.replace(
        /^> \[!(\w+)]\s*\n((?:[^>\n][^\n]*\n?)+)/gm,
        (_match: string, type: string, content: string) => {
          const fixedContent = content
            .trim()
            .split("\n")
            .map((line) => `>${line}`)
            .join("\n")

          return `> [!${type}]\n${fixedContent}`
        },
      )
    }
  }
}
@MaxWolf-01 MaxWolf-01 added the bug Something isn't working label Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant