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

Tabs vs Spaces #35

Closed
riosavila opened this issue Sep 7, 2023 · 8 comments
Closed

Tabs vs Spaces #35

riosavila opened this issue Sep 7, 2023 · 8 comments

Comments

@riosavila
Copy link

Hi Tim,
I recently noticed a small problem (not sure if its nbstata or pystata)
When copying a chunk of code from a dofile into a quarto document, and run the code, some problems emerge if the code starts with a tabulation (for long codes).

This can be easily fixed, however if one uses Spaces instead of Tabs
Minor problem, but may bite more when transferring from one Do to Quarto (and jupyter?)

Thank you
F

@hugetim
Copy link
Owner

hugetim commented Sep 7, 2023

It would be helpful to see a specific example: the code and what error it produces. In nbstata stuff, I've tried to make the processing of code robust to the use of Tabs, but it's certainly possible it's sometimes not.

@riosavila
Copy link
Author

riosavila commented Sep 7, 2023

Sorry that was totally my fault

---
title: "Stata Error"
format: html
jupyter: nbstat
---

Setup

sysuse auto, clear

Example

This one will work:

scatter price mpg, \\\
    ytitle("Price") xtitle("Miles per Gallon") ///
    title("Scatterplot of Price vs. Miles per Gallon") ///
    subtitle("Automobiles 1978") ///
    note("Source: Stata Example Datasets") ///
    caption("Scatterplot of Price vs. Miles per Gallon")

This one will not work:

scatter price mpg, ///
	ytitle("Price") xtitle("Miles per Gallon") ///
	title("Scatterplot of Price vs. Miles per Gallon") ///
	subtitle("Automobiles 1978") ///
	note("Source: Stata Example Datasets") ///
	caption("Scatterplot of Price vs. Miles per Gallon")

The difference. The second code chunk was written in Stata editor. So the Spaces are "tabs"
in the first case, I redid the indentation using vsc, so each tabulation is four "spaces"

In the second case it will indicate that command " " does not exists.

@friosavila
Copy link

friosavila commented Sep 7, 2023 via email

@riosavila
Copy link
Author

Not sure how to send you Jypter Notebooks, but
I did run an example with the code I provided earlier, and it works with Stata Magic, but with nbstata.

@hugetim
Copy link
Owner

hugetim commented Sep 8, 2023

Ok, right, I can confirm this is an nbstata issue, not pystata or quarto.

@hugetim
Copy link
Owner

hugetim commented Sep 8, 2023

The same issue occurs in v0.6.3 and v0.6.1, so it doesn't seem to have been introduced by recent changes to how comments and indentation are handled.

@hugetim hugetim closed this as completed in 9ca8320 Sep 8, 2023
@hugetim
Copy link
Owner

hugetim commented Sep 8, 2023

It's actually quite a specific issue. For example, if you combined the sysuse auto line together in the same cell as the offending code, no error would be triggered. I'll try to get the fix shipped to a new pypi version this evening.

@friosavila
Copy link

Thank you!
Best wishes

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

3 participants