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

Support pasting more HTML elements #67

Open
iansan5653 opened this issue Sep 8, 2022 · 2 comments
Open

Support pasting more HTML elements #67

iansan5653 opened this issue Sep 8, 2022 · 2 comments

Comments

@iansan5653
Copy link
Member

iansan5653 commented Sep 8, 2022

This was originally an issue by @imjohnbo in github/special-projects, a private repository:

Summary

Today, content is pasted into GitHub comments (issues, PRs, discussions, etc) as plaintext, except for a few special cases managed by @github/paste-markdown.

It's a laborious process to add formatting and links of the copy source back into the paste target. For example:

  • Copying/pasting part of a GitHub comment into a GitHub comment box – maybe in a different issue – in order to reply to it
  • Copying/pasting part of a Google Doc shared with a customer into a GitHub comment box in order to add context to it
  • ...

This issue would build on https://github.com/github/special-projects/issues/679 and investigate adding Slack-like paste functionality for the features GitHub developers care about, including:

name html markdown
headings <h1>, <h2>... #, ##, etc.
inline code <code> `code`
code block <pre><code> ```code```
bold <strong> **bold**
italics <em> *italics*
ordered lists <ol><li> 1. item
unordered lists <ul><li> - item
task lists ? - [x] completed item
quotes blockquote > a long quote

Example

This Google Doc:

is pasted as:

Big Heading
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris eleifend consectetur nisl, vel vestibulum odio mattis sit amet. Integer vehicula rhoncus augue, eu congue magna porttitor eget.
Medium Heading
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris eleifend consectetur nisl, vel vestibulum odio mattis sit amet. Integer vehicula rhoncus augue, eu congue magna porttitor eget.
Small Heading
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris eleifend consectetur nisl, vel vestibulum odio mattis sit amet. Integer vehicula rhoncus augue, eu congue magna porttitor eget.

when I would like it to be:

# Big Heading
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris eleifend consectetur nisl, vel vestibulum odio mattis sit amet. Integer vehicula rhoncus augue, eu congue magna porttitor eget.
## Medium Heading
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris eleifend consectetur nisl, vel vestibulum odio mattis sit amet. Integer vehicula rhoncus augue, eu congue magna porttitor eget.
### Small Heading
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris eleifend consectetur nisl, vel vestibulum odio mattis sit amet. Integer vehicula rhoncus augue, eu congue magna porttitor eget.

Spike

I started a spike over the weekend which allows for this:

paste

Other

@iansan5653
Copy link
Member Author

Comment by @matthiaswenz, abridged:

This looks like a good fit for a time boxed implementation. I want to clarify the expectation on user experience here and confirm this with owners:

  • When pasting via cmd/crtl + v the logic should attempt to discover any supported HTML formatting and turn it into Markdown
  • When pasting via cmd/crtl + shift + v, it should paste verbatim, like also described in the changelog.

For any of HTML elements which have a single corresponding Markdown formatting (headings, bold, emphasize, ...) this looks to be pretty straightforward.

I'm cautious about any instances which rely on context/sequence of elements, such as <ol><li> and the potential for nested lists. These might be simple from a well-formatted document, but given it's user input and HTML (😱) there could be all kinds of 🐉 in there, such as dealing with all kinds of HTML quirks, or having HTML within <code> which should then presumably not be interpreted.

If we're ok with treating these more complex formatting options as iterative/progressive enhancements by starting with the simpler ones, I think this works well and should be low effort.

@iansan5653
Copy link
Member Author

Comment by me:

In addition to the previously mentioned items, there is also the deleted text syntax:

name html markdown
deleted text del, s, strike ~~text~~

There are also plenty of HTML tags that are supported by GitHub. Some more useful than others, and some lower effort than others.

Tag Preview Example Notes Estimated Effort
kbd Ctrl + V <kbd>Ctrl</kbd> + <kbd>V</kbd> Very useful and common in documentation low
pre
preformatted text
<pre>preformatted text</pre> Looks like triple-backticks but is semantically different (doesn't render a <code> block) moderate
tt teletype <tt>teletype</tt> Probably not worth including; deprecated in HTML5
ins inserted text <ins>inserted text</ins> Represents the text that replaces a del - important for semantics low
sup textsuperscript text<sup>superscript</sup> Very useful, no Markdown representation low
sub textsubscript text<sub>subscript</sub> Very useful, no Markdown representation low
dl, dt, dd
Term
Definition of term
<dl><dt>Term</dt><dd>Definition of term</dd> This is fairly common, especially in documentation like MDN, and is a pretty useful list format that can't be represented in Markdown moderate
summary, details
SummaryDetails...
<details><summary>Summary</summary>Details...</details> This is probably not that common outside of GitHub markdown but we do use it a lot here - if you were quoting a comment it would be useful moderate
ruby, rt, rp ㄏㄢˋ alt <ruby>漢 <rt> ㄏㄢˋ </rt> <rp>alt</rp></ruby> Not to be confused with Ruby code. I don't really know what this is, to be honest 🤷

I hope this is a comprehensive list but I may have missed some.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant