Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leading whitespace not rendered #2

Closed
tyoung-JHUAPL opened this issue Feb 10, 2020 · 5 comments
Closed

Leading whitespace not rendered #2

tyoung-JHUAPL opened this issue Feb 10, 2020 · 5 comments

Comments

@tyoung-JHUAPL
Copy link

With a slight tweak to the tutorial, I'm noticing it's not rendering the leading-whitepace on many of the lines in my browser.

Example code:

import justpy as jp
string = [
'JustPy',
'',
' What is JustPy?',
' Introduction',
' Hello World!',
' Under the Hood',
' News and Updates',
' License',
' Tutorial',
' Getting Started',
' Basic Concepts',
' Handling Events',
' HTML Components',
]
def my_click(self, msg):
self.text = 'I was clicked!'

def hello_world():
wp = jp.WebPage()
for sub_str in string:
print(sub_str)
d = jp.Div(text=sub_str)
d.on('click', my_click)
wp.add(d)
return wp

jp.justpy(hello_world)

I comes out as:
JustPy
I was clicked!
Introduction
I was clicked!
Under the Hood
News and Updates
License
Tutorial
Getting Started
Basic Concepts
Handling Events
HTML Components

@elimintz
Copy link
Collaborator

I am not sure I understand the problem. Which white space is ignored?

@tyoung-JHUAPL
Copy link
Author

Sorry, now github stripped the leading whitespace from the code or there is some special whitespace character going on.

Attaching the source:
test_justpy.py.txt

@tyoung-JHUAPL
Copy link
Author

> import justpy as jp

string = [
'JustPy',
'',
'    What is JustPy?',
'        Introduction',
'        Hello World!',
'        Under the Hood',
'        News and Updates',
'        License',
'    Tutorial',
'        Getting Started',
'        Basic Concepts',
'        Handling Events',
'        HTML Components',
]
def my_click(self, msg):
    self.text = 'I was clicked!'

def hello_world():
    wp = jp.WebPage()
    for sub_str in string:
        print(sub_str)
        d = jp.Div(text=sub_str)
        d.on('click', my_click)
        wp.add(d)
    return wp

jp.justpy(hello_world)

@tyoung-JHUAPL
Copy link
Author

i.e. line 6 should have a string with a bunch of leading spaces. Is strip() called somewhere?

@elimintz
Copy link
Collaborator

If you want the leading spaces use Pre instead of Div:
d = jp.Pre(text=sub_str)

WolfgangFahl pushed a commit that referenced this issue Aug 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants