6

Have a look at the Parsedown plugin by P&T, it provides a line mode to not output any wrapping <p> tags. {{ entry.title|parsedown('line') }}


5

You can grab the first word with the split filter according to this thread {% set array = entry.title|split(' ', 2) %} <h1 class="section__heading"> <strong>{{ attribute(array, 0) }}</strong> {{ attribute(array, 1) }} </h1> I didn't test this tough. Edit: there is a Twig Fiddle demonstrating it.


5

If you're here looking for a Craft 3 answer, the Wordsmith plugin offers the same ability to only parse inline and not include paragraph tags: {{ entry.title|markdown(inlineOnly=true) }}


2

I just figured out how to do this. It was vexing me! Anyway, Craft is awesome and has provided support for Reference Tags. Write your Markdown like this: [link text]({entry:20}) Here's the Twig: {{ entry.markdown|parseRefs|markdown }} Reference Tags support more than just entries, but this was the bit that I needed.


2

I was able to get good results using {{ block.myFieldName|nl2br|markdown }}


1

Craft uses Github Flavored Markdown and I don't believe targets are supported in links: https://github.github.com/gfm/#links Honestly, not sure that I've seen any Markdown flavors that actually support that.


1

I would rather recommend to stick to semantic HTML and <ol> elements for your ordered lists. This not only makes showing the numbers easier, it really should be done out of accessibility reasons and it’s good practice in general. There are a couple of good solutions to modify the way numbers are displayed in ordered lists using CSS, if you are not ...


1

There is a Craft Parsedown plugin for Craft which supports Github Flavored Markdown you can use.


1

A workaround in light of my comments on Brandon’s reply… If I ignore the attempt to act on child tags only, I can search for opening tags of all generated elements (regardless of whether they are nested) with… {% set elems = elems|replace('/(<[a-z][a-z0-9]*\\b[^>]*>)/', '$1>,') %} and then… {# Convert elems to an array #} {% set elems = ...


1

Backreferences within the regex are normally defined as \1, \2, etc. In the |replace filter you need to escape all backslashes, so it’ll be \\1, \\2, etc.


Only top voted, non community-wiki answers of a minimum length are eligible