diff --git a/.github/docker-build-pdf.sh b/.github/docker-build-pdf.sh index 427bd76..d6e89e4 100755 --- a/.github/docker-build-pdf.sh +++ b/.github/docker-build-pdf.sh @@ -44,6 +44,30 @@ function run_pandoc() { ${DOCKER} run ${ARGS} "${PANDOCK}" "$@" } +for x in "$@"; do + case "$x" in + --help) + echo "Usage: $0 [--skip-policies] [--skip-bylaws] [--skip-agreements]" + echo "OR: $0 [pandoc command arguments]" + echo "OR: $0 sh [command]" + exit 0 + ;; + --skip-policies) + SKIP_POLICIES=true + shift + ;; + --skip-bylaws) + SKIP_BYLAWS=true + shift + ;; + --skip-agreements) + SKIP_AGREEMENTS=true + shift + ;; + *) + ;; + esac +done TO_CMD=${1:-noargs} # Invoke command in the pandock container with common docker arguments @@ -153,21 +177,23 @@ BYLAWS=( ./bylaws/9-amendments.md ) -# Verify that bylaws files exist -for x in "${BYLAWS[@]}"; do - if [[ ! -f ${x} ]]; then - echo "No file found at ${x}" - exit 1 - fi -done +if [[ -z "${SKIP_BYLAWS}" ]]; then + # Verify that bylaws files exist + for x in "${BYLAWS[@]}"; do + if [[ ! -f ${x} ]]; then + echo "No file found at ${x}" + exit 1 + fi + done -# # Convert bylaws to PDF -to_pdf_pattern \ - bylaws \ - "cf-bylaws.pdf" \ - "./bylaws/" \ - -M title:"Bylaws" \ - "${BYLAWS[@]}" + # # Convert bylaws to PDF + to_pdf_pattern \ + bylaws \ + "cf-bylaws.pdf" \ + "./bylaws/" \ + -M title:"Bylaws" \ + "${BYLAWS[@]}" +fi ## POLICIES @@ -185,30 +211,38 @@ function to_policy_pdf() { "./policies/${1}.md" } -# Convert all policies to PDF -to_policy_pdf code-of-conduct "Code of Conduct" -to_policy_pdf conflict-of-interest "Conflict of Interest" -to_policy_pdf ip-policy "Intellectual Property" -to_policy_pdf trademark-policy "Trademark" +if [[ -z "${SKIP_POLICIES}" ]]; then + # Convert all policies to PDF + to_policy_pdf code-of-conduct "Code of Conduct" + to_policy_pdf conflict-of-interest "Conflict of Interest" + to_policy_pdf ip-policy "Intellectual Property" + to_policy_pdf trademark-policy "Trademark" -to_pdf ./TRADEMARKS.md trademark-list ./ "Trademark List" + to_pdf ./TRADEMARKS.md trademark-list ./ "Trademark List" +fi ## AGREEMENTS function to_agreement_doc() { - if [[ ! -f "./agreements/${1}.md" ]]; then - echo "No agreement found at ./agreements/${1}.md" + local input=${1} + if [[ ! -f "./agreements/${input}.md" ]]; then + echo "No agreement found at ./agreements/${input}.md" exit 1 fi - if [[ -z "${2}" ]]; then - echo "No agreement name provided" - exit 1 + local output=${2} + if [[ -z "${output}" ]]; then + output=$(basename ${input}) fi run_docx \ - "./output/public/${2}.docx" \ - "./agreements/${1}.md" + "./output/public/${output}.docx" \ + "./agreements/${input}.md" } -to_agreement_doc bootstrapping/bootstrapping bootstrapping-agreement +if [[ -z "${SKIP_AGREEMENTS}" ]]; then + to_agreement_doc bootstrapping/bootstrapping bootstrapping-agreement + # to_agreement_doc project-contribution/asset-transfer-agreement + # to_agreement_doc project-contribution/fiscal-sponsorship-agreement + # to_agreement_doc project-contribution/fiscal-sponsorship-terms-and-conditions +fi ls -al output/public \ No newline at end of file diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 0e7fa27..d57e51d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -3,9 +3,12 @@ name: Build PDF and publish to commonhaus.github.io on: pull_request: paths: + - 'agreements/**' - 'bylaws/**' - 'policies/**' push: + branches: + - main paths: - 'agreements/**' - 'bylaws/**' @@ -58,7 +61,6 @@ jobs: fetch-depth: 0 - name: convert md to pdf - if: ${{ needs.main-root.outputs.is-main || github.event_name == 'pull_request' }} env: GIT_COMMIT: ${{ github.sha }} GH_TOKEN: ${{ github.token }} @@ -71,6 +73,11 @@ jobs: name: pdf-output path: output/public/*.pdf + - uses: actions/upload-artifact@v4 + with: + name: docx-output + path: output/public/*.docx + - name: Update snapshot tag if: ${{ needs.main-root.outputs.is-main }} env: diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 91e4014..3a32af4 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -3,6 +3,8 @@ name: Validate markdown and YAML on: pull_request: push: + branches: + - main workflow_dispatch: env: diff --git a/.pandoc/content/cf-agreement-template.docx b/.pandoc/content/cf-agreement-template.docx index 53ac60a..54c12c1 100644 Binary files a/.pandoc/content/cf-agreement-template.docx and b/.pandoc/content/cf-agreement-template.docx differ diff --git a/.pandoc/content/docx-template.txt b/.pandoc/content/docx-template.txt index b9807b0..a8a5ab3 100644 --- a/.pandoc/content/docx-template.txt +++ b/.pandoc/content/docx-template.txt @@ -71,6 +71,10 @@ $if(lot)$ $lot$ $endif$ $body$ + + + + $for(include-after)$ $include-after$ $endfor$ diff --git a/.pandoc/filters/agreement-form.lua b/.pandoc/filters/agreement-form.lua index 8371ec0..0980904 100644 --- a/.pandoc/filters/agreement-form.lua +++ b/.pandoc/filters/agreement-form.lua @@ -69,6 +69,8 @@ local horizontalSeparator = [[ ]] +local pagebreak = '' + local function HorizontalRule(elem) print("CFLUA: Found horizontal rule ") return pandoc.RawBlock('openxml', horizontalSeparator) @@ -78,8 +80,13 @@ local function Header(header) if header.level == 1 then local content = pandoc.utils.stringify(header.content) content = content:gsub("Commonhaus Foundation%s*(.*)", "%1") - print("CFLUA: Found header " .. content) return pandoc.Header(1, content) + elseif header.level == 2 then + local content = pandoc.utils.stringify(header.content) + if string.match(content, 'Exhibits') or string.match(content, 'Schedules') then + print("CFLUA: Found L2 header " .. content) + return { pandoc.RawBlock('openxml', pagebreak), header } + end end return header end @@ -88,8 +95,8 @@ local function Para(para) local content = pandoc.utils.stringify(para.content) local insert = string.match(content, "%[Insert.*]") if insert then - content = content:gsub("(.*)%[Insert.*](.*)", "%1______________________________%2") - print("CFLUA: Found insert " .. content) + content = content:gsub("(.*)%[Insert.*](.*)", "%1`______________________________`%2") + --print("CFLUA: Found insert " .. content) return pandoc.read(content, 'markdown').blocks end return para @@ -100,7 +107,7 @@ local function BulletList(list) if string.match(content, "%[Insert.*]") then for i, item in ipairs(list.content) do local itemContent = pandoc.utils.stringify(item[1].content) - itemContent = itemContent:gsub("(.*)%[Insert.*](.*)", "%1______________________________%2") + itemContent = itemContent:gsub("(.*)%[Insert.*](.*)", "%1`______________________________`%2") print("CFLUA: Found insert " .. itemContent) list.content[i][1] = pandoc.Plain(itemContent) end @@ -109,8 +116,8 @@ local function BulletList(list) end return { - { Header = Header }, { HorizontalRule = HorizontalRule }, + { Header = Header }, { BulletList = BulletList }, - { Para = Para } + { Para = Para }, } \ No newline at end of file