hexo-include-markdown icon indicating copy to clipboard operation
hexo-include-markdown copied to clipboard

Render differences with codeblock

Open bennycode opened this issue 4 years ago • 2 comments

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)

+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- UNMET DEPENDENCY [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
`-- [email protected]

Screenshot

image

bennycode avatar May 21 '21 16:05 bennycode

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 avatar May 22 '21 10:05 bennycode

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

  • https://github.com/bennycode/hexo-insert-markdown

bennycode avatar Jun 01 '21 17:06 bennycode