adrienbrignon / mkdocs-exporter

⚡ The fastest and most configurable plugin for MkDocs, allowing seamless export of individual pages or entire documentation as PDF documents.
https://adrienbrignon.github.io/mkdocs-exporter/
MIT License
71 stars 2 forks source link

UnicodeDecodeError: gbk - Illegal Multibyte Sequence #8

Closed yanedie closed 1 year ago

yanedie commented 1 year ago
Traceback (most recent call last):
  File "C:\Users\chenxianrui\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\chenxianrui\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\chenxianrui\AppData\Local\Programs\Python\Python39\Scripts\mkdocs.exe\__main__.py", line 7, in <module>
  File "C:\Users\chenxianrui\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\chenxianrui\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "C:\Users\chenxianrui\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\chenxianrui\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\chenxianrui\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\chenxianrui\AppData\Local\Programs\Python\Python39\lib\site-packages\mkdocs\__main__.py", line 234, in serve_command
    serve.serve(dev_addr=dev_addr, livereload=livereload, watch=watch, **kwargs)
  File "C:\Users\chenxianrui\AppData\Local\Programs\Python\Python39\lib\site-packages\mkdocs\commands\serve.py", line 83, in serve
    builder(config)
  File "C:\Users\chenxianrui\AppData\Local\Programs\Python\Python39\lib\site-packages\mkdocs\commands\serve.py", line 76, in builder
    build(config, live_server=live_server, dirty=dirty)
  File "C:\Users\chenxianrui\AppData\Local\Programs\Python\Python39\lib\site-packages\mkdocs\commands\build.py", line 332, in build
    config.plugins.run_event('post_build', config=config)
  File "C:\Users\chenxianrui\AppData\Local\Programs\Python\Python39\lib\site-packages\mkdocs\plugins.py", line 522, in run_event
    result = method(**kwargs)
  File "C:\Users\chenxianrui\AppData\Local\Programs\Python\Python39\lib\site-packages\mkdocs_exporter\plugins\pdf\plugin.py", line 151, in on_post_build
    self.loop.run_until_complete(asyncio.gather(*concurrently(self.tasks, max(1, self.config.concurrency or 1))))
  File "C:\Users\chenxianrui\AppData\Local\Programs\Python\Python39\lib\site-packages\nest_asyncio.py", line 90, in run_until_complete
    return f.result()
  File "C:\Users\chenxianrui\AppData\Local\Programs\Python\Python39\lib\asyncio\tasks.py", line 258, in __step
    result = coro.throw(exc)
  File "C:\Users\chenxianrui\AppData\Local\Programs\Python\Python39\lib\site-packages\mkdocs_exporter\plugins\pdf\plugin.py", line 147, in limit
    return await asyncio.create_task(coroutine)
  File "C:\Users\chenxianrui\AppData\Local\Programs\Python\Python39\lib\asyncio\futures.py", line 284, in __await__
    yield self  # This tells Task to wait for completion.
  File "C:\Users\chenxianrui\AppData\Local\Programs\Python\Python39\lib\asyncio\tasks.py", line 328, in __wakeup
    future.result()
  File "C:\Users\chenxianrui\AppData\Local\Programs\Python\Python39\lib\asyncio\futures.py", line 201, in result
    raise self._exception
  File "C:\Users\chenxianrui\AppData\Local\Programs\Python\Python39\lib\asyncio\tasks.py", line 256, in __step
    result = coro.send(None)
  File "C:\Users\chenxianrui\AppData\Local\Programs\Python\Python39\lib\site-packages\mkdocs_exporter\plugins\pdf\plugin.py", line 122, in render
    html = self.renderer.preprocess(page)
  File "C:\Users\chenxianrui\AppData\Local\Programs\Python\Python39\lib\site-packages\mkdocs_exporter\plugins\pdf\renderer.py", line 69, in preprocess
    preprocessor.script(importlib_resources.files(js).joinpath('pagedjs.min.js').read_text())
  File "C:\Users\chenxianrui\AppData\Local\Programs\Python\Python39\lib\pathlib.py", line 1267, in read_text
    return f.read()
UnicodeDecodeError: 'gbk' codec can't decode byte 0xbd in position 6267: illegal multibyte sequence

This error typically occurs when there is an issue with decoding a byte sequence using the 'gbk' codec, which is a character encoding commonly used for simplified Chinese text. It suggests that there might be a problem with the content of the file being processed, possibly due to an encoding mismatch or an invalid multibyte sequence.

I have followed the instruction and installed the prerequisite and when I run the "mkdocs serve", the error msg is above.

mat-inf commented 1 year ago

Hey @yanedie ,

Have you tried running it in Python virtual environments instead of directly on your system?

I am not an expert but by means of your logs, i would claim that this isn't a problem of this mkdocs-exporter. I had some issues too with this plugin, but most of the times it was a problem relating to my System or my CI/CD environment, and after i fixed it, the plugin ran without adjustments.

adrienbrignon commented 1 year ago

Hello,

I've just released the v4.0.1 which should solve the issue you are currently encountering @yanedie.