mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-14 17:51:41 +00:00
29 lines
732 B
Ruby
29 lines
732 B
Ruby
# frozen_string_literal: true
|
|
|
|
# Contenido con el editor de Markdown
|
|
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.
|
|
def sanitize(string)
|
|
string.tr("\r", '')
|
|
end
|
|
end
|