diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7794a27abcee82c739efa49bb925d66a95e8f944..c61060c269b18b62a96b82be498a3d561f8ee05c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,12 +8,26 @@ workflow: rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: $CI_COMMIT_TAG + - if: $CI_PIPELINE_SOURCE == "push" variables: stages: - generation - publication + - build + +Build pythonForPandocFilter docker image: + stage: build + before_script: cd pandocFilter + script: docker build --tag pandocFilter:latest -f dockerfile . + rules: + - if: $CI_PIPELINE_SOURCE == "push" + changes: + - pandocFilter/dockerfile + - pandocFilter/setup.py + - pandocFilter/requirements.txt + Word CR text: stage: generation @@ -44,7 +58,7 @@ Publish spec: - tags before_script: - | - curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/publish_spec%2Esh/raw?ref=publication" >> publish_spec.sh + curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/publish_spec%2Esh/raw?ref=master" >> publish_spec.sh - chmod +x publish_spec.sh #- | # curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/onem2m_spec_template%2Edocx/raw?ref=master" >> onem2m_coversheet_template.docx diff --git a/pandocFilter/dockerfile b/pandocFilter/dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7f39a11e2ed5190735bc8e1c599997c509c68cfa --- /dev/null +++ b/pandocFilter/dockerfile @@ -0,0 +1,7 @@ +FROM python:3.9-slim-bullseye + +ADD . /pandocFilter/ +RUN apt-get update -y && \ + rm -rf /var/lib/apt/lists/* &&\ + pip install -e pandocFilter/ &&\ + pip install -r pandocFilter/requirements.txt diff --git a/pandocFilter/pandocFilter.py b/pandocFilter/pandocFilter.py index 65c65e72382c383ef919c4ef99a1d9e8888f02bb..c8e3032ab80c131c8df62b500c4cd63a8e10e855 100644 --- a/pandocFilter/pandocFilter.py +++ b/pandocFilter/pandocFilter.py @@ -86,8 +86,8 @@ def replaceTableCaptions(progress:Progress, mdLines:list[str]) -> list[str]: _idx = len(_lines) - 1 while _idx >= 0 and _lines[_idx].startswith('|'): _idx -= 1 - if _idx > 0: - _lines.insert(_idx+1, f'Table: {matches[0]}\n') + #if _idx > 0: + # _lines.insert(_idx+1, f'Table: {matches[0]}\n') _lines.insert(_idx+1, f'Table: {matches[0]}\n') else: _lines.append(line) @@ -104,9 +104,7 @@ def process(document:str, outDirectory:str) -> None: mdLines = replaceTableCaptions(progress, mdLines) writeMDFile(progress, mdLines, document, outDirectory) - - -if __name__ == '__main__': +def main(args=None): # Parse command line arguments parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('--outdir', '-o', action='store', dest='outDirectory', default = 'out', metavar = '<output directory>', help = 'specify output directory') @@ -117,3 +115,6 @@ if __name__ == '__main__': os.makedirs(args.outDirectory, exist_ok = True) process(args.document, args.outDirectory) + +if __name__ == '__main__': + sys.exit(main()) \ No newline at end of file diff --git a/pandocFilter/setup.py b/pandocFilter/setup.py index 589119e5b664a9f95888517528ae36883f48ed71..7d47e526d3ec3967009e32f6287050c8cc1ef884 100644 --- a/pandocFilter/setup.py +++ b/pandocFilter/setup.py @@ -9,5 +9,9 @@ setup( packages=find_packages(), install_requires=[ 'rich', - ] + ], + entry_points= { + 'console_scripts' : ['pandocFilter=pandocFilter:main'] + } + )