mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-03-22 11:47:13 +01:00
add links
This commit is contained in:
parent
fcb8919669
commit
61def278b5
2 changed files with 59 additions and 4 deletions
|
@ -116,5 +116,61 @@ defmodule Textile.Lexer do
|
||||||
image_without_link
|
image_without_link
|
||||||
])
|
])
|
||||||
|
|
||||||
defparsec :image, image
|
|
||||||
|
# Links
|
||||||
|
|
||||||
|
|
||||||
|
{link_markup_start, link_markup_element} = markup_ending_in(string("\""))
|
||||||
|
|
||||||
|
link_contents_start =
|
||||||
|
choice([
|
||||||
|
image,
|
||||||
|
link_markup_start,
|
||||||
|
])
|
||||||
|
|
||||||
|
link_contents_element =
|
||||||
|
choice([
|
||||||
|
image,
|
||||||
|
link_markup_element
|
||||||
|
])
|
||||||
|
|
||||||
|
link_contents =
|
||||||
|
optional(link_contents_start)
|
||||||
|
|> repeat(link_contents_element)
|
||||||
|
|
||||||
|
bracketed_link_end =
|
||||||
|
string("\":")
|
||||||
|
|> unwrap_and_tag(:link_end)
|
||||||
|
|> concat(
|
||||||
|
url_ending_in(string("]"))
|
||||||
|
|> unwrap_and_tag(:link_url)
|
||||||
|
)
|
||||||
|
|
||||||
|
bracketed_link =
|
||||||
|
string("[\"")
|
||||||
|
|> unwrap_and_tag(:link_start)
|
||||||
|
|> concat(link_contents)
|
||||||
|
|> concat(bracketed_link_end)
|
||||||
|
|
||||||
|
unbracketed_link_end =
|
||||||
|
string("\":")
|
||||||
|
|> unwrap_and_tag(:link_end)
|
||||||
|
|> concat(
|
||||||
|
url_ending_in(space())
|
||||||
|
|> unwrap_and_tag(:link_url)
|
||||||
|
)
|
||||||
|
|
||||||
|
unbracketed_link =
|
||||||
|
string("\"")
|
||||||
|
|> unwrap_and_tag(:link_start)
|
||||||
|
|> concat(link_contents)
|
||||||
|
|> concat(unbracketed_link_end)
|
||||||
|
|
||||||
|
link =
|
||||||
|
choice([
|
||||||
|
bracketed_link,
|
||||||
|
unbracketed_link
|
||||||
|
])
|
||||||
|
|
||||||
|
defparsec :link, link
|
||||||
end
|
end
|
|
@ -4,7 +4,7 @@ defmodule Textile.MarkupLexer do
|
||||||
|
|
||||||
# Markup tags
|
# Markup tags
|
||||||
|
|
||||||
def markup_segment(ending_sequence) do
|
def markup_ending_in(ending_sequence) do
|
||||||
|
|
||||||
# The literal tag is special, because
|
# The literal tag is special, because
|
||||||
# 1. It needs to capture everything inside it as a distinct token.
|
# 1. It needs to capture everything inside it as a distinct token.
|
||||||
|
@ -157,7 +157,6 @@ defmodule Textile.MarkupLexer do
|
||||||
utf8_char([])
|
utf8_char([])
|
||||||
])
|
])
|
||||||
|
|
||||||
optional(markup_at_start)
|
{markup_at_start, markup_element}
|
||||||
|> repeat(markup_element)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Add table
Reference in a new issue