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

Getting the text only #145

Closed
samholmes opened this issue Mar 29, 2013 · 5 comments
Closed

Getting the text only #145

samholmes opened this issue Mar 29, 2013 · 5 comments

Comments

@samholmes
Copy link

I could use marked and cheerio to first convert the markdown to HTML, then use cheerio's text() method to get the textual content out of the HTML. However, why couldn't marked save me this step?

I suggest that marked add a simple feature to be able to get just the text out of a markdown file. Why is this useful? If I wanted to display an excerpt of the body of a blog post and have that except contain only text without formatting, I would need this method. Simple.

Thanks for reading! Please consider this small feature.

@kuba-kubula
Copy link

s = "";
JSON.stringify(marked.lexer('> markdowned text'), function(key, val) {
    if (key == 'text') {
        s += val;
    }
    return val;
});
console.log(s);

Not so nice solution, but works

@samholmes
Copy link
Author

@kuba-kubula doesn't seem to work actually.

@kuba-kubula
Copy link

@samholmes sorry, repaired the code.

@chjj
Copy link
Member

chjj commented Mar 30, 2013

@kuba-kubula is on the right track, but if you grab all the text tokens from the lexer, some of them will still have inline markdown in them. Another possibility is the renderer (#129) that's being proposed right now.

@chjj
Copy link
Member

chjj commented Feb 23, 2014

Solved with #129.

@chjj chjj closed this as completed Feb 23, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants