Spaces:
Running
Running
File size: 1,501 Bytes
98b3455 60feebd 98b3455 aba305c 98b3455 aba305c 98b3455 aba305c 60feebd 98b3455 60feebd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | 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)
|