Using GREP to format numbers which are succeeded by specific characters - adobe-indesign

Hi dear stackoverflow community,
I have a small GREP question and would need your help.
In my catalog, there are some ordering numbers which need specific formatting.
As you can see, the numbers are always bold and they also are colored when they are preceded by a "to ".
However, I want the two numbers before the " to" to be colored also.
I was not able to find out how this is done.
This is how they SHOULD look like using GREP. Basically the "00" is also colored.
Right now, my GREP code looks like this.
(?<=\d\d)-\d\d(?=\sto)
On the right you can see that right now, the "00" in front of the "to" is not colored.
Does someone know why this is not working? :)

Apply the following three Grep patterns to the Paragraph Style:
(?<=[A-Z]{2}-)\d{4}-\d{2} - Apply Character Style: Bold (example).
(?<=[A-Z]{2}-\d{4}-)(\d{2})(?= to -??\d{2}) - Apply Character Style: Bold-Color (example).
(?<=[A-Z]{2}-\d{4}-\d{2} to )-??\d{2} - Apply Character Style: Bold-Color (example).
Note: The two different Character Styles used, namely Bold, and Bold-Color
Paragraph Style Options > GREP Style:
Result:

Related

Escape character for labels in Bolt CMS

When I create a field with a label in the YAML, the label is not valid when I try to add an % for example. The following code is my current try.
content_image:
fields:
image:
type: image
label: "Afbeelding 100%"
As a guess I tried to do use \% as an escape character, but that does not solve it. Reading the documentation I cannot seem to find this information, and it keeps wondering if it is possible at all.
So my question: Is there an escape character in Bolt CMS to add to labels?
For this use case I fixed it by doing:
label: "Afbeelding 100% "
As you can see, I added a space (or any other character) after the % because otherwise the system would not allow it. A label can't end with a % for some reason, and when you place a space after a % there is no need for an escape character.

Using emoji's by typing colon generates smileys too early

When using Teams, I want to add emojis by using colons, ex. typing ":smile..."
However, Teams is too quick to add a smiley, thinking that ":s" what I want (which is not), i.e. I end up with not being able to get/use the emoji I want... See picture (I don't want the smiley which appear in the red square)
enter image description here
Use parenthesis instead of colon e.g.
(nod)
(smile)

Is it possible to separate STDOUT context by its colour?

I'm using the output of the excellent package icdiff (https://github.com/jeffkaufman/icdiff) to check for differences between updated iterations of files. I'd like to parse out just the significant differences though. From the package --help I can't see any in-built options (and for full disclosure I've 'cross posted' at the github issues page to see if it can be added or I've missed something).
This has got me wondering whether a hacky solution might be to parse out the lines by their colour, since they are also colour coded by 'severity of difference'. Is this at all possible in bash? (Alternative approaches are welcome too!)
Here's a sample of the output (I can only think to add a picture here since the markup wouldnt show colour). I'd like to get just the lines where the whole line is solid red/green for instance. Excuse some of the screen wrapping, my monitor isn't wide enough and the text is small enough already.
with GNU Grep, for example
grep -Po $'\e\[31m\K.*(?=\e\[\d+m)'
to extract text in red,
\K to keep the left outside match, like a lookbehind
(?=..) lookahead assertion 0 length match
you can grep on the ANSI escape sequences, e.g. (with 31 for red):
grep '^[\[31m' # make the escape character (^[) by typing ctrl+v ESC
but you need to make sure your output stays colored if it is not sent to a terminal : (many programs will make their output B&W when output is not a terminal. - you can check it with less, which will show you the escape sequences)

Use GREP for italic Old Style Figures in InDesign

When typsetting books, I often use GREP to locate all digits in a book and convert them to a character style for old stye figures.
But I also need to find italic digits already given an italic character style, and convert them to an italic old style figures character style.
Can GREP be used to find one character style and change it to another in an instance like this?
You should be able to add formatting options to your find criteria, but these are specified in the lower portion of the find dialog, not in GREP.

How can I use variables to DRY up Vim colorthemes

I would like to tidy up my Vim color scheme file, by replacing #ABCDEF colors
with variables. For example, I would like to replace this:
highlight String guifg=#61CE3C
highlight Identifier guifg=#61CE3C
highlight Type guifg=#84A7C1
with something like this (pseudo-code vimscript):
my_string =#61CE3C
my_type =#84A7C1
highlight String guifg=my_string
highlight Identifier guifg=my_string
highlight Type guifg=my_type
I wasn't sure whether vimscript considers the hex color to be a string, or a
hexadecimal number. Apparently it's a string, cause this seems to work:
:highlight Normal guifg='#ffffff'
So I thought I'd try this:
:let my_color='#ffffff'
:highlight Normal guifg=my_color
But this gives the error "E254: Cannot allocate color my_color". Can anyone
suggest a way to make this work?
Since :highlight doesn't accept a variable as an argument, you have to build the command to run as an expression and then evaluate it with the :execute command.
:let my_color='#ffffff'
:exe 'highlight Normal guifg=' . my_color
As jamessan has said, you need to use :exe to do this. I found the general syntax for the colour scheme files a bit difficult to manage, so I made my own, which you may be interested in. I find it a lot more maintainable, but you may still find it a bit too verbose, in which case see the alternative at the end of this answer.
Rather than writing the long :hi lines, you create a dictionary along the lines of:
" Unspecified colours default to NONE, EXCEPT cterm(.*) which default to matching gui(.*)
" ctermfg will default to 'Blue' and ctermbg to 'NONE' if gui(.*) are RGB
"
" In most cases, only GUIFG is therefore important unless support for Black and White
" terminals is essential
let ColourAssignment['Normal'] = {"GUIFG": 'White', "GUIBG": 'Black'}
let ColourAssignment['Comment'] = {"GUIFG": '#00ff00'}
As mentioned in the comment, all unspecified parts assume sensible defaults, so you don't have to do the common:
:hi Comment guifg=green ctermfg=green guibg=black ctermfg=black
repetition. You can also (of course) put variables in place of the '#00ff00' bit if you want.
It's currently designed around dark background colour schemes: for light background colour schemes, it automatically chooses an appropriate colour (it makes bright colours darker basically) unless you override it, but if you prefer light background colour schemes, it wouldn't be too hard to change so that the default is light.
The other advantage of it is that it comes with a syntax highlighting file that automatically highlights the "ColourAssignment" bit in the colour that you've selected.
Anyway, if that's any interest to you, you can get it from here.
An alternative you could use would be to create a command like this:
command! -nargs=+ Hi call CustomHighlighter(<f-args>)
function! CustomHighlighter(name, ...)
let colour_order = ['guifg', 'guibg']
let command = 'hi ' . a:name
if (len(a:000) < 1) || (len(a:000) > (len(colour_order)))
echoerr "No colour or too many colours specified"
else
for i in range(0,len(a:000)-1)
let command .= ' ' . colour_order[i] . '=' . a:000[i]
endfor
exe command
endif
endfunc
You could then use:
Hi Comment #00ff00
Hi String Yellow
Hi Normal White Black

Resources