markup lexer

This commit is contained in:
byte[] 2019-11-03 19:18:32 -05:00
parent 61def278b5
commit 9cfc426103
2 changed files with 33 additions and 9 deletions

View file

@ -172,5 +172,36 @@ defmodule Textile.Lexer do
unbracketed_link unbracketed_link
]) ])
defparsec :link, link
# Textile
{markup_start, markup_element} = markup_ending_in(eos())
textile_main =
choice([
bracketed_literal,
blockquote_open_cite,
blockquote_open,
blockquote_close,
spoiler_open,
spoiler_close,
link,
image,
markup_element
])
textile_start =
choice([
textile_main,
markup_start
])
textile =
optional(textile_start)
|> repeat(textile_main)
|> eos()
defparsec :lex, textile
end end

View file

@ -133,14 +133,6 @@ defmodule Textile.MarkupLexer do
sub_close sub_close
]) ])
markup_tags =
choice([
bracketed_markup_opening_tags,
bracketed_markup_closing_tags,
markup_opening_tags,
markup_closing_tags
])
markup_at_start = markup_at_start =
choice([ choice([
markup_opening_tags, markup_opening_tags,
@ -150,6 +142,7 @@ defmodule Textile.MarkupLexer do
markup_element = markup_element =
lookahead_not(ending_sequence) lookahead_not(ending_sequence)
|> choice([ |> choice([
literal,
bracketed_markup_closing_tags, bracketed_markup_closing_tags,
bracketed_markup_opening_tags |> lookahead_not(space()), bracketed_markup_opening_tags |> lookahead_not(space()),
special_characters() |> concat(markup_opening_tags), special_characters() |> concat(markup_opening_tags),