Skip to content
Merged
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
31 changes: 12 additions & 19 deletions .devcontainer.json → .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was automatically generated with PreTeXt 2.15.1.
// This file was automatically generated with PreTeXt 2.17.1.
// If you modify this file, PreTeXt will no longer automatically update it.
//
//////////////////////////////////////////////////////////////
Expand All @@ -13,22 +13,18 @@
//
///////////////////////////////////////////////////////////////
{
"name": "PreTeXt-Codespaces",
"image": "mcr.microsoft.com/devcontainers/universal:2",
"features": {},

// This Docker image includes some LaTeX support, but is still not to large. Note that if you keep your codespace running, it will use up your GitHub free storage quota. Additional options are listed below.
// "image": "oscarlevin/pretext:small",
// If you need to generate more complicated assets (such as sageplots) or use additional fonts when building to PDF, comment out the above line and uncomment the following line.
"image": "oscarlevin/pretext:full",
// If you only intend to build for web and don't have any latex-image generated assets, you can use a smaller image:
// "image": "oscarlevin/pretext:lite",

// Add gh cli as a feature (to support codechat)
"features": {
"ghcr.io/devcontainers/features/github-cli:1": {}
},
// Comment or uncomment lines below if you don't or do need that feature.
"postCreateCommand": {
"install sagemath": "bash ./.devcontainer/installSage.sh",
// "install pandoc": "bash ./.devcontainer/installPandoc.sh",
"install latex": "bash ./.devcontainer/installLatex.sh",
"install pretext": "bash ./.devcontainer/installPretext.sh",
"mark repo as safe": "git config --global --add safe.directory $(pwd)"
},

// Respect the project's designated dependencies
"postCreateCommand": "pip install -r requirements.txt",

// Port forwarding
// ---------------
Expand Down Expand Up @@ -61,6 +57,7 @@
}
},


// Configure tool-specific properties.
"customizations": {
"codespaces": {
Expand All @@ -76,13 +73,9 @@
"CodeChat.CodeChatServer.Command": "CodeChat_Server"
},
"extensions": [
"ms-vscode.live-server",
"oscarlevin.pretext-tools",
"CodeChat.codechat"
]
}
}

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
29 changes: 29 additions & 0 deletions .devcontainer/installLatex.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

# This file was automatically generated with PreTeXt 2.17.1.
# If you modify this file, PreTeXt will no longer automatically update it.

# We use TinyTeX (https://yihui.org/tinytex/)
wget -qO- "https://yihui.org/tinytex/install-bin-unix.sh" | sh

tlmgr install adjustbox amscdx bold-extra braket bussproofs cancel carlisle cases chessfss circuitikz colortbl enumitem extpfeil fontawesome5 fontaxes gensymb imakeidx jknapltx kastrup lambda-lists listings listingsutf8 marvosym mathalpha mathtools menukeys mhchem microtype musicography newpx newtx nicematrix pdfcol pdfpages pdflscape pgfplots phaistos physics polyglossia pstricks realscripts relsize siunitx skak skaknew smartdiagram snapshot stmaryrd tcolorbox tikzfill titlesec txfonts ulem upquote was xfrac xltxtra xpatch xstring

tlmgr path add

# Ensure fonts provided by TinyTeX are available, as suggested in the pretext guide
fontconfig="<?xml version=\"1.0\"?>
<!DOCTYPE fontconfig SYSTEM \"fonts.dtd\">
<fontconfig>
<dir>~/.TinyTeX/texmf-dist/fonts</dir>
<dir>~/.TinyTeX/texmf-local/fonts</dir>
</fontconfig>"

fontconfig_path="/etc/fonts/conf.d/09-texlive-fonts.conf"
if [ ! -f "$fontconfig_path" ]; then
echo "Creating fontconfig file at $fontconfig_path"
echo "$fontconfig" | sudo tee "$fontconfig_path" > /dev/null
else
echo "Fontconfig file already exists at $fontconfig_path"
fi
# Update font cache
fc-cache -f -v
17 changes: 17 additions & 0 deletions .devcontainer/installPandoc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

# This file was automatically generated with PreTeXt 2.17.1.
# If you modify this file, PreTeXt will no longer automatically update it.

wget https://github.com/jgm/pandoc/releases/download/3.6.4/pandoc-3.6.4-1-amd64.deb -O pandoc.deb

# wait for 60 second and then double check that no other script is using apt-get:
sleep 60
while fuser /var/lib/dpkg/lock >/dev/null 2>&1; do
echo "Waiting for apt-get to be free..."
sleep 15
done
# Install pandoc
sudo apt-get install -y --no-install-recommends ./pandoc.deb

rm pandoc.deb
27 changes: 27 additions & 0 deletions .devcontainer/installPretext.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

# This file was automatically generated with PreTeXt 2.17.1.
# If you modify this file, PreTeXt will no longer automatically update it.

sudo apt-get update
sudo apt-get install -y --no-install-recommends \
python3-louis \
libcairo2-dev \
librsvg2-bin

pip install --upgrade pip --break-system-packages

pip install pretext[homepage,prefigure] --only-binary {greenlet} --break-system-packages

pip install codechat-server --break-system-packages

playwright install-deps

playwright install

# Install mermaid for diagrams
npm install -g @mermaid-js/mermaid-cli

# echo '/usr/lib/python3/dist-packages' > /usr/local/lib/python3.8/dist-packages/louis.pth

prefig init
22 changes: 22 additions & 0 deletions .devcontainer/installSage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

# This file was automatically generated with PreTeXt 2.17.1.
# If you modify this file, PreTeXt will no longer automatically update it.

# Conda should already be installed in the codespace. We need to add the conda-forge channel

conda config --add channels conda-forge
conda config --set channel_priority strict

# We don't want conda to open the base environment always:
conda config --set auto_activate_base false

# Now create a conda environment for sage (called sage):
conda create --yes -n sage sage python=3.12

conda init

echo 'conda activate sage' >> ~/.bashrc

eval "$('conda' 'shell.bash' 'hook' 2> /dev/null)"
conda activate sage
41 changes: 21 additions & 20 deletions .github/workflows/pretext-cli.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,49 @@
# This file was automatically generated with PreTeXt 2.15.1.
# This file was automatically generated with PreTeXt 2.17.1.
# If you modify this file, PreTeXt will no longer automatically update it.
#
# This workflow file can be used to automatically build a project and create
# an artifact for deployment. It can also be used to deploy the project to
# GitHub Pages or Cloudflare Pages.
#
# The workflow is triggered on pull requests or can be run manually. You can uncomment
# the `push` event to have it run on pushes to the main branch as well.
name: PreTeXt-CLI Actions
on:
# Runs on pull requests
pull_request:
branches: ["*"]
# Runs on pushes to main
push:
branches: ["main"]
## Runs on pushes to main
#push:
# branches: ["main"]
# Runs on demand
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
container: oscarlevin/pretext:full

steps:
- name: Checkout source
uses: actions/checkout@v4

- name: install deps
- name: Install the things
run: |
eval "$('conda' 'shell.bash' 'hook' 2> /dev/null)"
conda activate sage
pip install -r requirements.txt
bash ./.devcontainer/installSage.sh
bash ./.devcontainer/installLatex.sh
bash ./.devcontainer/installPretext.sh
git config --global --add safe.directory $(pwd)

- name: build deploy targets
run: |
eval "$('conda' 'shell.bash' 'hook' 2> /dev/null)"
conda activate sage
version="$(pretext --version)" # also installs local ptx files
major="$(echo $version | cut -d '.' -f 1)"
minor="$(echo $version | cut -d '.' -f 2)"
if [ "$major" -ge 2 -a "$minor" -ge 5 ]; then
echo "PreTeXt version is 2.5 or greater; using new build command"
pretext build --deploys
else
echo "PreTeXt version is less than 2.5, using old build command"
pretext build
fi
pretext build --deploys

- name: stage deployment
run: pretext deploy --stage-only
run: |
eval "$('conda' 'shell.bash' 'hook' 2> /dev/null)"
conda activate sage
pretext deploy --stage-only

- name: Bundle output/stage as artifact
uses: actions/upload-artifact@v4
Expand Down
64 changes: 64 additions & 0 deletions .github/workflows/pretext-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# This file was automatically generated with PreTeXt 2.17.1.
# If you modify this file, PreTeXt will no longer automatically update it.
#

name: Build and Deploy
on:
# Currently, this workflow only runs when manually selected (the `workflow_dispatch` event).
# If you would like it to run on other events, uncomment some of the lines below.

# # Runs on pull requests
# pull_request:
# branches: ["*"]

# # Runs on pushes to main
# push:
# branches: ["main"]

# # Runs every day at 00:00 UTC
# schedule:
# - cron: '0 0 * * *'

# Runs on demand
workflow_dispatch:

permissions:
contents: write

jobs:
build-and-deploy:
runs-on: ubuntu-latest
container: oscarlevin/pretext:small

steps:
- name: Checkout source
uses: actions/checkout@v4

- name: add gh-cli
run: |
apt-get update
apt-get install gh jq -y

- name: setup git config
run: |
git config --global --add safe.directory $(pwd)
git config user.name "${{ github.actor }} via GitHub Actions"
git config user.email "${{ github.actor }}@github_actions.no_reply"

- name: install deps
run: pip install -r requirements.txt --break-system-packages

- name: install local ptx files
run: pretext --version

- name: build deploy targets
run: pretext build --deploys

- name: run deploy
run: pretext deploy --no-push

- name: push gh-pages branch
run: git push origin gh-pages --force
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was automatically generated with PreTeXt 2.15.1.
# This file was automatically generated with PreTeXt 2.17.1.
# If you modify this file, PreTeXt will no longer automatically update it.
#
# Boilerplate list of files in a PreTeXt project for git to ignore
Expand Down
2 changes: 1 addition & 1 deletion project.ptx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- This file was automatically generated by PreTeXt 2.15.1. -->
<!-- This file was automatically generated by PreTeXt 2.17.1. -->
<!-- If you modify this file, PreTeXt will no longer automatically update it.-->

<!-- This file, the project manifest, provides the overall configuration for your PreTeXt project. To edit the content of your document, open `source/main.ptx`. See https://pretextbook.org/doc/guide/html/processing-CLI.html#cli-project-manifest. -->
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# This file was automatically generated with PreTeXt 2.15.1.
pretext == 2.15.1
# This file was automatically generated with PreTeXt 2.17.1.
pretext == 2.17.1