I use Mathjax on my static (jekyll-generated) site : Mathjax is loaded but curly brackets don't show up.
$ \{ 2*3 \} $ -> 2*3
$ \left{ 2*3 \right} -> \left{ 2*3 \right} (math style)
I'd like to have (for instance) a simple {2*3}
Cheers
OK found out :
You have to escape the backslash because there seems to be 2 levels of interpretation : jekyll then mathjax. So you need to escape the backslash from Jekyll so it renders for Mathjax to escape the bracket :
$ \\{ 2*3 \\} $ -> {2*3}
Related
I have some difficulties with the sed command on Unix AIX IBM). It's seems also on linux...
here is a line of my file, that i would change :
# id=<$IdEDFRGB.RR '" fgg t uj67575 uj:$ g re ee >
it should be after the subsitution :
# id=<$Id22 02 21 17:13$ g re ee >f rgrge
when i use this sed command (after initialize the DT variable) :
sed "s/<\$Id.*\$/<\$Id${DT}\$/g"
I obtain :
# id=<$Id22 02 2021 17:41$
I loose the right part.
Someone could help me ?
thx
You need to escape the backslashes in the regexp so they're treated as literal backslash by the shell's string parser, and then they will escape the $ in the regexp. You also need to escape the $ in the regexp so that they don't start a variable expansion.
sed "s/<\\\$Id.*\\\$/<\$Id${DT}\$/g"
If you use echo ".*\$", you will see .*$, the pattern matches any text up to the string end, that's why your "right side" is eaten up. $ in a double quoted string is used to expand variables and in order to use a literal $, you need to use a "\$" char combination. In order to introduce a \$ literal text into a double quoted string, you need "\\$".
Use single quotes to avoid these issues, only use double quotes around the variable:
sed 's/\(<\$Id\).*\(\$\)/\1'"$DT"'\2/' file
Here, \(<\$Id\) is a capturing group 1 (\1) that captures <$Id literal text and \(\$\) is a capturing group 2 (\2) that captures a $ char. The $DT is within double quotes and is expanded correctly.
Using capturing groups, you avoid having to double the literal text both inside the pattern and the replacement.
I have a string like FIRSTNAME\nLASTNAME in a file. I want to put the first name and last name in their own variables. I have to use /bin/sh, not bash.
How can I easily do this?
You can use parameter expansion operators to strip everything following the \n as well as everything preceding it.
$ s="Stealth\nRabbi"
$ first=${s%\\n*}
$ last=${s#*\\n}
$ echo "$first"
Stealth
$ echo "$last"
Rabbi
Note that there are no literal newlines involved; you have two characters, \ and n.
I'm using the R terminal (Rterm). In R I often have to type "/" instead of "\" for paths. The problem is, that "/" on the num block doesn't work in the R terminal.
The regular "/" on the keyboard can only by typed with Shift (on a German keyboard).
Why can't I use num block in R terminal? Is there a way to activate num block "/" in R terminal?
I am using rscript to run some expressions but I'm having an issue with some cases with dashes. A simple example would be:
$ rscript -e '-1'
ERROR: option '-e' requires a non-empty argument
Adding parenthesis works out (rscript -e (-1)) but I'm not always sure that they will be properly parenthesized.
In the documentation it says
When using -e options be aware of the quoting rules in the shell used
So I tried using different quoting rules for bash, escaping the dashes or using single quotes but it still doesn't work.
$ rscript -e "\-1"
Error: unexpected input in "\"
Execution halted
Is there something I'm missing?
You misunderstand one part here. "Expression" is something R can parse, ie:
$ R --slave -e '1+1'
[1] 2
$
What you hit with -1 is a corner case. You can do
$ R --slave -e 'a <- -1; a'
[1] -1
$
or
$ R --slave -e 'print(-1)'
[1] -1
$
For actual argument parsing do you want an package like docopt (which I like and use a lot), or getopt (which I used before) or optparse. All are on CRAN.
Basically, I'm wondering if its possible to do this:
#compdef foo
_arguments \
'--arg=[Description of --arg [With square brackets in the string!]]' \
without getting an invalid option error due to the nested square brackets?
I've tried all manner of escape characters. Single vs. double quotes makes no difference.
Try to escaping them like this:
'--arg=\\[Description of --arg \\[With square brackets in the string!\\]\\]'