More link parsing fixes
This commit is contained in:
		
							parent
							
								
									fee6e34d34
								
							
						
					
					
						commit
						602130c0f7
					
				
					 1 changed files with 11 additions and 4 deletions
				
			
		| 
						 | 
					@ -190,8 +190,8 @@ public class MarkdownProcessor {
 | 
				
			||||||
                        linkValue[0] = buffer.toString().trim();
 | 
					                        linkValue[0] = buffer.toString().trim();
 | 
				
			||||||
                        buffer.setLength(0);
 | 
					                        buffer.setLength(0);
 | 
				
			||||||
                        int j = i + 1;
 | 
					                        int j = i + 1;
 | 
				
			||||||
                        int newlines = 0;
 | 
					                        int newlines = c == '\n' ? 1 : 0;
 | 
				
			||||||
                        while (j < length && chars[j] != ')' && Character.isWhitespace(chars[j])) {
 | 
					                        while (j < length && Character.isWhitespace(chars[j])) {
 | 
				
			||||||
                            if (chars[j] == '\n') {
 | 
					                            if (chars[j] == '\n') {
 | 
				
			||||||
                                newlines += 1;
 | 
					                                newlines += 1;
 | 
				
			||||||
                                if (newlines > 1) {
 | 
					                                if (newlines > 1) {
 | 
				
			||||||
| 
						 | 
					@ -203,7 +203,7 @@ public class MarkdownProcessor {
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                            j += 1;
 | 
					                            j += 1;
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                        if ((chars[j] == '"' || chars[j] == '\'' || chars[j] == '(') && newlines <= 1) {
 | 
					                        if (j < length && newlines <= 1 && isLinkQuote(chars[j])) {
 | 
				
			||||||
                            char quoteChar = chars[j] == '(' ? ')' : chars[j];
 | 
					                            char quoteChar = chars[j] == '(' ? ')' : chars[j];
 | 
				
			||||||
                            int start = j = j + 1;
 | 
					                            int start = j = j + 1;
 | 
				
			||||||
                            int len = -1;
 | 
					                            int len = -1;
 | 
				
			||||||
| 
						 | 
					@ -221,13 +221,16 @@ public class MarkdownProcessor {
 | 
				
			||||||
                                c = chars[j];
 | 
					                                c = chars[j];
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                        if (c == '\n') {
 | 
					                        if (c == '\n' && state != NONE) {
 | 
				
			||||||
                            links.put(linkId.toLowerCase(), linkValue);
 | 
					                            links.put(linkId.toLowerCase(), linkValue);
 | 
				
			||||||
                            System.arraycopy(chars, i, chars, linestart, length - i);
 | 
					                            System.arraycopy(chars, i, chars, linestart, length - i);
 | 
				
			||||||
                            length -= (i - linestart);
 | 
					                            length -= (i - linestart);
 | 
				
			||||||
                            i = linestart;
 | 
					                            i = linestart;
 | 
				
			||||||
                            buffer.setLength(0);
 | 
					                            buffer.setLength(0);
 | 
				
			||||||
                            linkId = null;
 | 
					                            linkId = null;
 | 
				
			||||||
 | 
					                        } else {
 | 
				
			||||||
 | 
					                            // no valid link title - escape
 | 
				
			||||||
 | 
					                            state = NONE;
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    } else {
 | 
					                    } else {
 | 
				
			||||||
                        buffer.append(c);
 | 
					                        buffer.append(c);
 | 
				
			||||||
| 
						 | 
					@ -985,6 +988,10 @@ public class MarkdownProcessor {
 | 
				
			||||||
        return b.toString();
 | 
					        return b.toString();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    boolean isLinkQuote(char c) {
 | 
				
			||||||
 | 
					        return c == '"' || c == '\'' || c == '(';
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    boolean isSpace(char c) {
 | 
					    boolean isSpace(char c) {
 | 
				
			||||||
        return c == ' ' || c == '\t';
 | 
					        return c == ' ' || c == '\t';
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue