Skip to content

Commit f24a008

Browse files
sideshowbarkerdomenic
authored andcommitted
Update highlighter and Docker to Python 3
This also updates the install process for the highlighter to pull from pip.
1 parent cf91400 commit f24a008

File tree

7 files changed

+19
-28
lines changed

7 files changed

+19
-28
lines changed

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
FROM debian:stable
22

3-
## dependency installation: nginx, wattsi, and other build tools
4-
## cleanup freepascal since it is no longer needed after wattsi build
3+
## dependency installation: nginx and other build tools
54
RUN apt-get update && \
6-
apt-get install -y ca-certificates curl git unzip nginx python2.7 python-pip && \
5+
apt-get install -y ca-certificates curl git unzip nginx python3 python3-pip && \
76
rm -rf /etc/nginx/sites-enabled/* && \
87
rm -rf /var/lib/apt/lists/*
98

109
COPY --from=whatwg/wattsi:latest /whatwg/wattsi/bin/wattsi /bin/wattsi
1110

1211
ADD . /whatwg/build
1312

13+
RUN pip3 install bs-highlighter
14+
1415
ARG html_source_dir
1516
ADD $html_source_dir /whatwg/html
1617
ENV HTML_SOURCE /whatwg/html

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Make sure you have `git` installed on your system, and you are using a Bash shel
88

99
Then, clone this ([html-build](https://github.com/whatwg/html-build)) repo:
1010

11-
```
11+
```bash
1212
git clone https://github.com/whatwg/html-build.git && cd html-build
1313
```
1414

@@ -22,13 +22,13 @@ To build locally, you'll need the following commands installed on your system:
2222

2323
- `curl`, `grep`, `perl`, `unzip`
2424

25-
Optionally, for faster builds, you can install [Wattsi](https://github.com/whatwg/wattsi) and Python 2.7 (necessary for applying syntax highlighting to `pre` contents). If you don't bother with that, the build will use [Wattsi Server](https://github.com/domenic/wattsi-server), which requires an internet connection.
25+
Optionally, for faster builds, you can install [Wattsi](https://github.com/whatwg/wattsi) and Python 3.7+ (necessary for applying syntax highlighting to `pre` contents). If you don't bother with that, the build will use [Wattsi Server](https://github.com/domenic/wattsi-server), which requires an internet connection.
2626

2727
### Running the build
2828

2929
Run the `build.sh` script from inside your `html-build` working directory, like this:
3030

31-
```
31+
```bash
3232
./build.sh
3333
```
3434

@@ -59,7 +59,7 @@ The Dockerized version of the build allows you to run the build entirely inside
5959

6060
To perform a Dockerized build, use the `--docker` flag:
6161

62-
```
62+
```bash
6363
./build.sh --docker
6464
```
6565

@@ -73,13 +73,13 @@ Note that due to the way Docker works, the HTML source repository must be contai
7373

7474
Your clone doesn't need the HTML standard's complete revision history just for you to build the spec and contribute patches. So, if you use `build.sh` to create the clone, we don't start you out with a clone of the history. That makes your first build finish much faster. And if later you decide you do want to clone the complete history, you can still get it, by doing this:
7575

76-
```
76+
```bash
7777
cd ./html && git fetch --unshallow
7878
```
7979

8080
That said, if you really do want to *start out* with the complete history of the repo, then run the build script for the first time like this:
8181

82-
```
82+
```bash
8383
HTML_GIT_CLONE_OPTIONS="" ./build.sh
8484
```
8585

build.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,19 @@ export HTML_TEMP
3636
# Used specifically when the Dockerfile calls this script
3737
SKIP_BUILD_UPDATE_CHECK=${SKIP_BUILD_UPDATE_CHECK:-false}
3838
SHA_OVERRIDE=${SHA_OVERRIDE:-}
39-
HIGHLIGHT_SERVER_URL="http://127.0.0.1:8080" # this needs to be coordinated with the highlighter submodule
39+
HIGHLIGHT_SERVER_URL="http://127.0.0.1:8080" # this needs to be coordinated with the bs-highlighter package
4040

4141
function main {
4242
processCommandLineArgs "$@"
4343

4444
# $SKIP_BUILD_UPDATE_CHECK is set inside the Dockerfile so that we don't check for updates both inside and outside
4545
# the Docker container.
4646
if [[ $DO_UPDATE == "true" && $SKIP_BUILD_UPDATE_CHECK != "true" ]]; then
47-
git submodule update --init
4847
checkHTMLBuildIsUpToDate
48+
# If we're using Docker then this will be installed inside the container.
49+
if [[ $USE_DOCKER != "true" ]]; then
50+
pip3 install bs-highlighter
51+
fi
4952
fi
5053

5154
findHTMLSource
@@ -627,14 +630,10 @@ function generateBacklinks {
627630
# - A server will be running in the background, at $HIGHLIGHT_SERVER_URL
628631
# - $HIGHLIGHT_SERVER_PID will be set for later use by stopHighlightServer
629632
function startHighlightServer {
630-
# Setting PYTHONPATH is a workaround for https://github.com/whatwg/html-build/issues/169.
631-
# See also https://github.com/tabatkins/highlighter/issues/5 and
632-
# https://bitbucket.org/birkenfeld/pygments-main/issues/1448.
633-
export PYTHONPATH="$DIR/highlighter/highlighter/pygments${PYTHONPATH:+:$PYTHONPATH}"
634633
HIGHLIGHT_SERVER_ARGS=()
635634
$QUIET && HIGHLIGHT_SERVER_ARGS+=( --quiet )
636635
# shellcheck disable=SC2068
637-
"$DIR/highlighter/server.py" ${HIGHLIGHT_SERVER_ARGS[@]+"${HIGHLIGHT_SERVER_ARGS[@]}"} &
636+
bs-highlighter-server ${HIGHLIGHT_SERVER_ARGS[@]+"${HIGHLIGHT_SERVER_ARGS[@]}"} &
638637
HIGHLIGHT_SERVER_PID=$!
639638

640639
trap stopHighlightServer EXIT

ci-deploy/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ RUN apt-get update && \
66
apt-get install -y ca-certificates curl rsync git unzip \
77
default-jre \
88
libfontconfig1 libgomp1 libxml2 \
9-
python2.7 python-pip \
9+
python3 python3-pip \
1010
fonts-dejavu fonts-droid-fallback fonts-liberation fonts-symbola fonts-unfonts-core
1111

1212
# Dependency lines above are:
@@ -16,6 +16,8 @@ RUN apt-get update && \
1616
# - Highlighter
1717
# - fonts
1818

19+
RUN pip3 install bs-highlighter
20+
1921
# Dependecies of prince_11.3-1_debian8.0_amd64.deb (not used) are libc6 libcurl3 libfontconfig1
2022
# libfreetype6 libgif4 libgomp1 libjpeg62-turbo libpng12-0 libssl1.0.0 libtiff5 libxml2 zlib1g.
2123
# Above we install only the subset that's needed to make Prince work.

ci-deploy/outside-container.sh

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,6 @@ IS_TEST_OF_HTML_BUILD_ITSELF=${IS_TEST_OF_HTML_BUILD_ITSELF:-false}
1717
# - DOCKER_PASSWORD is set from the outside
1818
# - ENCRYPTION_LABEL is set from the outside
1919

20-
# Initialize the highlighter submodule for html-build
21-
(
22-
cd html-build
23-
git submodule init
24-
git submodule update
25-
)
26-
2720
git clone --depth 1 https://github.com/pts/pdfsizeopt.git pdfsizeopt
2821

2922
# Copy the Docker-related stuff into the working (grandparent) directory.

highlighter

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)