campo de markdown

This commit is contained in:
f 2020-06-24 17:48:16 -03:00
parent 00fafc2e84
commit 4aba16d450
3 changed files with 21 additions and 13 deletions

View file

@ -1,3 +1,17 @@
# frozen_string_literal: true
class MetadataMarkdown < MetadataText; end
# Markdown
class MetadataMarkdown < MetadataText
# Renderizar a HTML y sanitizar
def to_s
sanitize CommonMarker.render_doc(value, %i[FOOTNOTES SMART],
%i[table strikethrough autolink]).to_html
end
# XXX: No sanitizamos acá porque se escapan varios símbolos de
# markdown y se eliminan autolinks. Mejor es habilitar la generación
# SAFE de CommonMark en la configuración del sitio.
def sanitize(string)
string
end
end

View file

@ -1,17 +1,8 @@
# frozen_string_literal: true
# Contenido con el editor de Markdown
class MetadataMarkdownContent < MetadataContent
# Renderizar a HTML y sanitizar
def to_s
sanitize CommonMarker.render_doc(value, %i[FOOTNOTES SMART],
%i[table strikethrough autolink]).to_html
end
# XXX: No sanitizamos acá porque se escapan varios símbolos de
# markdown y se eliminan autolinks. Mejor es habilitar la generación
# SAFE de CommonMark en la configuración del sitio.
def sanitize(string)
string
class MetadataMarkdownContent < MetadataMarkdown
def front_matter?
false
end
end

View file

@ -0,0 +1,3 @@
%tr{ id: attribute }
%th= post_label_t(attribute, post: post)
%td{ lang: locale, dir: dir }= metadata.value.to_s.html_safe