Skip to content

Feature: Markdown page part - #1430

Closed
wakproductions wants to merge 1 commit into
SpinaCMS:mainfrom
wakproductions:feature-add-markdown-page-part
Closed

wakproductions wants to merge 1 commit into
SpinaCMS:mainfrom
wakproductions:feature-add-markdown-page-part

Conversation

@wakproductions

@wakproductions wakproductions commented May 10, 2026 •

Copy link
Copy Markdown
Contributor

Context

Some users may prefer to write formatting in Markdown as an alternative to the Trix editor formatting.

Changes proposed in this pull request

Add a Markdown page part to be included with Spina's default set of available page parts.

Guidance to review

For including this in your Spina pages:

# config/initializers/themes/default.rb
  theme.parts = [
    {name: "markdown", title: "Markdown section", part_type: "Spina::Parts::Markdown"},
  ]

  theme.view_templates = [
    {name: "page_parts_demo", title: "Page Parts Demo", parts: %w[markdown]}
  ]

# views/default/pages/page_parts_demo.html.erb
<h1><%= current_page.title %></h1>
<div class="pt-5">
  <%= content.markdown(:markdown) %>
</div>

It uses Kramdown as the Markdown rendering engine. If requested, I can add a setting that would allow the user to choose a different Markdown processor. Such a setting would allow even greater flexibility.

spina-markdown-component

@Bramjetten

Bramjetten commented May 22, 2026 •

Copy link
Copy Markdown
Contributor

Wouldn't it be preferred to instead switch from Trix to Lexxy? https://github.com/basecamp/lexxy
Lexxy supports Markdown out of the box.

You could already do what you're doing now with a regular MultiLine part.

@wakproductions

wakproductions commented May 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Wouldn't it be preferred to instead switch from Trix to Lexxy? https://github.com/basecamp/lexxy Lexxy supports Markdown out of the box.

This is the first time I've heard of Lexxy. Looks like the project was only started last year and is intended to replace Trix. That might require some significant overhaul work on the admin editor, especially since it's configured to use a custom toolbar.

The reason I'm interested in directly using Markdown is to get more control over how the content is stored in the database. I don't like the limited options Trix editor allows for embedding media. See #1428 Streamfield for my proposed solution.

You could already do what you're doing now with a regular MultiLine part.

This did not occur to me - just using a regular MultiLine part and interpreting it as markdown in the page rendering template. It wouldn't have a built in presenter though.

I gave it a try with a custom helper and this works:

module ApplicationHelper
  def markdown(text_page_part)
    Kramdown::Document.new(text_page_part.to_s).to_html.html_safe
  end
end

# in page_parts_demo.html.erb (rendering template for the page)

<%= markdown(content.text(:simpletext)) %>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants