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

Indentation missing from 'pre' example in sample article? #1389

Closed
sean-fitzpatrick opened this issue Nov 19, 2020 · 18 comments
Closed

Indentation missing from 'pre' example in sample article? #1389

sean-fitzpatrick opened this issue Nov 19, 2020 · 18 comments
Labels

Comments

@sean-fitzpatrick
Copy link
Contributor

In the sample article there is an example of using the <pre> tag for code with indentation.

There is then a short <pre> paragraph that claims to include a normal line, an indented line, and an outdented line.
But all three lines appear with the same alignment, and there is no whitespace in the source.

@davidfarmer
Copy link
Contributor

davidfarmer commented Nov 19, 2020 via email

@sean-fitzpatrick
Copy link
Contributor Author

OK. But shouldn't the second line appear with indentation? It doesn't on my browser.
I have a colleague who is looking for solutions for displaying code online for students to annotate, using hypothes.is or similar.

But for programming languages like Python, indentation is part of the code.
I was hoping to be able to point to an example that shows code with indentation to illustrate that this is possible.

@Alex-Jordan
Copy link
Contributor

David is saying that the reason there is no indentation is because that indentation would be caused by whitespace characters in the source which are now gone from the HTML.

For Python code, I think someone should be using c and cd elements, not pre.

I think maybe PTX pre should be renamed verbatim. The behavior of PTX pre is not the same as HTML pre, which is only about using monospace font and preserving whitespace. For example, it is OK to use markup inside HTML pre. The difference will probably cause some confusion.

@Alex-Jordan
Copy link
Contributor

David is saying that the reason there is no indentation is because that indentation would be caused by whitespace characters in the source which are now gone from the HTML.

Meaning, there is a bug in the HTML translation.

@rbeezer
Copy link
Collaborator

rbeezer commented Nov 19, 2020

A mistake somewhere, but I can't say just what might have led to it, which is odd (alarming?).

This is why we have the sample article. See PDF where the right things happen with this example.

A few things with deadlines are stacking up - may be the weekend before I can investigate. Should be easy to fix.

@rbeezer
Copy link
Collaborator

rbeezer commented Nov 19, 2020

For Python code, I think someone should be using c and cd elements, not pre.

pre is a peer of a paragraph, c and cd are for within a paragraph. See the schema.

Perhaps a better alternative would be the program element, also a peer of a paragraph. And can go in a listing for a caption (or title?).

@rbeezer
Copy link
Collaborator

rbeezer commented Nov 19, 2020

@sean-fitzpatrick Forgot to say. Convince your colleague that we'll get it right quickly.

@sean-fitzpatrick
Copy link
Contributor Author

OK, thanks! If it works in PDF, that might be good enough. I think she was dealing with the same frustration of HTML ignoring whitespace. (But maybe was trying to make PDF.)

Anyway, I think the goal was to provide students with (possibly flawed) code samples and have them use annotation to analyze (and possibly debug) the code. I think PreTeXt HTML with hypothes.is built in might be a good candidate for this.

@Alex-Jordan
Copy link
Contributor

While we are looking at this page of the sample article, there are some cd down below on the page. I think that cd content is supposed to be centered (at least that's what the sample article says should happen). But it's all flush left. See this paragraph:

https://pretextbook.org/examples/sample-article/annotated/section-20.html#p-885

At first if looked like a CSS issue. But the HTML for the PTX cds is the same as for the PTX pres. Both are HTML <pre class="code-block tex2jax_ignore"> and I don't see how CSS would distinguish them.

@rbeezer
Copy link
Collaborator

rbeezer commented Nov 20, 2020

Thanks, Alex.

Let's put proposing name changes on -dev, and cd can go on a new issue. This will get closed once the bug is fixed and the other two items are not related to that (I think).

@rbeezer
Copy link
Collaborator

rbeezer commented Nov 20, 2020

Really mystified now. Checked the code. Appears fine. Tested a minimal example, pre works fine. Built sample article locally, pre outdent example looks fine. Checked sample article at website. pre looks fine.

https://pretextbook.org/examples/sample-article/html/section-20.html

@sean-fitzpatrick Can you pull and try a test with that example in the sample article? Just to make sure I am not delusional? (See you at drop-in?)

@sean-fitzpatrick
Copy link
Contributor Author

It looks fine to me as well! But the indentation is still missing in the annotated version of the sample article.
Maybe something with the annotation ("View Source") is causing the problem?

@Alex-Jordan
Copy link
Contributor

Alex-Jordan commented Nov 20, 2020 via email

@rbeezer
Copy link
Collaborator

rbeezer commented Nov 20, 2020

Aah - I did not notice you were talking about the annotated version!

@rbeezer
Copy link
Collaborator

rbeezer commented Nov 20, 2020

The "annotated" version has not been updated in months, since the script to produce it has an error. I believe this pull request would fix it:

davidfarmer/LaTeXtoLaTeX#25

Then we can see what morte needs to happen. This might be a part of a bigger-picture issue:

davidfarmer/LaTeXtoLaTeX#23

@sean-fitzpatrick
Copy link
Contributor Author

Got it. Sorry for causing undue alarm. I always go to the annotated version because I'm usually looking for some ptx code :-)

@rbeezer rbeezer removed the bug label Nov 21, 2020
@rbeezer
Copy link
Collaborator

rbeezer commented Nov 21, 2020

Rebuilt annotated version of sample article, now that LaTeXtoLaTeX script is functional at davidfarmer/LaTeXtoLaTeX#25 (thanks, @davidfarmer!). Public now. So will review the migration of various bits of verbatim text next.

@rbeezer
Copy link
Collaborator

rbeezer commented Nov 21, 2020

The annotated article is such a mess, and my style a bit archaic, that we pretty-print the article before making annotations.

Independent of our use, this will clobber indentation in programs (e.g. Python, Sage), so this needs to be addressed in the pretty-printing code. And once done, all the improvements will migrate here automatically, since the website build pulls automatically from relevant repositories and so is always up-to-date. So I'm closing this in lieu of

davidfarmer/LaTeXtoLaTeX#28

Much more detail there. Thanks, @sean-fitzpatrick for the report. Sorry for my initial mis-understanding.

@rbeezer rbeezer closed this as completed Nov 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants