orzih / mkdocs-with-pdf

Generate a single PDF file from MkDocs repository.
MIT License
332 stars 77 forks source link

Apostrophe in site_author name causes plugin to crash #29

Closed binnes closed 3 years ago

binnes commented 4 years ago

An author name specified in the the mkdocs.yaml file containing an apostrophe will cause the pdf generation to crash.
E.g. O'Leary

Traceback (most recent call last):
  File "/usr/local/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/__main__.py", line 176, in gh_deploy_command
    build.build(cfg, dirty=not clean)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/commands/build.py", line 295, in build
    config['plugins'].run_event('post_build', config=config)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/plugins.py", line 96, in run_event
    result = method(**kwargs)
  File "/usr/local/lib/python3.9/site-packages/mkdocs_with_pdf/plugin.py", line 106, in on_post_build
    self.generator.on_post_build(config, self.config['output_path'])
  File "/usr/local/lib/python3.9/site-packages/mkdocs_with_pdf/generator.py", line 101, in on_post_build
    add_stylesheet(style_for_print(self._options))
  File "/usr/local/lib/python3.9/site-packages/mkdocs_with_pdf/styles/__init__.py", line 17, in style_for_print
    root = sass.compile(string=scss)
  File "/usr/local/lib/python3.9/site-packages/sass.py", line 738, in compile
    raise CompileError(v)
sass.CompileError: Error: Invalid CSS after "...copyright 'None": expected expression (e.g. 1px, bold), was "';"
        on line 4:36 of stdin
>>         string-set: copyright 'None';

The apostrophe can be escaped O\'Leary, which no longer crashes, but the name appears in the pdf with the escaping backslash.

orzih commented 4 years ago

Thank you for your reporting. This issue was fixed in v0.7.7.