Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs failing to load due to markdown parser breaking changes #6197

Closed
jakeswenson opened this issue Jun 15, 2024 · 2 comments
Closed

Docs failing to load due to markdown parser breaking changes #6197

jakeswenson opened this issue Jun 15, 2024 · 2 comments

Comments

@jakeswenson
Copy link

The rustfmt docs site is failing to load for me.

I've tracked it down to what looks like a change in marked.

Specifically the heading function is now handed a single object argument instead of what the current code is expecting.

In marked:

case 'heading': {
  out += this.renderer.heading(token);
  continue;
}

https://github.com/markedjs/marked/blob/70bb55e0af5128a657a14b8b25d7d406661e6936/src/Parser.ts#L69-L71

Marked made an API contract breaking change for this: markedjs/marked#3291

In rustfmt page:

rustfmt/docs/index.html

Lines 172 to 178 in c97996f

const renderer = new marked.Renderer();
renderer.heading = function(text, level) {
const id = htmlToId(text);
return `<h${level}>
<a id="${id}" href="#${id}" name="${id}" class="header-link">${text}</a>
</h${level}>`;
};

htmlToId is now failing because text is an object, and doesn't have a .trim() method

rustfmt/docs/index.html

Lines 304 to 308 in c97996f

function htmlToId(text) {
const tmpl = document.createElement('template');
tmpl.innerHTML = text.trim();
return encodeURIComponent(CSS.escape(tmpl.content.textContent));
}

@jakeswenson
Copy link
Author

jakeswenson commented Jun 15, 2024

Quickest fix would be to pin to a proper major version for marked

<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>

Setting it to https://cdn.jsdelivr.net/npm/marked@12/marked.min.js works for me locally

@jakeswenson
Copy link
Author

Fixed in #6194

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant