https://flyte.org logo
#ask-the-community
Title
# ask-the-community
m

Mateusz Kwasniak

12/15/2023, 7:15 AM
Hi all, I have a problem with
MarkdownRenderer
which seem to only parse Markdown partially. Deck content start with Header 1 (
#
) and then all the rest is displayed as a Header 1 despite newlines or new headers being introduced. Also it does not recognize other syntax (I copied exactly the same content into GitHub and it works fine). Any idea?
My usage of renderer is as simple as:
Deck("page content", MarkdownRenderer().to_html(generated_content))
k

Kevin Su

12/15/2023, 7:18 AM
is generated_content a string?
m

Mateusz Kwasniak

12/15/2023, 7:23 AM
yes
k

Kevin Su

12/15/2023, 7:23 AM
I try this, it works for me
Copy code
@task(enable_deck=True, container_image=imageSpec)
def foo() -> str:
    Deck("source code", MarkdownRenderer().to_html("## Hello World"))
    return "foo"
m

Mateusz Kwasniak

12/15/2023, 7:24 AM
sample content:
Copy code
# Evaluating Second Derivatives in Implicit Equations  <br>  <br>## Introduction  <br>  <br>In advanced differentiation, we often encounter implicit equations where the dependent and independent variables are not explicitly defined.
k

Kevin Su

12/15/2023, 7:24 AM
let me try it
thanks
m

Mateusz Kwasniak

12/15/2023, 7:27 AM
thanks, let me know if it works
k

Kevin Su

12/15/2023, 7:31 AM
replacing <br> with \n work for me
image.png
Copy code
from flytekit import workflow, task, Deck, ImageSpec
from flytekitplugins.deck import MarkdownRenderer

imageSpec = ImageSpec(registry="pingsutw", packages=["flytekitplugins-deck-standard"])


@task(enable_deck=True, container_image=imageSpec)
def foo() -> str:
    Deck("source code", MarkdownRenderer().to_html("# Evaluating Second Derivatives in Implicit Equations  \n  \n## Introduction  \n  \nIn advanced differentiation, we often encounter implicit equations where the dependent and independent variables are not explicitly defined. "))
    return "foo"


@workflow
def wf():
    foo()


if __name__ == '__main__':
    foo()
looks like markdown package doesn’t support <br>
m

Mateusz Kwasniak

12/15/2023, 7:32 AM
yeah, I did exactly the same now and seems to work
thanks
k

Kevin Su

12/15/2023, 7:33 AM
would you mind creating a PR for this? we can replace <br> with \n in the markdown renderer
m

Mateusz Kwasniak

12/15/2023, 7:34 AM
meanwhile:
k

Kevin Su

12/15/2023, 7:36 AM
hmm? could you share your generated_content
or try the example above^^^
m

Mateusz Kwasniak

12/15/2023, 7:36 AM
so the thing is
Copy code
<http://logger.info|logger.info>(f"Generated content: {generated_content}")

# this is value of generated_content which I copied from logs
# when pasted explicitly - works, when I comment line below and use value directly from generated_content - does not work
generated_content = "# Evaluating Second Derivatives in Implicit Equations\n\n## Introduction\nIn calculus, the second derivative of a function provides important information about the behavior of a function. It helps determine whether the function is concave up or concave down, as well as the location of inflection points. While evaluating second derivatives for explicit functions is relatively straightforward, it becomes more challenging when dealing with implicit equations where the derivative is not given explicitly. In this lesson, we will learn how to evaluate second derivatives in implicit equations.\n\n## Implicit Differentiation\nImplicit differentiation is a technique used to find"

Deck("page content", MarkdownRenderer().to_html(generated_content))
I didn't change anything, I just copied the content from logs (
<http://logger.info|logger.info>
above) and then it works, otherwise it does not 😄
Ok, @Kevin Su I fixed it, partially, the workaround is wild:
Copy code
generated_content = generated_content.replace('\\n', '<br>').replace('<br>', '\n')