diff --git a/Units/parser-html.r/whitespace-prefixed.html.d/expected.tags b/Units/parser-html.r/whitespace-prefixed.html.d/expected.tags
new file mode 100644
index 0000000000..9e54554063
--- /dev/null
+++ b/Units/parser-html.r/whitespace-prefixed.html.d/expected.tags
@@ -0,0 +1 @@
+heading1 input.html /^<\/h1>$/;" h
diff --git a/Units/parser-html.r/whitespace-prefixed.html.d/input.html b/Units/parser-html.r/whitespace-prefixed.html.d/input.html
new file mode 100644
index 0000000000..c3727d4d0b
--- /dev/null
+++ b/Units/parser-html.r/whitespace-prefixed.html.d/input.html
@@ -0,0 +1,3 @@
+
+ heading1
+
diff --git a/Units/parser-javascript.r/js-broken-template.d/expected.tags b/Units/parser-javascript.r/js-broken-template.d/expected.tags
index 3dec97c22e..e69de29bb2 100644
--- a/Units/parser-javascript.r/js-broken-template.d/expected.tags
+++ b/Units/parser-javascript.r/js-broken-template.d/expected.tags
@@ -1 +0,0 @@
-\n input.js /^let`$/;" v
diff --git a/main/entry.c b/main/entry.c
index 04c361b19f..cbbce83711 100644
--- a/main/entry.c
+++ b/main/entry.c
@@ -1280,8 +1280,25 @@ static void makeTagEntriesForSubwords (tagEntryInfo *const subtag)
stringListDelete (list);
}
-extern int makeTagEntry (const tagEntryInfo *const tag)
+static char *trimPrefixedWhitespaces (const char *name)
{
+ const char *start;
+
+ for (start = name; isspace(*start); start++)
+ ;
+
+ if (start != name)
+ return eStrdup (start);
+
+ return NULL;
+}
+
+extern int makeTagEntry (const tagEntryInfo *const tag_const)
+{
+ char *trimmed_name;
+ const tagEntryInfo *tag = tag_const;
+ tagEntryInfo tag_backingstore;
+
int r = CORK_NIL;
Assert (tag->name != NULL);
@@ -1295,6 +1312,14 @@ extern int makeTagEntry (const tagEntryInfo *const tag)
return CORK_NIL;
}
+ trimmed_name = trimPrefixedWhitespaces (tag->name);
+ if (trimmed_name)
+ {
+ tag_backingstore = *tag_const;
+ tag = &tag_backingstore;
+ tag_backingstore.name = trimmed_name;
+ }
+
if (tag->name [0] == '\0' && (!tag->placeholder))
{
if (!doesInputLanguageAllowNullTag())
@@ -1314,6 +1339,8 @@ extern int makeTagEntry (const tagEntryInfo *const tag)
makeTagEntriesForSubwords (&subtag);
}
out:
+ if (trimmed_name)
+ eFree (trimmed_name);
return r;
}