numbered section not working + table width problem
cutelittleturtle opened this issue · 9 comments
Q1.
Hi I am trying to turn on the numbered section option supported by native pandoc with this plugin.
I set the config file as
pandoc:
extra:
-number-sections: true
I expected it to be passed as --number-sections
to pandoc and in html show
1. Header1
2. Header2
2.1 Sub-header1
But I don't see the generated html having section headers numbered. I tried to put numbersections: true
in the .md's front matter as well. The {-}
function to not number a section didn't work either.
Q2.
Also, I created a multiline table using pandoc's syntax. The table width however only extends to the number of dashes I have in the markdown file. The relative width works. Is it possible to make pandoc adopt the full width of the section while still maintain the relative width?
Thank you.
Hi @cutelittleturtle ,
For the first question, you should separate -
and number-sections
with a space.
pandoc:
extra:
- number-sections: true
That should works.
For the second question, it's not caused by pandoc. Its controlled by your style sheets. You can easily adopt it by modifying your style files, like css file for html.
Thank you! Is it possible to control the number-sections option only to certain posts by adding YAML? And for second question, should I add a css for pandoc-table as a table.pandoc-table item? Because with marked
rendered I think the width is automatically extended to full width.
Is it possible to control the number-sections option only to certain posts by adding YAML?
I guess not. You can't pass the front-end options to the renderer.
should I add a css for pandoc-table as a table.pandoc-table item?
Yes. You might give it a try.
thanks.
Hi, I have corrected my _config.yml as you suggested but now it seems not parsing the option correctly:
Error: pandoc exited with code 2: pandoc: unrecognized option `--0'
I checked my pandoc installation and the option --number-sections works with pandoc in terminal.
I'm celebrating a holiday so I currently don't have the device to test this plugin and henceforth I just can't answer you for a while.
FYI, for now I still can't figure out where the option --0
comes from. It definitely not comes from my codes. You can see how the extra
configs are passed to the code:
if(config.extra) {
for(var e in config.extra) {
extra.push('--' + e);
extra.push(config.extra[e]);
}
}
I found the problem. The YAML front matter translation is tricky here. For a configuration input like this:
pandoc:
extra:
- number-sections: true
- test: false
This YAML snippet translates into one .js object:
{
"pandoc": {
"extra": [
{
"number-sections": true
},
{
"test": false
}
]
}
}
As you can see, the data structure is object-object(pandoc)-object(extra)-array-object(numer-sections)
. The parsing code you have assumes object-object(pandoc)-object(extra)-object(numer-sections)
. That's why var e
there returns '0'. It is the index. The config.extra[e]
will return [object Object]
So I changed the parsing code and it's working properly. I can see numbered section in my post.
if(config.extra) {
for(var e in config.extra) {
var eoption = config.extra[e];
for (var key in eoption){
extra.push('--' + key);
//extra.push(eoption[key]);
}
}
}
I commented out the second push
because it adds the key value true
as another option to pandoc. It does not give out error but I am just not sure what it will do implicitly.
The YAML front matter translation is tricky here
Where did you put the settings to? Your root _config.yml
file, or YAML front matter of a certain post? For the second case, the plugin is not guarantee to work well.
In the _config.yml