@@ -0,0 +1,2886 @@
+package flow.netbeans.markdown.typinghooks;%0A%0Aimport flow.netbeans.markdown.csl.MarkdownLanguageConfig;%0Aimport java.util.regex.Matcher;%0Aimport java.util.regex.Pattern;%0Aimport javax.swing.text.BadLocationException;%0Aimport javax.swing.text.StyledDocument;%0Aimport org.netbeans.api.editor.mimelookup.MimePath;%0Aimport org.netbeans.api.editor.mimelookup.MimeRegistration;%0Aimport org.netbeans.spi.editor.typinghooks.TypedBreakInterceptor;%0Aimport org.openide.text.NbDocument;%0A%0A/**%0A *%0A * @author junichi11%0A */%0Apublic class MarkdownTypedBreakInterceptor implements TypedBreakInterceptor %7B%0A%0A    @Override%0A    public boolean beforeInsert(Context context) throws BadLocationException %7B%0A        return false;%0A    %7D%0A%0A    @Override%0A    public void insert(MutableContext context) throws BadLocationException %7B%0A        StyledDocument document = (StyledDocument) context.getDocument();%0A        int caretOffset = context.getCaretOffset();%0A        int lineNumber = NbDocument.findLineNumber(document, caretOffset);%0A        int lineOffset = NbDocument.findLineOffset(document, lineNumber);%0A        String lineText = document.getText(lineOffset, caretOffset - lineOffset);%0A%0A        if (lineText.matches(%22%5E%5C%5Cs%7B4,%7D$%22)) %7B // NOI18N%0A            return;%0A        %7D%0A%0A        StringBuilder sb = new StringBuilder(%22%5Cn%22); // NOI18N%0A        Pattern pattern = Pattern.compile(%22%5E(%5B-*%5D %7C%5B#%5D+ %7C(%5C%5Cd+)%5C%5C. %7C%5Ct+%7C%5C%5Cs%7B4,%7D).+$%22); // NOI18N%0A        Matcher matcher = pattern.matcher(lineText);%0A        if (matcher.find()) %7B%0A            String numberText = matcher.group(2);%0A            if (numberText != null) %7B%0A                int number = Integer.parseInt(numberText);%0A                sb.append(++number).append(%22. %22); // NOI18N%0A            %7D else %7B%0A                sb.append(matcher.group(1));%0A            %7D%0A        %7D%0A        context.setText(sb.toString(), 0, sb.length());%0A    %7D%0A%0A    @Override%0A    public void afterInsert(Context context) throws BadLocationException %7B%0A        StyledDocument document = (StyledDocument) context.getDocument();%0A        int caretOffset = context.getCaretOffset();%0A        int lineNumber = NbDocument.findLineNumber(document, caretOffset);%0A        int lineOffset = NbDocument.findLineOffset(document, lineNumber);%0A        String lineText = document.getText(lineOffset, caretOffset - lineOffset);%0A        if (lineText.matches(%22%5E(%5B-*%5D %7C%5B#%5D+ %7C%5C%5Cd+%5C%5C. %7C%5Ct+%7C%5C%5Cs%7B4,%7D)$%22)) %7B // NOI18N%0A            document.remove(lineOffset, lineText.length());%0A        %7D%0A    %7D%0A%0A    @Override%0A    public void cancelled(Context context) %7B%0A    %7D%0A%0A    @MimeRegistration(mimeType = MarkdownLanguageConfig.MIME_TYPE, service = TypedBreakInterceptor.Factory.class)%0A    public static class MarkdownFactory implements TypedBreakInterceptor.Factory %7B%0A%0A        @Override%0A        public TypedBreakInterceptor createTypedBreakInterceptor(MimePath mimePath) %7B%0A            return new MarkdownTypedBreakInterceptor();%0A        %7D%0A    %7D%0A%0A%7D%0A

Add typinghooks