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

Markdown syntax still being rendered #41

Open
djmtype opened this issue Jan 26, 2024 · 2 comments
Open

Markdown syntax still being rendered #41

djmtype opened this issue Jan 26, 2024 · 2 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request good first issue Good for newcomers

Comments

@djmtype
Copy link

djmtype commented Jan 26, 2024

First, thanks for a must needed Astro integration.

I came across an issue in both .mdx and .md files.

The text I get back still has markdown formatting applied to it, at least where italics (*text* or _text_) and bold (**text**) text are concerned. I tried all 3 options for PropRenderer, and they all yielded the same result.

Using Astro 4.2.4.

<PostExcerpt post={post} words={20} addEllipsis={true} headings={PropHeadings.TextOnly} renderer={PropRenderer.Html} />

Example return:

Lorem ipsum dolor **sit amet**, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ![fpo](../../assets/uploads/blog-placeholder-1.jpg) Adipiscing enim…

@djmtype djmtype changed the title Markdown syntax still being included Markdown syntax still being rendered Jan 26, 2024
@djmtype
Copy link
Author

djmtype commented Jan 26, 2024

BTW, in regards to choosing the plain text render, it would probably be ideal to remove images too.

BTW, it might be worth checking out how Astroplate handles the markdown body in order to return plain text. It uses the help of marked to parse the content, among other rules.

https://github.com/zeon-studio/astroplate/blob/main/src/lib/utils/textConverter.ts#L35

@igorskyflyer igorskyflyer self-assigned this Jan 28, 2024
@igorskyflyer igorskyflyer added bug Something isn't working enhancement New feature or request good first issue Good for newcomers labels Jan 28, 2024
@igorskyflyer
Copy link
Owner

igorskyflyer commented Jan 28, 2024

@djmtype, thanks for taking your time to create the issue and providing a possible fix for it.
Indeed, everything except headings is left intact because the component's behavior is inspired by a very common Markdown authoring style, i.e.:


### Some heading

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam id elementum nunc. Morbi pharetra, sem interdum suscipit tristique, tellus mi sodales erat, id consectetur sem odio eget eros.

Aenean non laoreet quam, eget semper nisl. Suspendisse potenti. Aenean in convallis odio, id mollis neque. Vestibulum dictum, massa fringilla consectetur posuere, risus mi bibendum metus, id elementum massa libero in dolor. Phasellus mattis, nunc eu sollicitudin hendrerit, nisl eros bibendum enim, sed ultrices risus lacus vitae diam.

Nam sapien mauris, pretium nec eros et, mattis fermentum est.

### Some other heading

Etc.


Which in turn means anything else well stay as-is. Also *.mdx are quite more complex and difficult to strip of Markdown/JS code.

Either way, I can see the feature to strip all formatting as well being useful/needed and will be something I'll implement in the near future, quite possibly in the next release.

If you have any additional issues/comments feel free to post them. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants