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

-[NSAttributedString markdownRepresentation] doesn't escape Markdown characters. #5

Open
simonward opened this issue May 11, 2020 · 2 comments

Comments

@simonward
Copy link

simonward commented May 11, 2020

See attached unit tests.

NSAttributedString+Markdown_Tests.m.txt

@chockenberry
Copy link
Owner

This is a good test, but it's not exhaustive.

The code currently doesn't escape literals because the need to do so is contextual. You want to escape them when they occur in plain text, but you don't when they're not (e.g. a URL). I need solve that problem first - and it's subtly difficult one.

If someone enters the plain text my_variable_name = 1; is the intent to make "variable" italic? Will changing the text to my\_variable\_name = 1; be a welcome change? I'm still grappling with that...

@chockenberry
Copy link
Owner

I've added ESCAPE_ALL_LITERALS to convert all literals in rich text (including punctuation!). You'll probably find this irritating. Not only is text harder to read, it breaks many of the tests.

For example, the text above becomes:

I've added ESCAPE\_ALL\_LITERALS to convert all literals in rich text \(including punctuation\!\)\. You'll probably find this irritating\. Not only is text harder to read, it breaks many of the tests\.

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

2 participants