Skip to content

Commit

Permalink
Implement "double-space line breaks" syntax in Markdown
Browse files Browse the repository at this point in the history
Ending a line with two spaces is supposed to create a line break in
Markdown.  This implements that syntax.
  • Loading branch information
Alex Merry committed Mar 18, 2014
1 parent 683ef76 commit e4596c7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/markdown.cpp
Expand Up @@ -1656,6 +1656,16 @@ static int writeTableBlock(GrowBuf &out,const char *data,int size)
}


static int hasLineBreak(const char *data,int size)
{
int i=0;
while (i<size && data[i]!='\n') i++;
if (i>=size) return 0; // empty line
if (i<2) return 0; // not long enough
return (data[i-1]==' ' && data[i-2]==' ');
}


void writeOneLineHeaderOrRuler(GrowBuf &out,const char *data,int size)
{
int level;
Expand Down Expand Up @@ -1729,6 +1739,10 @@ void writeOneLineHeaderOrRuler(GrowBuf &out,const char *data,int size)
else // nothing interesting -> just output the line
{
out.addStr(data,size);
if (hasLineBreak(data,size))
{
out.addStr("<br>");
}
}
}

Expand Down

0 comments on commit e4596c7

Please sign in to comment.