Copy link to clipboard
Copied
Buenas a todos.
He estado investigando por mi cuenta pero no he encontrado una solución definitiva.
Éste es un ejemplo del texto con el que estoy trabajando:
" Moraira, ne se développa pas avant que les pirates le lui permirent au milieu du XIXe siècle. Le passage des corsaires nous y est prouvé par la tour de vigie du cap d’Oro, construite au XVIe siècle.
« Charles III, roi des Espagnes, le fit le construire ».
comme la tour San José qui fut une prison au XIVe siècle, le cimetière ou le phare qui s’élève à côté de la pointe Falcó. "
Tengo que cambiar el formato de los siglos: pasar los números romanos a minúsculas (lowercase) y a small caps y, a la vez, pasar la e minúscula que los sigue a superíndice.
Todo ésto sin alterar el Charles III, que debe quedar en mayúsculas tal y como está.
Mediante Buscar/cambiar con GREP he conseguido encontrar los diferentes siglos (XIXe, XVIe, etc) con el siguiente comando: (\u\u+)(e). Pero no sé cómo indicarle los cambios que necesito.
Por otro lado he encontrado este script: http://www.in-tools.com/indesign/scripts/freeware/CapsToSmallCaps.zip que funciona pero a medias, ya que también me cambia el III de Charles III.
¿Alguien me puede echar un cable?¿O a lo mejor hay un sistema más eficiente para hacer este cambio?
Muchas gracias
Ah well...
I did find the time ^^ (to be tested in real life)
Script also manage the possibility of "Ier siècle".
I kept Harb's feature to run script on parentStory's selection, or over the whole doc if nothing is selected.
...// Remplacer les siècles en majuscule par des petites caps et mettre le "e" en exposant.
// by Vinny, Based on "CapstoSmallCaps" script by Harbs.
(function() {
if (app.documents.length == 0) {
return
}
var doc = app.documents[0];
// Nom des styles de caractères
Copy link to clipboard
Copied
Hi there!
It's nice to see that some people keep formatting centuries in a proper way in French language ^^
Here's a suggestion:
Modify Harb's script this way:
instead of looking for \u\u+, look for a string containing I, V or X, followed by a "e". Add some words boundaries in order to avoid changing words like "Vecteur" for instance.
Change line 15 to:
app.findGrepPreferences.findWhat="\\<[IVX]+(?=e\\>)";
That should fix the capitalization issue.
About the superscript part, it also could be scripted.
I don't have enough time to script it right now, maybe later.
But you still can use the Find/Replace Grep panel after having run the script:
Find \<[ivx]+\Ke\>
Replace by your superscript characters style.
Thanks for this interesting question!
Hope that helps
Vinny
Copy link to clipboard
Copied
"La vie n'est jamais aussi simple! …"
Best,
Michel, from FRIdNGE
Copy link to clipboard
Copied
Bien vu! Et très joliment amené
To the OP:
OK my mistake, Grep Find replace \<[IVX]+\Ke\> before running the script.
As Michel pointed it out, we don't want a vie like this ^^
Copy link to clipboard
Copied
Ah well...
I did find the time ^^ (to be tested in real life)
Script also manage the possibility of "Ier siècle".
I kept Harb's feature to run script on parentStory's selection, or over the whole doc if nothing is selected.
// Remplacer les siècles en majuscule par des petites caps et mettre le "e" en exposant.
// by Vinny, Based on "CapstoSmallCaps" script by Harbs.
(function() {
if (app.documents.length == 0) {
return
}
var doc = app.documents[0];
// Nom des styles de caractères
var SmallCaps_charstyle_name = 'Petites Capitales';
var Superscript_charstyle_name = 'Exposant';
//Crée le style de caractère Petites Capitales si n'existe pas déjà
var SmallCapsCS = doc.characterStyles.itemByName(SmallCaps_charstyle_name);
if (!SmallCapsCS.isValid) {
var SmallCapsCS = doc.characterStyles.add();
SmallCapsCS.name = SmallCaps_charstyle_name;
SmallCapsCS.capitalization = Capitalization.smallCaps;
}
//Crée le style de caractère Exposant si n'existe pas déjà
var SuperscriptCS = doc.characterStyles.itemByName(Superscript_charstyle_name);
if (!SuperscriptCS.isValid) {
var SuperscriptCS = doc.characterStyles.add();
SuperscriptCS.name = Superscript_charstyle_name;
SuperscriptCS.position = Position.SUPERSCRIPT;
}
try {
var range = app.selection[0].parentStory
} catch (err) {
var range = doc
}
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = "\\<[IVX]+\\Ker?\\>";
var finds = range.findGrep();
for (var i = 0; i < finds.length; i++) {
finds.appliedCharacterStyle = SuperscriptCS;
}
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = "\\<[IVX]+(?=er?\\>)";
var finds = range.findGrep();
for (var i = 0; i < finds.length; i++) {
finds.changecase(ChangecaseMode.lowercase);
finds.appliedCharacterStyle = SmallCapsCS;
}
app.findGrepPreferences = app.changeGrepPreferences = null;
})
();
Copy link to clipboard
Copied
Thanks a lot vinny38!
Your script looks great but I have some issues... There's a Javascript error. So I've modified a little bit the script:
// Remplacer les siècles en majuscule par des petites caps et mettre le "e" en exposant. | |
// by Vinny, Based on "CapstoSmallCaps" script by Harbs. | |
(function() { | |
if (app.documents.length == 0) { | |
return | |
} | |
var doc = app.documents[0]; | |
// Nom des styles de caractères | |
var SmallCaps_charstyle_name = 'Petites Capitales'; | |
var Superscript_charstyle_name = 'Exposant'; | |
//Crée le style de caractère Petites Capitales si n'existe pas déjà | |
//var SmallCapsCS = doc.characterStyles.itemByName(SmallCaps_charstyle_name); | |
//if (!SmallCapsCS.isValid) { | |
// var SmallCapsCS = doc.characterStyles.add(); | |
//SmallCapsCS.name = SmallCaps_charstyle_name; | |
//SmallCapsCS.capitalization = Capitalization.smallCaps; | |
//} | |
//Crée le style de caractère Exposant si n'existe pas déjà | |
//var SuperscriptCS = doc.characterStyles.itemByName(Superscript_charstyle_name); | |
//if (!SuperscriptCS.isValid) { | |
//var SuperscriptCS = doc.characterStyles.add(); | |
//SuperscriptCS.name = Superscript_charstyle_name; | |
//SuperscriptCS.position = Position.SUPERSCRIPT; | |
//} | |
try { | |
var range = app.selection[0].parentStory | |
} catch (err) { | |
var range = doc | |
} | |
app.findGrepPreferences = app.changeGrepPreferences = null; | |
app.findGrepPreferences.findWhat = "\\<[IVX]+\\Ker?\\>"; | |
var finds = range.findGrep(); | |
for (var i = 0; i < finds.length; i++) { | |
finds.position=Position.SUPERSCRIPT; | |
} | |
app.findGrepPreferences = app.changeGrepPreferences = null; | |
app.findGrepPreferences.findWhat = "\\<[IVX]+(?=er?\\>)"; | |
var finds = range.findGrep(); | |
for (var i = 0; i < finds.length; i++) { | |
finds.changecase(ChangecaseMode.lowercase); | |
finds.capitalization=Capitalization.smallCaps); | |
} |
app.findGrepPreferences = app.changeGrepPreferences = null; | |
}) | |
(); |
I commented out lines who creates the character styles and I changed line 55 to this: finds.capitalization=Capitalization.smallCaps);
This changes works for me, but there's still an issue. "\\<[IVX]+\\Ker?\\>"; this Grep cannot find match
Copy link to clipboard
Copied
Another solution I found is this:
//DESCRIPTION: Finds all caps, converts to lowercase, and applies small caps. Works either on selected story, or whole doc.
// CS3 script by Harbs
(function()
{
if(app.documents.length==0){return}
var doc=app.documents[0];
// Change the following to your style name!
var character_style_name = 'segles';
try{var range = app.selection[0].parentStory}
catch (err){var range = doc}
//comment out next line if you do not want styles.
//var charStyle = GetCharacterStyle(character_style_name,doc);
app.findGrepPreferences = null;
app.findGrepPreferences.findWhat="(\\u\\u+)(e)";
var finds=range.findGrep();
for (var i=0;i<finds.length;i++){
finds.changecase(ChangecaseMode.lowercase);
//comment out next line if you do not want styles.
//finds.applyCharacterStyle (charStyle)
//uncomment next line if you do not want styles.
finds.capitalization=Capitalization.smallCaps;
}
//finds.position=Position.SUPERSCRIPT;
function GetCharacterStyle(styleName,doc){
var charStyles=doc.allCharacterStyles;
for(var i=0;i<charStyles.length;i++){
if(charStyles.name==styleName){
return charStyles;
}
}
return doc.characterStyles.add({name:styleName,capitalization:Capitalization.smallCaps});
}
}
)();
So this brings me something like XVIE (small caps mode)
Then, using Find/Change in Text, find 'e' +small caps and change it to -caps + superscript
Copy link to clipboard
Copied
Hi there!
About Javascript error, not having any detail would not allow me to understand and fix. (Works here...)
So, I understand you got rid of the character styles, maybe not the best workflow, but that's your call.
Now, I have been re-thinking about your request, because, as I said, I think it's an interesting puzzle (and I might use it for future projects, who knows).
I came up with a couple of thoughts I'd like to share:
Grep queries are great but have an obvious huge limitation: in order to automate a process using GREP, you need unique patterns for unique matches.
Grep is magic, but if the magical formula is not perfect, unexpected results will occur.
"Abracadabra! Change frogs into princes... " might also transform frenchies into Minneapolis kids
Now, I can think of many situations where you just can't make any difference between century numbering and some other kind of numbering. Here' a non-exhaustive list:
Régimes politiques
Manifestations culturelles, sportives, religieuses, etc.
Divisions d'une oeuvre artistique ou littéraire :
Cas particulier : "Ier"
Grep could help to clean up identified cases \<[ivx]+(?=e\\s((?i)millénaire|reich|république|dynastie|empire|concile|jeux|olympiades|biennale|internationale|festival|[eé]dition|etc.)) but I doubt we can really list them all.
So I'm afraid that at the end of the day, manual checking will still be necessary, using GREP F/R...
Bon courage ^^
Vinny
Copy link to clipboard
Copied
God save the community!
First of all, sorry for my poor english...
I was working with Indesign CS3 and there was that javascript error. Now I'm testing your script (not modified) in Indesign CC and it works properly. Thank you so much.
That's an interesting reflexion. But I think that they are the same kind of numbering, so you can use small caps too. The particular case ( Ier) is a different situation... but at least you can use Find/Change to locate these few cases.
Copy link to clipboard
Copied
Your English is just fine!! ^^
I am pretty sure that roman small caps only apply to centuries numbering.
So I rechecked my French official typographic reference guides and I can confirm that.
Even if reading a century number written in big caps would slightly hurt my eye, reading xxe dynastie or ve République in small caps would really make my eye bleed...
For the sake of completeness, we also can add military regions or (sometimes) units to big caps list:
"Lille est le siège de la IIe région militaire"
Also, please note that if you have a century in an All-Caps paragraph, it also should be written in big caps.
Finally, I should correct my previous mistakes:
Les XXe Jeux olympiques should have read les XXes Jeux olympiques (so, no more problem here)
And, even if we should write chapitre IV, we should write quatrième chapitre instead of IVe chapitre.
That said, typographic "rules" are just "conventions" and you'll hardly meet two typographic experts who would agree on all the rules...
^^
Copy link to clipboard
Copied
XDDD there are many things that make eyes bleeding!
I'm not a typographic expert so you're probably right. I'm only a self-taught "worker".
At least I have solved my problem!