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

Multiline selections only add "quote" markdown to the first line #95

Closed
glenatron opened this issue Jul 2, 2024 · 3 comments · Fixed by #97
Closed

Multiline selections only add "quote" markdown to the first line #95

glenatron opened this issue Jul 2, 2024 · 3 comments · Fixed by #97
Labels
bug Something isn't working released

Comments

@glenatron
Copy link
Contributor

glenatron commented Jul 2, 2024

If I have a larger block of markdown and I want to quote a section of it, it feels intuitive that I should be able to select the block and hit the "quote" button to get it quoted, like this:

> This is my text
> but I have more than one line selected
> so they are all marked up as a quote.

But instead I only get the first line marked up:

> This is my text
but I have more than one line selected
and they are not marked up as a quote.

The "quote" button here on Github behaves in the way that I would expect:

In that a single
selection permits more than
one line be quoted.

Also Github's quotes treat newlines as newlines instead of insisting on a line break between each line of markdown, which is easier to work with if one is loading text in from somewhere else. That's not really part of this issue, though, just something I notice in using it.

@BearToCode BearToCode added the bug Something isn't working label Jul 2, 2024
@BearToCode
Copy link
Owner

That is something that needs to be fixed, thanks for pointing it out!

Regarding newlines, you can use this plugin: remark-breaks. Just wrap it in a custom extension:

const newlines: Plugin = {
  transformers: [{
    execution: 'sync',
    type: 'remark',
    transform({ processor }) {
      processor.use(remarkBreaks);
    }
  }]
};

const carta = new Carta({
  // ...
  extensions: [newlines]
});

Haven't tested but it should work :)

glenatron added a commit to glenatron/carta that referenced this issue Jul 3, 2024
…refix

Addresses bug BearToCode#95 - the `toggleLinePrefix` function was only prefixing the first line of a multline
selection and instead of toggling prefixes on and off it would continue adding further prefixes.
This change attempts to address both.

fix BearToCode#95
@glenatron
Copy link
Contributor Author

glenatron commented Jul 3, 2024

The PR includes a bonus fix because it would also add the prefix again instead of removing it when the button was pressed again. It looks like everyone involved (including me, until I figured out what was going on) was assuming that JavaScript's String.slice() took a number of characters to slice as the second parameter instead of an ending index!

BearToCode pushed a commit that referenced this issue Jul 3, 2024
…refix (#97)

Addresses bug #95 - the `toggleLinePrefix` function was only prefixing the first line of a multline
selection and instead of toggling prefixes on and off it would continue adding further prefixes.
This change attempts to address both.

fix #95
Copy link

github-actions bot commented Jul 3, 2024

🎉 This issue has been resolved in version carta-md-v4.3.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants