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

Avoid escaping in <p> #343

Closed
LukeTOBrien opened this issue Aug 9, 2020 · 2 comments
Closed

Avoid escaping in <p> #343

LukeTOBrien opened this issue Aug 9, 2020 · 2 comments

Comments

@LukeTOBrien
Copy link

Hello there,

My question is simuliar to #340
But I don't wish to escape the whole element, only parts of it.

I am building a graphical MD editor, users can select HTML elements with the contentEditable attribute` in the designer and type, what when a is then processed.
The issue is that when a user types a list inside a paragraph, the list is escaped:
The user types:

* abc
* 123

The returned Markdown is:

\* abc
\* 123

Is there any way to change this behaviour?

Thanks

@martincizek
Copy link
Collaborator

My question is simuliar to #340

Not really similar. Although #340 mentions avoiding escaping, the solution is actually avoiding standard Turndown rules completely. Not only text escaping, but also HTML formatting inside a pre block should just be dropped, as it has no representation in MD and most likely it is just some generated syntax highlighting.

I am building a graphical MD editor

If you are building a source-level editor with inline formatting highlighting like https://stackedit.io/, then Turndown is not really a match. I guess you are building a mixed wysiwyg + source editor, which combines HTML formatting with user-entered Markdown syntax, correct?

If that is the case, you can upvote PR #339, which would give you the ability to contextually change escaping behaviour.

@LukeTOBrien
Copy link
Author

Hi, thanks for taking a look.

Stackedit goes one way, Markdown to HTML, I want to allow for both ways, the user can edit the HTML element.
I have code that adds contentEditable to all HTML elements post-render.
I have recently started using Turndown and it does work nicely and do what I want.

So I guess what I mean is that I want to allow for Markdown to be entered inside the node text.
I will close your issue awaiting for your PR, I think I can also do string replacement for simple things like lists.

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