docpler / app.py
chiang01's picture
Claude Opus 4.6 (1M context)
Enable MCP server for Claude integration
60feebd
Raw History Blame Contribute Delete
1.5 kB
import gradio as gr
from docpler.hwp import convert
def hwp_to_markdown(file):
"""Convert an HWP (Korean word processor) document to Markdown.
Upload a .hwp file and get back the converted Markdown text.
HWP is the native format of Hangul Word Processor, widely used
in South Korea for government, legal, and academic documents.
Args:
file: The HWP file to convert (.hwp format)
Returns:
Converted Markdown text
"""
if file is None:
return "", ""
md = convert(file.name)
return md, md
with gr.Blocks(title="docpler โ€” HWP to Markdown") as demo:
gr.Markdown(
"# docpler โ€” HWP to Markdown\n\n"
"Convert HWP (Korean word processor) documents to Markdown. "
"Powered by a high-performance Rust parser.\n\n"
"HWP(ํ•œ๊ธ€ ์›Œ๋“œํ”„๋กœ์„ธ์„œ) ๋ฌธ์„œ๋ฅผ Markdown์œผ๋กœ ๋ณ€ํ™˜ํ•ฉ๋‹ˆ๋‹ค. "
"Rust ๊ธฐ๋ฐ˜์˜ ๋น ๋ฅด๊ณ  ์ •ํ™•ํ•œ ํŒŒ์„œ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค."
)
file_input = gr.File(label="Upload HWP file / HWP ํŒŒ์ผ ์—…๋กœ๋“œ", file_types=[".hwp"])
with gr.Tabs():
with gr.Tab("Raw"):
raw_output = gr.Textbox(label="Markdown source", lines=20)
with gr.Tab("Preview"):
preview_output = gr.Markdown(label="Rendered preview")
file_input.change(
fn=hwp_to_markdown,
inputs=file_input,
outputs=[raw_output, preview_output],
api_name="convert",
)
if __name__ == "__main__":
demo.launch(mcp_server=True)