You need to be logged in to post in the forum - Log In

An active JCE Pro Subscription is required to post in the forum - Buy a Subscription

Support is currently Offline

Official support hours
Monday to Friday
09:00 - 17:00 Europe/London (BST)

Please create a new Ticket and we will get back to you as soon as we can.

#105683 Non-breaking space before colon in Fr-fr

Posted in ‘Suggestions & Feature Requests’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Latest post by lesyeux on Tuesday, 01 December 2020 19:26 GMT

BigStef
Hi JCE Team,
In french, there's a non-breaking space before a colon, something like "Example : my texte"
I would like to know if ther's anyway to change that space automatically so the space is non-breaking (modify a " " to a " " ) only for colon (":" ).
That would be so nice! Maybe have I miss a param somewhere ?

Ryan
Use the Non-breaking space button to add the space before the colon, instead of using the space bar.

The space bar will only create a non-breaking space for every consecutive space after the first.

Ryan Demmer

Lead Developer / CEO / CTO

Just because you're not paranoid doesn't mean everybody isn't out to get you.

BigStef
Hi Ryan, thank you very much for your answer.
Actually I was wondering if there was a way to check automatically if the space before colon is non-breaking, and change from simple space to non-breaking if needed.
As I'm working on websites where I adda lot of content each days, sent to me in Word file. I just wanted to avoid this repetitive and really demanding task.

Ryan
You could use a custom script to convert the space to a non-breaking space for you. Create an editor.js file in media/jce/js/ and add the following:

(function() {
	tinyMCE.onAddEditor.add(function (mgr, ed) {
		ed.onSetContent.add(function(ed, o) {
			o.content = o.content.replace(/\s:/g, ' :');
		});
		
		ed.onGetContent.add(function(ed, o) {
			o.content = o.content.replace(/\s:/g, ' :');
		});
	});
})();

Ryan Demmer

Lead Developer / CEO / CTO

Just because you're not paranoid doesn't mean everybody isn't out to get you.

BigStef
HI ryan, you are full of good ideas :), but... Should I not write :
'&nbsp:'
instead of
' :'

Ryan
Yes, the forum converted the non-breaking space to an actual space when it displayed the post.

See this - https://gist.github.com/ryandemmer/18714ea584a7f63b527503038823fa30

Ryan Demmer

Lead Developer / CEO / CTO

Just because you're not paranoid doesn't mean everybody isn't out to get you.

BigStef
Great Ryan, works like a charm!
Thanks you so much for your tip!

lesyeux
Bonjour,

Je vais me permettre de répondre en français, mais traduire aussi en anglais.

Mon astuce, pour les espaces insécables (par exemple avant ou après les signes de ponctuation, mais aussi dans de nombreuses autres situations) consiste à utiliser un correcteur de langue française capable de mettre des espaces insécables partout où cela est réquis en fonction des règles typographiques de la langue française. Ensuite, je fais un copier-coller depuis mon éditeur de texte (Word, TextEdit…) dans l'éditeur JCE. Et là, je conserve tous mes espaces insécables (automatiquement remplacés par le code html correspondant).

On peut aussi utiliser la fonction de rechercher-remplacer de JCE, en mode code.

+++

Hello,

I will take the liberty of answering in French, but will also translate into English.

My trick, for unbreakable spaces (for example before or after punctuation marks, but also in many other situations) is to use a French language proofreader capable of putting unbreakable spaces wherever required according to the typographical rules of the French language. Then, I make a copy-paste from my text editor (Word, TextEdit...) in the JCE editor. And there, I keep all my unbreakable spaces (automatically replaced by the corresponding html code).

You can also use the search-replace function of JCE, in code mode.