-
Notifications
You must be signed in to change notification settings - Fork 164
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
Presets for Markdown #48
Comments
Thanks @brownieboy for the snippets, they're really helpful!
whereas
Any ideas how to make this work for multiple matches? Thanks :) |
Try these: const boldPattern = /\*(\S(.*?\S)?)\*/gm;
const italicPattern = /_(\S(.*?\S)?)\_/gm;
const strikethroughPattern = /~((?:\[.*?\]|<.*?>(?:.*?<.*?>)?|`.*?`|.)*?)~/gm; The first two taken from react-markdown-jsx, I think, so should work better than my first attempt. |
Markdown is a crazy beast, and there are many flavors! I'd support if we want to add this as an Example or Documentation, but I don't want us to add it to the default patterns or we'll have fights between "Standard Markdown" or "Markdown+" or "Github-Flavored Markdown" or others. Additionally, as alternatives, there are other libraries more optimized for markdown. For example, as a transitive dependency, I've used this library: https://github.com/GetStream/react-native-simple-markdown Is this something you or others are still interested in discussing? I'm going to close this for now, as it's over 2 years old, but if this is still interesting, we can reopen the ticket. If you find a bug or have a PR, I'm working on a new release in #79 |
I've been experimenting with this very excellent library to try and implement a basic Markdown functionality. So far, I have bold, italics and strikethrough working. I wondering if there's any interest out there in a PR to add such functionality, or maybe setting it up as an add-on to it.
I've gone for the asterisks to denote bold text, underscores for italics and dashes for strikethrough. This follows what I'm used from using JIRA, although I don't how standard an implementation their's is!
The difficulty I had was ignoring whitespace and line breaks in the regex statements. The markdown character (asterisk, underscore or dash) has to be directly against the start and ending words, like so:
Okay, so Github itself is actually rendering the italics and bold examples above! But it's not doing it for strikethrough, so you can see what I mean on that one.
Using https://regexr.com/, these are the regex patterns that I came up with:
Plugging in that in the configs for react-native-parsed-text, I came up with this:
Anybody interested in my taking this any further?
The text was updated successfully, but these errors were encountered: