-
Notifications
You must be signed in to change notification settings - Fork 435
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
Variables of type 'string' rendered without spaces #56
Comments
Hi @michaellisitsa, Dealing with multi-word text strings is a limited in handcalcs. Currently they are only handled within comments. I have run into this issue in my own scripts where I want to indicate a "flag" or something during the calculations. I have adapted the calculations to either use single words, descriptive subscripted variables, or booleans. However, given your post to the Showcase (#50), I have a sense of what you may be trying to achieve. For creating a title block, I like to create a new Python module on my system to have a bunch of functions that I can pull into any new notebook, including this function: from IPython.display import HTML
def title_block(
name: str,
proj: str,
date: str,
design: str,
size: str = "1.5em"
):
# This can be used to create a "title block" in your notebooks
# before you start your calculations
html_title = f"""
<table style="width:100%; font-size:{size}; border:1px;">
<tr>
<td style="width:15%; text-align:right; font-weight:bold">Name: </td>
<td style="width:35%; text_align:right">{name}</td>
<td style="width:15%; text-align:right; font-weight:bold">Date: </td>
<td style="width:35%; text_align:right">{date}</td>
</tr>
<tr>
<td style="width:15%; text-align:right; font-weight:bold">Project: </td>
<td style="width:35%; text_align:right">{proj}</td>
<td style="width:15%; text-align:right; font-weight:bold">Design: </td>
<td style="width:35%; text_align:right">{design}</td>
</tr>
</table>
"""
display(HTML(html_title)) Here is an example of the export to HTML and PDF printed in Chrome: You can get even fancier and include your company logo in the title block, also! |
Thanks. It never crossed my mind to use HTML within a .py function. This would be useful when using PaperMill, where you may not want to manually edit the Markdown cells with separate headers. |
Oooh...that's a good call. I have not thought to parameterize my Markdown headers yet...Nice one! |
Going to close this issue for now. Still a problem but I do not anticipate fixing it unless it eventually becomes a major issue. |
Were a variable is declared with a 'string' and then rendered, the string is shown with all spaces removed.
How to reproduce
name = "John Smith"
Expected behaviour
Show with a space.
Setup
Handcalcs 1.1.3
MacOS High Sierra
Jupyter Notebook
The text was updated successfully, but these errors were encountered: