mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 21:47:59 +01:00
less special casing of literal, require del_open not be followed by a greater than sign to allow it to be replaced as an arrow
This commit is contained in:
parent
2c2ad9ee82
commit
3012de58b6
4 changed files with 22 additions and 18 deletions
|
@ -14,13 +14,24 @@ defmodule Textile.Lexer do
|
||||||
ignore(string("[=="))
|
ignore(string("[=="))
|
||||||
|> repeat(lookahead_not(string("==]")) |> utf8_char([]))
|
|> repeat(lookahead_not(string("==]")) |> utf8_char([]))
|
||||||
|> ignore(string("==]"))
|
|> ignore(string("==]"))
|
||||||
|
|
||||||
|
unbracketed_literal =
|
||||||
|
ignore(string("=="))
|
||||||
|
|> repeat(lookahead_not(string("==")) |> utf8_char([]))
|
||||||
|
|> ignore(string("=="))
|
||||||
|
|
||||||
|
literal =
|
||||||
|
choice([
|
||||||
|
bracketed_literal,
|
||||||
|
unbracketed_literal
|
||||||
|
])
|
||||||
|> reduce({List, :to_string, []})
|
|> reduce({List, :to_string, []})
|
||||||
|> unwrap_and_tag(:bracketed_literal)
|
|> unwrap_and_tag(:literal)
|
||||||
|
|
||||||
blockquote_cite =
|
blockquote_cite =
|
||||||
lookahead_not(string("\""))
|
lookahead_not(string("\""))
|
||||||
|> choice([
|
|> choice([
|
||||||
bracketed_literal |> reduce(:unwrap),
|
literal |> reduce(:unwrap),
|
||||||
utf8_char([])
|
utf8_char([])
|
||||||
])
|
])
|
||||||
|> repeat()
|
|> repeat()
|
||||||
|
@ -146,7 +157,7 @@ defmodule Textile.Lexer do
|
||||||
blockquote_open,
|
blockquote_open,
|
||||||
blockquote_open_cite,
|
blockquote_open_cite,
|
||||||
blockquote_close,
|
blockquote_close,
|
||||||
bracketed_literal,
|
literal,
|
||||||
link_markup_start
|
link_markup_start
|
||||||
])
|
])
|
||||||
|
|
||||||
|
@ -158,7 +169,7 @@ defmodule Textile.Lexer do
|
||||||
blockquote_open,
|
blockquote_open,
|
||||||
blockquote_open_cite,
|
blockquote_open_cite,
|
||||||
blockquote_close,
|
blockquote_close,
|
||||||
bracketed_literal,
|
literal,
|
||||||
link_markup_element
|
link_markup_element
|
||||||
])
|
])
|
||||||
|
|
||||||
|
@ -215,7 +226,7 @@ defmodule Textile.Lexer do
|
||||||
|
|
||||||
textile_default =
|
textile_default =
|
||||||
choice([
|
choice([
|
||||||
bracketed_literal,
|
literal,
|
||||||
blockquote_open_cite |> optional(markup_start),
|
blockquote_open_cite |> optional(markup_start),
|
||||||
blockquote_open |> optional(markup_start),
|
blockquote_open |> optional(markup_start),
|
||||||
blockquote_close,
|
blockquote_close,
|
||||||
|
|
|
@ -117,7 +117,7 @@ defmodule Textile.MarkupLexer do
|
||||||
code_open,
|
code_open,
|
||||||
ins_open,
|
ins_open,
|
||||||
sup_open,
|
sup_open,
|
||||||
del_open,
|
del_open |> lookahead_not(string(">")),
|
||||||
sub_open
|
sub_open
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
|
@ -102,13 +102,13 @@ defmodule Textile.Parser do
|
||||||
# markup =
|
# markup =
|
||||||
# blockquote | spoiler | link | image | bold | italic | strong | emphasis |
|
# blockquote | spoiler | link | image | bold | italic | strong | emphasis |
|
||||||
# code | inserted | superscript | deleted | subscript | newline | literal |
|
# code | inserted | superscript | deleted | subscript | newline | literal |
|
||||||
# bracketed_literal | text;
|
# literal | text;
|
||||||
#
|
#
|
||||||
defp markup(parser, tokens) do
|
defp markup(parser, tokens) do
|
||||||
markups = [
|
markups = [
|
||||||
&blockquote/2, &spoiler/2, &link/2, &image/2, &bold/2, &italic/2, &strong/2,
|
&blockquote/2, &spoiler/2, &link/2, &image/2, &bold/2, &italic/2, &strong/2,
|
||||||
&emphasis/2, &code/2, &inserted/2, &superscript/2, &deleted/2, &subscript/2,
|
&emphasis/2, &code/2, &inserted/2, &superscript/2, &deleted/2, &subscript/2,
|
||||||
&newline/2, &literal/2, &bracketed_literal/2, &text/2
|
&newline/2, &literal/2, &literal/2, &text/2
|
||||||
]
|
]
|
||||||
|
|
||||||
value =
|
value =
|
||||||
|
@ -305,13 +305,6 @@ defmodule Textile.Parser do
|
||||||
do: {:error, "Expected a line break"}
|
do: {:error, "Expected a line break"}
|
||||||
|
|
||||||
|
|
||||||
defp bracketed_literal(_parser, [{:bracketed_literal, text} | r_tokens]),
|
|
||||||
do: {:ok, [markup: escape_nl2br(text)], r_tokens}
|
|
||||||
|
|
||||||
defp bracketed_literal(_parser, _tokens),
|
|
||||||
do: {:error, "Expected a bracketed literal"}
|
|
||||||
|
|
||||||
|
|
||||||
defp text(_parser, [{:text, text} | r_tokens]),
|
defp text(_parser, [{:text, text} | r_tokens]),
|
||||||
do: {:ok, [text: escape_nl2br(text)], r_tokens}
|
do: {:ok, [text: escape_nl2br(text)], r_tokens}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue