Scratch-blocks: Block html not logically ordered

Created on 27 Oct 2020  路  6Comments  路  Source: LLK/scratch-blocks

Expected Behavior

Block html should be ordered in a logical and "readable" manner

(This is a crude interpretation of the suggested structure, purely for demonstration)

<block>
    <text>set</text>
    <variable>variable</variable>
    <text>to</text>
    <child>
        <input>480<input>
        <text>/</text> 
        <input>256</input>
    </child>
    <block-stack>
        ...
    </block-stack>
</block>

Logical organization following the rendering
image

Actual Behavior

(again a crude interpretation of the _actual_ structure, purely for demonstration)

<block>
    <child>
        <input>480<input>
        <input>256</input>
        <text>/</text>
    </child>
    <block-stack>
        ...
    </block-stack>
    <text>set</text>
    <variable>variable</variable>
    <text>to</text>
</block>

Here is that same structure, if it actually was reflected in the block rendering
image

Steps to Reproduce

Inspect the html of any blocks/stack in the editor

Operating System and Browser

_Windows NT 10.0, Chrome 86.0.4240.111_

All 6 comments

This is by design. The rendering of the blocks is independent of the html representation.

How is this works as intended? If it is independent, then why isn't it ordered in a manner as i described?

This is by design. The rendering of the blocks is independent of the html representation.

How is this by design? This makes absolutely no sense.

If it was logically ordered, then it would be extremely easy to parse the html as text block code that could be used for the forums.

Parsing has to be written in a completely different manner because of this

@BryceLTaylor I understand that it is intended, but is there a possibility that the "intended" behavior could be changed? You said it yourself, it is independent of the rendering. This issue wasn't about rendering, it was about ease of use for developers and parsing. Would you be willing to accept a PR, if we changed this with no problems?

The block xml is supposed to be agnostic of how the block is laid out. In particular, something that is not reflected in this issue description is that the block XML has named inputs. These are important for being able to layout the block inputs in different orders (e.g. in different languages) while keeping the block XML exactly the same regardless of which language the block is rendered in.

For example here is the same block in English vs. Japanese, notice that the text and inputs are in different orders:

image

image

Some languages will have even more of a drastic difference than this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

towerofnix picture towerofnix  路  4Comments

tmickel picture tmickel  路  3Comments

towerofnix picture towerofnix  路  4Comments

thisandagain picture thisandagain  路  6Comments

rachel-fenichel picture rachel-fenichel  路  4Comments