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

How to disable MD syntax #33

Closed
steven-qi opened this issue Oct 7, 2017 · 10 comments
Closed

How to disable MD syntax #33

steven-qi opened this issue Oct 7, 2017 · 10 comments

Comments

@steven-qi
Copy link

Sorry for use this as a Q&A here, but I cannot find anything useful elsewhere.

The new MD syntax is awesome, but could cause surprising issues if the original translation file was not MD-ready (say, a translation could contains [] but doesn't mean to render it to a separate paragraph).

So here I have two questions:

  1. is there anyway to opt-out the MD rendering for individual translation key, e.g., an escape character, or a parameter to translate method?
  2. is there any option to opt-out MD rendering for all keys?
@steven-qi
Copy link
Author

Well..., just realize that this library is always doing MD render from day one. But the problem remains here: how to render text as-is, especially for [abc].

@alexdrel
Copy link
Owner

alexdrel commented Oct 7, 2017

@steven-qi, the MD syntax is the raison d'etre of this library, it can be turned off :)
The [] syntax is one of the most useful for externalizing texts.
Of course you can clone and deactivate it.
Otherwise the workaround is to pass literal strings as arguments as they are included as is. E.g.

T.setTexts({  k: "Example {v}!" }); 
<T.text text={{ key: "k", v: "[a]" }}/>

Renders: Example [a]!

@alexdrel alexdrel closed this as completed Oct 7, 2017
@alexdrel
Copy link
Owner

alexdrel commented Oct 7, 2017

@steven-qi, I thought some more about it and while I'm still not in favor of disable MD, new MD syntax can be added to allow screening of the special cases.
And luckily `` is nice for it as it is similar to original MD meaning and being very rare in the wild.
I pushed new version just now - 0.6.

@steven-qi
Copy link
Author

steven-qi commented Oct 9, 2017

@alexdrel Thanks much for the new `` syntax, love it! 👍

@steven-qi
Copy link
Author

steven-qi commented Oct 9, 2017

@alexdrel checkout this one ``[``{val}``]`` (say val is abc), which will be rendered as [abc``]``.

I guess this is due to that, v1 maybe test won't pass for ``]``, thus whole segment was rendered as plain text without stripping leading/trailing ``.

Although I can fix it easily by change it to ``[``{val}], but just feel a bit confused, as `` is supposed to render anything between as-is. Maybe we could just change maybe of v1 to /[\*_~\{\[\n`]/

@alexdrel
Copy link
Owner

Hi @steven-qi,
I'm out of town for a week - I will look into when I'll be back. I think you are right the issue is with
maybe filter which I have not updated when added the new regex.

@alexdrel alexdrel reopened this Oct 10, 2017
@alexdrel
Copy link
Owner

Fixed in 0.6.1, @steven-qi exactly as you suggested.

@steven-qi
Copy link
Author

@alexdrel Great. Thanks!

@munkhorgil
Copy link

@alexdrel Could you make MD Syntax optional? I can't even use [], ..., . in my strings.

@steven-qi
Copy link
Author

@munkhorgil Just FYI, you may wrap text into `` to make it render as-is (aka, literal).

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