package com.todoist.markup;

import java.util.regex.Pattern;

class Patterns {
    public static final Pattern HEADER = Pattern.compile("^\\*\\s+");
    // Bold text is wrapped with __ or !! or **
    public static final Pattern BOLD = Pattern.compile("(?:__|!!|\\*\\*)\\s*((?!(?:__|!!|\\*\\*)).+?)\\s*(?:__|!!|\\*\\*)");
    // Italic text is wrapped with _ or *
    public static final Pattern ITALIC = Pattern.compile("[_\\*]\\s*((?![_\\*]).+?)\\s*[_\\*]");
    // Inline code is wrapped with `
    public static final Pattern INLINE_CODE = Pattern.compile("`\\s*((?!`).+?)\\s*`");
    // Code block is wrapped with ```
    public static final Pattern CODE_BLOCK = Pattern.compile("(?:```)\\s*((?!(?:```)).+?)\\s*(?:```)", Pattern.DOTALL);
    public static final Pattern LINK = Pattern.compile("((?:[a-zA-Z]+)://[^\\s]+)(?:\\s+\\(([^)]+)\\))?");
    public static final Pattern MARKDOWN_LINK = Pattern.compile("\\[(.+?)\\]\\((.+?)\\)");
    public static final Pattern GMAIL = Pattern.compile("\\[\\[gmail=\\s*(.*?)\\s*,\\s*(.*?)\\s*\\]\\]");
    public static final Pattern OUTLOOK = Pattern.compile("\\[\\[outlook=\\s*(.*?)\\s*,\\s*(.*?)\\s*\\]\\]");
    public static final Pattern THUNDERBIRD =
            Pattern.compile("\\[\\[thunderbird\\n?\\s*([^\\n]+)\\s+([^\\n]+)\\s+\\]\\]");
}

@@ -252,70 +252,90 @@
 (%22(?
-:__%7C!!%7C%5C%5C*%5C%5C*)%5C%5Cs*((?!(?:__%7C!!%7C%5C%5C*%5C%5C*)).+?)%5C%5Cs*(?:__%7C!!%7C%5C%5C*%5C%5C*
+%3C=%5E%7C%5B%5C%5Cs!?,;%3E:%5C%5C(%5C%5C)%5D)(?:%5C%5C*%5C%5C*%7C__%7C!!)(.*?)(?:%5C%5C*%5C%5C*%7C__%7C!!)(?=$%7C%5B%5C%5Cs!?,;%3E%3C:%5C%5C(%5C%5C)%5D
 )%22);
@@ -439,43 +439,77 @@
 le(%22
-%5B_%5C%5C*%5D%5C%5Cs*((?!%5B_%5C%5C*%5D).+?)%5C%5Cs*%5B_%5C%5C*%5D
+(?%3C=%5E%7C%5B%5C%5Cs!?,;%3E:%5C%5C(%5C%5C)%5D)(?:%5C%5C*%7C_)(.*?)(?:%5C%5C*%7C_)($%7C%5B%5C%5Cs!?,;%3E%3C:%5C%5C(%5C%5C)%5D)
 %22);%0A
@@ -613,26 +613,15 @@
 e(%22%60
-%5C%5Cs*((?!%60).+?)%5C%5Cs*
+(%5B%5E%60%5D+)
 %60%22);

Make BOLD ITALIC and INLINE_CODE patterns same as web Fixes Doist/Todoist-Android-Issues#214