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

Markdown line highlighting fails in v1.0.0-alpha.40 #1364

Closed
1 task done
AngusFu opened this issue Feb 27, 2019 · 4 comments
Closed
1 task done

Markdown line highlighting fails in v1.0.0-alpha.40 #1364

AngusFu opened this issue Feb 27, 2019 · 4 comments
Labels
has PR Has a related PR type: bug Something isn't working type: question or discussion Question or discussion

Comments

@AngusFu
Copy link

AngusFu commented Feb 27, 2019

  • I confirm that this is a issue rather than a question.

Bug report

It seems that v1.0.0-alpha.40 breaks markdown line highlighting feature.

I believe this is caused by commit f04adbf1, which changed @vuepress/markdown-loader/index.js. Since I replaced the content of node_modules/@vuepress/markdown-loader/index.js with code from previous version, everything turns normal.

Version

v1.0.0-alpha.40

Steps to reproduce

I created a simple repo: vuepress-bug-report

What is expected?

markdown line highlighting feature should works.

image

What is actually happening?

image

Other relevant information

None

@shigma shigma added the type: bug Something isn't working label Feb 27, 2019
@AngusFu
Copy link
Author

AngusFu commented Feb 27, 2019

@shigma Two way to fix this issue (basically by reverting some changes):

  • remove md.parse = (src, env) => {
  • or, recover the LRU instance cache in markdown-loader

I have no idea why the whole compiling runs twice, with the requests being:

request:"${HOME}/vuepress-bug-report/node_modules/cache-loader/dist/cjs.js??ref--1-0!${HOME}/vuepress-bug-report/node_modules/vue-loader/lib/index.js??ref--1-1!${HOME}/vuepress-bug-report/node_modules/@vuepress/markdown-loader/index.js??ref--1-2!${HOME}/vuepress-bug-report/docs/README.md"
request:"${HOME}/vuepress-bug-report/node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/@vuepress/core/node_modules/.cache/vuepress","cacheIdentifier":"0954d92e-vue-loader-template"}!${HOME}/vuepress-bug-report/node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!${HOME}/vuepress-bug-report/node_modules/cache-loader/dist/cjs.js??ref--1-0!${HOME}/vuepress-bug-report/node_modules/vue-loader/lib/index.js??ref--1-1!${HOME}/vuepress-bug-report/node_modules/@vuepress/markdown-loader/index.js??ref--1-2!${HOME}/vuepress-bug-report/docs/README.md?vue&type=template&id=c6f5370e&"

By rewriting md.parse, of course we can cache tokens, BUT highlightLines.js would rewrite (link) token.info during the first compilation. Thus, when it comes to the second compilation process, it outputs the wrong result. (I don't know why we got two 😭 )

    const langName = rawInfo.replace(RE, '').trim()
    // ensure the next plugin get the correct lang.
    token.info = langName

@shigma
Copy link
Collaborator

shigma commented Feb 27, 2019

@AngusFu Thanks a lot!

To address this issue, I found a simple solution here.

However, I believe recover the LRU instance cache is much safer for more potential problems. You are right. Accually, we have met such things before.

cc @ulivz

@shigma shigma added type: question or discussion Question or discussion has PR Has a related PR labels Feb 27, 2019
@meteorlxy
Copy link
Member

And the markdown toc fails for the similar reason

@shigma
Copy link
Collaborator

shigma commented Mar 1, 2019

@meteorlxy Fixed at #1375

@ulivz ulivz closed this as completed in 5a111a2 Mar 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has PR Has a related PR type: bug Something isn't working type: question or discussion Question or discussion
Projects
None yet
Development

No branches or pull requests

3 participants