Welcome to DU! The truly grassroots left-of-center political community where regular people, not algorithms, drive the discussions and set the standards. Join the community: Create a free account Support DU (and get rid of ads!): Become a Star Member Latest Breaking News Editorials & Other Articles General Discussion The DU Lounge All Forums Issue Forums Culture Forums Alliance Forums Region Forums Support Forums Help & Search

progree

(11,463 posts)
Sun Oct 29, 2023, 10:15 AM Oct 2023

Thanks for monospace font. But I still can't make a decent table because 2 or more spaces in a row

are compressed into one space. For example this table showing PCE inflation.

Month over month changes, % May Jun Jul Aug Sep
PCE 0.1 0.2 0.2 0.4 0.4
PCE, excluding food and energy 0.3 0.2 0.2 0.1 0.3


In Word I did a find and replace of space with backquote:

`````Month`over`month`changes,`%`````May``Jun``Jul``Aug``Sep
`````PCE`````````````````````````````0.1``0.2``0.2``0.4``0.4
`````PCE,`excluding`food`and`energy``0.3``0.2``0.2``0.1``0.3


It works, but the backquotes are annoying, they look like gnats one wants to put the spray can to.

I tried using #nbsp; in place of spaces (but where # is replaced by &), and it helped but still messed up.

Is there some other hack I can use? Thanks

Edit: desktop Windows 10 computer, 24" monitor, Edge browser, if that helps

13 replies = new reply since forum marked as read
Highlight: NoneDon't highlight anything 5 newestHighlight 5 most recent replies

progree

(11,463 posts)
9. Thanks for reply. If I have trouble with #nbsp; again, I will try those codes
Sun Oct 29, 2023, 11:28 AM
Oct 2023

(same deal with the # for & )

EarlG

(22,540 posts)
2. The nbsp hack should work
Sun Oct 29, 2023, 10:48 AM
Oct 2023

When you do your find and replace in Word, instead of replacing all spaces with a period or quote, replace them with this:

 

The catch is that you can't use Preview as you normally would. Your post will look correct the first time you preview it, but once you preview, the converted HTML will reappear in the post form, so if you hit Preview again, or Post, the spaces you added will be wiped out.

So the workaround is:

1) Write your post in Word, then replace the spaces with the code above.

2) Copy the post into the DU post window.

3) Hit preview -- if it looks good, RE-PASTE from your Word document back into the DU post window and hit Post, not Preview.

Otherwise, make any necessary adjustments in Word and then re-paste again -- but if you always re-paste from Word before previewing or posting it should work. Bear in mind that if you need to edit the post, the same thing applies -- when you go to the Edit page, the spaces will have been converted again. So make sure you keep the Word doc until you're sure the post is good and you don't need to edit it.

Hope that helps...

Edited to add: lol, I made the preview mistake myself and the code didn't appear correctly, trying again...

progree

(11,463 posts)
4. Thanks for your reply. But I can't read your HTML code, all I see is a semicolon:
Sun Oct 29, 2023, 11:19 AM
Oct 2023
When you do your find and replace in Word, instead of replacing all spaces with a period or quote, replace them with this:

;


I tried replacing all spaces with ampersandnbsp;

and got

     Month over month changes, %     May  Jun  Jul  Aug  Sep      
     PCE                             0.1  0.2  0.2  0.4  0.4
     PCE, excluding food and energy  0.3  0.2  0.2  0.1  0.3


Well darn, it worked this time.

EarlG

(22,540 posts)
7. Yeah I messed up
Sun Oct 29, 2023, 11:25 AM
Oct 2023

I previewed when I shouldn't have and accidentally wiped out the code, which is what I was telling you to be careful about It's fixed now.

It looks like you were able to get the trick working. All you have to remember is to keep a copy of the post you're previewing separate because the codes will be wiped out on preview. You can preview each time as a reference, but just remember to copy your post before you preview, then re-paste it into the posting form and make any adjustments, then copy again before previewing.

progree

(11,463 posts)
10. It happens. My section on this issue in Word is part of a long long Word file
Sun Oct 29, 2023, 11:36 AM
Oct 2023

and I accidentally replaced all spaces in the entire file with #nbsp; (# = &). Something like 433,000 replacements! It hung Word for 10 minutes. (I thought I had selected the table first but I hadn't selected anything).

Fortunately my previous saved copy was very recent. And I found other productive use for those 10 minutes, so all is good.

Thanks much again

EarlG

(22,540 posts)
5. Here's an example of your table using that technique
Sun Oct 29, 2023, 11:21 AM
Oct 2023

I created this in a monospace text editor, then did a find and replace on the spaces with the code I mentioned above to get this:

                                   Month over month changes, % 
                               | May |  Jun |  Jul |  Aug |  Sep |
------------------------------------------------------------------
PCE                            | 0.1 |  0.2 |  0.2 |  0.4 |  0.4 |
PCE, excluding food and energy | 0.3 |  0.2 |  0.2 |  0.1 |  0.3 |



It's a bit fiddly but it works, as you can see.

EarlG

(22,540 posts)
11. One other thing to bear in mind
Sun Oct 29, 2023, 11:38 AM
Oct 2023

While this is a step up from what we had before (ie. no monospace capability) it's not a very elegant way to produce a table. Unfortunately, on smaller screens, wide tables will look weird. The nbsp code is literally short for "non-breaking space" so if you use them to fill every space in the excerpt, once the text lines reach the end of the viewport, they'll just keep going off the edge of the screen. So if you're using this technique and you want everyone to be able to read the table, my advice would be to try to keep the table as narrow as possible. For example, the test table I produced is viewable on my phone but only if I turn it sideways, otherwise the table flows off the edge of the screen.

Phones and tables don't really mix very well together because of the limited width. One possibility is usonian's alternate suggestion -- to post the table as an image. Obviously this is also not ideal, because it makes it harder to copy data from the table should you want to do that. However, it does avoid the line-wrapping problem as an image of a table would shrink to fit a phone's width (and can be pinched-and-zoomed to read the data if the text is too small).

usonian

(13,781 posts)
3. May I suggest an ugly hack? Take a screenshot of your table and post it as an image.
Sun Oct 29, 2023, 11:07 AM
Oct 2023

Of course, you can’t edit it in place, but would have to edit on the computer and upload the new image.

Added steps but the editing on your computer is easier than editing the markup language in the textarea, and TBH, is completely independent of whatever browsers do to your table.

If I had to present an equation, that’s what I would do.

The HTML rendering engine at DU obviously needs to be as simple and bulletproof as possible, thanks to hackers.

HTH

progree

(11,463 posts)
6. Thanks much. I've used IMGUR to post a lot of tables, I'm just hoping not to have to do that
Sun Oct 29, 2023, 11:23 AM
Oct 2023

but so be it.

I find making the table in Word and replacing spaces with ampersandnbsp; to be faster and easier than making the table in Word, screen shotting it, and using IMGUR.


usonian

(13,781 posts)
13. Indeed, many complaints here involve quirks of browser (mis)behavior.
Sun Oct 29, 2023, 12:56 PM
Oct 2023

It looks like the table element isn’t supported.
https://www.democraticunderground.com/12561674
Basic HTML on DU

so we seem to be relying on a rendered version of tables (correct me if I got this wrong) and math is unsupported (there was a thread about greek characters not rendering, a bug that’s being worked on)

I do recall in the days before MathML, all equations were pasted as images.

“This ain’t wordpress” so we adapt.
Simple is beautiful (even if it’s a PITA at times)

Latest Discussions»Help & Search»DU Community Help»Thanks for monospace font...