package com.todoist.markup;

import java.util.regex.Pattern;

class Patterns {
    public static final Pattern HEADER = Pattern.compile("^\\*\\s+");
    public static final Pattern BOLD = Pattern.compile("!!\\s*((?!!!).+?)\\s*!!");
    public static final Pattern ITALIC = Pattern.compile("_\\s*((?!_).+?)\\s*_");
    public static final Pattern INLINE_CODE = Pattern.compile("`\\s*((?!`).+?)\\s*`");
    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 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+\\]\\]");
}

@@ -72,16 +72,91 @@
 terns %7B%0A
+    private static final String PATTERN_BASE = %22%25s%5C%5Cs*((?!%25s).+?)%5C%5Cs*%25s%22;%0A%0A
     publ
@@ -276,33 +276,58 @@
 ile(
-%22!!%5C%5Cs*((?!!!).+?)%5C%5Cs*!!%22
+PATTERN_BASE.replaceAll(%22%25s%22, %22(?:__%7C%5C%5C%5C%5C*%5C%5C%5C%5C*)%22)
 );%0A 
@@ -386,30 +386,47 @@
 ile(
-%22_%5C%5Cs*((?!_).+?)%5C%5Cs*_%22
+PATTERN_BASE.replaceAll(%22%25s%22, %22%5B_%5C%5C*%5D%22)
 );%0A 
@@ -490,30 +490,42 @@
 ile(
-%22%60%5C%5Cs*((?!%60).+?)%5C%5Cs*%60%22
+PATTERN_BASE.replaceAll(%22%25s%22, %22%60%22)
 );%0A 
@@ -588,36 +588,45 @@
 ile(
-%22%60%60%60%5C%5Cs*((?!%60%60%60).+?)%5C%5Cs*%60%60%60%22
+PATTERN_BASE.replaceAll(%22%25s%22, %22%60%7B3%7D%22)
 , Pa

Extend bold and italic pattern