Skip to content
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
94 changes: 65 additions & 29 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,46 +1,82 @@
// This file was automatically generated with PreTeXt 2.18.1.
// If you modify this file, PreTeXt will no longer automatically update it.
//
//////////////////////////////////////////////////////////////
//
// This file provides configuration options so that a PreTeXt
// project can be edited and built using GitHub's Codespaces.
// It is recommended to keep this in your repository even if you
// do not use this feature, as it will allow other to explore
// your project easily.
// This file will be automatically generated by PreTeXt with the
// latest updates unless you remove the first comment line above.
//
///////////////////////////////////////////////////////////////
{
"name": "PreTeXt-Lite",
"image": "mcr.microsoft.com/devcontainers/python:3",
"features": {
"ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/rocker-org/devcontainer-features/pandoc:1": {}
"image": "mcr.microsoft.com/devcontainers/universal:2",
"features": {},

// 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)"
},


// Port forwarding
// ---------------
// This is needed by the CodeChat Server.
"forwardPorts": [
// The port used for a Thrift connection between the VSCode CodeChat
// extension and the CodeChat Server.
27376,
// The port used for an HTTP connection from the CodeChat Client to
// the CodeChat Server.
27377,
// The port used by a websocket connection between the CodeChat
// Server and the CodeChat Client.
27378
],
// See the [docs](https://containers.dev/implementors/json_reference/#port-attributes).
"portsAttributes": {
"27376": {
"label": "VSCode extension <-> CodeChat Server",
"requireLocalPort": true
},
"27377": {
"label": "CodeChat Client",
"requireLocalPort": true
},
"27378": {
"label": "CodeChat Client<->Server websocket",
"requireLocalPort": true
// This port needs to be public; however, there's no way to specify port visibility here. See `server.py` in the CodeChat Server for details.
}
},
// "forwardPorts": [
// 27377,
// 27378
// ],
// "portsAttributes": {
// "27378": {
// "label": "CodeChat",
// "onAutoForward": "openPreview",
// "requireLocalPort": true,
// "elevateIfNeeded": true,
// "protocol": "https"
// }
// },
"onCreateCommand": "pip install pretext",
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "sudo bash ./.devcontainer/postCreateCommand.sh",


// Configure tool-specific properties.
"customizations": {
"codespaces": {
"openFiles": [
"source/main.ptx"
]
"openFiles": ["source/main.ptx"]
},
"vscode": {
"settings": {
"editor.quickSuggestions": {
"other": "off"
},
"editor.snippetSuggestions": "top",
"xml.validation.enabled": false
"xml.validation.enabled": false,
"redhat.telemetry.enabled": false,
"CodeChat.CodeChatServer.Command": "CodeChat_Server"
},
"extensions": ["ms-vscode.live-server", "oscarlevin.pretext-tools"]
"extensions": [
"oscarlevin.pretext-tools",
"CodeChat.codechat"
]
}
}

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
46 changes: 46 additions & 0 deletions .devcontainer/devcontainer.json.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "PreTeXt-Lite",
"image": "mcr.microsoft.com/devcontainers/python:3",
"features": {
"ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/rocker-org/devcontainer-features/pandoc:1": {}
},
// "forwardPorts": [
// 27377,
// 27378
// ],
// "portsAttributes": {
// "27378": {
// "label": "CodeChat",
// "onAutoForward": "openPreview",
// "requireLocalPort": true,
// "elevateIfNeeded": true,
// "protocol": "https"
// }
// },
"onCreateCommand": "pip install pretext",
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "sudo bash ./.devcontainer/postCreateCommand.sh",

// Configure tool-specific properties.
"customizations": {
"codespaces": {
"openFiles": [
"source/main.ptx"
]
},
"vscode": {
"settings": {
"editor.quickSuggestions": {
"other": "off"
},
"editor.snippetSuggestions": "top",
"xml.validation.enabled": false
},
"extensions": ["ms-vscode.live-server", "oscarlevin.pretext-tools"]
}
}

// 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.18.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 tikz-cd 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.18.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
29 changes: 29 additions & 0 deletions .devcontainer/installPretext.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.18.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] pycairo --only-binary {greenlet} --break-system-packages

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

playwright install-deps

playwright install


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

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

echo "PreTeXt installation complete."
21 changes: 21 additions & 0 deletions .devcontainer/installSage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

# This file was automatically generated with PreTeXt 2.18.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

source ~/.bashrc
112 changes: 112 additions & 0 deletions .github/workflows/pretext-cli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# This file was automatically generated with PreTeXt 2.18.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 demand
workflow_dispatch:

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

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

- name: install deps
run: pip install -r requirements.txt

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

- name: build deploy targets
run: |
version="$(pretext --version)"
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
- name: stage deployment
run: pretext deploy --stage-only

- name: Bundle output/stage as artifact
uses: actions/upload-artifact@v4
with:
name: deploy
path: output/stage

deploy-cloudflare:
runs-on: ubuntu-latest
needs: build
if: vars.CLOUDFLARE_PROJECT_NAME != ''
permissions:
contents: read
deployments: write

steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: deploy
path: deploy
- name: Create 404.html
run: echo "404 page not found" >> deploy/404.html
- name: Publish to Cloudflare
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: ${{ vars.CLOUDFLARE_PROJECT_NAME }}
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.head_ref || github.ref_name }}
directory: deploy

deploy-ghpages:
runs-on: ubuntu-latest
needs: build
if: vars.PTX_ENABLE_DEPLOY_GHPAGES == 'yes' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "page"
cancel-in-progress: false
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Download website artifact
uses: actions/download-artifact@v4
with:
name: deploy
path: deploy
- name: Setup GitHub Pages
id: check
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: deploy
- name: Deploy to Github Pages
id: deployment
uses: actions/deploy-pages@v4
Loading