When pasting output from Google AI Studio into Obsidian, words break in half at the end of the line

When I copy output from Google AI Studio and Ctrl-V paste into Obsidian, words do not hang together. If the word “and” is at the end of a line and is too long to fit, it’ll break so “a” is at the end of the first line and “nd” is at the beginning of the second.

Ctrl-Shift-V makes words hang together but removes all formatting like headers and bullets. Ctrl-V copying into Obsidian to establish markdown formatting, then Ctrl-X cutting and Ctrl-Shift-V pasting changes nothing, with words still breaking in the middle. Even when pasting into Notepad to force only text and cutting and pasting back into Obsidian, words still break in half at the end of lines.

I can’t find any reference to this problem anywhere. Source mode does not reveal anything that could explain why it’s doing this. The plugin Text Format does not seem to have any feature to address this. How to copy and reformat the text so it breaks properly while preserving headers and bullets?

2 Likes

You can use the Copilot plugin with Google Gemini Pro and copy from the sidebar (you can even use my CSS snippet for Copilot as well).

As for the cleanup, there are plugins and even scripts on the forum. E.g. in this thread I started, someone mentions a Text Format plugin.

Thanks @gino_m! The Copilot plugin looks awesome for many uses. But I’m using Google AI Studio in Chrome with Gemini 1.5 Pro, taking full advantage of the 1M context window with about half a million words of reference material. Looks like Copilot has a new Vault QA functionality, but that won’t fully address my needs.

As for the Text Format plugin, I’ve got that installed and, and it does not provide an option to address this problem.

Do you know what the basic issue is? Why would text become fully breakable, even in a text editor, so that all characters can be broken to the next line, not just spaces?

Can’t you feed the API to the plugin still?

As for Text Format not working… can you try the Templater script I made? I don’t know what else to recommend, off the top of my head…

As for the other question, I have no idea why that happens.

But apart from the CNRL+SHIFT+V method (that makes it lose the formatting), there’s another one that comes to mind: select all text you want and drag the selection to an Obsidian note?

Could set up an API probably, but I’m thinking Copilot isn’t set up to integrate with AI Studio’s capacity for such a huge context. Plus, the way things are set up right now in AI Studio, I get to run quite a lot for free without needing to set up API payment. And I’m happy with the AI Studio interface for doing the work I want to do, without cluttering it more by adding into Obsidian.

As for selecting and dragging into a note, the problem gets dragged right in with it.

Not sure what to do. I’ll keep looking and come back with a solution if I find one.

The Linter plugin also has rules for pasting and could help you (I have these turned off because for my native language and use cases I have built my own tools):

Alternatively, if you are wise on AI stuff, I have seen some Template method with the Text Generator plugin where you tell the robot to clean up text for you. But that’s (free) credit down the drain, of course.

Linter looks like a useful plugin, but looking through its documentation I do not see anything that addresses this particular problem. Lines break in the middle of a word with no hyphen added, for example, no leading or trailing whitespace, etc.

Text Generator also looks interesting, but again, I’m not sure how it will enable me to base my interactions with Gemini 1.5 Pro on half a million words of context, which is what I need.

These may not be the solution I’m looking for, but I do appreciate your bringing these plugins to my awareness. Thanks!!

Yeah, so the final solution may lie in the settings of Google AI Studio. Try to look for a way to save output to file or something.

I’m over in the Google Developers Discord community asking for help, and it seems this formatting weirdness is a thing. There may not be a solution at this point, according to one person at least.

But really, though. How is it that characters in a stream of text behave differently than normal? What exactly could be causing that? I mean, they’re not normal characters, right? Because they’re not being treated normally by any app. But they have normal appearances.

I tried to go online (makersuite.google right?) to have a look but since the new 1.5 version I get no output (with VPN). So I cannot have a look. Apparently I need to sign out everywhere and back in to have my API work? … Copilot does output, though (I only use this for some translations, mind you; Gemini 1.0 was stupider than the old OpenAI 3.5 chat robot, it seemed).

As for the stream of characters having these breakups, you said the paste no formatting way didn’t have this issue, so it’s some cosmetic interference of some sort? I have no idea. Most irritating, indeed.

It’s at https://aistudio.google.com. You can create a new API in there.

And yes, irritating. Can’t be cosmetic, though, must be something more or it wouldn’t be showing up pasting into multiple apps. Right? IDK.

OK, new insight.

Here’s a screen clipping of AI Studio with Chrome DevTools open to show what’s going on.

Every freakin’ letter is wrapped with a span, and the class has overflow-wrap set to anywhere. At least, I think that has something to do with it.

Anyway, I know this is clearly not an Obsidian problem, but is there a way to remove the spans and keep other formatting?

Quick update with the best solution so far:

  1. Copy the output you want.
  2. Paste into Word.
  3. Select all, cut from Word and paste into Google Docs.
  4. Select all, set background to no color and text to black if necessary.
  5. Select all, cut from Docs and paste back into Word.
  6. Finally, select all, cut from Word and paste into Obsidian.

This keeps the maximum amount of formatting and normalizes letter/word behavior.

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