asciidoctor / asciidoctor-vscode

AsciiDoc support for Visual Studio Code using Asciidoctor
Other
340 stars 97 forks source link

Footer in PDF only says "undefined" #526

Closed gurbindersingh closed 2 years ago

gurbindersingh commented 2 years ago

Description

The PDF generated using wkthtmltopdf only has the word "undefined" in the footer. I double checked by running it manually and it didn't happen. I believe it's because this statement

https://github.com/asciidoctor/asciidoctor-vscode/blob/e15256254407d508aca84c3d6553d81d002f0ddc/src/commands/exportAsPDF.ts#L258

is missing a && footerCenter !== undefined.

System Information

Version: 1.64.2 (user setup)
Commit: f80445acd5a3dadef24aa209168452a3d97cc326
Date: 2022-02-09T22:02:28.252Z
Electron: 13.5.2
Chromium: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Windows_NT x64 10.0.19044

To Reproduce

Steps to reproduce the issue:

  1. Create a AsciiDoc file with the following content
= Doc
:toc: auto
:sectnums: all
:sectnumlevels: 5
:nofooter:

== Undefined Footer

Foo bar.
  1. Export the document as a PDF
ggrossetie commented 2 years ago

Indeed, the code is wrong, it should be:

if (footerCenter) {
  cmdArguments.push('--footer-center', footerCenter)
}

The type declaration should also be fixed on the html2pdf function since footerCenter is either string | undefined.

@gurbindersingh are you willing to submit a fix?

gurbindersingh commented 2 years ago

Sure thing. Is there anything I should keep in mind? The contribution guidelines don't mention pull requests.

ggrossetie commented 2 years ago

You should run the linter before opening a pull request: npm run lint.

You can also run the tests suite even though we currently have very few tests: npm t.

Our plan is to progressively add more tests 😉