From 7316896019329878c00f27cdf7913c0d07d1b4a8 Mon Sep 17 00:00:00 2001
From: marihachi <marihachi0620@gmail.com>
Date: Wed, 17 Mar 2021 01:34:22 +0900
Subject: [PATCH] wip

---
 src/parser/core-parser.pegjs | 63 +++++++++++++++++++++++-------------
 1 file changed, 41 insertions(+), 22 deletions(-)

diff --git a/src/parser/core-parser.pegjs b/src/parser/core-parser.pegjs
index 3bfbf69..bccba55 100644
--- a/src/parser/core-parser.pegjs
+++ b/src/parser/core-parser.pegjs
@@ -162,12 +162,34 @@ inline
 	/ big
 	/ bold
 	/ small
+	/ italic
 	/ strike
 	/ inlineCode
 	/ mathInline
 	/ hashtag
 	/ text
 
+// inline: emoji
+
+emoji
+	= customEmoji / unicodeEmoji
+
+customEmoji
+	= ":" name:emojiName ":"
+{
+	return createNode('emoji', { name: name });
+}
+
+emojiName
+	= [a-z0-9_+-]i+ { return text(); }
+
+// NOTE: if the text matches one of the emojis, it will count the length of the emoji sequence and consume it.
+unicodeEmoji
+	= &{ return matchUnicodeEmoji(); } (&{ return forwardUnicodeEmoji(); } .)+
+{
+	return createNode('emoji', { emoji: text() });
+}
+
 // inline: big
 
 big
@@ -186,7 +208,7 @@ bold
 {
 	return createNode('bold', { }, mergeText(content));
 }
-	/ "__" content:$(!"__" c:[a-zA-Z0-9 \t] { return c; })+ "__"
+	/ "__" content:$(!"__" c:[a-z0-9 \t]i { return c; })+ "__"
 {
 	const parsedContent = applyParser(content, 'inlineParser');
 	return createNode('bold', { }, parsedContent);
@@ -208,6 +230,24 @@ strike
 	return createNode('strike', { }, mergeText(content));
 }
 
+// inline: italic
+
+italic
+	= "<i>" content:(!"</i>" i:inline { return i; })+ "</i>"
+{
+	return createNode('italic', { }, mergeText(content));
+}
+	/ "*" content:$(!"*" [a-z0-9 \t]i)+ "*"
+{
+	const parsedContent = applyParser(content, 'inlineParser');
+	return createNode('italic', { }, parsedContent);
+}
+	/ "_" content:$(!"_" [a-z0-9 \t]i)+ "_"
+{
+	const parsedContent = applyParser(content, 'inlineParser');
+	return createNode('italic', { }, parsedContent);
+}
+
 // inline: inlineCode
 
 inlineCode
@@ -247,27 +287,6 @@ hashtagBracketPair
 hashtagChar
 	= ![  \t.,!?'"#:\/\[\]【】()「」] CHAR
 
-// inline: emoji
-
-emoji
-	= customEmoji / unicodeEmoji
-
-customEmoji
-	= ":" name:emojiName ":"
-{
-	return createNode('emoji', { name: name });
-}
-
-emojiName
-	= [a-z0-9_+-]i+ { return text(); }
-
-// NOTE: if the text matches one of the emojis, it will count the length of the emoji sequence and consume it.
-unicodeEmoji
-	= &{ return matchUnicodeEmoji(); } (&{ return forwardUnicodeEmoji(); } .)+
-{
-	return createNode('emoji', { emoji: text() });
-}
-
 // inline: text
 
 text
-- 
GitLab