Skip to content

Commit 1603eb9

Browse files
authored
fix rendering issues: remove highlighting and show raw text for templates (#532)
* remove highlightingg and show row text for templates * remove the highlighter import * remove commented lines
1 parent 289276e commit 1603eb9

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

promptsource/app.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import plotly.express as px
77
import streamlit as st
88
from datasets import get_dataset_infos
9-
from jinja2 import TemplateSyntaxError
109
from pygments import highlight
1110
from pygments.formatters import HtmlFormatter
1211
from pygments.lexers import DjangoLexer
@@ -86,10 +85,13 @@ def show_jinja(t, width=WIDTH):
8685
st.write(out, unsafe_allow_html=True)
8786

8887

89-
def show_text(t, width=WIDTH):
88+
def show_text(t, width=WIDTH, with_markdown=False):
9089
wrap = [textwrap.fill(subt, width=width, replace_whitespace=False) for subt in t.split("\n")]
9190
wrap = "\n".join(wrap)
92-
st.write(wrap, unsafe_allow_html=True)
91+
if with_markdown:
92+
st.write(wrap, unsafe_allow_html=True)
93+
else:
94+
st.text(wrap)
9395

9496

9597
#
@@ -373,10 +375,7 @@ def get_infos(d_name):
373375
st.write(example)
374376
if num_templates > 0:
375377
with col2:
376-
try:
377-
prompt = template.apply(example, highlight_variables=True)
378-
except (TemplateSyntaxError, TypeError):
379-
prompt = template.apply(example, highlight_variables=False)
378+
prompt = template.apply(example, highlight_variables=False)
380379
if prompt == [""]:
381380
st.write("∅∅∅ *Blank result*")
382381
else:
@@ -453,7 +452,7 @@ def get_infos(d_name):
453452
col1, _, _ = st.beta_columns([18, 1, 6])
454453
with col1:
455454
if state.template_name is not None:
456-
show_text(variety_guideline)
455+
show_text(variety_guideline, with_markdown=True)
457456

458457
#
459458
# Edit the created or selected template

0 commit comments

Comments
 (0)