mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-01-19 22:27:59 +01:00
fix tokenization rules for links
This commit is contained in:
parent
41ea1f6b71
commit
7f0ac2f68f
1 changed files with 18 additions and 19 deletions
|
@ -94,24 +94,6 @@ defmodule FastTextile.Lexer do
|
|||
image_url_scheme
|
||||
])
|
||||
|
||||
unbracketed_image =
|
||||
ignore(string("!"))
|
||||
|> concat(image_url_scheme)
|
||||
|> repeat(utf8_char(not: ?!))
|
||||
|> ignore(string("!"))
|
||||
|> reduce({List, :to_string, []})
|
||||
|> unwrap_and_tag(:unbracketed_image)
|
||||
|
||||
bracketed_image =
|
||||
ignore(string("[!"))
|
||||
|> concat(image_url_scheme)
|
||||
|> repeat(lookahead_not(string("!]")) |> utf8_char([]))
|
||||
|> ignore(string("!]"))
|
||||
|> reduce({List, :to_string, []})
|
||||
|> unwrap_and_tag(:bracketed_image)
|
||||
|
||||
defparsec :bracketed_image, bracketed_image
|
||||
|
||||
unbracketed_url =
|
||||
string(":")
|
||||
|> concat(link_url_scheme)
|
||||
|
@ -128,6 +110,24 @@ defmodule FastTextile.Lexer do
|
|||
|> reduce({List, :to_string, []})
|
||||
|> unwrap_and_tag(:unbracketed_link_url)
|
||||
|
||||
unbracketed_image =
|
||||
ignore(string("!"))
|
||||
|> concat(image_url_scheme)
|
||||
|> repeat(utf8_char(not: ?!))
|
||||
|> ignore(string("!"))
|
||||
|> reduce({List, :to_string, []})
|
||||
|> unwrap_and_tag(:unbracketed_image)
|
||||
|> concat(optional(unbracketed_image_url))
|
||||
|
||||
bracketed_image =
|
||||
ignore(string("[!"))
|
||||
|> concat(image_url_scheme)
|
||||
|> repeat(lookahead_not(string("!]")) |> utf8_char([]))
|
||||
|> ignore(string("!]"))
|
||||
|> reduce({List, :to_string, []})
|
||||
|> unwrap_and_tag(:bracketed_image)
|
||||
|> concat(optional(unbracketed_image_url))
|
||||
|
||||
link_delim =
|
||||
string("\"")
|
||||
|> unwrap_and_tag(:link_delim)
|
||||
|
@ -200,7 +200,6 @@ defmodule FastTextile.Lexer do
|
|||
bracketed_link_open,
|
||||
bracketed_link_url,
|
||||
unbracketed_link_url,
|
||||
unbracketed_image_url,
|
||||
link_delim,
|
||||
bracketed_b_open,
|
||||
bracketed_i_open,
|
||||
|
|
Loading…
Reference in a new issue