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

Indent code snippets using js-beautify #5259

Merged
merged 8 commits into from
Aug 1, 2024
Merged

Conversation

jmuzina
Copy link
Member

@jmuzina jmuzina commented Jul 26, 2024

Done

Formats all HTML, JS, and CSS code shown in pre code snippet blocks using js-beautify

Fixes #5245, WD-13629

QA

  • Look at some example code blocks and make sure they are indented with 2-space indentation.
  • Full width dropdown navigation is a good example to check as it has HTML, CSS, and JS, and was made with macros that generate some incorrect indentation in main

Check if PR is ready for release

If this PR contains Vanilla SCSS code changes, it should contain the following changes to make sure it's ready for the release:

  • PR should have one of the following labels to automatically categorise it in release notes:
    • Feature 🎁, Breaking Change 💣, Bug 🐛, Documentation 📝, Maintenance 🔨.
  • Vanilla version in package.json should be updated relative to the most recent release, following semver convention:
    • if CSS class names are not changed it can be bugfix release (x.x.X)
    • if CSS class names are changed/added/removed it should be minor version (x.X.0)
    • see the wiki for more details
  • Any changes to component class names (new patterns, variants, removed or added features) should be listed on the what's new page.

Screenshots

Before

image

After

image

@jmuzina jmuzina added the Documentation 📝 Documentation changes or updates label Jul 26, 2024
@webteam-app
Copy link

templates/_layouts/docs.html Fixed Show fixed Hide fixed
templates/_layouts/docs.html Fixed Show fixed Hide fixed
templates/_layouts/docs.html Fixed Show resolved Hide resolved
@jmuzina
Copy link
Member Author

jmuzina commented Jul 26, 2024

Here's my initial implementation @bartaz @pastelcyborg - any thoughts?
Feel free to edit the branch as you see fit @pastelcyborg as you're also interested in this problem

@pastelcyborg
Copy link
Contributor

Honestly I think this is perfectly sufficient - simple, easy, will gracefully fail. The only change I might make would be to either document that the functions come from a global/window scope or actually reference window, since otherwise the script calling the library functions might fail compilation/bundling in some scenarios.

This reverts commit c8fa625.

Revert "Use js_beautify from minified CDN"

This reverts commit 82205ab.
@pastelcyborg pastelcyborg self-requested a review July 29, 2024 13:58
@jmuzina
Copy link
Member Author

jmuzina commented Jul 29, 2024

The only change I might make would be to either document that the functions come from a global/window scope or actually reference window, since otherwise the script calling the library functions might fail compilation/bundling in some scenarios.

@pastelcyborg Good call, updated this to reference window when calling the beautify functions

@jmuzina jmuzina marked this pull request as ready for review July 29, 2024 16:59
@jmuzina jmuzina added Review: QA needed Review: Code needed Review: Percy needed This PR needs a review of Percy for visual regressions Review: Percy +1 and removed Review: Percy needed This PR needs a review of Percy for visual regressions labels Jul 29, 2024
@jmuzina jmuzina requested a review from bartaz July 30, 2024 13:40
Copy link
Member

@bartaz bartaz left a comment

Choose a reason for hiding this comment

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

Looks great, thanks for adding this!

@jmuzina jmuzina merged commit a9b73b8 into main Aug 1, 2024
16 checks passed
@jmuzina jmuzina deleted the indent-example-html-js branch August 1, 2024 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix inconsistent whitespace & indentation in macro-generated examples markup
4 participants