tea3 / hexo-include-markdown

Easily load markdownfiles in Markdown .
MIT License
17 stars 2 forks source link

Render differences with codeblock #7

Open bennycode opened 3 years ago

bennycode commented 3 years ago

I am using hexo-include-markdown v1.0.2 & hexo v5.4.0 and I noticed that code blocks behave differently. When writing them directly in my main Markdown file, the code line numbers render fine but if I use the Markdown include they are distorted.

Here is an example to test:

include.md

{% codeblock lang:ts %}
export const sendRequestWithCookie = async (
  client: HttpClient,
  config: AxiosRequestConfig,
  engine: CRUDEngine
): AxiosPromise => {
  const cookie: Cookie = await loadExistingCookie(engine);

  if (!cookie.isExpired) {
    config.headers = config.headers || {};
    config.headers['Cookie'] = `zuid=${cookie.zuid}`;
    config.withCredentials = true;
  }

  return client._sendRequest(config);
};
{% endcodeblock %}

Try to use it in index.md with:

---
title: Test
---

## Test

<!-- include.md -->

Plugin version(npm ls --depth 0)

+-- hexo-browsersync@0.3.0
+-- hexo-clean-css@1.0.0
+-- hexo-filter-nofollow@2.0.2
+-- hexo-generator-archive@1.0.0
+-- hexo-generator-category@1.0.0
+-- hexo-generator-feed@3.0.0
+-- hexo-generator-index@2.0.0
+-- hexo-generator-sitemap@2.1.0
+-- hexo-generator-tag@1.0.0
+-- hexo-include-markdown@1.0.2
+-- hexo-renderer-ejs@1.0.0
+-- hexo-renderer-marked@4.0.0
+-- hexo-renderer-sass@0.4.0
+-- UNMET DEPENDENCY hexo-renderer-scss@1.2.0
+-- hexo-renderer-stylus@2.0.1
+-- hexo-server@2.0.0
+-- hexo@5.4.0
+-- highlight.js@10.7.2
+-- normalize.css@8.0.1
`-- prettier@2.3.0

Screenshot

image

bennycode commented 3 years ago

After debugging further I noticed that this error also happens with simple code like this:

console.log('Hello, World!');

I have the assumption that highlight.js kicks in too late when files are included with "hexo-include-markdown".

bennycode commented 3 years ago

Because codeblocks are not working with "hexo-include-markdown", I created my own plugin which supports it: