Skip to content

Commit

Permalink
Recognize block comments everywhere.
Browse files Browse the repository at this point in the history
Fixes #7
  • Loading branch information
dhasenan committed Nov 16, 2018
1 parent d5e18c8 commit 620fa6f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions examples/simple.sub
Expand Up @@ -2,3 +2,9 @@

\chapter{Nameless}
This is \emph{italic and \b{bold.}}
<%
This is a block comment.
It extends several lines.
%>

This is another paragraph. % And this is a line comment.
14 changes: 13 additions & 1 deletion source/parser.d
Expand Up @@ -230,7 +230,7 @@ private:
{
return;
}
auto i = data.indexOfAny("%\\}");
auto i = data.indexOfAny("%\\}<");
if (i == -1)
{
// We don't have any more special characters for the rest of time.
Expand Down Expand Up @@ -272,6 +272,18 @@ private:
data = data[j + 1 .. $];
continue;
}
if (data.startsWith("<%"))
{
data = data[2..$];
auto j = data.indexOf("%>");
if (j < 0)
{
error("Unterminated block comment. Terminate with %>.");
data = "";
continue;
}
data = data[j+2 .. $];
}
if (data.startsWith("\\"))
{
data = data[1 .. $];
Expand Down

0 comments on commit 620fa6f

Please sign in to comment.