Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing some things #6

Merged
merged 15 commits into from
Jun 20, 2024
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
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "daily"
time: "00:00"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
time: "00:00"
12 changes: 11 additions & 1 deletion .github/workflows/md-to-pdf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ on:
description: upload artifact
required: false
type: boolean
run-script:
description: test converter script
required: true
type: boolean

defaults:
run:
Expand Down Expand Up @@ -38,8 +42,14 @@ jobs:
python -m pip install pypandoc pypandoc-binary
- name: Run pypandoc
if: inputs.run-script
run: |
python converter.py ${{ inputs.markdown-source-dir }}
python converter.py $GITHUB_WORKSPACE/${{ inputs.markdown-source-dir }}
#- name: Debug
# run: |
# echo "${{ github.workspace }}"
# echo "$GITHUB_WORKSPACE"

- name: Run pandoc
run: |
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ venv/

# Output PDF path directory
_output/

23 changes: 13 additions & 10 deletions converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,21 @@
print("Invalid path to markdown directory!")
sys.exit(1)

if not DESTINATION_PATH_TO_PDF.exists():
DESTINATION_PATH_TO_PDF.mkdir()

markdown_files = list(SOURCE_PATH_TO_MD.rglob("*.md"))

if not markdown_files:
print(f"No markdown files found in {SOURCE_PATH_TO_MD}")
sys.exit(1)

if not DESTINATION_PATH_TO_PDF.exists():
DESTINATION_PATH_TO_PDF.mkdir()

source_md_files = []
output_pdf_files = []

print("Convert MD to PDF:\n")
print("Converter from markdown to PDF\n")
print(f"Input directory: {SOURCE_PATH_TO_MD.absolute()}")
print(f"Output directory: {DESTINATION_PATH_TO_PDF.absolute()}\n")
for markdown_file in markdown_files:
relative_path = markdown_file.relative_to(SOURCE_PATH_TO_MD)
pdf_output_path = DESTINATION_PATH_TO_PDF / relative_path.with_suffix(".pdf")
Expand All @@ -40,21 +43,21 @@
try:
pypandoc.convert_file(
str(markdown_file),
'pdf',
"pdf",
outputfile=str(pdf_output_path),
extra_args=[
'--pdf-engine=pdflatex',
'--from=markdown+rebase_relative_paths'
]
"--pdf-engine=pdflatex",
"--from=markdown+rebase_relative_paths",
],
)
except Exception as e:
print(f"Error converting {markdown_file}: {e}")
sys.exit(1)

print("Source markdown files:")
for input_md in source_md_files:
print(input_md)
print(input_md.absolute())

print("\nOutput PDF files:")
for output_pdf in output_pdf_files:
print(output_pdf)
print(output_pdf.absolute())
21 changes: 21 additions & 0 deletions images/converter-python/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ARG PANDOC_IMAGE_NAME=pandoc/latex
ARG PANDOC_IMAGE_TAG=edge-ubuntu

FROM ${PANDOC_IMAGE_NAME}:${PANDOC_IMAGE_TAG} AS pypandoc

RUN apt-get update && \
apt-get install -y \
unzip python3 python3.12-venv python3-pip -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

RUN pip3 install pypandoc pypandoc-binary \
--break-system-packages

RUN mkdir /app

COPY converter.py /app/converter.py

ENTRYPOINT ["python3", "/app/converter.py"]
CMD []

15 changes: 15 additions & 0 deletions images/pypandoc-python/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ARG PANDOC_IMAGE_NAME=pandoc/latex
ARG PANDOC_IMAGE_TAG=edge-ubuntu

FROM ${PANDOC_IMAGE_NAME}:${PANDOC_IMAGE_TAG} AS pypandoc

RUN apt-get update && \
apt-get install -y \
unzip python3 python3.12-venv python3-pip -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

RUN pip3 install pypandoc pypandoc-binary \
--break-system-packages

ENTRYPOINT ["python3"]
5 changes: 5 additions & 0 deletions images/pypandoc-python/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

# shellcheck source=/dev/null
source /data/venv/bin/activate
exec "$@"