I'm using Responsive Site Designer to make webpages that are phone-friendly and I am trying to include some code in <pre><code> tags but it always strips off all the leading whitespace. How do you stop it from doing that? Example:
https://vickyb.ca/results/code.html
Every piece of leading whitespace has been stripped in all of the code blocks, rendering them unreadable by humans. I'm not a web person so I really don't know what to do. I've tried spaces, tabs, html code for tabs, and I have this in my element (that may not be uploaded but trying it locally still doesn't work):
<pre style="font-size: 14px; white-space: pre;"><code>
I'm using a syntax highlighter but even if I remove that, I still get completely left justified code blocks.
https://vickyb.ca/results/code.html
Every piece of leading whitespace has been stripped in all of the code blocks, rendering them unreadable by humans. I'm not a web person so I really don't know what to do. I've tried spaces, tabs, html code for tabs, and I have this in my element (that may not be uploaded but trying it locally still doesn't work):
<pre style="font-size: 14px; white-space: pre;"><code>
I'm using a syntax highlighter but even if I remove that, I still get completely left justified code blocks.
I don't know the answer, but it doesn't seem directly caused by Responsive Site Designer.
I started with a blank RSD project, inserted an HTML element in a column, and copied the final <pre>...</code> lines of code into it. In 'Preview on...' it displayed fully formatted, but showed full stops instead of white spaces. I replaced the full stops at the beginning of some lines with normal spaces, and those normal spaces were not stripped out.
No doubt others cleverer than me will be able to identify which item(s) are overriding the normal operation of RSD in the page shown.
Frank
I started with a blank RSD project, inserted an HTML element in a column, and copied the final <pre>...</code> lines of code into it. In 'Preview on...' it displayed fully formatted, but showed full stops instead of white spaces. I replaced the full stops at the beginning of some lines with normal spaces, and those normal spaces were not stripped out.
No doubt others cleverer than me will be able to identify which item(s) are overriding the normal operation of RSD in the page shown.
Frank
Hi Frank. Use this site to make code post-able.
http://www.elliotswan.com/postable/
http://www.elliotswan.com/postable/
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.
This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
It's easy to overlook something you're not looking for.
This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
Hi Eric.
Thanks for looking at this. I'll leave it to Vicky to see whether that proves to be the best solution for her.
I have discovered that, contrary to what happens in a normal HTML paragraph, white spaces are not stripped from the beginning of lines in an RSD paragraph element, because RSD intersperses the normal spaces at the start of lines with non-breaking spaces. I would therefore simply put the code straight into an RSD paragraph element. I tried it by putting Vicky's lines 291-384 into an RSD paragraph element, and it displayed perfectly whether one replaced the full stops with spaces or not. This may therefore be the simplest solution.
Frank
Thanks for looking at this. I'll leave it to Vicky to see whether that proves to be the best solution for her.
I have discovered that, contrary to what happens in a normal HTML paragraph, white spaces are not stripped from the beginning of lines in an RSD paragraph element, because RSD intersperses the normal spaces at the start of lines with non-breaking spaces. I would therefore simply put the code straight into an RSD paragraph element. I tried it by putting Vicky's lines 291-384 into an RSD paragraph element, and it displayed perfectly whether one replaced the full stops with spaces or not. This may therefore be the simplest solution.
Frank
Thanks for the responses!
The only problem with putting it in a paragraph is I'll lose the syntax highlighting (the syntax highlighter targets anything in a <pre><code> block).
I originally wasn't going to post any code at all. I was just going to provide it as linked raw text files. I only thought about posting it when I found the syntax highlighter and realized I could make little pseudo inline scrollable syntax highlighted code blocks. But maybe it needs more coding to get it to work properly - I don't know. All I know is this is not the focus of the project so I've "fixed" it by putting all the cool little scrollable code blocks in their own html files, with no css. That has worked perfectly. I get whitespace and syntax highlighting now, but the code is no longer inline with the rest of the text. But that's fine; it's readable (well, to the people who need to read it, at least).
The only problem with putting it in a paragraph is I'll lose the syntax highlighting (the syntax highlighter targets anything in a <pre><code> block).
I originally wasn't going to post any code at all. I was just going to provide it as linked raw text files. I only thought about posting it when I found the syntax highlighter and realized I could make little pseudo inline scrollable syntax highlighted code blocks. But maybe it needs more coding to get it to work properly - I don't know. All I know is this is not the focus of the project so I've "fixed" it by putting all the cool little scrollable code blocks in their own html files, with no css. That has worked perfectly. I get whitespace and syntax highlighting now, but the code is no longer inline with the rest of the text. But that's fine; it's readable (well, to the people who need to read it, at least).
Sorry Frank I didn't see you were responding to another post. That is a a strange. I no sometimes I've manually added the space to clean up the code for readability.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.
This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
It's easy to overlook something you're not looking for.
This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
Hi Eric.
The page referred to in the first post has now been updated in accordance with Vicky's last post. I'm pretty sure that Vicky's latest solution is the best, as it cuts out any possible interference that the highlighting script may have been causing to the RSD HTML element contents.
The question has been useful for me because I'd not previously realised that the RSD paragraph element had the feature of not losing white space at the beginning of lines. Had it not been for Vicky's need for the syntax highlighting, just putting the code into an RSD paragraph element would, I think, have been a good solution.
Regards,
Frank
The page referred to in the first post has now been updated in accordance with Vicky's last post. I'm pretty sure that Vicky's latest solution is the best, as it cuts out any possible interference that the highlighting script may have been causing to the RSD HTML element contents.
The question has been useful for me because I'd not previously realised that the RSD paragraph element had the feature of not losing white space at the beginning of lines. Had it not been for Vicky's need for the syntax highlighting, just putting the code into an RSD paragraph element would, I think, have been a good solution.
Regards,
Frank
The maddening thing is I just found a page (from here - the one on embedding maps) that has code blocks exactly how I want, with leading white-space and syntax highlighting, and it was clearly made in the coffeecup product universe. So obviously what I want to do is possible. When I have the time, I will try to understand this better.
I have considered using WordPress or Github but part of me wants to learn more about web stuff (reminder: I'm not a web person), plus I just like the inline code blocks. I use them in R Markdown, for example, but that software generates everything for me. The only things I need to know there are stats and R. (future project: learn how to display R Markdown pages, or maybe even Shiny apps, in something I make using coffeecup's software - basically so I get a site-wide consistent appearance, which is my ultimate goal)
I also noticed I'm way out of date on my version of the software?? Oops, sorry. I'm on version 1.2. Maybe that's part of the problem. I'm a student who doesn't use this for commercial purposes so I can't afford to buy a new one too often. (and I don't believe in piracy)
I have considered using WordPress or Github but part of me wants to learn more about web stuff (reminder: I'm not a web person), plus I just like the inline code blocks. I use them in R Markdown, for example, but that software generates everything for me. The only things I need to know there are stats and R. (future project: learn how to display R Markdown pages, or maybe even Shiny apps, in something I make using coffeecup's software - basically so I get a site-wide consistent appearance, which is my ultimate goal)
I also noticed I'm way out of date on my version of the software?? Oops, sorry. I'm on version 1.2. Maybe that's part of the problem. I'm a student who doesn't use this for commercial purposes so I can't afford to buy a new one too often. (and I don't believe in piracy)
Frank Cook wrote:
Hi Eric.
The page referred to in the first post has now been updated in accordance with Vicky's last post.
Hi Eric.
The page referred to in the first post has now been updated in accordance with Vicky's last post.
Oh yes, sorry, I tried to edit out the link so no one would go looking at it now, but I don't seem to be able to edit the original post anymore.
Just as an update: I downloaded version 1.5 as a separate copy. I loaded my project into it, made a new code block, and saw the same thing. I also made a brand new project with nothing but a single html element in it. I pasted the code block in and saw the same thing. It strips white-space every time. I'm starting to wonder if there's a bug in the Mac version.
Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.