suchnsuch / Tangent

The publicly-available modules of the Tangent project.
65 stars 5 forks source link

Copy / Pasting rich text includes extra formatting information #1

Closed taylorhadden closed 1 year ago

taylorhadden commented 1 year ago

The following is provided from a Twitter DM:

if you paste rich text in you get like a header with the text formatting info, like so:

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; text-align: center; font: 13.0px 'Helvetica Neue'; color: #000000; color: rgba(0, 0, 0, 0.85)}

**this is a string**

Copy / Pasting the same thing straight into here just gives the string: this is a string

Perhaps this is something some people would find useful but it definitely wasn't what I needed. I've seen apps that gave separate shortcuts for Paste vs Paste as Plain Text (Cmd Opt V usually, I think), perhaps that might be a solve?

taylorhadden commented 1 year ago

Here is an example of a payload causing this problem:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="2113.5">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
</style>
</head>
<body>
<p class="p1">This is a test of <b>some stuff.</b></p>
</body>
</html>

It appears that the style tag is being included. We don't want that (or really anything in the head).

taylorhadden commented 1 year ago

A fix for this is not in a current build of Tangent yet, but it will be once Tangent is using tangent-html-to-markdown, so I'm marking it as resolved.