RedMadRobot / figma-export

Command line utility to export colors, typography, icons and images from Figma to Xcode / Android Studio project
MIT License
719 stars 115 forks source link

nameReplaceRegexp is not working #99

Closed danielloureda closed 3 years ago

danielloureda commented 3 years ago

Hello!

I am trying to configure my own figma-export.yml but I am having issues with nameReplaceRegexp. I tried even with the examples you give in config.md but I cannot make it work... I may be doing something wrong or maybe I simply do not understand what is this param used for... but could you tell me if these params are ok? Basically, all I want is to append "ic_" to the beginning of the icon name.

icons: output: "icons" format: svg nameValidateRegexp: '^[a-z A-Z0-9_]+$' nameReplaceRegexp: 'ic_$1'

Thank you very much!

subdan commented 3 years ago

Hello.

$1 — means the first capture group but you don’t have a capture group in the nameValidateRegexp. Add round braces to nameValidateRegexp to add a capture group.

nameValidateRegexp: ^([a-z A-Z0-9_]+)$
danielloureda commented 3 years ago

Good morning,

I had tried that before writing the comment but it is still not working... I have these colors: content_bubbles, content_inverse_primary, content_negative, etc. With this yml it should get the whole name as first group and export color_content_bubbles, color_content_inverse_primary, color_content_negative and so on, right?

colors:
    # [optional] RegExp pattern for color name validation before exporting
    nameValidateRegexp: '^([a-z A-Z0-9_]+)$' # RegExp pattern for: background, background_primary, widget_primary_background
    # [optional] RegExp pattern for replacing. Supports only $n
    nameReplaceRegexp: 'color_$1'
danielloureda commented 3 years ago

Oh... forget it, I was setting these values in Android side, not in common...

Thank you very much anyway.