question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

html tags disappear

See original GitHub issue
  • Markwon version: 4.3.1
  1. Please specify expected/actual behavior I want the output of <owo>Hello!</owo> <strong>ok</strong> to be unchanged but what actually happens is the html tags get removed: Hello! ok
  2. Please specify conditions/steps to reproduce (layout, code, markdown used, etc)
private val markwon: Markwon = Markwon.builder(applicationContext).build()
markwon.setMarkdown(messageArea, "<owo>Hello!</owo> <whatever>ok</whatever>")

I’m trying to make a chat app so I dont want people typing in html code. Thanks!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
notiescommented, Apr 27, 2020

You can sanitize input before it is persisted (save in database, sent to server) or before rendering. For example here is how to do it before rendering:

final Markwon markwon = Markwon.builder(this)
        .usePlugin(new AbstractMarkwonPlugin() {
            @NonNull
            @Override
            public String processMarkdown(@NonNull String markdown) {
                return markdown
                        .replaceAll("<", "&lt;")
                        .replaceAll(">", "&gt;");
            }
        })
        .build();

If you wish to disable links then you will have to use experimental inline parser. It is experimental because it uses some internal classes from commonmark-java but it still passes the whole commonmark test spec, so I would say it is pretty stable

final Markwon markwon = Markwon.builder(this)
        .usePlugin(MarkwonInlineParserPlugin.create())
        .usePlugin(new AbstractMarkwonPlugin() {
            @Override
            public void configure(@NonNull Registry registry) {
                registry.require(MarkwonInlineParserPlugin.class, plugin -> {
                    plugin.factoryBuilder()
                            .excludeInlineProcessor(HtmlInlineProcessor.class)
                            .excludeInlineProcessor(OpenBracketInlineProcessor.class);
                });
            }
        })
        .build();
0reactions
notiescommented, Apr 28, 2020

You are welcome 🙌

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to make HTML disappear completely - freeCodeCamp
Run away! Run far, far away! ... One final way you can hide an element is just to move it so far off...
Read more >
Why are my HTML tags disappearing? - php - Stack Overflow
Why are my HTML tags disappearing? ... My structure is : ... php: <?php $con = mysql_connect('myServerAddress', 'ainsworthremote', 'myPassword'); if ...
Read more >
HTML Code disappears - WordPress.org
I am using latest version of Beaver Builder along with WP's latest version. I designed a page using BB and everything is all...
Read more >
Some HTML Tags Disappear After Saving the Source Code in ...
I am trying to add a new HTML tag to the source code of my dynamic or shared content section. After saving a...
Read more >
My HTML Markup in Sections is disappearing! - GeneratePress
My custom HTML markup in Sections (text tab) disappears every time I save. Div tags seem to remain, but P and BR do...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found