Fix anchor.toMarkup (#1246)

* Fix anchor.toMarkup

* Add space between `a`(tag name) and `href`(attribute name)
* Remove `this.href` appended to `markup` in the template literal

* Add regression test on #1245
This commit is contained in:
ylemkimon
2018-03-31 21:44:27 +09:00
committed by Erik Demaine
parent 850a0713cb
commit 1c5a7ed232
2 changed files with 6 additions and 1 deletions

View File

@@ -290,7 +290,7 @@ class anchor implements HtmlDomInterface {
let markup = "<a";
// Add the href
markup += `href="${markup += utils.escape(this.href)}"`;
markup += ` href="${utils.escape(this.href)}"`;
// Add the class
if (this.classes.length) {
markup += ` class="${utils.escape(createClass(this.classes))}"`;

View File

@@ -2591,6 +2591,11 @@ describe("An href command", function() {
const ae = getParsed(`\\href{${input}}{\\alpha}`)[0];
expect(ae.value.href).toBe(url);
});
it("should be marked up correctly", function() {
const markup = katex.renderToString("\\href{http://example.com/}{example here}");
expect(markup).toContain("<a href=\"http://example.com/\">");
});
});
describe("A parser that does not throw on unsupported commands", function() {