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

Can we support rendering of pug templates? #6763

Closed
3 tasks done
hamishwillee opened this issue Jul 24, 2022 · 5 comments
Closed
3 tasks done

Can we support rendering of pug templates? #6763

hamishwillee opened this issue Jul 24, 2022 · 5 comments

Comments

@hamishwillee
Copy link
Contributor

Summary

There are some pug template code blocks in https://developer.mozilla.org/en-US/docs/Learn/Server-side/Express_Nodejs/Displaying_data/LocalLibrary_base_template that are marked as plain because yari doesn't support pug syntax highlighting.

If it were easy and not "costly" to support pug as well that would be good. I am not sure it would be easy/I think it is not supported, but just checking.

This came out of mdn/content#18744

URL

https://developer.mozilla.org/en-US/docs/Learn/Server-side/Express_Nodejs/Displaying_data/LocalLibrary_base_template

Reproduction steps

Open a page, use ```pug to highlight some pug text. Url above is good. It renders as plain.

Expected behavior

Would be nice to render pug if we can

Actual behavior

We can't :-)

Device

Desktop

Browser

Chrome

Browser version

Stable

Operating system

Windows

Screenshot

No response

Anything else?

No response

Validations

@github-actions github-actions bot added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Jul 24, 2022
@Josh-Cena
Copy link
Member

w.r.t. Prism highlighting support. Prism has a component for virtually every non-esoteric language, so the only blocker is whether we want to include that in our bundle or not. I wish there's a better workflow to assess the tradeoffs of adding each language. My stance is that we should add every language that ought to be added (e.g. we should have diff, svelte, jsx, etc. as well).

Even better—I wonder if we can code-split by Prism components, so we don't have to worry about bundle size too much.

@hamishwillee
Copy link
Contributor Author

Ah, you're right it's there: https://prismjs.com/#supported-languages

So let's find out the cost. But honestly, we're talking very few pages of relatively easy to read and parse text with pug. So if the cost is at all significant it isn't worth paying.

@Josh-Cena
Copy link
Member

Josh-Cena commented Jul 25, 2022

node_modules/prismjs/components/prism-pug.min.js is 2882 characters long—that's 2.8KB, roughly the same size as markup (which html maps to) and 60% of js. I don't know what the bundle size of Yari is—comparatively speaking pug is definitely a big chunk.

Still, from a semantic point of view, I'd say marking code blocks as languages Yari doesn't support is strictly better than marking it as plain or marking it as some random language. It means we don't have to update it again if Yari updates it some time in the future—also, in VSCode, if you supply the right language key, you get the right highlighting:

image

I don't know if that's what mdn/content#18744 was talking about.

@hamishwillee
Copy link
Contributor Author

hamishwillee commented Aug 7, 2022

Also see

I'm not sure how far we can progress things without knowing if languages are a per-page or every-page cost.

@caugner
Copy link
Contributor

caugner commented Aug 22, 2022

Fixed by #6831.

@caugner caugner closed this as completed Aug 22, 2022
@caugner caugner added syntax-highlighting and removed needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. labels Aug 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants