Skip to content

Bug: Line breaks are missing/swallowed when clipping posts from x.com (Twitter) #336

Description

@agiledolphin

Describe the bug

When using the Obsidian Web Clipper to capture posts from x.com (formerly Twitter), the line breaks within the tweet text are entirely missing/swallowed in the generated Markdown. The entire tweet content is squeezed into a single continuous block of text, making it difficult to read.

To Reproduce

  1. Install the official Obsidian Web Clipper extension.
  2. Navigate to any multi-paragraph post on X, for example: https://x.com/AndrewYNg/status/2071988145667928442
  3. Click the clipper extension icon and view the preview using the default template (or any template using default {{content}} / |markdown filter).
  4. Notice that all paragraph breaks and line breaks from the original tweet have disappeared.

Expected behavior

The clipped Markdown should respect and preserve the original line breaks/paragraphs of the tweet, matching the layout displayed on the webpage.

Environment & Context

  • Platform/OS: macOS / Windows / Linux
  • Browser: Chrome / Edge / Brave / Firefox (Choose your browser)
  • Extension Version: [e.g., v1.0.x - check your extension version]

Additional Context & Technical Insights

The root cause stems from how x.com renders text layouts in its modern frontend architecture:

  1. X doesn't use standard <p> or <br> tags for line breaks inside the tweet body. Instead, it relies on nested structural <div> / <span> elements combined with CSS properties (like white-space: break-spaces) to visually render breaks.
  2. The default HTML-to-Markdown converter (like Turndown used under the hood) fails to recognize these CSS-driven visual breaks and strips them away, concatenating everything into a single line.

Current Workaround:
As a temporary fix, using a custom selector to extract raw text bypassing the default HTML converter works perfectly because the browser's text API natively translates those CSS breaks into standard \n characters:

{{selector:div[data-testid="tweetText"]|first}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions