taipy icon indicating copy to clipboard operation
taipy copied to clipboard

Unable to use markdown attribute lists with "text" element

Open arcanaxion opened this issue 1 year ago • 4 comments

What went wrong? 🤔

Per title, cannot use attribute lists with text, since Taipy tries to evaluate the content of the curly braces: https://python-markdown.github.io/extensions/attr_list/

from taipy.gui import Gui, Markdown
import taipy.gui.builder as tgb

with tgb.Page() as page_tgb:
    tgb.text("This is a **Taipy**{: style='color:red'} application.")

page_md = Markdown(
"""
<|This is a **Taipy**{: style='color:red'} application.|text|>
""")

if __name__ == "__main__":
    page = page_tgb
    gui = Gui(page)
    gui.run(debug=True, run_browser=False, use_reloader=True)

Both page_tgb and page_md fail with the traceback:

  File "<unknown>", line 1
    : style='color:red'
    ^
SyntaxError: invalid syntax

<|Hello|text|> translates to tgb.text("Hello"). How do you represent "normal" text not in a text element, like in the page_md example above?

E.g. the following example (seemingly) only available with the markdown syntax, works:

page_md_working = Markdown(
"""
This is a **Taipy**{: style='color:red'} application.
""")

Expected Behavior

  1. Attribute lists should work with text controls
  2. tgb syntax should have a way to display text without using the text element, like what is possible with the markdown syntax

Steps to Reproduce Issue

NA

Solution Proposed

NA

Screenshots

NA

Runtime Environment

No response

Browsers

No response

OS

No response

Version of Taipy

No response

Additional Context

No response

Acceptance Criteria

  • [ ] Ensure new code is unit tested, and check code coverage is at least 90%.
  • [ ] Create related issue in taipy-doc for documentation and Release Notes.

Code of Conduct

  • [X] I have checked the existing issues.
  • [ ] I am willing to work on this issue (optional)

arcanaxion avatar Sep 12 '24 09:09 arcanaxion

As a workaround, I put these texts as bold in my application, and I use CSS to change the color of all bold texts to show a different color.

strong, b {
    font-weight: bold; /* This is equivalent to 700 */
    color: #ff6049;
}

FlorianJacta avatar Sep 12 '24 09:09 FlorianJacta

@arcanaxion in which repo/branch should I search for this to contribute my solution pls help

yashpal2104 avatar Sep 25 '24 20:09 yashpal2104

Kindly assign it to me I want to fix it

KunjShah95 avatar Oct 01 '24 08:10 KunjShah95

@yashpal2104 Thank you for your help.

jrobinAV avatar Oct 01 '24 08:10 jrobinAV

There's already a solution that will be proposed by R&D team soon. You'll be able to add style to page (available in 4.0) or even components (4.1 I guess) I think this should be removed from HacktoberFest @jrobinAV

FredLL-Avaiga avatar Oct 06 '24 17:10 FredLL-Avaiga

oh okay happy to know you did find the solution, no worries I will try on some other good first issues. Thank you for informing about this @FredLL-Avaiga

yashpal2104 avatar Oct 06 '24 18:10 yashpal2104

@FredLL-Avaiga OK. Thank you.

jrobinAV avatar Oct 06 '24 18:10 jrobinAV

There's already a solution that will be proposed by R&D team soon. You'll be able to add style to page (available in 4.0) or even components (4.1 I guess)

Hi @FredLL-Avaiga. Is this feature available yet? Specifically I want to specify the text colour hex code in a text component

arcanaxion avatar Nov 14 '24 06:11 arcanaxion

it is for pages in 4.0 It's coming in 4.1 for components

FredLL-Avaiga avatar Nov 14 '24 08:11 FredLL-Avaiga

@FredLL-Avaiga I see, thank you. For posterity, is this the page style feature you are referring to? https://docs.taipy.io/en/develop/refmans/reference/pkg_taipy/pkg_gui/pkg_builder/Page/#taipy.gui.builder.Page.set_style

arcanaxion avatar Nov 14 '24 08:11 arcanaxion

yes and it is supported as well in the page constructor ex: Markdown("""...""", style={...})

FredLL-Avaiga avatar Nov 14 '24 09:11 FredLL-Avaiga