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

add python media type #2538

Merged
merged 7 commits into from
Oct 26, 2023
Merged

add python media type #2538

merged 7 commits into from
Oct 26, 2023

Conversation

elocremarc
Copy link
Contributor

Add file type python closes #1481

@elocremarc
Copy link
Contributor Author

elocremarc commented Oct 16, 2023

@raphjaph I was realizing after I submitted this that the mime-type returned for the highlight code JS is gonna be text/x-python This won't be recognized as a type for highlight Js. Do you think it would be worth making a more generic highlight JS template with auto highlight to support adding executable code like rust or say typescript? We have the optimized one already where we specify the languge for code types that are used in inscriptions. However any other code that is just reference code using ord as a CDN we would fallback to auto highlight these ones won't be rendered nearly as often.

Another option is we could just regex if the mimetype contains python then set it to the correct name to pass in as language variable.

@elocremarc
Copy link
Contributor Author

@raphjaph got highlight working with latest commit.
image

@casey casey added the stream label Oct 25, 2023

const inscription = document.documentElement.dataset.inscription;
const response = await fetch(`/content/${inscription}`);
const contentType = response.headers.get("content-type");
const language = contentType.split("/")[1];
let language = contentType.split("/")[1];
if (language.includes("python")) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (language.includes("python")) {
if (language === "x-python") {

Copy link
Collaborator

@casey casey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LFG

@casey casey enabled auto-merge (squash) October 26, 2023 00:43
@casey casey merged commit 231bdda into ordinals:master Oct 26, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add python content type
3 participants