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

feat: support writing HTML(Vue) anywhere in the header. #711

Merged
merged 1 commit into from
Aug 8, 2018

Conversation

ulivz
Copy link
Member

@ulivz ulivz commented Aug 8, 2018

Summary

Since VuePress needs to extract the header from the markdown source file and display it in the sidebar or title (#238), this file(lib/util/parseHeaders.js) simply removes some unnecessary elements to make header displays well at sidebar or title.

But header's parsing in the markdown content is done by the markdown loader based on markdown-it. markdown-it parser will will always keep HTML in headers, so in VuePress, after being parsed by the markdiwn loader, the raw HTML in headers will finally be parsed by Vue-loader. so that we can write HTML/Vue in the header. One exception is the HTML wrapped by <code>(markdown token: '`') tag.

This PR is to support writing HTML(Vue) anywhere in the header, not just at the end of the header.

Some key points about this PR:

  1. Write HTML(Vue) anywhere in the header as long as it is not wrapped by code(`).
  2. The HTML wrapped by code will be shown as it is.
  3. A good practice when using HTML in a header is to leave a space between plain text and HTML.

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Docs
  • Build-related changes
  • Other, please describe:

If changing the UI of default theme, please provide the before/after screenshot:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

  • When resolving a specific issue, it's referenced in the PR's title (e.g. fix #xxx[,#xxx], where "xxx" is the issue number)

You have tested in the following browsers: (Providing a detailed version will be better.)

  • Chrome
  • Firefox
  • Safari
  • Edge
  • IE

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature
  • Related documents have been updated
  • Related tests have been updated

To avoid wasting your time, it's best to open a feature request issue first and wait for approval before working on it.

Other information:

Close: #693
Close: #688
Close: #689

A correct solution to replace #694

1. You can write HTML(Vue) anywhere in the header as long as it is not wrapped by code(`).
2. The HTML wrapped by code will be shown as it is.
3. A good practice when using HTML in a header is to leave a space between plain text and HTML.
@ulivz
Copy link
Member Author

ulivz commented Aug 8, 2018

Updated docs at 12c2beb

@ulivz ulivz deleted the header-extraction-enhancement branch August 9, 2018 18:31
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 this pull request may close these issues.

Strip HTML from the left in headers extraction Badge Component HTML displays in Page Title when used in H1
1 participant