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

Keep HTML comments in render #498

Open
Tracked by #568
Gregcop1 opened this issue Mar 8, 2023 · 4 comments
Open
Tracked by #568

Keep HTML comments in render #498

Gregcop1 opened this issue Mar 8, 2023 · 4 comments
Labels
assigned Whether or not this bug has been assigned some to some other issues as a subtask or pre-req enhancement New feature or request
Milestone

Comments

@Gregcop1
Copy link

Gregcop1 commented Mar 8, 2023

Hi. First of all, thanks for this module, it's awesome.
To build excerpt on blog post, I need to keep html comments in the return of render function. Is there's a way to do this?
At the moment, when I add a <!--more--> HTML comment in markdown, the render removes it.

Thanks for your answer.

@hovancik
Copy link

hovancik commented Sep 2, 2023

Hi @Gregcop1 , were you able to solve this? have the same issue

@ZachSaucier
Copy link

ZachSaucier commented Oct 24, 2023

I too would like to be able to retain comments for the purpose of <!--more--> for excerpts.

@pngwn Are you able to help direct us to the right area here? I see that comments are found in the AST but I'm not finding where the removal of them is. Is the removal of comments an indirect effect of the composition approach or something?

@ZachSaucier
Copy link

As a workaround, I am able to use a span with a special class name as a marker for the end of the excerpt:

<span class="excerpt-marker"></span>

Usage:

const SEPARATOR = '<span class="excerpt-marker"></span>';
const excerpt = html.indexOf(SEPARATOR) >= 0 ? html.split(SEPARATOR)[0] : html;

You could even strip it from the HTML after you get the excerpt if you'd like.

@steven-aj
Copy link

I realize this doesn't directly address the posted issue, but it should be noted that front-matter is better suited for a post's excerpt. HTML comments weren't really meant to be used this way.

@pngwn pngwn added this to the 1.0 milestone Feb 23, 2024
@pngwn pngwn mentioned this issue Feb 23, 2024
27 tasks
@pngwn pngwn added enhancement New feature or request assigned Whether or not this bug has been assigned some to some other issues as a subtask or pre-req labels Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assigned Whether or not this bug has been assigned some to some other issues as a subtask or pre-req enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants