From 9f0ff55b5f126c31b6d8f3cd28907e5b87601e28 Mon Sep 17 00:00:00 2001 From: Ilya Ryzhenkov Date: Mon, 13 Oct 2014 13:38:40 +0400 Subject: Parse and format inline code, fix strong & emph formatting. --- .../jetbrains/markdown/MarkdownElementTypes.java | 1 + gen/org/jetbrains/markdown/MarkdownParser.java | 67 +++++++++++++++++++++- 2 files changed, 67 insertions(+), 1 deletion(-) (limited to 'gen/org/jetbrains/markdown') diff --git a/gen/org/jetbrains/markdown/MarkdownElementTypes.java b/gen/org/jetbrains/markdown/MarkdownElementTypes.java index e8910c7b..337ff1a5 100644 --- a/gen/org/jetbrains/markdown/MarkdownElementTypes.java +++ b/gen/org/jetbrains/markdown/MarkdownElementTypes.java @@ -11,6 +11,7 @@ public interface MarkdownElementTypes { IElementType BLOCK = new IElementType("BLOCK", null); IElementType BULLET = new IElementType("BULLET", null); IElementType BULLET_LIST = new IElementType("BULLET_LIST", null); + IElementType CODE = new IElementType("CODE", null); IElementType EMPH = new IElementType("EMPH", null); IElementType END_LINE = new IElementType("END_LINE", null); IElementType ENUMERATOR = new IElementType("ENUMERATOR", null); diff --git a/gen/org/jetbrains/markdown/MarkdownParser.java b/gen/org/jetbrains/markdown/MarkdownParser.java index c6068e5b..efad3d6e 100644 --- a/gen/org/jetbrains/markdown/MarkdownParser.java +++ b/gen/org/jetbrains/markdown/MarkdownParser.java @@ -37,6 +37,9 @@ public class MarkdownParser implements PsiParser { else if (t == BULLET_LIST) { r = BulletList(b, 0); } + else if (t == CODE) { + r = Code(b, 0); + } else if (t == EMPH) { r = Emph(b, 0); } @@ -259,6 +262,67 @@ public class MarkdownParser implements PsiParser { return r; } + /* ********************************************************** */ + // '`' !Whitespace (!'`' Inline)+ '`' + public static boolean Code(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Code")) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, ""); + r = consumeToken(b, "`"); + r = r && Code_1(b, l + 1); + r = r && Code_2(b, l + 1); + r = r && consumeToken(b, "`"); + exit_section_(b, l, m, CODE, r, false, null); + return r; + } + + // !Whitespace + private static boolean Code_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Code_1")) return false; + boolean r; + Marker m = enter_section_(b, l, _NOT_, null); + r = !Whitespace(b, l + 1); + exit_section_(b, l, m, null, r, false, null); + return r; + } + + // (!'`' Inline)+ + private static boolean Code_2(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Code_2")) return false; + boolean r; + Marker m = enter_section_(b); + r = Code_2_0(b, l + 1); + int c = current_position_(b); + while (r) { + if (!Code_2_0(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "Code_2", c)) break; + c = current_position_(b); + } + exit_section_(b, m, null, r); + return r; + } + + // !'`' Inline + private static boolean Code_2_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Code_2_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = Code_2_0_0(b, l + 1); + r = r && Inline(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + + // !'`' + private static boolean Code_2_0_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "Code_2_0_0")) return false; + boolean r; + Marker m = enter_section_(b, l, _NOT_, null); + r = !consumeToken(b, "`"); + exit_section_(b, l, m, null, r, false, null); + return r; + } + /* ********************************************************** */ // BOM? Whitespace* AnonymousSection? (Whitespace* NamedSection)* static boolean Document(PsiBuilder b, int l) { @@ -716,13 +780,14 @@ public class MarkdownParser implements PsiParser { } /* ********************************************************** */ - // Strong | Emph | Link | PlainText + // Strong | Emph | Code | Link | PlainText public static boolean Inline(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "Inline")) return false; boolean r; Marker m = enter_section_(b, l, _NONE_, ""); r = Strong(b, l + 1); if (!r) r = Emph(b, l + 1); + if (!r) r = Code(b, l + 1); if (!r) r = Link(b, l + 1); if (!r) r = PlainText(b, l + 1); exit_section_(b, l, m, INLINE, r, false, null); -- cgit