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

Format Codepen Code #5332

Closed
jmuzina opened this issue Aug 29, 2024 · 3 comments
Closed

Format Codepen Code #5332

jmuzina opened this issue Aug 29, 2024 · 3 comments
Assignees
Labels
P3 Triaged Issue has been reviewed as part of legacy backlog grooming (project P3). Triaged: v4 Triaged, to be implemented as part of Vanilla v4

Comments

@jmuzina
Copy link
Member

jmuzina commented Aug 29, 2024

The code that is sent to CodePen is not formatted by js-beautify like the code shown in our code snippets is.

Screenshot 2024-08-29 at 4 09 08 PM

We should more consistently apply this formatting so that the code is formatted in one place, and the formatting result is used by both the example code snippets and CodePen.

Context

Here's the code path that the (correctly formatted) code snippet code follows:

  1. createPreCode is called on htmlSource

    codeSnippet.appendChild(createPreCode(htmlSource, 'html'));

  2. createPreCode calls formatSource, which calls the relevant js-beautify formatter.

    function createPreCode(source, lang) {
    var code = document.createElement('code');
    code.appendChild(document.createTextNode(formatSource(source, lang)));

Here's the code that is defining what is sent to CodePen:

var htmlSource = stripScriptsFromSource(bodyHTML);
var jsSource = getScriptFromSource(bodyHTML);
var cssSource = getStyleFromSource(headHTML);
var externalScripts = getExternalScriptsFromSource(html);
var codePenData = {
html: htmlSource,
css: cssSource,
js: jsSource,
externalJS: externalScripts,
};

We are using htmlSource, which is not formatted (it is later passed into createPreCode as discussed above).
Maybe we should format htmlSource, jsSource, and cssSource at their initialization, rather than doing it in createPreCode.

Copy link

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/WD-14598.

This message was autogenerated

@bartaz
Copy link
Member

bartaz commented Sep 25, 2024

I believe this is in progress with jinja macro snippets. So triaging it as part of current codebase.

@bartaz bartaz added P3 Triaged Issue has been reviewed as part of legacy backlog grooming (project P3). Triaged: v4 Triaged, to be implemented as part of Vanilla v4 and removed Good first issue 🔰 labels Sep 25, 2024
@jmuzina
Copy link
Member Author

jmuzina commented Dec 18, 2024

Closing as completed in #5321

@jmuzina jmuzina closed this as completed Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 Triaged Issue has been reviewed as part of legacy backlog grooming (project P3). Triaged: v4 Triaged, to be implemented as part of Vanilla v4
Projects
None yet
Development

No branches or pull requests

2 participants