Unfortunately there is an issue in discount library https://github.com/Orc/discount/pull/84 and there is no way to re-define tags after calling mkd_deallocate_tags(). With that, you won't be able to use html5 tags with TMD->new(html5=>1) after doing TMD->new(html5=>1), TMD->new(). In order to address the issue, we have to call mkd_define_tag() several times instead of calling mkd_with_html5_tags(). It's gonna be something like:

    if ( self->html5 == 0 ) {
      mkd_shlib_destructor();
    } else {
      mkd_define_tag("ASIDE", 0);
      mkd_define_tag("FOOTER", 0);
      mkd_define_tag("HEADER", 0);
      mkd_define_tag("HGROUP", 0);
      mkd_define_tag("NAV", 0);
      mkd_define_tag("SECTION", 0);
      mkd_define_tag("ARTICLE", 0);
    
      mkd_sort_tags();
    }