Closed sean-fitzpatrick closed 3 years ago
The white space in the source has been stripped from the HTML.
On Thu, 19 Nov 2020, Sean Fitzpatrick wrote:
In the sample article there is an example of using the
tag for code with indentation.There is then a short
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.— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.[AABTULCXZ36UFGRAGK7CUT3SQVWZXA5CNFSM4T32ONYKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4LEEGQAA.gif]
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.
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.
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.
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.
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
?).
@sean-fitzpatrick Forgot to say. Convince your colleague that we'll get it right quickly.
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.
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 cd
s is the same as for the PTX pre
s. Both are HTML <pre class="code-block tex2jax_ignore">
and I don't see how CSS would distinguish them.
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).
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?)
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?
The link this started with was "annotated" and I still see the issue there: https://pretextbook.org/examples/sample-article/annotated/section-20.html
On Fri, Nov 20, 2020 at 8:03 AM Sean Fitzpatrick notifications@github.com wrote:
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?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rbeezer/mathbook/issues/1389#issuecomment-731255261, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABEDOAA5MBQW5XKFA4TCZWDSQ2HMPANCNFSM4T32ONYA .
-- Alex Jordan Mathematics Instructor Portland Community College
Aah - I did not notice you were talking about the annotated version!
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:
https://github.com/davidfarmer/LaTeXtoLaTeX/pull/25
Then we can see what morte needs to happen. This might be a part of a bigger-picture issue:
Got it. Sorry for causing undue alarm. I always go to the annotated version because I'm usually looking for some ptx
code :-)
Rebuilt annotated version of sample article, now that LaTeXtoLaTeX
script is functional at https://github.com/davidfarmer/LaTeXtoLaTeX/pull/25 (thanks, @davidfarmer!). Public now. So will review the migration of various bits of verbatim text next.
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
https://github.com/davidfarmer/LaTeXtoLaTeX/issues/28
Much more detail there. Thanks, @sean-fitzpatrick for the report. Sorry for my initial mis-understanding.
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.