File size: 752 Bytes
4a5a872
 
 
6bcf23a
 
 
648017c
4a5a872
7014750
 
 
 
 
 
6bcf23a
7014750
 
 
 
08d8497
4a5a872
7014750
 
 
4a5a872
7014750
4a5a872
08d8497
 
4a5a872
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
import gradio as gr

mf={
    "Heading1":"# $INP",
    "Heading2":"## $INP",
    "Heading3":"### $INP",
    "Bold":"**$INP**"
}
def upd(inp,cur_l,cur_d,format):
    if not cur_l:
        cur_l=[]
    if not cur_d:
        cur_d={}
        #for ea in list(cur.keys()):
    line=f'{mf[format].replace("$INP",inp)}'
    cur_l.append(line)   
    out_str=""
    for ea in cur_l:
        out_str+=ea
    return out_str,cur_l,out_str
with gr.Blocks() as app:
    cur_l=gr.State()
    cur_d=gr.State()
    prev=gr.Markdown("")
    format=gr.Dropdown(label="Line Format",choices=[m for m in list(mf.keys())])
    txt=gr.Textbox(lines=20)
    btn=gr.Button()
    out_txt=gr.Textbox()
    btn.click(upd,[txt,cur_l,cur_d,format],[prev,cur_l,out_txt])
app.launch()