Showdown: need to render html without paragraph tags

Created on 25 Jan 2018  路  2Comments  路  Source: showdownjs/showdown

need to render html without paragraph tags.

help wanted

Most helpful comment

I was working on solving a different problem and stumbled across a possible solution for this one:

var noMorePsExt = {
  type: 'output',
  filter: function(text, converter) {
    var re = /<\/?p[^>]*>/ig;
    text = text.replace(re, '');
    return text;
  }
};

const converter = new showdown.Converter({extensions: [noMorePsExt]});

then the rest of your code.

All 2 comments

Showdown does not allow for selective parsing. You can, however, create an extension that replaces <p> tags with something else (or remove them entirely).

I was working on solving a different problem and stumbled across a possible solution for this one:

var noMorePsExt = {
  type: 'output',
  filter: function(text, converter) {
    var re = /<\/?p[^>]*>/ig;
    text = text.replace(re, '');
    return text;
  }
};

const converter = new showdown.Converter({extensions: [noMorePsExt]});

then the rest of your code.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jonaskello picture jonaskello  路  4Comments

LeahPike picture LeahPike  路  5Comments

Ehesp picture Ehesp  路  3Comments

DesignResponds picture DesignResponds  路  3Comments

xduseko picture xduseko  路  3Comments