Stop the internal text editor replacing spaces with tabs

This forum is for all Flare issues not related to any of the other categories.
Post Reply
fchapman42
Jr. Propeller Head
Posts: 9
Joined: Thu Jul 19, 2012 12:22 pm

Stop the internal text editor replacing spaces with tabs

Post by fchapman42 »

Hi,

I have a lot of code examples to add to the help. Flare has an unfortunate habit to replacing the spaces in the code with tabs. This is a big problem for me because our Git review process rejects any pull requests that use tabs for code indentation. I would expect there to be an option somewhere to turn off this unwanted behaviour but haven't found it yet.

Can anyone help?

Thanks, Felicity
RamonS
Senior Propellus Maximus
Posts: 4293
Joined: Thu Feb 02, 2006 9:29 am
Location: The Electric City

Re: Stop the internal text editor replacing spaces with tabs

Post by RamonS »

I don't think there is a straight forward way. Flare is XML based and there is no such thing as a tab even when you use the <pre> tag to retain formatting as is. My suggestion is to use a tool such as Notepad++ to paste the code samples into. Do a find and replace on the tab character and replace it with five non-breakable spaces. The number of spaces might need some adjustment, my suggestion of five seems like a good starting point. The intent is to keep the indentation and retain the relative position of the line starts. There may be other means, but this one is low tech and rather quick. Prepping a code sample will take a few seconds.
yonatanlehman
Propeller Head
Posts: 51
Joined: Mon Sep 18, 2017 6:14 am

Re: Stop the internal text editor replacing spaces with tabs

Post by yonatanlehman »

Sorry, I don't like the answer :?

If I copy a <code> </code> block from one topic to another, I expect Flare to simply copy it "as is" -
what happens in practice is that it replaces my carefully placed spaced with tabs......
Flare should have three options in the text editor:
1) keep spacing and indenting "as is" bit when switching between text editor and XML editor and when doing copy/paste
2) Reformat/pretty print the entire XML (instead of having to copy/paste/copy/paste to some resource on the web)
3) try and be intelligent and pretty print things as I type - and keep messing up my input in some undefined way.

Unfortunately, Madap does only the third option..... :wink:

BTW - I have similar problems when I use snippets as a template, I use right click "convert to text" and Madcap goes and messes up my indentation.
RamonS
Senior Propellus Maximus
Posts: 4293
Joined: Thu Feb 02, 2006 9:29 am
Location: The Electric City

Re: Stop the internal text editor replacing spaces with tabs

Post by RamonS »

Are you sure it replaces it with tabs as in tab character rather than indentation? Unless things changed recently, HTML and with that XML cannot work with the tab character. Using spaces for formatting only works when you use monospace fonts. Browsers typically display pre and code tagged content in monospace font, but the tags are subject to formatting directives from CSS. If you do not see the results you expect have a look at the CSS and check if any less than ideal formatting is set.

Flare should convert any spaces pasted into a pre or code block into non-breaking spaces. That is the only way you get what you pasted in, even if it messes up page formatting. Are you pasting from a plain text editor? Some sources add inline formatting to the content copied to the clipboard (Chrome does that and it is super annoying). That may mess things up, although I find that to be unlikely to be the case.
fchapman42
Jr. Propeller Head
Posts: 9
Joined: Thu Jul 19, 2012 12:22 pm

Re: Stop the internal text editor replacing spaces with tabs

Post by fchapman42 »

I can confirm that this is what happens when you paste content into Flare.

I've discovered a related but different problem today. When Flare generates output, it seems to replace some spaces in the source files with tabs in the output. Since my company has an aggressive pull request check for files with mixed spaces, this is very inconvenient. There seems to be no change that I can make to the Flare source file to stop it doing this. Another author has added a brief <style> section to the top of one topic, and the spaces in this are automatically converted to tabs on building.

Given that Flare does this sort of thing, it would make a big difference if you could choose whether it used spaces or tabs automatically.
RamonS
Senior Propellus Maximus
Posts: 4293
Joined: Thu Feb 02, 2006 9:29 am
Location: The Electric City

Re: Stop the internal text editor replacing spaces with tabs

Post by RamonS »

As mentioned before, XML is unaware of tab. Tab is unspecific as to what the tab width is. The tab width would need to get passed along with the text and CSS has other means to accomplish that. While it may not desired, Flare turns what gets pasted into valid XML. You could try using &#009 instead for the tab character, but I wouldn't know what Flare or browsers would do to display the tab.
I hope I am wrong, because that would help you out a lot. :lol:
Post Reply