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

Add stripMarkdown method for text parsing #6453

Open
1 task
Antreesy opened this issue Jan 24, 2025 · 4 comments
Open
1 task

Add stripMarkdown method for text parsing #6453

Antreesy opened this issue Jan 24, 2025 · 4 comments
Labels
1. to develop Accepted and waiting to be taken care of enhancement New feature or request feature: richtext Related to the richtext component
Milestone

Comments

@Antreesy
Copy link
Contributor

Antreesy commented Jan 24, 2025

Can be done with unified plugin https://github.com/remarkjs/strip-markdown, which we already using (in NcRichText)
Method needs to be exportable (as function / util / composable) to be used in apps and projects

  • Might be a part of NcRichPlainText component (if implemented)
@Antreesy Antreesy added 1. to develop Accepted and waiting to be taken care of enhancement New feature or request feature: richtext Related to the richtext component labels Jan 24, 2025
@Antreesy Antreesy added this to the 8.23.0 milestone Jan 24, 2025
@ShGKme
Copy link
Contributor

ShGKme commented Jan 24, 2025

Is there a place where we need to get the text and cannot render a component? If there isn't, we can add is as a prop of NcRichText

@Antreesy
Copy link
Contributor Author

Antreesy commented Jan 24, 2025

@ShGKme
Copy link
Contributor

ShGKme commented Jan 24, 2025

See these places in Talk:

Both look like rendering content and don't require JS API.

to pull all the NcRichText logic

We have the component in the bundle anyway. And the logic isn't executed until we enable MD rendering.

if it can be done in easier way

That's why I'd propose to do

<NcRichText :text strip-markdown />

instead of

<!-- eslint-disable-next-line vue/no-v-html -->
<p v-html="textWithoutMarkdown" />

<script setup>
import { stripMarkdown } from '@nextcloud/vue/functions/stripMarkdown'

const textWithoutMarkdown = computed(() => stripMarkdown(text))
</script>

@susnux
Copy link
Contributor

susnux commented Jan 27, 2025

Yes this would make sense also for some apps, e.g. where we render a preview of markdown text as second line of list item.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1. to develop Accepted and waiting to be taken care of enhancement New feature or request feature: richtext Related to the richtext component
Projects
None yet
Development

No branches or pull requests

3 participants