Source: https://github.com/aipoch/medical-research-skills
Validation Shortcut
Run this minimal command first to verify the supported execution path:
python scripts/format_adjuster.py --help
When to Use
- You have a draft in Word/LaTeX/Markdown and must submit it in a different format (e.g., DOCX → LaTeX).
- A journal or school requires strict typography rules (fonts, sizes, margins, spacing) and you want them applied automatically.
- You need to enforce consistent figure/table captions and table border styles across the whole manuscript.
- You must switch or standardize citation/reference styles (e.g., IEEE, APA, GB/T 7714) before submission.
- You want to apply a known journal template (e.g., Nature/Science/Elsevier) or a custom JSON/YAML template to multiple papers.
Key Features
Dependencies
Runtime
Python packages (typical)
python-docx (Word read/write)
markdown (Markdown processing)
PyYAML (YAML parsing)
requests (template download)
beautifulsoup4 (HTML parsing)
System tools
pandoc (required for DOCX ↔ LaTeX conversions)
- Windows:
choco install pandoc
- macOS:
brew install pandoc
- Linux (Debian/Ubuntu):
apt install pandoc
Note: Exact package versions depend on requirements.txt in your repository.
Example Usage
1) Apply a built-in journal template (DOCX → formatted DOCX)
python scripts/init_run.py \
--input paper.docx \
--journal "Nature" \
--output paper_formatted.docx
2) Apply a custom configuration (MD → formatted MD)
python scripts/init_run.py \
--input paper.md \
--config formats/my_journal.json \
--output paper_adjusted.md
3) Download a journal template configuration
python scripts/init_run.py \
--download-template "Science" \
--output templates/science_format.json
4) Minimal end-to-end runnable Python example (module usage)
from scripts.format_converter import FormatConverter
from scripts.format_adjuster import FormatAdjuster
def run(input_file: str, config: dict, output_file: str):
converter = FormatConverter()
adjuster = FormatAdjuster(config)
# 1) Normalize to Markdown as an intermediate representation
md = converter.to_markdown(input_file)
# 2) Apply formatting rules
formatted_md = adjuster.apply_format(md, config)
# 3) Validate against the same rules
ok = adjuster.validate_format(formatted_md, config)
if not ok:
raise RuntimeError("Validation failed: output does not meet the configured requirements.")
# 4) Convert back to the desired output format inferred from output_file
converter.from_markdown(formatted_md, output_file)
if __name__ == "__main__":
config = {
"font": {"body": "Times New Roman", "body_size": 10},
"spacing": {"line_space": "single", "paragraph_space": 6, "indent": 0.5},
"margins": {"top": 2.54, "bottom": 2.54, "left": 2.54, "right": 2.54},
"references": {"style": "Nature", "format": "numbered"},
"figures": {"caption_position": "below", "font_size": 9},
"tables": {"caption_position": "above", "font_size": 9, "borders": True},
}
run("paper.docx", config, "paper_formatted.docx")
Implementation Details
Processing pipeline
- Detect input format (
.docx / .md / .tex)
- Convert to Markdown as a unified intermediate representation
- Apply formatting rules from a selected journal template or custom config
- Validate the formatted result against the config
- Convert to target format (DOCX/MD/TEX)
Core modules (typical responsibilities)
format_converter.py
- Conversion engine between Word/Markdown/LaTeX
- Uses Pandoc for conversions involving LaTeX and/or DOCX where needed
format_adjuster.py
- Applies typography, figure/table, and reference formatting rules
- Provides validation routines to check compliance
template_downloader.py
- Downloads template/config by journal name (best-effort)
- Parses web sources (often via
requests + beautifulsoup4)
format_validator.py
- Performs rule-based checks (margins, font sizes, caption placement, citation style selection, etc.)
Configuration schema (key parameters)
A configuration file (JSON/YAML) typically includes:
font
body, body_size, title, title_size, caption, caption_size
spacing
line_space (single / 1.5 / double)
paragraph_space (e.g., points)
indent (e.g., first-line indent)
margins
top, bottom, left, right (commonly in cm)
references
style (e.g., IEEE, APA, GB/T 7714-2015)
format (e.g., numbered, author-year)
figures / tables
caption_position (above / below)
font_size
borders (tables)
CLI parameters (behavior)
--input: input file path (required)
--output: output file path (auto-generated if omitted)
--config: path to JSON/YAML config (uses built-in default if omitted)
--journal: journal name (selects a built-in or downloaded template)
--download-template: journal name to download a template config
--format: output format (docx / md / tex), defaults to the input format
When Not to Use
- Do not use this skill when the required source data, identifiers, files, or credentials are missing.
- Do not use this skill when the user asks for fabricated results, unsupported claims, or out-of-scope conclusions.
- Do not use this skill when a simpler direct answer is more appropriate than the documented workflow.
Required Inputs
- A clearly specified task goal aligned with the documented scope.
- All required files, identifiers, parameters, or environment variables before execution.
- Any domain constraints, formatting requirements, and expected output destination if applicable.
Recommended Workflow
- Validate the request against the skill boundary and confirm all required inputs are present.
- Select the documented execution path and prefer the simplest supported command or procedure.
- Produce the expected output using the documented file format, schema, or narrative structure.
- Run a final validation pass for completeness, consistency, and safety before returning the result.
Output Contract
- Return a structured deliverable that is directly usable without reformatting.
- If a file is produced, prefer a deterministic output name such as
article_format_adjustment_result.md unless the skill documentation defines a better convention.
- Include a short validation summary describing what was checked, what assumptions were made, and any remaining limitations.
Validation and Safety Rules
- Validate required inputs before execution and stop early when mandatory fields or files are missing.
- Do not fabricate measurements, references, findings, or conclusions that are not supported by the provided source material.
- Emit a clear warning when credentials, privacy constraints, safety boundaries, or unsupported requests affect the result.
- Keep the output safe, reproducible, and within the documented scope at all times.
Failure Handling
- If validation fails, explain the exact missing field, file, or parameter and show the minimum fix required.
- If an external dependency or script fails, surface the command path, likely cause, and the next recovery step.
- If partial output is returned, label it clearly and identify which checks could not be completed.
Quick Validation
Run this minimal verification path before full execution when possible:
python scripts/format_adjuster.py --help
Expected output format:
Result file: article_format_adjustment_result.md
Validation summary: PASS/FAIL with brief notes
Assumptions: explicit list if any
Deterministic Output Rules
- Use the same section order for every supported request of this skill.
- Keep output field names stable and do not rename documented keys across examples.
- If a value is unavailable, emit an explicit placeholder instead of omitting the field.
Completion Checklist
- Confirm all required inputs were present and valid.
- Confirm the supported execution path completed without unresolved errors.
- Confirm the final deliverable matches the documented format exactly.
- Confirm assumptions, limitations, and warnings are surfaced explicitly.
1---2name: article-format-adjustment3description: Adjust academic paper formatting and convert between DOCX/LaTeX/Markdown when you need to meet a journal or school template requirement.4license: MIT5---6> **Source**: [https://github.com/aipoch/medical-research-skills](https://github.com/aipoch/medical-research-skills)
7
8## Validation Shortcut
9
10Run this minimal command first to verify the supported execution path:
11
12```bash
13python scripts/format_adjuster.py --help
14```
15
16## When to Use
17
18- You have a draft in **Word/LaTeX/Markdown** and must submit it in a **different format** (e.g., DOCX → LaTeX).
19- A journal or school requires strict **typography rules** (fonts, sizes, margins, spacing) and you want them applied automatically.
20- You need to enforce consistent **figure/table captions** and table border styles across the whole manuscript.
21- You must switch or standardize **citation/reference styles** (e.g., IEEE, APA, GB/T 7714) before submission.
22- You want to apply a **known journal template** (e.g., Nature/Science/Elsevier) or a **custom JSON/YAML template** to multiple papers.
23
24## Key Features
25
26- **Format conversion**
27 - Word (`.docx`) ↔ Markdown (`.md`)
28 - Word (`.docx`) ↔ LaTeX (`.tex`) (via Pandoc)
29 - Markdown (`.md`) ↔ LaTeX (`.tex`)
30 - Preserves document structure and basic formatting as much as possible
31
32- **Full formatting adjustment**
33 - Typography: fonts, font sizes (body/headings/footnotes), line spacing, margins, paragraph indentation and spacing
34 - Figures/Tables: caption font size, caption position, table font, table border/line styles
35 - References: citation styles (APA/MLA/Chicago/IEEE/GB/T 7714), reference list formatting, in-text citation formatting
36 - Terminology: first-occurrence abbreviation annotation, terminology consistency checks, unit formatting standardization
37
38- **Journal template management**
39 - Built-in templates (e.g., Nature, Science, IEEE, Elsevier)
40 - Template download by journal name (best-effort from official sources/Overleaf)
41 - Custom templates via **JSON/YAML** configuration
42
43- **Validation**
44 - Checks whether the output meets the configured formatting requirements.
45
46## Dependencies
47
48### Runtime
49- Python `>= 3.8`
50
51### Python packages (typical)
52- `python-docx` (Word read/write)
53- `markdown` (Markdown processing)
54- `PyYAML` (YAML parsing)
55- `requests` (template download)
56- `beautifulsoup4` (HTML parsing)
57
58### System tools
59- `pandoc` (required for DOCX ↔ LaTeX conversions)
60 - Windows: `choco install pandoc`
61 - macOS: `brew install pandoc`
62 - Linux (Debian/Ubuntu): `apt install pandoc`
63
64> Note: Exact package versions depend on `requirements.txt` in your repository.
65
66## Example Usage
67
68### 1) Apply a built-in journal template (DOCX → formatted DOCX)
69```bash
70python scripts/init_run.py \
71 --input paper.docx \
72 --journal "Nature" \
73 --output paper_formatted.docx
74```
75
76### 2) Apply a custom configuration (MD → formatted MD)
77```bash
78python scripts/init_run.py \
79 --input paper.md \
80 --config formats/my_journal.json \
81 --output paper_adjusted.md
82```
83
84### 3) Download a journal template configuration
85```bash
86python scripts/init_run.py \
87 --download-template "Science" \
88 --output templates/science_format.json
89```
90
91### 4) Minimal end-to-end runnable Python example (module usage)
92```python
93from scripts.format_converter import FormatConverter
94from scripts.format_adjuster import FormatAdjuster
95
96def run(input_file: str, config: dict, output_file: str):
97 converter = FormatConverter()
98 adjuster = FormatAdjuster(config)
99
100 # 1) Normalize to Markdown as an intermediate representation
101 md = converter.to_markdown(input_file)
102
103 # 2) Apply formatting rules
104 formatted_md = adjuster.apply_format(md, config)
105
106 # 3) Validate against the same rules
107 ok = adjuster.validate_format(formatted_md, config)
108 if not ok:
109 raise RuntimeError("Validation failed: output does not meet the configured requirements.")
110
111 # 4) Convert back to the desired output format inferred from output_file
112 converter.from_markdown(formatted_md, output_file)
113
114if __name__ == "__main__":
115 config = {
116 "font": {"body": "Times New Roman", "body_size": 10},
117 "spacing": {"line_space": "single", "paragraph_space": 6, "indent": 0.5},
118 "margins": {"top": 2.54, "bottom": 2.54, "left": 2.54, "right": 2.54},
119 "references": {"style": "Nature", "format": "numbered"},
120 "figures": {"caption_position": "below", "font_size": 9},
121 "tables": {"caption_position": "above", "font_size": 9, "borders": True},
122 }
123 run("paper.docx", config, "paper_formatted.docx")
124```
125
126## Implementation Details
127
128### Processing pipeline
1291. **Detect input format** (`.docx` / `.md` / `.tex`)
1302. **Convert to Markdown** as a unified intermediate representation
1313. **Apply formatting rules** from a selected journal template or custom config
1324. **Validate** the formatted result against the config
1335. **Convert to target format** (DOCX/MD/TEX)
134
135### Core modules (typical responsibilities)
136- `format_converter.py`
137 - Conversion engine between Word/Markdown/LaTeX
138 - Uses Pandoc for conversions involving LaTeX and/or DOCX where needed
139- `format_adjuster.py`
140 - Applies typography, figure/table, and reference formatting rules
141 - Provides validation routines to check compliance
142- `template_downloader.py`
143 - Downloads template/config by journal name (best-effort)
144 - Parses web sources (often via `requests` + `beautifulsoup4`)
145- `format_validator.py`
146 - Performs rule-based checks (margins, font sizes, caption placement, citation style selection, etc.)
147
148### Configuration schema (key parameters)
149A configuration file (JSON/YAML) typically includes:
150
151- `font`
152 - `body`, `body_size`, `title`, `title_size`, `caption`, `caption_size`
153- `spacing`
154 - `line_space` (`single` / `1.5` / `double`)
155 - `paragraph_space` (e.g., points)
156 - `indent` (e.g., first-line indent)
157- `margins`
158 - `top`, `bottom`, `left`, `right` (commonly in cm)
159- `references`
160 - `style` (e.g., `IEEE`, `APA`, `GB/T 7714-2015`)
161 - `format` (e.g., `numbered`, `author-year`)
162- `figures` / `tables`
163 - `caption_position` (`above` / `below`)
164 - `font_size`
165 - `borders` (tables)
166
167### CLI parameters (behavior)
168- `--input`: input file path (**required**)
169- `--output`: output file path (auto-generated if omitted)
170- `--config`: path to JSON/YAML config (uses built-in default if omitted)
171- `--journal`: journal name (selects a built-in or downloaded template)
172- `--download-template`: journal name to download a template config
173- `--format`: output format (`docx` / `md` / `tex`), defaults to the input format
174
175## When Not to Use
176
177- Do not use this skill when the required source data, identifiers, files, or credentials are missing.
178- Do not use this skill when the user asks for fabricated results, unsupported claims, or out-of-scope conclusions.
179- Do not use this skill when a simpler direct answer is more appropriate than the documented workflow.
180
181## Required Inputs
182
183- A clearly specified task goal aligned with the documented scope.
184- All required files, identifiers, parameters, or environment variables before execution.
185- Any domain constraints, formatting requirements, and expected output destination if applicable.
186
187## Recommended Workflow
188
1891. Validate the request against the skill boundary and confirm all required inputs are present.
1902. Select the documented execution path and prefer the simplest supported command or procedure.
1913. Produce the expected output using the documented file format, schema, or narrative structure.
1924. Run a final validation pass for completeness, consistency, and safety before returning the result.
193
194## Output Contract
195
196- Return a structured deliverable that is directly usable without reformatting.
197- If a file is produced, prefer a deterministic output name such as `article_format_adjustment_result.md` unless the skill documentation defines a better convention.
198- Include a short validation summary describing what was checked, what assumptions were made, and any remaining limitations.
199
200## Validation and Safety Rules
201
202- Validate required inputs before execution and stop early when mandatory fields or files are missing.
203- Do not fabricate measurements, references, findings, or conclusions that are not supported by the provided source material.
204- Emit a clear warning when credentials, privacy constraints, safety boundaries, or unsupported requests affect the result.
205- Keep the output safe, reproducible, and within the documented scope at all times.
206
207## Failure Handling
208
209- If validation fails, explain the exact missing field, file, or parameter and show the minimum fix required.
210- If an external dependency or script fails, surface the command path, likely cause, and the next recovery step.
211- If partial output is returned, label it clearly and identify which checks could not be completed.
212
213## Quick Validation
214
215Run this minimal verification path before full execution when possible:
216
217```bash
218python scripts/format_adjuster.py --help
219```
220
221Expected output format:
222
223```text
224Result file: article_format_adjustment_result.md
225Validation summary: PASS/FAIL with brief notes
226Assumptions: explicit list if any
227```
228
229## Deterministic Output Rules
230
231- Use the same section order for every supported request of this skill.
232- Keep output field names stable and do not rename documented keys across examples.
233- If a value is unavailable, emit an explicit placeholder instead of omitting the field.
234
235## Completion Checklist
236
237- Confirm all required inputs were present and valid.
238- Confirm the supported execution path completed without unresolved errors.
239- Confirm the final deliverable matches the documented format exactly.
240- Confirm assumptions, limitations, and warnings are surfaced explicitly.