Skip to main content
oleguerf30653514
Participant
March 29, 2018
Answered

Indesign Buscar/cambiar mayúsculas a small caps y superíndice

  • March 29, 2018
  • 1 reply
  • 1790 views

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

This topic has been closed for replies.
Correct answer vinny38

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;

})

();

1 reply

vinny38
Legend
March 29, 2018

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

FRIdNGE
March 29, 2018

"La vie n'est jamais aussi simple! …"

Best,

Michel, from FRIdNGE

vinny38
Legend
March 29, 2018

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 ^^