Open morsssss opened 4 years ago
@matthiasrohmer , I wonder if this is something else we can look at after Pixi?
@morsssss can you explain 1 more? All of the <script>
s are one lined on the linked page. Can you share a screenshot of an affected example
Yeah, you're right. It must have started working at some point, because even in the screenshot I included here, it works 🙄
Sorries!
It would be great to fix #2, though. Until we do, people will think that we don't know how to format JavaScript 😬
that actually appears to be by design.
If you have anything other than the string <div>
, it won't be removed
That's not what I mean, though! I mean, that the following issues occur:
</script>
tag is indented incorrectly.ah! you want <amp-script> to be the same line? In that case, you'd want to add amp-script
to the same array as script
unformatted: ['noscript', 'style', 'head', 'script', 'amp-script'],
Rereading, I am not sure we are on the same page. I'll try to summarize, can you correct what is wrong, @morsssss?
a. you want the attributes for <script>
and <amp-script>
elements to be on one line.
b. Vertical spaces are sometimes removed from <amp-script>
samples
c. <amp-script>
demos get indented incorrectly in some instances.
Is there anything else?
I'm sorry. I'm just an idiot. Or trying to do too many things at once.
Since I keep mistaking the <amp-script>
attributes on different lines for an error, when in fact I deliberately chose not to include that tag in the unformatted
array: what do you think? Do you prefer them on separate lines? Or on one line?
"b" and "c" up there is what I meant, yes.
Do you prefer them on separate lines? Or on one line?
don't have a strong feeling either direction, but in general new line if it is important, same line if it isn't
do you have an example of b and/or c?
For b/c, sure! See this sample.
Working on the
<amp-script>
examples page, I've hit a couple of snags:1. Pretty-printing
I find it confusing that HTML attributes for
<script>
tags get automatically pretty-printed so that each is on a separate line - as that tends to mush into the JavaScript that people will need to focus on. @sebastianbenz showed me that I could defeat this behavior by adding<script>
toBEAUTIFY_OPTIONS.unformatted[]
inDocumentParser.js'
:However, this is having no effect.
2. Indentation
The pretty-printing normally works beautifully for JavaScript in examples. However, I'm having spacing problems in cases where I need to wrap the whole example in a
<div>
- since AFAIK a single example can't have multiple parent tags, but needs to have a single parent tag, which then gets magically removed.So, this code:
gets formatted like this: