Comments (8)
My suspicion is that our code block is hijacked by hexo's syntax highlight plugin and isn't processed my pandoc at all.
Can you try and see if any of the following two approaches works?
- if you don't want hexo's syntax highlight, then, in your
_config.yml
, add
highlight:
enable: false
to turn off hexo's syntax highlight, and use the following syntax to pass preserve-tabs
to pandoc (note the colon!!)
pandoc:
extra:
- preserve-tabs: # note this colon!!
Then your code block will be processed by pandoc and have tabs preserved.
- if you want hexo's syntax highlight, then of course pandoc's
--preserve-tabs
won't be effective. In this case, add to_config.yml
the following:
highlight:
enable: false
tab_replace: '	' # or put a tab character between the quotes instead
from hexo-renderer-pandoc.
None of them works:
1
highlight:
enable: false
pandoc:
extra:
- preserve-tabs: # note this colon!!
2
highlight:
enable: false
tab_replace: '	'
3
highlight:
enable: true
tab_replace: '	'
I suspect that hexo-theme-tree I use hijacks the highlighting of the code blocks. Because I have uninstalled almost all unnecessary npm modules. All modules remained are as follows:
➜ blog git:(master) ✗ npm list
[email protected] /home/searchstar/git/blog
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]
I don't think there is any other module that can hijack the highlighting of code blocks.
from hexo-renderer-pandoc.
I removed all code related to highlighting in hexo-theme-tree
: seekstar/blog@299bdce
And the code blocks become plain, e.g., http://localhost:4000/2022/09/30/c-panic/:
But each tab is still replaced with four whitespaces.
from hexo-renderer-pandoc.
I need your help to pin-point the location of the issue.
Can you locate the following code in node_modules/hexo-renderer-pandoc/index.js
var res = spawnSync(pandoc_path, args, {
cwd: process.cwd(),
env: process.env,
encoding: "utf8",
input: src
});
and change it to
console.log(args) // ADDED
console.log(data) // ADDED
var res = spawnSync(pandoc_path, args, {
cwd: process.cwd(),
env: process.env,
encoding: "utf8",
input: src
});
console.log(res) // ADDED
Then render a minimal working example, such as the one below:
---
title: test codeblock
---
begin
```
function () {
// <- put a tab here before the slashes
}
```
Then post the content of stdout here. By looking at the output I may be able to see what's causing the issue.
from hexo-renderer-pandoc.
Also, please don't post urls that contain localhost
(like your http://localhost:4000/2022/09/30/c-panic/). Those urls are only accessible on your own machine.
from hexo-renderer-pandoc.
I've already tried console.log
. When it is added before pandocRenderer
, it prints to stdout. But when it is added in pandocRenderer
, it does not print anything, even when refreshing the blog page. I suspect that the output is printed elsewhere.
By the way, the URL http://localhost:4000/2022/09/30/c-panic/ was posted to indicate the source blog post of the screenshot. It is useful if you (or someone else) clone my blog repo and hexo g && hexo s
to reproduce the problem.
from hexo-renderer-pandoc.
I accidentally found that the re-rendering of a blog post can only be triggered by pressing ctrl+s
in the post in vscode, and the tabs in the re-rendered posts are perfectly preserved. Do you have any suggestions about re-rendering all blog posts without discarding the deployment history?
from hexo-renderer-pandoc.
Do you have any suggestions about re-rendering all blog posts without discarding the deployment history?
I accidentally found that hexo clean && hexo g
works fine.
In conclusion, a solution to this issue is disabling the highlight of hexo and passing --preserve-tabs
to pandoc
:
highlight:
enable: false
pandoc:
extra:
- preserve-tabs: # note this colon!!
And then hexo clean && hexo g
and optionally hexo s
or hexo d
to make the changes take effect. This works for hexo-theme-tree I use out-of-the-box, i.e., there is no need to remove highlight-related code, and the theme can still highlight the tabs-preserved code blocks outputted by pandoc
.
Thank you for your attention!
from hexo-renderer-pandoc.
Related Issues (20)
- 关于 \newcommand 的问题 HOT 1
- Is it possible to add a link to header tag as what hexo-renderer-marked did? HOT 2
- 嵌套的tag渲染错误 HOT 4
- Is it possible to render external package? HOT 1
- Why it's <embed> instead of <img> tag? HOT 5
- The task list or todo list cannot be rendered correctly HOT 2
- 关于新版本pandoc中citeproc模块的处理 HOT 10
- about env of pandoc HOT 3
- 多级列表转换异常 HOT 3
- '\oiint' could not show HOT 2
- Lua-filter support HOT 1
- 📢 This repo has been transfered to hexojs organization HOT 8
- `hexo-renderer-pandoc` with `hexo-generator-feed` produces HTML generation errors | `hexo-renderer-pandoc` 搭配 `hexo-generator-feed` 会出现 HTML 生成错误 HOT 2
- Can I set the resource root path? HOT 1
- 回车换行不起作用 HOT 3
- New interface to specify arguments to pandoc
- Unexpected Changes in Article Headerlink and Missing Headerlink Icon HOT 7
- Error handling tag id assignment through pandoc syntax HOT 2
- How to escape dollar signs? HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hexo-renderer-pandoc.