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

fix($markdown): Fix four spaces codeblocks rendering (Closes #1921) #1958

Merged
merged 2 commits into from
Dec 9, 2019
Merged

fix($markdown): Fix four spaces codeblocks rendering (Closes #1921) #1958

merged 2 commits into from
Dec 9, 2019

Conversation

pyaillet
Copy link
Contributor

@pyaillet pyaillet commented Oct 16, 2019

Summary

Fix #1921

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:

@pyaillet pyaillet marked this pull request as ready for review October 16, 2019 11:45
@pyaillet pyaillet changed the title fix #1921: render four spaces codeblocks consistently fix: Fix four spaces codeblocks rendering (Closes #1921) Oct 16, 2019
@kefranabg kefranabg changed the title fix: Fix four spaces codeblocks rendering (Closes #1921) fix($markdown): Fix four spaces codeblocks rendering (Closes #1921) Oct 16, 2019
Copy link
Collaborator

@kefranabg kefranabg left a comment

Choose a reason for hiding this comment

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

Nice job @pyaillet ! Thanks for you work 💪

return `<!--beforebegin--><div class="language-${token.info.trim()} extra-class">`
+ `<!--afterbegin-->${rawCode}<!--beforeend--></div><!--afterend-->`
}
const fence = md.renderer.rules.fence
Copy link
Collaborator

@kefranabg kefranabg Oct 17, 2019

Choose a reason for hiding this comment

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

Actually, I think you could make a small improvement :

const { fence, codeBlock } = md.renderer.rules
md.renderer.rules.fence = wrap(fence)
md.renderer.rules.code_block = wrap(codeBlock)

What do you think @pyaillet ?

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 need to rename codeBlock to code_block to do this.
And sadly, the linter doesn't like it:

vuepress/packages/@vuepress/markdown/lib/preWrapper.js
  18:18  error  Identifier 'code_block' is not in camel case  camelcase

✖ 1 problem (1 error, 0 warnings)

Copy link
Collaborator

@kefranabg kefranabg Oct 17, 2019

Choose a reason for hiding this comment

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

Oh sure, I missed that 😉
const { fence, code_block: codeBlock } = md.renderer.rules should work

@kefranabg kefranabg assigned ulivz and unassigned ulivz Oct 23, 2019
@kefranabg kefranabg requested a review from ulivz October 23, 2019 10:11
@kefranabg kefranabg merged commit 7bc5825 into vuejs:master Dec 9, 2019
@vue-bot
Copy link

vue-bot commented Dec 9, 2019

Hey @pyaillet, thank you for your time and effort spent on this PR, contributions like yours help make Vue better for everyone. Cheers! 💚

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.

Four spaces codeblock is rendered different than three backsticks codeblock on small devices
4 participants