- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一些脚本,其中包含单行脚本或来自其他语言的排序脚本。如何让 LaTeX 列表检测到这一点并更改脚本中的语法格式语言?我相信这对于 bash 中的 awk 尤其有用。
重击
#!/bin/bash
echo "hello world"
R --vanilla << EOF
# Data on motor octane ratings for various gasoline blends
x <- c(88.5,87.7,83.4,86.7,87.5,91.5,88.6,100.3,
95.6,93.3,94.7,91.1,91.0,94.2,87.5,89.9,
88.3,87.6,84.3,86.7,88.2,90.8,88.3,98.8,
94.2,92.7,93.2,91.0,90.3,93.4,88.5,90.1,
89.2,88.3,85.3,87.9,88.6,90.9,89.0,96.1,
93.3,91.8,92.3,90.4,90.1,93.0,88.7,89.9,
89.8,89.6,87.4,88.9,91.2,89.3,94.4,92.7,
91.8,91.6,90.4,91.1,92.6,89.8,90.6,91.1,
90.4,89.3,89.7,90.3,91.6,90.5,93.7,92.7,
92.2,92.2,91.2,91.0,92.2,90.0,90.7)
x
length(x)
mean(x);var(x)
stem(x)
EOF
perl -n -e '
@t = split(/\t/);
%t2 = map { $_ => 1 } split(/,/,$t[1]);
$t[1] = join(",",keys %t2);
print join("\t",@t); ' knownGeneFromUCSC.txt
awk -F'\t' '{
n = split($2, t, ","); _2 = x
split(x, _) # use delete _ if supported
for (i = 0; ++i <= n;)
_[t[i]]++ || _2 = _2 ? _2 "," t[i] : t[i]
$2 = _2
}-3' OFS='\t' infile
#!/usr/local/bin/python
print "Hello World"
os.system("""
VAR=even;
sed -i "s/$VAR/odd/" testfile;
for i in `cat testfile` ;
do echo $i; done;
echo "now the tr command is removing the vowels";
cat testfile |tr 'aeiou' ' '
""")
% This gives syntax highlighting in the python environment
\renewcommand{\lstlistlistingname}{Code Listings}
\renewcommand{\lstlistingname}{Code Listing}
\definecolor{gray}{gray}{0.5}
\definecolor{key}{rgb}{0,0.5,0}
\lstloadlanguages{Fortran,C++,C,[LaTeX]TeX,Python,bash,R, Perl}
\lstnewenvironment{python}[1][]{
\lstset{
language=python,
basicstyle=\ttfamily\small,
otherkeywords={1, 2, 3, 4, 5, 6, 7, 8 ,9 , 0, -, =, +, [, ], (, ), \{, \}, :, *, !},
keywordstyle=\color{blue},
stringstyle=\color{red},
showstringspaces=false,
emph={class, pass, in, for, while, if, is, elif, else, not, and, or,
def, print, exec, break, continue, return},
emphstyle=\color{black}\bfseries,
emph={[2]True, False, None, self},
emphstyle=[2]\color{key},
emph={[3]from, import, as},
emphstyle=[3]\color{blue},
upquote=true,
morecomment=[s]{"""}{"""},
commentstyle=\color{gray}\slshape,
rulesepcolor=\color{blue},#1
}
}{}
\lstnewenvironment{bash}{%
\lstset{%
language=bash,
otherkeywords={=, +, [, ], (, ), \{, \}, *},
% bash commands from:
%http://www.math.montana.edu/Rweb/Rhelp/00Index.html
emph={addgroup,adduser,alias,
ant,
apropos,apt-get,aptitude,aspell,awk,
basename,bash,bc,bg,break,builtin,bzip2,cal,case,cat,cd,cfdisk,chgrp,
chkconfig,chmod,chown,chroot,cksum,clear,cmp,comm,command,continue,
cp,cron,crontab,csplit,cut,date,dc,dd,ddrescue,declare,df,diff,diff3,
dig,dir,dircolors,dirname,dirs,dmesg,du,echo,egrep,eject,enable,env,
ethtool,eval,exec,exit,expand,expect,export,expr,false,fdformat,
fdisk,fg,fgrep,file,find,fmt,fold,for,format,free,fsck,ftp,function,
fuser,gawk,getopts,
git,
grep,groups,gzip,
gunzip,
,hash,head,help,history,hostname,
id,if,ifconfig,ifdown,ifup,import,install,
java, java6, java_cur
join,kill,killall,less,
let,ln,local,locate,logname,logout,look,lpc,lpr,lprint,lprintd,
lprintq,lprm,ls,lsof,make,man,mkdir,mkfifo,mkisofs,mknod,mmv,more,
mount,mtools,mtr,mv,
mysql,
netstat,nice,nl,nohup,notify-send,
noweb,noweave,
nslookup,op,
open,passwd,paste,pathchk,ping,pkill,popd,pr,printcap,printenv,
printf,ps,pushd,pwd,quota,quotacheck,quotactl,ram,rcp,read,
readarray,readonly,reboot,remsync,rename,renice,return,rev,rm,rmdir,
rsync,scp,screen,sdiff,sed,select,seq,set,sftp,shift,shopt,shutdown,
sleep,slocate,sort,source,split,ssh,strace,su,sudo,sum,
svn, svn2git,
symlink,sync,
tail,tar,tee,test,time,times,top,touch,tr,traceroute,trap,true,
tsort,tty,type,ulimit,umask,umount,unalias,uname,unexpand,uniq,
units,
unrar,
unset,unshar,until,useradd,usermod,users,uudecode,uuencode,
vdir,vi,vmstat,watch,wc,Wget,whereis,which,while,who,whoami,write,
zcat},
breaklines=true,
keywordstyle=\color{blue},
stringstyle=\color{red},
emphstyle=\color{black}\bfseries,
commentstyle=\color{gray}\slshape,
}
}{}
\lstnewenvironment{latexCode}[1]{\lstset{language=[latex]tex} \lstset{#1}}{}
\lstnewenvironment{Rcode}{
\lstset{%
language={R},
basicstyle=\small, % print whole listing small
keywordstyle=\color{black}, % style for keyword
% Function list from:
% http://www.math.montana.edu/Rweb/Rhelp/00Index.html
emph={abbreviate, abline,
abs, acos, acosh, all, all.names,
all.vars, anova, anova.glm, anova.lm, any,
aperm, append, apply, approx, approxfun,
apropos, Arg, args, Arithmetic, array,
arrows, as.array, as.call, as.character, as.complex,
as.data.frame, as.double, as.expression, as.factor, asin,
asinh, as.integer, as.list, as.logical, as.matrix,
as.na, as.name, as.null, as.numeric, as.ordered,
as.qr, as.real, assign, as.ts, as.vector,
atan, atan2, atanh, attach, attr,
attributes, autoload, .AutoloadEnv, axis, backsolve,
barplot, beta, binomial, box, boxplot,
boxplot.stats, break, browser, bw.bcv, bw.sj,
bw.ucv, bxp, c, .C, call,
cat, cbind, ceiling, character, charmatch,
chisq.test, chol, chol2inv, choose, class,
class<-, codes, coef, coefficients, coefficients.glm,
coefficients.lm, co.intervals, col, colnames, colors,
colours, Comparison, complete.cases, complex, Conj,
contour, contrasts, contr.helmert, contr.poly, contr.sum,
contr.treatment, convolve, cooks.distance, coplot, cor,
cos, cosh, count.fields, cov, covratio,
crossprod, cummax, cummin, cumprod, cumsum,
curve, cut, D, data, data.class,
data.entry, dataentry, data.frame, data.matrix, dbeta,
dbinom, dcauchy, dchisq, de, debug,
delay, demo, de.ncols, density, deparse,
de.restore, deriv, deriv.default, deriv.formula, de.setup,
detach, deviance, deviance.glm, deviance.lm, device,
Devices, dev.off, dexp, df, dfbetas,
dffits, df.residual, df.residual.glm, df.residual.lm, dgamma,
dgeom, dget, dhyper, diag, diff,
digamma, dim, dim<-, dimnames, dimnames<-,
dlnorm, dlogis, dnbinom, dnchisq, dnorm,
do.call, dotplot, double, dpois, dput,
drop, dt, dump, dunif, duplicated,
dweibull, dyn.load, edit, effects.glm, effects.lm,
eigen, else, emacs, end, environment,
environment<-, eval, exists, exp, expression,
Extract, factor, family, family.glm, fft,
finite, fitted, fitted.values, fitted.values.glm, fitted.values.lm,
fivenum, fix, floor, for, formals,
format, formatC, format.default, formula.default, formula.formula,
formula.terms, .Fortran, frame, frequency, function,
Gamma, gamma, gaussian, gc, gcinfo,
get, getenv, gl, glm, glm.control,
glm.fit, .GlobalEnv, graphics.off, gray, grep,
grid, gsub, hat, heat.colors, help,
hist, hsv, identify, if, ifelse,
Im, image, \%in\%, influence.measures, inherits,
integer, interactive, .Internal, inverse.gaussian, invisible,
invisible, IQR, is.array, is.atomic, is.call,
is.character, is.complex, is.data.frame, is.double, is.environment,
is.expression, is.factor, is.function, is.integer, is.language,
is.list, is.loaded, is.logical, is.matrix, is.na,
is.name, is.null, is.numeric, is.ordered, is.qr,
is.real, is.recursive, is.single, is.ts, is.unordered,
is.vector, lapply, lbeta, lchoose, legend,
length, LETTERS, letters, levels, levels<-,
lgamma, .lib.loc, .Library, library, library.dynam,
license, lines, lines.default, list, lm,
lm.fit, lm.influence, lm.wfit, load, locator,
log, log10, log2, Logic, logical,
lower.tri, lowess, ls, ls.diag, lsfit,
lsf.str, ls.print, ls.str, .Machine, Machine,
machine, macintosh, mad, match, match.arg,
match.call, matlines, mat.or.vec, matplot, matpoints,
matrix, max, mean, median, menu,
methods, min, missing, Mod, mode,
mode<-, model.frame, model.frame.default, model.matrix, model.matrix.default,
month.abb, month.name, mtext, mvfft, NA,
na.action, na.action.default, na.fail, names, na.omit,
nargs, nchar, NCOL, ncol, next,
NextMethod, nextn, nlevels, nlm, [.noquote,
noquote, NROW, nrow, NULL, numeric,
objects, on.exit, optimize, options, order,
ordered, outer, pairs, palette, par,
parse, paste, pbeta, pbinom, pcauchy,
pchisq, pentagamma, pexp, pf, pgamma,
pgeom, phyper, pi, pictex, piechart,
plnorm, plogis, plot, plot.default, plot.density,
plot.ts, plot.xy, pmatch, pmax, pmin,
pnbinom, pnchisq, pnorm, points, points.default,
poisson, polygon, polyroot, postscript, ppoints,
ppois, pretty, print, print.anova.glm, print.anova.lm,
print.data.frame, print.default, print.density, print.formula, print.glm,
print.lm, print.noquote, print.plot, print.summary.glm, print.summary.lm,
print.terms, print.ts, proc.time, prod, prompt,
prompt.default, prop.test, provide, .Provided, ps.options,
pt, punif, pweibull, q, qbeta,
qbinom, qcauchy, qchisq, qexp, qf,
qgamma, qgeom, qhyper, qlnorm, qlogis,
qnbinom, qnchisq, qnorm, qpois, qqline,
qqnorm, qqplot, qr, qr.coef, qr.fitted,
qr.Q, qr.qty, qr.qy, qr.R, qr.resid,
qr.solve, qr.X, qt, quantile, quasi,
quit, qunif, quote, qweibull, rainbow,
.Random.seed, range, rank, rbeta, rbind,
rbinom, rcauchy, rchisq, Re, readline,
read.table, real, rect, remove, rep,
repeat, replace, require, resid, residuals,
residuals.glm, residuals.lm, return, rev, rexp,
rf, rgamma, rgb, rgeom, rhyper,
RLIBS, rlnorm, rlogis, rm, rnbinom,
rnchisq, rnorm, round, row, row.names,
rownames, rpois, rstudent, rt, runif,
rweibull, sample, sapply, save, save.plot,
scale, scan, sd, segments, seq,
sequence, sign, signif, sin, sinh,
sink, solve, solve.qr, sort, source,
spline, splinefun, split, sqrt, start,
stem, stop, storage.mode, storage.mode<-, str,
str.data.frame, str.default, strheight, stripplot, strsplit,
structure, strwidth, sub, Subscript, substitute,
substr, substring, sum, summary, summary.glm,
summary.lm, svd, sweep, switch, symbol.C,
symbol.For, symnum, sys.call, sys.calls, sys.frame,
sys.frames, sys.function, sys.nframe, sys.on.exit, sys.parent,
sys.parents, system, system.date, system.time, t,
table, tabulate, tan, tanh, tapply,
tempfile, terms, terms.default, terms.formula, terms.terms,
terrain.colors, tetragamma, text, time, title,
topo.colors, trace, traceback, trigamma, trunc,
ts, tsp, t.test, typeof, unclass,
undebug, unique, uniroot, unlink, unlist,
untrace, update, update.formula, update.glm, update.lm,
upper.tri, UseMethod, var, vector, Version,
version, vi, warning, weighted.mean, weights.lm,
while, window, windows, write, x11,
xedit, xemacs, xinch, xor, xy.coords,
yinch}, % define a list of word to emphasis
stringstyle=\color{red},
emphstyle=\color{black}\bfseries, % define the way to emphase
showspaces=false, % show the space in code, or not
stringstyle=\ttfamily, % style of the string (like "hello word")
showstringspaces=false, % show the space in string, on not #1
commentstyle=\color{gray}\slshape,
tabsize=2, % sets default tabsize to 2 spaces
breaklines=true, % sets automatic line breaking
breakatwhitespace=false, % sets if automatic breaks should only happen at whitespace
}
}{}
\lstnewenvironment{Perl}{
\lstset{%
language={perl},
basicstyle=\small, % print whole listing small
keywordstyle=\color{black}, % style for keyword
emph={% From http://www.sdsc.edu/~moreland/courses/IntroPerl/docs/manual/pod/perlfunc.html
-X, run, abs, absolute, accept, accept, alarm, schedule, atan2,
arctangent, bind, binds, binmode, prepare, bless, create, caller,
get, chdir, change, chmod, changes, chomp, remove, chop, remove,
chown, change, chr, get, chroot, make, close, close, closedir, close,
connect, connect, continue, optional, cos, cosine, crypt, one-way,
dbmclose, breaks, dbmopen, create, defined, test, delete, deletes,
die, raise, do, turn, dump, create, each, retrieve, endgrent, be,
endhostent, be, endnetent, be, endprotoent, be, endpwent, be,
endservent, be, eof, test, eval, catch, exec, abandon, exists, test,
exit, terminate, exp, raise, fcntl, file, fileno, return, flock,
lock, fork, create, format, declare, formline, internal, getc, get,
getgrent, get, getgrgid, get, getgrnam, get, gethostbyaddr, get,
gethostbyname, get, gethostent, get, getlogin, return, getnetbyaddr,
get, getnetbyname, get, getnetent, get, getpeername, find, getpgrp,
get, getppid, get, getpriority, get, getprotobyname, get,
getprotobynumber, get, getprotoent, get, getpwent, get, getpwnam,
get, getpwuid, get, getservbyname, get, getservbyport, get,
getservent, get, getsockname, retrieve, getsockopt, get, glob,
expand, gmtime, convert, goto, create, grep, locate, hex, convert,
import, patch, int, get, ioctl, system-dependent, join, join, keys,
retrieve, kill, send, last, exit, lc, return, lcfirst, return,
length, return, link, create, listen, register, local, create,
localtime, convert, log, retrieve, lstat, stat, m//, match, map,
apply, mkdir, create, msgctl, SysV, msgget, get, msgrcv, receive,
msgsnd, send, my, declare, next, iterate, no, unimport, oct, convert,
open, open, opendir, open, ord, find, pack, convert, package,
declare, pipe, open, pop, remove, pos, find, print, output, printf,
output, prototype, get, push, append, q/STRING/, singly, qq/STRING/,
doubly, quotemeta, quote, qw/STRING/, quote, qx/STRING/, backquote,
rand, retrieve, read, fixed-length, readdir, get, readlink,
determine, recv, receive, redo, start, ref, find, rename, change,
require, load, reset, clear, return, get, reverse, flip, rewinddir,
reset, rindex, right-to-left, rmdir, remove, s///, replace, scalar,
force, seek, reposition, seekdir, reposition, select, reset, semctl,
SysV, semget, get, semop, SysV, send, send, setgrent, prepare,
sethostent, prepare, setnetent, prepare, setpgrp, set, setpriority,
set, setprotoent, prepare, setpwent, prepare, setservent, prepare,
setsockopt, set, shift, remove, shmctl, SysV, shmget, get, shmread,
read, shmwrite, write, shutdown, close, sin, return, sleep, block,
socket, create, socketpair, create, sort, sort, splice, add, split,
split, sprintf, formatted, sqrt, square, srand, seed, stat, get,
study, optimize, sub, declare, substr, get, symlink, create, syscall,
execute, sysread, fixed-length, system, run, syswrite, fixed-length,
tell, get, telldir, get, tie, bind, time, return, times, return,
tr///, transliterate, truncate, shorten, uc, return, ucfirst, return,
umask, set, undef, remove, unlink, remove, unpack, convert, unshift,
prepend, untie, break, use, load, utime, set, values, return, vec,
test, wait, wait, waitpid, wait, wantarray, get, warn, print, write,
print, y///, transliterate}, % define a list of word to emphasis
stringstyle=\color{red},
emphstyle=\color{black}\bfseries, % define the way to emphase
showspaces=false, % show the space in code, or not
stringstyle=\ttfamily, % style of the string (like "hello word")
showstringspaces=false, % show the space in string, on not #1
commentstyle=\color{gray}\slshape,
tabsize=2, % sets default tabsize to 2 spaces
breaklines=true, % sets automatic line breaking
breakatwhitespace=false, % sets if automatic breaks should only happen at whitespace
}
}{}
\lstnewenvironment{plaintext}{
\lstset{
tabsize=2, % sets default tabsize to 2 spaces
breaklines=true, % sets automatic line breaking
breakatwhitespace=false, % sets if automatic breaks should only happen at whitespace
basicstyle=\normalfont\ttfamily,
}
}{}
最佳答案
几乎可以肯定,修改 Bash/Python 荧光笔比编写上下文敏感的荧光笔更容易。我猜只是将关键字添加到其他荧光笔应该会给出可接受的结果。
修改 Pygments 看起来并不难,来自 Pygments 的 Write your own lexer文档。
关于latex - 使用 LaTeX 列表正确检测和语法突出脚本中不同语言的嵌入代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2993630/
我需要将文本放在 中在一个 Div 中,在另一个 Div 中,在另一个 Div 中。所以这是它的样子: #document Change PIN
奇怪的事情发生了。 我有一个基本的 html 代码。 html,头部, body 。(因为我收到了一些反对票,这里是完整的代码) 这是我的CSS: html { backgroun
我正在尝试将 Assets 中的一组图像加载到 UICollectionview 中存在的 ImageView 中,但每当我运行应用程序时它都会显示错误。而且也没有显示图像。 我在ViewDidLoa
我需要根据带参数的 perl 脚本的输出更改一些环境变量。在 tcsh 中,我可以使用别名命令来评估 perl 脚本的输出。 tcsh: alias setsdk 'eval `/localhome/
我使用 Windows 身份验证创建了一个新的 Blazor(服务器端)应用程序,并使用 IIS Express 运行它。它将显示一条消息“Hello Domain\User!”来自右上方的以下 Ra
这是我的方法 void login(Event event);我想知道 Kotlin 中应该如何 最佳答案 在 Kotlin 中通配符运算符是 * 。它指示编译器它是未知的,但一旦知道,就不会有其他类
看下面的代码 for story in book if story.title.length < 140 - var story
我正在尝试用 C 语言学习字符串处理。我写了一个程序,它存储了一些音乐轨道,并帮助用户检查他/她想到的歌曲是否存在于存储的轨道中。这是通过要求用户输入一串字符来完成的。然后程序使用 strstr()
我正在学习 sscanf 并遇到如下格式字符串: sscanf("%[^:]:%[^*=]%*[*=]%n",a,b,&c); 我理解 %[^:] 部分意味着扫描直到遇到 ':' 并将其分配给 a。:
def char_check(x,y): if (str(x) in y or x.find(y) > -1) or (str(y) in x or y.find(x) > -1):
我有一种情况,我想将文本文件中的现有行包含到一个新 block 中。 line 1 line 2 line in block line 3 line 4 应该变成 line 1 line 2 line
我有一个新项目,我正在尝试设置 Django 调试工具栏。首先,我尝试了快速设置,它只涉及将 'debug_toolbar' 添加到我的已安装应用程序列表中。有了这个,当我转到我的根 URL 时,调试
在 Matlab 中,如果我有一个函数 f,例如签名是 f(a,b,c),我可以创建一个只有一个变量 b 的函数,它将使用固定的 a=a1 和 c=c1 调用 f: g = @(b) f(a1, b,
我不明白为什么 ForEach 中的元素之间有多余的垂直间距在 VStack 里面在 ScrollView 里面使用 GeometryReader 时渲染自定义水平分隔线。 Scrol
我想知道,是否有关于何时使用 session 和 cookie 的指南或最佳实践? 什么应该和什么不应该存储在其中?谢谢! 最佳答案 这些文档很好地了解了 session cookie 的安全问题以及
我在 scipy/numpy 中有一个 Nx3 矩阵,我想用它制作一个 3 维条形图,其中 X 轴和 Y 轴由矩阵的第一列和第二列的值、高度确定每个条形的 是矩阵中的第三列,条形的数量由 N 确定。
假设我用两种不同的方式初始化信号量 sem_init(&randomsem,0,1) sem_init(&randomsem,0,0) 现在, sem_wait(&randomsem) 在这两种情况下
我怀疑该值如何存储在“WORD”中,因为 PStr 包含实际输出。? 既然Pstr中存储的是小写到大写的字母,那么在printf中如何将其给出为“WORD”。有人可以吗?解释一下? #include
我有一个 3x3 数组: var my_array = [[0,1,2], [3,4,5], [6,7,8]]; 并想获得它的第一个 2
我意识到您可以使用如下方式轻松检查焦点: var hasFocus = true; $(window).blur(function(){ hasFocus = false; }); $(win
我是一名优秀的程序员,十分优秀!