Skip to content
This repository has been archived by the owner on Nov 17, 2022. It is now read-only.

Solve some problems in use #102

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: ci

on:
push:
branches:
- master

jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/gitbook2pdf:latest
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM python:3.8.12-bullseye

RUN echo """deb http://mirrors.ustc.edu.cn/debian stable main contrib non-free \
deb http://mirrors.ustc.edu.cn/debian stable-updates main contrib non-free \
deb http://mirrors.ustc.edu.cn/debian-security stable-security main contrib non-free""" > /etc/apt/sources.list

RUN apt update \
&& apt-get install -y ttf-mscorefonts-installer fontconfig \
&& apt-get install ttf-wqy-microhei ttf-wqy-zenhei

ENV LANG=zh_CN.UTF-8 LANGUAGE=zh_CN.UTF-8

RUN apt-get install -y locales \
&& dpkg-reconfigure --frontend=noninteractive locales

RUN git clone https://github.com/is2ac-zhao/gitbook2pdf /app
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use COPY not git clone?


WORKDIR /app

RUN python -m pip install --upgrade pip \
&& python -m pip install -r requirements.txt

CMD ["python"]


4 changes: 2 additions & 2 deletions gitbook2pdf/gitbook2pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def srcrepl(self, match):
pathStr = match.group(3)
if pathStr.startswith(".."):
pathStr = pathStr[3:]
return "<" + match.group(1) + match.group(2) + "=" + "\"" + absolutePath + pathStr + "\"" + match.group(
return "<" + match.group(1) + match.group(2) + "=" + "\"" + urljoin(absolutePath, pathStr) + "\"" + match.group(
4) + ">"

def relative_to_absolute_path(self, origin_text):
Expand Down Expand Up @@ -189,7 +189,7 @@ def __init__(self, base_url, fname=None):
self.meta_list.append(
('generator', 'gitbook2pdf')
)
weasyprint.HTML._ua_stylesheets = local_ua_stylesheets
# weasyprint.HTML._ua_stylesheets = local_ua_stylesheets
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is to ensure a consistent Style, why remove it?


def run(self):
content_urls = self.collect_urls_and_metadata(self.base_url)
Expand Down
Loading