Single-line styled text appears as double-spaced when pasted into Canvas with KM action

I have to believe I'm missing some obvious feature of what I think is Markdown, but I'm missing it.

When I use an action to paste styled text into a Canvas text field, it appears that extra space is added between the lines.

I'm pretty sure the text field in Canvas is a markdown space, so I had hoped that
would generate closely spaced lines, but
is not being interpreted.

Now \n IS being interpreted as paragraph breaks (that is, lines with extra spacing between them).

What I'm trying to do is preserve the close spacing of lines of text when the text is pasted into Canvas's text field. I've tried to us \n \f
all to no avail. I also tried using shift-return in the styled text field in KM.

"Canvas" ?

1 Like

Ah, since you mention markdown, I think perhaps you are referring to the “canvas” feature in Obsidian. Either way, it sounds to me as though you want to replace two line breaks with one. You could do that in KM by searching for “\n\n” and replacing it with “\n”.

Canvas is a education Learning Management System (LMS).

I'm actually pasting text into the Canvas text field (in Safari).

Once pasted, the text still has one line break for each of my lines, but the spacing is wider (as per single-space vs double-space).

I can not figure out how to paste the text such that it appears in the text field of Canvas as single space, the way it was styled in the KM "Paste with styled text" action.

When you paste styled text into a Canvas text field, even if you use Keyboard Maestro’s "Paste Styled Text" action, Canvas may be interpreting that text as HTML — not as "pure styled text" or raw Markdown and applying its own CSS.

You may have your own custom Style Sheet (CSS) in Safari's preference under advance also set but I highly doubt it. Things can get weird in a browser so for things like this I like to check in a couple different browsers with the different things you have tried to see if you get the same results.

"To login to Canvas, open your web browser. Chrome is our recommendation, but here is a full list of supported browsers." Certainly try it in Chrome.

See if you can replace all line breaks (\n) with <br> manually in Keyboard Maestro before you paste.

  • Before pasting, use KM's Search and Replace action to:
    • Search for: \n
    • Replace with: <br>

Then paste the result into Canvas.

Canvas might interpret <br> properly as a soft line break, meaning no double-spacing. This might not work still though if you are shift returning and it is not working for you.

Thanks for the thorough and thoughtful response.

I tried adding <br> to the KM action. It pastes into Canvas as "<br>". (It doesn't get interpreted into a soft line break.:frowning: )

To get a soft line-break (so it isn't interpreted as an HTML <p>) you'd use Shift-Return when typing -- so either use those instead of Returns in your text or search'n'replace in your macro.

The S'n'R method will depend on how the characters are handled when Pasted so you'll have to try it and see -- I couldn't get the Unicode "soft return" U+2029 character to work in Word, but that's probably me doing it wrong :wink:

Another way would be to paste in one line at a time, following each with a Shift-Return "Keystroke" action:

image

...which does work in Word, and should in your browser.