From dda108f14f4c8a555ddd0d05dcc6a9177bbd80e4 Mon Sep 17 00:00:00 2001 From: Wu Zhenyu Date: Sat, 11 Mar 2023 21:29:07 +0800 Subject: [PATCH] :construction_worker: Add latexindent --- .pre-commit-config.yaml | 16 +++++---- latexindent.yaml | 13 +++++++ main.tex | 58 ++++++++++++++++---------------- scripts/generate-template.tex.pl | 2 +- template.tex | 30 ++++++++--------- 5 files changed, 68 insertions(+), 51 deletions(-) create mode 100755 latexindent.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fc0bbf3..106eef1 100755 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: - id: check-toml - id: check-json - repo: https://github.com/Lucas-C/pre-commit-hooks - rev: v1.3.1 + rev: v1.4.2 hooks: - id: remove-crlf - repo: https://github.com/codespell-project/codespell @@ -32,13 +32,13 @@ repos: additional_dependencies: - tomli - repo: https://github.com/jorisroovers/gitlint - rev: v0.18.0 + rev: v0.19.0dev hooks: - id: gitlint args: - --msg-filename - repo: https://github.com/editorconfig-checker/editorconfig-checker.python - rev: 2.6.2 + rev: 2.7.1 hooks: - id: editorconfig-checker - repo: https://github.com/jumanjihouse/pre-commit-hooks @@ -46,7 +46,7 @@ repos: hooks: - id: check-mailmap - repo: https://github.com/adrienverge/yamllint - rev: v1.28.0 + rev: v1.29.0 hooks: - id: yamllint - repo: https://github.com/executablebooks/mdformat @@ -69,8 +69,12 @@ repos: - id: markdownlint-cli2 additional_dependencies: - markdown-it-texmath@0.9.1 - - repo: https://github.com/Freed-Wu/pre-commit-make - rev: 0.0.1 + - repo: https://github.com/cmhughes/latexindent.pl + rev: V3.20.3 + hooks: + - id: latexindent + - repo: https://github.com/Freed-Wu/pre-commit-hooks + rev: 0.0.10 hooks: - id: make diff --git a/latexindent.yaml b/latexindent.yaml new file mode 100755 index 0000000..2a64fc9 --- /dev/null +++ b/latexindent.yaml @@ -0,0 +1,13 @@ +#!/usr/bin/env -S latexindent -l +--- +defaultIndent: " " +indentPreamble: 1 +onlyOneBackUp: 1 +fileExtensionPreference: + .dtx: 1 + .ins: 2 + .tex: 3 + .sty: 4 + .cls: 5 + .tikz: 6 + .bib: 7 diff --git a/main.tex b/main.tex index 1e5e258..d406dfe 100644 --- a/main.tex +++ b/main.tex @@ -31,55 +31,55 @@ \begin{longtable}{|p{2.2in}|p{4.64in}|} \firsthline - \Item{Name:} & \Authorname\\ + \Item{Name:} & \Authorname \\ \hline - \Item{Project Name:} & \\ + \Item{Project Name:} & \\ \hline - \Item{Reporting Period:} & Week\\ + \Item{Reporting Period:} & Week \\ \hline - \multicolumn{2}{|p{\linewidth}|}{\Item{Summary}}\\ + \multicolumn{2}{|p{\linewidth}|}{\Item{Summary}} \\ \hline \multicolumn{2}{|p{\linewidth}|}{% - Please provide a short overview (1--2 sentences) of the on-going project, - including research purpose, tasks mentioned in the past week, - progress/outputs in this week. - }\\ + Please provide a short overview (1--2 sentences) of the on-going project, + including research purpose, tasks mentioned in the past week, + progress/outputs in this week. + } \\ \hline - \multicolumn{2}{|p{\linewidth}|}{\Item{Tasks and Progress}}\\ + \multicolumn{2}{|p{\linewidth}|}{\Item{Tasks and Progress}} \\ \hline \multicolumn{2}{|p{\linewidth}|}{% - Report on tasks outlined in the weekly meeting and describe any changes - to this, including the reasons for these. Do include any additional - activities undertaken that are not in the work plan, providing the - background to their inclusion. - }\\ + Report on tasks outlined in the weekly meeting and describe any changes + to this, including the reasons for these. Do include any additional + activities undertaken that are not in the work plan, providing the + background to their inclusion. + } \\ \hline - \multicolumn{2}{|p{\linewidth}|}{\Item{Outputs and Deliverables}}\\ + \multicolumn{2}{|p{\linewidth}|}{\Item{Outputs and Deliverables}} \\ \hline \multicolumn{2}{|p{\linewidth}|}{% - Describe any preliminary results, outputs or deliverables (e.g. - presentations, studies, papers)? If no preliminary results are available, - state why. - }\\ + Describe any preliminary results, outputs or deliverables (e.g. + presentations, studies, papers)? If no preliminary results are available, + state why. + } \\ \hline - \multicolumn{2}{|p{\linewidth}|}{\Item{Risk, Issues and Challenges}}\\ + \multicolumn{2}{|p{\linewidth}|}{\Item{Risk, Issues and Challenges}} \\ \hline \multicolumn{2}{|p{\linewidth}|}{% - Report on any issues or problems that have impacted on the development - and implementation of the project. - }\\ + Report on any issues or problems that have impacted on the development + and implementation of the project. + } \\ \hline - \multicolumn{2}{|p{\linewidth}|}{\Item{Collaboration}}\\ + \multicolumn{2}{|p{\linewidth}|}{\Item{Collaboration}} \\ \hline \multicolumn{2}{|p{\linewidth}|}{% - Is there any collaboration you have with any parties to run the project - tasks? If any; please list them and what type of collaborations you have - }\\ + Is there any collaboration you have with any parties to run the project + tasks? If any; please list them and what type of collaborations you have + } \\ \hline - \multicolumn{2}{|p{\linewidth}|}{\Item{Next Steps}}\\ + \multicolumn{2}{|p{\linewidth}|}{\Item{Next Steps}} \\ \hline \multicolumn{2}{|p{\linewidth}|}{% - }\\ + } \\ \lasthline \end{longtable} diff --git a/scripts/generate-template.tex.pl b/scripts/generate-template.tex.pl index 9685cef..a50f9a6 100755 --- a/scripts/generate-template.tex.pl +++ b/scripts/generate-template.tex.pl @@ -1,2 +1,2 @@ #!/usr/bin/env -S perl -0777 -p -s/(?<=\\multicolumn\{2\}\{\|p\{\\linewidth\}\|\}\{%\n)(.|\n)*?(?= \}\\\\)//g +s/(?<=\\multicolumn\{2\}\{\|p\{\\linewidth\}\|\}\{%\n)(.|\n)*?(?= \}\s*\\\\)//g diff --git a/template.tex b/template.tex index fb8ee1b..7240651 100644 --- a/template.tex +++ b/template.tex @@ -31,41 +31,41 @@ \begin{longtable}{|p{2.2in}|p{4.64in}|} \firsthline - \Item{Name:} & \Authorname\\ + \Item{Name:} & \Authorname \\ \hline - \Item{Project Name:} & \\ + \Item{Project Name:} & \\ \hline - \Item{Reporting Period:} & Week\\ + \Item{Reporting Period:} & Week \\ \hline - \multicolumn{2}{|p{\linewidth}|}{\Item{Summary}}\\ + \multicolumn{2}{|p{\linewidth}|}{\Item{Summary}} \\ \hline \multicolumn{2}{|p{\linewidth}|}{% - }\\ + } \\ \hline - \multicolumn{2}{|p{\linewidth}|}{\Item{Tasks and Progress}}\\ + \multicolumn{2}{|p{\linewidth}|}{\Item{Tasks and Progress}} \\ \hline \multicolumn{2}{|p{\linewidth}|}{% - }\\ + } \\ \hline - \multicolumn{2}{|p{\linewidth}|}{\Item{Outputs and Deliverables}}\\ + \multicolumn{2}{|p{\linewidth}|}{\Item{Outputs and Deliverables}} \\ \hline \multicolumn{2}{|p{\linewidth}|}{% - }\\ + } \\ \hline - \multicolumn{2}{|p{\linewidth}|}{\Item{Risk, Issues and Challenges}}\\ + \multicolumn{2}{|p{\linewidth}|}{\Item{Risk, Issues and Challenges}} \\ \hline \multicolumn{2}{|p{\linewidth}|}{% - }\\ + } \\ \hline - \multicolumn{2}{|p{\linewidth}|}{\Item{Collaboration}}\\ + \multicolumn{2}{|p{\linewidth}|}{\Item{Collaboration}} \\ \hline \multicolumn{2}{|p{\linewidth}|}{% - }\\ + } \\ \hline - \multicolumn{2}{|p{\linewidth}|}{\Item{Next Steps}}\\ + \multicolumn{2}{|p{\linewidth}|}{\Item{Next Steps}} \\ \hline \multicolumn{2}{|p{\linewidth}|}{% - }\\ + } \\ \lasthline \end{longtable}