Skip to content

chore(docs): correcting headers and adding header linking #6040

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

Merged
merged 3 commits into from
Aug 1, 2017

Conversation

amcdnl
Copy link
Contributor

@amcdnl amcdnl commented Jul 26, 2017

This PR fixes inconsistent headers and adds header linking for the table of contents in the material docs.

This PR is part of angular/material.angular.io#230

@@ -69,10 +69,25 @@ task('docs', [

/** Generates html files from the markdown overviews and guides. */
task('markdown-docs', () => {
// Extend the renderer for custom heading anchor rendering
markdown.marked.Renderer.prototype.heading = (text: string, level: number): string => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs for marked give a different API for customizing a renderer, don't think you're supposed to monkey-patch the renderer prototype:
https://github.com/chjj/marked#overriding-renderer-methods

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we are using the gulp plugin, I wasn't able to override the renderer like that. In order to do that, I would need to roll our own gulp adapter so we can pass in a custom renderer. Is that something you would like me to look at?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, didn't know the gulp config wasn't a full pass-through

if(level === 3 || level === 4) {
const escapedText = text.toLowerCase().replace(/[^\w]+/g, '-');
return `
<h${level} id="${escapedText}">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it easier to add the ids during generation than when the html file is loaded on the docs site?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured it would be faster to do it during generation. Happy to change it if you don't fancy this approach.

@amcdnl
Copy link
Contributor Author

amcdnl commented Jul 29, 2017

@jelbourn - please advise on next steps :)

@jelbourn jelbourn changed the title chore(*): correcting headers and adding header linking chore(docs): correcting headers and adding header linking Jul 31, 2017
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -69,10 +69,25 @@ task('docs', [

/** Generates html files from the markdown overviews and guides. */
task('markdown-docs', () => {
// Extend the renderer for custom heading anchor rendering
markdown.marked.Renderer.prototype.heading = (text: string, level: number): string => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, didn't know the gulp config wasn't a full pass-through

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Jul 31, 2017
@tinayuangao tinayuangao merged commit f5dc120 into angular:master Aug 1, 2017
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants