Docxir (docxir v0.1.0)
View SourceA lightweight DOCX to HTML converter with Tailwind CSS styling.
Docxir converts Microsoft Word documents (.docx) into clean HTML documents styled with standard Tailwind CSS utility classes. It preserves basic formatting including:
- Paragraphs with alignment and indentation
- Text styling (bold, italic, underline, font sizes)
- Tables with colspan support
- Standard Tailwind classes only (no JIT dynamic classes)
Usage
The main API provides two functions for conversion:
convert/3- Returns{:ok, output_path}or{:error, reason}convert!/3- Returnsoutput_pathor raises an exception
Examples
# Using the tuple-returning version
case Docxir.convert("input.docx", "output.html") do
{:ok, path} -> IO.puts("Converted to #{path}")
{:error, reason} -> IO.puts("Error: #{reason}")
end
# Using the bang version
Docxir.convert!("input.docx", "output.html", title: "My Document")Options
:title- Document title (default: "Document"):lang- HTML language code (default: "zh-TW")
Summary
Functions
Converts a DOCX file to HTML with Tailwind CSS styling.
Converts a DOCX file to HTML, raising on error.
Returns the version of Docxir.
Functions
Converts a DOCX file to HTML with Tailwind CSS styling.
Parameters
input_path- Path to the input DOCX fileoutput_path- Path where the HTML file should be writtenopts- Keyword list of options (see module documentation)
Returns
{:ok, output_path}on success{:error, reason}on failure
Examples
iex> Docxir.convert("missing.docx", "output.html")
{:error, :enoent}
iex> {:error, _} = Docxir.convert("nonexistent.docx", "output.html")
iex> true
true
Converts a DOCX file to HTML, raising on error.
Similar to convert/3 but raises exceptions instead of returning
error tuples.
Parameters
input_path- Path to the input DOCX fileoutput_path- Path where the HTML file should be writtenopts- Keyword list of options (see module documentation)
Returns
- The output path on success
Raises
File.Errorif file operations failRuntimeErrorfor other conversion errors
@spec version() :: binary()
Returns the version of Docxir.
Examples
iex> Docxir.version()
"0.1.0"