-
Notifications
You must be signed in to change notification settings - Fork 375
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
bug: prune doesnt work on non-english strings #418
Comments
AssafShalin
changed the title
prune doesnt work on non-english strings
bug: prune doesnt work on non-english strings
Apr 25, 2015
DSchau
referenced
this issue
in gatsbyjs/gatsby
Feb 25, 2019
…raphQL field (#11237) ## Description This PR adds/refactors excerpt + excerptAst (which is a new field) because I personally found it incovenient `gatsby-transformer-remark` not exporting an excerpt field in AST. What I did was basically refactoring by splitting out the resolver of `excerpt` that was internally converting ASTs to HTML to two functions that have similar signatures to the `getHtml()` and `getHtmlAst()`, with some caching feature as well. The tests have been added for these ASTs. Documentation could be added something like this: ```diff diff --git a/packages/gatsby-transformer-remark/README.md b/packages/gatsby-transformer-remark/README.md index 423329b..36a0d59 100644 --- a/packages/gatsby-transformer-remark/README.md +++ b/packages/gatsby-transformer-remark/README.md @@ -119,6 +119,7 @@ By default, excerpts have a maximum length of 140 characters. You can change the node { html excerpt(pruneLength: 500) + excerptAst(pruneLength: 500) } } } @@ -178,14 +181,15 @@ Any file that does not have the given `excerpt_separator` will fall back to the ### Excerpts for non-latin languages -By default, `excerpt` uses `underscore.string/prune` which doesn't handle non-latin characters ([https://github.com/epeli/underscore.string/issues/418](https://github.com/epeli/underscore.string/issues/418)). +By default, `excerpt` and `excerptAst` use `underscore.string/prune` which doesn't handle non-latin characters ([https://github.com/epeli/underscore.string/issues/418](https://github.com/epeli/underscore.string/issues/418)). -If that is the case, you can set `truncate` option on `excerpt` field, like: +If that is the case, you can set `truncate` option on `excerpt` and `excerptAst` field, like: ```graphql { markdownRemark { excerpt(truncate: true) + excerptAst(truncate: true) } } ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
tested with node.js
can be reproduced with the following text:
prune("שלום עולם", 5)
will return the string
"..."
should return
"שלום..."
The text was updated successfully, but these errors were encountered: