Skip to content

Code snippets for paste service links #2679

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

Open
DownDev opened this issue Jul 12, 2023 · 8 comments · May be fixed by #3310
Open

Code snippets for paste service links #2679

DownDev opened this issue Jul 12, 2023 · 8 comments · May be fixed by #3310
Assignees
Labels
a: utility Related to utility commands: (bot, eval, extensions, jams, reminders, snekbox, utils) area: features l: 1 - intermediate p: 2 - normal Normal Priority status: approved The issue has received a core developer's approval t: feature New feature or request

Comments

@DownDev
Copy link
Contributor

DownDev commented Jul 12, 2023

The new paste service offers the ability to select specific line when someone sends a link to a paste service with a selected line. In such cases, you can replace the selected line with a code block like its already done for github etc.

Althrough i still did not find a way to select more than one line

@shtlrs
Copy link
Member

shtlrs commented Jul 12, 2023

In such cases, you can replace the selected line with a code block like its already done for github etc.
I'm not sure I follow what's exactly meant here.

Are you asking whether it's possible to highlight a specific line range like in Github ?

AFAIK, pinnwand allows to highlight a single line and not a range.

Relevant issue: supakeen/pinnwand#39
Relevant PR: supakeen/pinnwand#104

@DownDev
Copy link
Contributor Author

DownDev commented Jul 12, 2023

Are you asking whether it's possible to highlight a specific line range like in Github ?

Yes, i couldnt find a way to select more than one line
Its possible now: supakeen/pinnwand#170

But still if only 1 line is possible it could send codeblock with only one line anyways.
So do we add support for code snippets for paste service now?

@HassanAbouelela HassanAbouelela added t: feature New feature or request p: 2 - normal Normal Priority a: utility Related to utility commands: (bot, eval, extensions, jams, reminders, snekbox, utils) l: 1 - intermediate status: approved The issue has received a core developer's approval area: features labels Aug 21, 2023
@HassanAbouelela
Copy link
Member

Issue approved, please leave a comment if you'd like to work on it.

@DownDev
Copy link
Contributor Author

DownDev commented Aug 21, 2023

I can work on this when supakeen/pinnwand#194 is done and merged.

@HassanAbouelela HassanAbouelela added the s: stalled Something is blocking further progress label Aug 21, 2023
@wookie184 wookie184 added up for grabs Available for anyone to work on and removed s: stalled Something is blocking further progress labels Apr 14, 2024
@ChrisLovering
Copy link
Member

We have now forked pinnwand and pushed the latest changes to paste.pythondiscord.com

https://paste.pythondiscord.com/api/v1/paste/{id} can be used to get the paste data, and lexer for the code block.

EG https://paste.pythondiscord.com/api/v1/paste/NCXY2ZKJ2TT2E6RBEZHMTJ52VQ

@Senjan21 Senjan21 removed the up for grabs Available for anyone to work on label May 18, 2024
@vivekashok1221
Copy link
Member

vivekashok1221 commented Mar 12, 2025

Could this issue be assigned to me? 🥺
I' plan to use this regex to capture the paste ID, start line and end line (following suit with this):

https://paste\.(?:pythondiscord\.com|pydis\.wtf)/(?P<paste_id>[a-zA-Z0-9]+)#\d+L(?P<start_line>\d+)-L(?P<end_line>\d+)(?:,.*)?

(https://regex101.com/r/GkhxSx/2) 1

In case multiple files are specified in the URL, only contents of the first file will be displayed. 2

Footnotes

  1. edit:
    Technically, https://paste.pythondiscord.com/EMJQ#1L2 works the same way as https://paste.pythondiscord.com/EMJQ#1L2-L2 but I don't think links like the former will be generated by the pastebin if you only use the pastebin's UI. So we won't really encounter such links unless the user manually types out the URL that way.
    Anyway, the regex can be adjusted as:
    https://paste\.(?:pythondiscord\.com|pydis\.wtf)/(?P<paste_id>[a-zA-Z0-9]+)#\d+L(?P<start_line>\d+)(?:-L(?P<end_line>\d+))?(?:,.*)?
    (https://regex101.com/r/xqafe4/1)

  2. edit: TBH, I believe we can easily support multiple files. I can't think of a neat regex that will capture all the individual file numbers and line ranges, so I'll probably end up splitting the last part (the one containing the file number and line numbers, eg, 1L1-L2,2L2-L4,5L2-L4,6L2-L4) manually with Python after matching the URL with regex.

@shtlrs
Copy link
Member

shtlrs commented Mar 13, 2025

@DownDev I see you have been assigned to this issue. Is there ongoing work for this, and do you still plan on doing it ? Or shall I assign vivek instead ?

@wookie184 wookie184 assigned vivekashok1221 and unassigned DownDev Mar 28, 2025
@wookie184
Copy link
Contributor

Assigned @vivekashok1221

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: utility Related to utility commands: (bot, eval, extensions, jams, reminders, snekbox, utils) area: features l: 1 - intermediate p: 2 - normal Normal Priority status: approved The issue has received a core developer's approval t: feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants