Merge pull request #16 from thradec/fenced-code-block-delimited-by-tilde

Fenced code block delimited by tilde ~ characters
This commit is contained in:
René Jeschke 2013-02-07 00:50:09 -08:00
commit 99e83e6ee5
3 changed files with 9 additions and 5 deletions

View File

@ -773,6 +773,7 @@ class Emitter
case '_':
case '!':
case '`':
case '~':
case '^':
return MarkToken.ESCAPE;
default:

View File

@ -138,6 +138,7 @@ class Line
case '_':
case '!':
case '`':
case '~':
sb.append(c);
pos++;
break;
@ -263,9 +264,11 @@ class Line
if(extendedMode)
{
if(this.value.length() - this.leading - this.trailing > 2 && this.value.charAt(this.leading) == '`')
if(this.value.length() - this.leading - this.trailing > 2)
{
if(this.countCharsStart('`') >= 3)
if(this.value.charAt(this.leading) == '`' && this.countCharsStart('`') >= 3)
return LineType.FENCED_CODE;
if(this.value.charAt(this.leading) == '~' && this.countCharsStart('~') >= 3)
return LineType.FENCED_CODE;
}
}

View File

@ -639,11 +639,11 @@ class Utils
}
/**
* Removes trailing <code>`</code> and trims spaces.
* Removes trailing <code>`</code> or <code>~</code> and trims spaces.
*
* @param fenceLine
* Fenced code block starting line
* @return Rest of the line after trimming and backtick removal
* @return Rest of the line after trimming and backtick or tilde removal
* @since 0.7
*/
public final static String getMetaFromFence(String fenceLine)
@ -651,7 +651,7 @@ class Utils
for(int i = 0; i < fenceLine.length(); i++)
{
final char c = fenceLine.charAt(i);
if(!Character.isWhitespace(c) && c != '`')
if(!Character.isWhitespace(c) && c != '`' && c != '~' )
{
return fenceLine.substring(i).trim();
}