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

Feature request: ability to format code files hosted on github #108

Open
fxnoob opened this issue Nov 26, 2019 · 9 comments
Open

Feature request: ability to format code files hosted on github #108

fxnoob opened this issue Nov 26, 2019 · 9 comments
Labels
enhancement New feature or request github This is related to the formatting behavior on GitHub

Comments

@fxnoob
Copy link

fxnoob commented Nov 26, 2019

When I am on GitHub in some project directory .if that's a file say index.js then by clicking on some extensions option I should get that file content rerendered with prettier formatted code

@lipis lipis added the enhancement New feature or request label Nov 26, 2019
@nickserv nickserv added the github This is related to the formatting behavior on GitHub label Nov 26, 2019
@nickserv
Copy link
Member

To be clear, do you mean a read-only display or within the file editor?

@fxnoob
Copy link
Author

fxnoob commented Nov 26, 2019

@nickmccurdy
In file editor, is ok to me. nice to have both.
Screenshot 2019-11-26 at 10 05 28 PM
eg file content shown should be formatted and rendered

@nickserv
Copy link
Member

The former should we easy as we would just need to tweak how we detect text fields and make sure the button styles are appropriate in this toolbar. I'm not sure if we can reliably do the latter, as even if we supported read-only formatting, it could interfere with GitHub features like highlighting, selections, line/range links, and comments.

@fxnoob
Copy link
Author

fxnoob commented Nov 26, 2019

if we supported read-only formatting, it could interfere with GitHub features like highlighting, selections, line/range links, and comments.

Good point.
@nickmccurdy
Maybe provide an option in content menu of chrome to get it formatted in the option page of this chrome extension

eg

Screenshot 2019-11-26 at 10 15 52 PM

@nickserv
Copy link
Member

We're tracking that in #21

@kaicataldo
Copy link
Member

Agreed with @nickmccurdy. I don’t think it’s a good idea to format read-only content. The overhead of reverse-engineering the DOM structure to work with GitHub’s scripts would be extremely difficult, with no guarantees that it’ll work at any given time.

@fxnoob fxnoob closed this as completed Nov 26, 2019
@nickserv
Copy link
Member

I'm okay with keeping this open to track support for GitHub's file editors.

@nickserv nickserv reopened this Nov 26, 2019
@hyperupcall
Copy link

hyperupcall commented Jan 15, 2024

I did some investigating and this seems less straightfoward. The file editor is CodeMirror 6 (with gist.github.com, it is CodeMirror 5). From what I know about CodeMirror 6, it tracks state changes internally (not reading DOM), so a solution may require writing an extension. But I doubt GitHub has some mechanism for customizing CodeMirror editor extensions.

@nickserv
Copy link
Member

nickserv commented Jan 15, 2024

@hyperupcall I think that's just for code editors, not discussion editors, right? We could shift focus to supporting discussion editors since GitHub's VSCode based editors (replacing code editors) already support Prettier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request github This is related to the formatting behavior on GitHub
Projects
None yet
Development

No branches or pull requests

5 participants