Skip to content

[Bug] Story generator adds last char into storyΒ #329

@RSWilli

Description

@RSWilli

Describe the bug

The story generator adds the last char into the story as markup. If the file ends with a newline then it isn't obvious but other chars are visible:

Image

Steps to reproduce the behavior

Remove the last newline of any stories.svelte. The story will always contain the last char.

A story like:

<script module lang="ts">
    // ...
</script>

<script lang="ts">
    // ...
</script>

<Story name="primary" {args}>
    {#snippet template(args: Props)}
        <Button {...args}>Save</Button>
        <Button {...args}>Save</Button>
    {/snippet}
</Story>
foo

will produce the following (must remove the newline at the end!):

Image

If the last char is the > of the </Story> then this is also added to the markup. Not sure if this can be used in any malicous way?

Expected behavior

Only story markup.

Environment

  System:
    OS: Linux 6.12 Arch Linux
    CPU: (8) x64 Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.0.1 - ~/.nvm/versions/node/v24.0.1/bin/node
    Yarn: 1.22.22 - /usr/bin/yarn
    npm: 11.6.0 - ~/.nvm/versions/node/v24.0.1/bin/npm <----- active
  npmPackages:
    @storybook/addon-essentials: ^8.6.7 => 8.6.14 
    @storybook/addon-interactions: ^8.6.7 => 8.6.14 
    @storybook/addon-links: ^8.6.7 => 8.6.14 
    @storybook/addon-svelte-csf: ^5.0.0-next.11 => 5.0.8
    @storybook/blocks: ^8.6.7 => 8.6.14 
    @storybook/svelte: ^8.6.7 => 8.6.14 
    @storybook/sveltekit: ^8.6.7 => 8.6.14 
    @storybook/test: ^8.6.7 => 8.6.14 
    @storybook/testing-library: ^0.2.2 => 0.2.2 
    storybook: ^8.6.7 => 8.6.14 

Not sure if also present in storybook v9

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions