From 9cfc42610306230578777f2fc71ae35208b1350b Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Sun, 3 Nov 2019 19:18:32 -0500 Subject: [PATCH] markup lexer --- lib/textile/lexer.ex | 33 ++++++++++++++++++++++++++++++++- lib/textile/markup_lexer.ex | 9 +-------- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/lib/textile/lexer.ex b/lib/textile/lexer.ex index 297c1509..7bfccdb3 100644 --- a/lib/textile/lexer.ex +++ b/lib/textile/lexer.ex @@ -172,5 +172,36 @@ defmodule Textile.Lexer do 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 \ No newline at end of file diff --git a/lib/textile/markup_lexer.ex b/lib/textile/markup_lexer.ex index 968ca83a..6464c0cb 100644 --- a/lib/textile/markup_lexer.ex +++ b/lib/textile/markup_lexer.ex @@ -133,14 +133,6 @@ defmodule Textile.MarkupLexer do sub_close ]) - markup_tags = - choice([ - bracketed_markup_opening_tags, - bracketed_markup_closing_tags, - markup_opening_tags, - markup_closing_tags - ]) - markup_at_start = choice([ markup_opening_tags, @@ -150,6 +142,7 @@ defmodule Textile.MarkupLexer do markup_element = lookahead_not(ending_sequence) |> choice([ + literal, bracketed_markup_closing_tags, bracketed_markup_opening_tags |> lookahead_not(space()), special_characters() |> concat(markup_opening_tags),