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

[idea] <pre> tag dedentation #7087

Open
Jamesernator opened this issue Sep 19, 2021 · 0 comments
Open

[idea] <pre> tag dedentation #7087

Jamesernator opened this issue Sep 19, 2021 · 0 comments
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest

Comments

@Jamesernator
Copy link

Jamesernator commented Sep 19, 2021

Currently the <pre> tag is the primary way in which we specify preformatted text, however it's currently quite painful for authoring, i.e. consider the following example:

<section>
    <code><pre>function example() {
    if (someCondition) {
        return 3;
    }
    return 5;
}</pre></code>
</section>

In this example our code is split up over multiple indentation levels without the source itself, on the starting <pre> line it's completely inconsistent with following lines, and the final line is dedented relative to the usual indentation for authoring.

It would be nice for this tag to be more human authorable, code samples is a particularly large use case, but I imagine there are other uses for improved formatting.

Now one way we could improve this is to implement something along the lines of the JS string dedent proposal, in that proposal you can indent preformatted strings more logically following conventional indentation styles within the code itself.

For example one could dedent a string as such:

const s = ```
    function example() {
        if (someCondition) {
            return 5;
        }
        return 4;
    }
 ``` // Space added because of Github markdown

It would be nice to have this sort've capability with the <pre> tag, perhaps a dedent attribute or something that allows for authoring dedented blocks:

<section>
    <code><pre dedent>
        function example() {
            if (someCondition) {
                return 5;
            }
            return 4;
        }
    </pre></code>
</section>
@Jamesernator Jamesernator changed the title <pre> tag dedentation for improved authoring [idea] <pre> tag dedentation Sep 19, 2021
@domenic domenic added addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest labels Sep 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest
Development

No branches or pull requests

2 participants