From f73e6ecb6fb06f72828d7690b3f10c2992a8675c Mon Sep 17 00:00:00 2001 From: f Date: Wed, 3 Mar 2021 09:46:02 -0300 Subject: [PATCH] no mezclar markdown con html --- app/models/metadata_markdown_content.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/models/metadata_markdown_content.rb b/app/models/metadata_markdown_content.rb index 50aaac16..d3cc6dec 100644 --- a/app/models/metadata_markdown_content.rb +++ b/app/models/metadata_markdown_content.rb @@ -1,13 +1,25 @@ # frozen_string_literal: true # Contenido con el editor de Markdown -class MetadataMarkdownContent < MetadataContent +class MetadataMarkdownContent < MetadataText # Renderizar a HTML y sanitizar def to_s sanitize CommonMarker.render_doc(value, %i[FOOTNOTES SMART], %i[table strikethrough autolink]).to_html end + def value + self[:value] || value_from_document || default_value + end + + def front_matter? + false + end + + def value_from_document + document.content + end + # XXX: No sanitizamos acá porque se escapan varios símbolos de # markdown y se eliminan autolinks. Mejor es deshabilitar la # generación SAFE de CommonMark en la configuración del sitio.