Evals / documents / Convert between formats

Web page to Word

Convert article.html to article.docx.

normalsingledeft html to-docx

The task

The reference answer shows the job can be done with deft. It is not an agent run.

deft html to-docx article.html -o article.docx

Input

<!doctype html>
<html lang="en">
<head><title>Tea exports in 2025</title><style>body{font-family:serif}</style><script>track()</script></head>
<body>
<header><a href="/">Daily Leaf</a></header>
<nav><ul><li><a href="/news">News</a></li><li><a href="/about">About us</a></li></ul></nav>
<main>
<article>
<h1>Tea exports in 2025</h1>
<p>Exports rose for the third year in a row, led by <strong>Kenya</strong> and Sri Lanka. Growers credit a mild season and steady demand from the Gulf states, while shipping costs fell back after two difficult years.</p>
<h2>By country</h2>
<table><thead><tr><th>Country</th><th>Tonnes</th></tr></thead><tbody><tr><td>Kenya</td><td>590000</td></tr><tr><td>Sri Lanka</td><td>245000</td></tr></tbody></table>
<ul><li>Prices were stable</li><li>Green tea grew fastest</li></ul>
</article>
</main>
<aside>Subscribe to our newsletter</aside>
<footer>Copyright Daily Leaf</footer>
<script>analytics()</script>
</body>
</html>

Reference output

Rendered by macOS Quick Look, first page

Rendered by macOS Quick Look, first page

Text inside
Daily Leaf
	•	News
	•	About us
Tea exports in 2025
Exports rose for the third year in a row, led by Kenya and Sri Lanka. Growers credit a mild season and steady demand from the Gulf states, while shipping costs fell back after two difficult years.
By country
Country
Tonnes
Kenya
590000
Sri Lanka
245000

	•	Prices were stable
	•	Green tea grew fastest
Subscribe to our newsletter
Copyright Daily Leaf
How a result is judged (1 check)
  • format: file = "article.docx", format = "docx"

Runs

CodexWithout deftPassed2026-11-07

Time
53s
New tokens
8.5k
Total input
56.8k
Output tokens
2.6k
Commands
3
Failed
0

Trace

  1. I’ll inspect the HTML and available conversion tools, then create `article.docx` in the current directory.

  2. pwd && rg --files -g 'article.html' -g 'AGENTS.md' -g '*article*' | head -50 && command -v pandoc || true && command -v libreoffice || true && command -v soffice || true && python3 - <<'PY' import importlib.util for m in ['docx','bs4','html2docx']: print(m, bool(importlib.util.find_spec(m))) PY
    output
    article.html
    docx False
    bs4 False
    html2docx False
  3. sed -n '1,240p' article.html && ls -la
    output
    <!doctype html>
    <html lang="en">
    <head><title>Tea exports in 2025</title><style>body{font-family:serif}</style><script>track()</script></head>
    <body>
    <header><a href="/">Daily Leaf</a></header>
    <nav><ul><li><a href="/news">News</a></li><li><a href="/about">About us</a></li></ul></nav>
    <main>
    <article>
    <h1>Tea exports in 2025</h1>
    <p>Exports rose for the third year in a row, led by <strong>Kenya</strong> and Sri Lanka. Growers credit a mild season and steady demand from the Gulf states, while shipping costs fell back after two difficult years.</p>
    <h2>By country</h2>
    <table><thead><tr><th>Country</th><th>Tonnes</th></tr></thead><tbody><tr><td>Kenya</td><td>590000</td></tr><tr><td>Sri Lanka</td><td>245000</td></tr></tbody></table>
    <ul><li>Prices were stable</li><li>Green tea grew fastest</li></ul>
    </article>
    </main>
    <aside>Subscribe to our newsletter</aside>
    <footer>Copyright Daily Leaf</footer>
    <script>analytics()</script>
    </body>
    </html>
    total 8
    drwxr-xr-x@    3 user  staff     96 Nov  7 00:47 .
    drwx------@ 2103 user  staff  67296 Nov  7 00:47 ..
    -rw-r--r--@    1 user  staff    952 Nov  5 18:26 article.html
  4. python3 - <<'PY' from html.parser import HTMLParser from zipfile import ZipFile, ZIP_DEFLATED from xml.sax.saxutils import escape from pathlib import Path class ArticleParser(HTMLParser): def __init__(self): super().__init__(); self.in_article=False; self.depth=0; self.blocks=[]; self.cur=None; self.bold=0; self.cell=None; self.row=None; self.table=None; self.list_depth=0 def handle_starttag(self, tag, attrs): if tag=='article': self.in_article=True; self.depth+=1; return if not self.in_article: return if tag in ('h1','h2','p'): self.cur={'tag':tag,'runs':[]} elif tag=='strong': self.bold+=1 elif tag=='table': self.table=[] elif tag=='tr': self.row=[] elif tag in ('th','td'): self.cell=[] elif tag=='ul': self.list_depth+=1 elif tag=='li': self.cur={'tag':'li','runs':[]} def handle_endtag(self, tag): if not self.in_article: return if tag=='article': self.in_article=False; return if tag=='strong': self.bold=max(0,self.bold-1) elif tag in ('h1','h2','p','li') and self.cur is not None: if tag=='li': self.cur['style']='ListBullet' self.blocks.append(self.cur); self.cur=None elif tag in ('th','td') and self.cell is not None: self.row.append(''.join(t for t,b in self.cell)); self.cell=None elif tag=='tr' and self.row is not None: self.table.append(self.row); self.row=None elif tag=='table' and self.table is not None: self.blocks.append({'tag':'table','rows':self.table}); self.table=None elif tag=='ul': self.list_depth=max(0,self.list_depth-1) def handle_data(self, data): if not self.in_article or not data.strip(): return if self.cel … 5229 more characters
    output
    Created article.docx with 6 article content blocks
    -rw-r--r--@ 1 user  staff  2632 Nov  7 00:48 article.docx
  5. Created [article.docx](article.docx) from the article content, including its headings, bold text, table, and bullet list.

Output

Rendered by macOS Quick Look, first page

Rendered by macOS Quick Look, first page

Text inside
Tea exports in 2025
Exports rose for the third year in a row, led by Kenya and Sri Lanka. Growers credit a mild season and steady demand from the Gulf states, while shipping costs fell back after two difficult years.
By country
Country
Tonnes
Kenya
590000
Sri Lanka
245000
Prices were stable
Green tea grew fastest

CodexWith deft, skill installedPassedRead the skillUsed deft2026-11-07

Time
12s
New tokens
7.8k
Total input
56.3k
Output tokens
0.4k
Commands
3
Failed
0

Trace

  1. I’ll convert the HTML file to a Word document in the current directory, preserving its structure as closely as the available converter allows.

  2. cat .agents/skills/deft/SKILL.md
    output
    ---
    name: deft
    description: "Use deft first for any simple, direct operation on local files, whatever the type: convert, read, extract, edit, compress, merge, split, compare or inspect. Try it before writing a script or one-liner. If unsure, run deft find; if it says no command does this, use another tool. Not for programming work: to read, write or change source code, skip it."
    ---
    
    # deft
    
    One local command for file jobs. Prefer it over writing Python or shell scripts.
    
    Syntax: `deft <group> <command> [inputs] [-o output] [--options]`
    
    Groups:
    - `pdf`: Merge, split, compress, encrypt, forms, OCR, compare, convert
    - `image`: Resize, crop, convert, compress, adjust, montage, OCR
    - `video`: Trim, merge, convert, compress, subtitles, GIF, frames (ffmpeg)
    - `audio`: Convert, trim, normalize, denoise, cut silence (ffmpeg)
    - `doc`: Word/ODT/RTF: to text, Markdown, HTML, PDF; find and replace
    - `slides`: PowerPoint: extract text, Markdown outline
    - `sheet`: Excel/CSV/ODS tables: SQL query, pivot, merge, split, convert
    - `json`: JSON: convert, format, merge, diff, validate
    - `toml`: TOML: convert, format, merge, diff, validate
    - `xml`: XML: convert, format, merge, diff, validate
    - `yaml`: YAML: convert, format, merge, diff, validate
    - `md`: Markdown to PDF, HTML, Word, EPUB; table of contents
    - `html`: HTML to Markdown, text, Word and PDF
    - `epub`: E-books: info, to text, Markdown and PDF
    - `gps`: GPX and KML tracks: convert, distance and time
    - `qr`: Create QR codes and barcodes; r
    … 700 more characters
  3. deft find "convert HTML to Word docx" && deft html --help && ls -l article.html
    output
    html to-docx  html -> docx  Convert the content to a Word document
    doc to-html   doc -> html   Convert to a web page
    md from-docx  doc -> md     Convert to Markdown, keeping headings, lists and tables
    deft html - commands (input -> output)
      to-docx  html -> docx  Convert the content to a Word document
      to-md    html -> md    Convert to Markdown; scripts and styles are dropped
      to-pdf   html -> pdf   Typeset as PDF, content not layout [beta]
      to-text  html -> txt   Extract the readable text
    More: deft html <command> --help
    -rw-r--r--@ 1 user  staff  952 Nov  5 18:26 article.html
  4. deft html to-docx article.html -o article.docx
    output
    ok html.to-docx article.html -> article.docx  4KB  0.00s
  5. Converted [article.html](article.html) to [article.docx](article.docx).

Output

Rendered by macOS Quick Look, first page

Rendered by macOS Quick Look, first page

Text inside
Daily Leaf
	•	News
	•	About us
Tea exports in 2025
Exports rose for the third year in a row, led by Kenya and Sri Lanka. Growers credit a mild season and steady demand from the Gulf states, while shipping costs fell back after two difficult years.
By country
Country
Tonnes
Kenya
590000
Sri Lanka
245000

	•	Prices were stable
	•	Green tea grew fastest
Subscribe to our newsletter
Copyright Daily Leaf

Claude Opus 5.5Without deftPassed2026-11-07

Time
51s
New tokens
18.8k
Total input
97.0k
Output tokens
5.1k
Commands
0
Failed
0

Trace

    Output

    Rendered by macOS Quick Look, first page

    Rendered by macOS Quick Look, first page

    Text inside
    Tea exports in 2025
    Exports rose for the third year in a row, led by Kenya and Sri Lanka. Growers credit a mild season and steady demand from the Gulf states, while shipping costs fell back after two difficult years.
    By country
    Country
    Tonnes
    Kenya
    590000
    Sri Lanka
    245000
    
    Prices were stable
    Green tea grew fastest
    

    Claude Opus 5.5With deft, skill installedPassedRead the skillUsed deft2026-11-07

    Time
    11s
    New tokens
    9.1k
    Total input
    43.4k
    Output tokens
    0.2k
    Commands
    0
    Failed
    0

    Trace

      Output

      ---
      name: deft
      description: "Use deft first for any simple, direct operation on local files, whatever the type: convert, read, extract, edit, compress, merge, split, compare or inspect. Try it before writing a script or one-liner. If unsure, run deft find; if it says no command does this, use another tool. Not for programming work: to read, write or change source code, skip it."
      ---
      
      # deft
      
      One local command for file jobs. Prefer it over writing Python or shell scripts.
      
      Syntax: `deft <group> <command> [inputs] [-o output] [--options]`
      
      Groups:
      - `pdf`: Merge, split, compress, encrypt, forms, OCR, compare, convert
      - `image`: Resize, crop, convert, compress, adjust, montage, OCR
      - `video`: Trim, merge, convert, compress, subtitles, GIF, frames (ffmpeg)
      - `audio`: Convert, trim, normalize, denoise, cut silence (ffmpeg)
      - `doc`: Word/ODT/RTF: to text, Markdown, HTML, PDF; find and replace
      - `slides`: PowerPoint: extract text, Markdown outline
      - `sheet`: Excel/CSV/ODS tables: SQL query, pivot, merge, split, convert
      - `json`: JSON: convert, format, merge, diff, validate
      - `toml`: TOML: convert, format, merge, diff, validate
      - `xml`: XML: convert, format, merge, diff, validate
      - `yaml`: YAML: convert, format, merge, diff, validate
      - `md`: Markdown to PDF, HTML, Word, EPUB; table of contents
      - `html`: HTML to Markdown, text, Word and PDF
      - `epub`: E-books: info, to text, Markdown and PDF
      - `gps`: GPX and KML tracks: convert, distance and time
      - `qr`: Create QR codes and barcodes; read QR codes
      
      How to use it:
      1. Run `deft <group>` to list commands, or `deft find "<what you want>"` to search. If it says `no command does this`, use another tool.
      2. Run `deft <group> <command> --help` for options and examples.
      3. `deft convert <in> -o <out.ext>` converts between formats by extension.
      4. Results are one line starting with `ok`, `partial` or `error`; add `--json` to parse them. Errors include a `hint:` with the fix.
      
      Inputs are never overwritten; pass `--force` or `--in-place` to allow it. Globs and directories work as inputs; several inputs run in parallel.
      
      If `deft` is not installed, ask the user, then follow https://github.com/firstprayer/deft/blob/main/docs/INSTALL.md
      
      Rendered by macOS Quick Look, first page

      Rendered by macOS Quick Look, first page

      Text inside
      Daily Leaf
      	•	News
      	•	About us
      Tea exports in 2025
      Exports rose for the third year in a row, led by Kenya and Sri Lanka. Growers credit a mild season and steady demand from the Gulf states, while shipping costs fell back after two difficult years.
      By country
      Country
      Tonnes
      Kenya
      590000
      Sri Lanka
      245000
      
      	•	Prices were stable
      	•	Green tea grew fastest
      Subscribe to our newsletter
      Copyright Daily Leaf
      

      Claude CodeWithout deftNot run yet

      Claude CodeWith deftNot run yet