5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-06-02 06:24:17 +00:00

no mezclar markdown con html

This commit is contained in:
f 2021-03-03 09:46:02 -03:00
parent c006ed7f29
commit f73e6ecb6f

View file

@ -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.