add missing span wrapper, handle nested quote/spoiler interactions inside link text

This commit is contained in:
byte[] 2019-12-02 09:32:14 -05:00
parent c53c7d283f
commit 1bec3e0caa
2 changed files with 14 additions and 4 deletions

View file

@ -141,12 +141,22 @@ defmodule Textile.Lexer do
link_contents_start =
choice([
image,
spoiler_open,
spoiler_close,
blockquote_open,
blockquote_open_cite,
blockquote_close,
link_markup_start,
])
link_contents_element =
choice([
image,
spoiler_open,
spoiler_close,
blockquote_open,
blockquote_open_cite,
blockquote_close,
link_markup_element
])

View file

@ -199,25 +199,25 @@ defmodule Textile.Parser do
defp image(parser, [{:image_url, image_url}, {:image_title, title}, {:image_link_url, link_url} | r_tokens]) do
image_url = parser.image_transform.(image_url)
{:ok, [markup: ~s|<a href="#{escape_html(link_url)}"><img src="#{escape_html(image_url)}" title="#{escape_html(title)}"/></a>|], r_tokens}
{:ok, [markup: ~s|<a href="#{escape_html(link_url)}"><span class="imgspoiler"><img src="#{escape_html(image_url)}" title="#{escape_html(title)}"/></span></a>|], r_tokens}
end
defp image(parser, [{:image_url, image_url}, {:image_title, title} | r_tokens]) do
image_url = parser.image_transform.(image_url)
{:ok, [markup: ~s|<img src="#{escape_html(image_url)}" title="#{escape_html(title)}"/>|], r_tokens}
{:ok, [markup: ~s|<span class="imgspoiler"><img src="#{escape_html(image_url)}" title="#{escape_html(title)}"/></span>|], r_tokens}
end
defp image(parser, [{:image_url, image_url}, {:image_link_url, link_url} | r_tokens]) do
image_url = parser.image_transform.(image_url)
{:ok, [markup: ~s|<a href="#{escape_html(link_url)}"><img src="#{escape_html(image_url)}"/></a>|], r_tokens}
{:ok, [markup: ~s|<a href="#{escape_html(link_url)}"><span class="imgspoiler"><img src="#{escape_html(image_url)}"/></span></a>|], r_tokens}
end
defp image(parser, [{:image_url, image_url} | r_tokens]) do
image_url = parser.image_transform.(image_url)
{:ok, [markup: ~s|<img src="#{escape_html(image_url)}"/>|], r_tokens}
{:ok, [markup: ~s|<span class="imgspoiler"><img src="#{escape_html(image_url)}"/></span>|], r_tokens}
end
defp image(_parser, _tokens),