# Markdown parsing order in custom Liquid tags

**URL:** https://talk.jekyllrb.com/t/markdown-parsing-order-in-custom-liquid-tags/4397
**Category:** Help
**Created:** [May 11, 2020, 1:20pm UTC](https://talk.jekyllrb.com/t/markdown-parsing-order-in-custom-liquid-tags/4397 "2020-05-11T13:20:40Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![ClayH60](https://avatars.discourse-cdn.com/v4/letter/c/f19dbf/32.png) [@ClayH60](https://talk.jekyllrb.com/u/ClayH60)
#### Post date: [May 12, 2020, 9:17pm UTC](https://talk.jekyllrb.com/t/markdown-parsing-order-in-custom-liquid-tags/4397/3 "2020-05-12T21:17:47Z")

</div>

The problem is in a custom tag, _not_ the front matter. Just for the benefit of anyone having a similar issue as I did, I solved it by running the markdown converter inside the custom liquid tag code. The problem stems from the fact that the Kramdown converter does not play well with HTML5 `<figure>` and `<figcaption>` tags. By running the converter on the string in question inside the Liquid code, it converted it to HTML, but had the unfortunate side effect of wrapping everything in a `<p>` tag pair. So I had to strip the `<p>` tags.

The relevant code solution was this:

```auto
      site = context.registers[:site]
      converter = site.find_converter_instance(::Jekyll::Converters::Markdown)

      baseurl = context.registers[:site].config['baseurl']
      label = Kramdown::Document.new(@text[1],{remove_span_html_tags:true}).to_html # render markdown in caption
      label = converter.convert(label).gsub(/<\/?p[^>]*>/, "").chomp # remove <p> tags from render output

```

---

_[View the full topic](https://talk.jekyllrb.com/t/markdown-parsing-order-in-custom-liquid-tags/4397)._
