Seems to me that markdown should perhaps be an option to a string or text field. Instead if I want a string that honors markdown, I get a super huge textbox.
This can be done too (I think). Most fields accept a
:form_helper option. So you could try something like this:
field :my_text, :markdown, form_helper: :text_field
Bare in mind the markdown renderer will wrap a single line the value in
<p /> tags .
Is there a way to control exactly what the markdown renderer does?
This didn’t work for me btw. Still resulted in a textarea.
Strange. I just tried it. It works for me… ?
Yes. Under the hood it’s using Redcarpet, The markdown field accepts a few relevant options:
:extensions. Take a look at:
even restarted the server,etc. So you get a text field?
Can you try what happens when you leave off the form helper and them put it in?
any way to eliminate p-tags and just render what was typed?
@epipheus I’m not too sure what to say about the
text_field as I can’t recreate and it works OK here. Could you perhaps try creating a new rails app with pushtype, generate a single node type and try setting the
:form_helper option there.
If you can get it to work on a clean app, then at least we can say with some confidence there is something about your current app that is causing this - then we can try and explore why. It’s possible it’s a bug, but need to try and narrow it down first.
Regarding customising the makrdown output to not render
<p>, I’m sure it’s possible by creating a custom Redcarpt renderer, but may be more hassle than it’s worth. Might be simpler to just use Rails’
sanitize method in your view to strip out paragraphs, or a regular expression.