I would like to exploit vim's syntax highlighting capabilities to highlight code (any language) in latex (using the xcolor package). Therefore I wonder if it is possible to have a vim-script export the vim internal information about the highlighted text in the buffer. Obviously it would be sufficient to know start, end and color of each highlighted entity. The generation of the latex code or other languages such as html would then be obvious.
You can use my formatvim plugin: it can export to latex-xcolor format with
Format format latex-xcolor
. If you are not fine with the result (it is completely untested and I almost never used this option) feel free to send patches, dictionary with format specification can be seen here, everything what you need to create your own format is in documentation.
Note: if you need to export to any other language all you need is to write a specification for it in terms of my plugin. Here is a code that will add latex-xcolor-clone format to my plugin:
scriptencoding utf-8
execute frawor#Setup('0.0', {'plugin/format': '3.0'})
let s:texescape=
\'substitute('.
\ 'substitute(###, ''\v[\\\[\]{}&$_\^%#]'', '.
\ '''\=''''\char''''.char2nr(submatch(0))."{}"'', '.
\ '"g"),'.
\'" ", ''\\enskip{}'', "g")'
let s:texstylestart=
\'((#inverse#)?'.
\ '(''\colorbox[HTML]{''.'.
\ '((#fgcolor#!=#"")?'.
\ '(toupper(#fgcolor#[1:])):'.
\ '(toupper(#_fgcolor#[1:])))."}{".'.
\ '''\textcolor[HTML]{''.'.
\ '((#bgcolor#!=#"")?'.
\ '(toupper(#bgcolor#[1:])):'.
\ '(toupper(#_bgcolor#[1:])))."}{"):'.
\ '(((#bgcolor#!=#"")?'.
\ '(''\colorbox[HTML]{''.toupper(#bgcolor#[1:])."}{"):'.
\ '("")).'.
\ '''\textcolor[HTML]{''.'.
\ '((#fgcolor#!=#"")?'.
\ '(toupper(#fgcolor#[1:])):'.
\ '(toupper(#_fgcolor#[1:])))."}{"))'
let s:texstyleend=
\'repeat("}", '.
\ '((#inverse#)?'.
\ '(2):'.
\ '((#bgcolor#!=#"")+1)))'
let s:format={
\'begin': '\documentclass[a4paper,12pt]{article}'.
\ '\usepackage[utf8]{inputenc}'.
\ '\usepackage[HTML]{xcolor}'.
\ '\pagecolor[HTML]{%''toupper(#_bgcolor#[1:])''%}'.
\ '\color[HTML]{%''toupper(#_fgcolor#[1:])''%}'.
\ '\begin{document}{\ttfamily\noindent',
\'line': '%>'.s:texstylestart.".".
\ s:texescape.".".
\ s:texstyleend,
\'lineend': '\\',
\'end': '}\end{document}',
\'strescape': s:texescape,
\}
call s:_f.format.add('latex-xcolor-clone', s:format)
The :TOhtml command is built in Vim. It, rather obviously, generates HTML, not Latex, though.
Related
I used HaplotypeCaller for variant calling out of WES picard.sorted.MarkedDup.bam file with GATK 4.2.6.1. HaplotypeCaller standard command line.
Apparently, everything worked well and I received standard .vcf file. But the number of identified variants are too much for WES result. It's close to one million variants for one sample!
Did I perform something wrong?
What solution do you recommend?
Any help would be appreciated.
The command line I used was as follow:
gatk --java-options -Xmx8g HaplotypeCaller \ -R $refFile \ -I ${base}.picard.sorted.markedDup.bam \ --dont-use-soft-clipped-bases -stand-call-conf 20.0 \ --emit-ref-confidence GVCF \ -O ${base}.rrrrealigned.vcf
I would like to have a simple way of reading in a LaTex File in python.
The main problem are the escape signs \ that are supposed to be
escaped for a python string like \ -> \\.
(re.escape seems to escape not just \ but all other signs like { as well.)
I downloaded and installed SyntaxNet following Syntax official documentation on Github. following the documentation (annotating corpus) I tried to read a .conll file named wj.conll by SyntaxNet and write the results in wj-tagged.conll but I could not. My questions are:
does SyntaxNet always reads .conll files? (not .txt files?). I got a bit confused as I knew SyntaxNet reads .conll file for training and testing process but I am a bit suspicious that it is necessary to convert a .txt file to .conll file in order to have their Part Of Speach and Dependancy Parsing.
How can I make SyntaxNet reads from files (I tired all possible ways explain in GitHub documentation about SyntaxNet and It didn't work for me)
Add these declaration lines to "context.pbtxt" at the end of the file. Here "inp" and "out" are the text files present in the root directory of syntexnet.
input {
name: 'inp_file'
record_format: 'english-text'
Part {
file_pattern: 'inp'
}
}
input {
name: 'out_file'
record_format: 'english-text'
Part {
file_pattern: 'out'
}
}
Add sentences to the "inp" file for which you want tagging to be done and specify them in shell the next time you run syntaxnet using --input and --output tags.
Just to help you a bit more I am pasting an example shell command.
bazel-bin/syntaxnet/parser_eval \
--input inp_file \
--output stdout-conll \
--model syntaxnet/models/parsey_mcparseface/tagger-params \
--task_context syntaxnet/models/parsey_mcparseface/context.pbtxt \
--hidden_layer_sizes 64 \
--arg_prefix brain_tagger \
--graph_builder structured \
--slim_model \
--batch_size 1024 | bazel-bin/syntaxnet/parser_eval \
--input stdout-conll \
--output out_file \
--hidden_layer_sizes 512,512 \
--arg_prefix brain_parser \
--graph_builder structured \
--task_context syntaxnet/models/parsey_mcparseface/context.pbtxt \
--model_path syntaxnet/models/parsey_mcparseface/parser-params \
--slim_model --batch_size 1024
In the above script the output(POS tagging) of the first shell command is used as an input for the second shell command, where the two shell commands are seperated by "|"
just a quick help if you want to save the output of demo in a .txt file:
try echo "open file X with application Y" | ./demo.sh > output.txt
it gives you sentence tree to the current directory.
I have write the code according to book*learning vi and vim* p202
set statusline=%<%t%h%m%r\ \ %a\ %{strftime(\"%c\")}%=0x%B\
\\ line:%1,\ \ col:%c%V\ %P
i write the sentence in my _vimrc ,when i open a file ,an mistake occur .
Unknown option: %{strftime("%c")}%=0x%B\\
what is the matter?
Just before the %{strftime, you have two space characters, and only the first one is properly escaped with \. Therefore, Vim thinks the option value ends there and another option name begins. You need to either remove that additional space, or escape it (same for later occurrences of multiple spaces):
set statusline=%<%t%h%m%r\ \ %a\ \ %{strftime(\"%c\")}%=0x%B\
\\ \ line:%1,\ \ \ \ col:%c%V\ %P
As this is cumbersome and hard to read and edit, an alternative is to use :let, which avoids that escaping:
let &statusline = '%<%t%h%m%r %a %{strftime("%c")}%=0x%B line:%1, col:%c%V %P'
I am writing a script that reads some markup data, generates a tex document and converts it to a png image.
As long as I use a resolution up tp 286 px/inch everything works fine. Unfortunately GhostScript, which I use to create picture data, does nothing when I use higher values.
How can I fix this behaviour?
Since info about your problem is not very detailed (What kind of fonts are used in the TeX document? Are they Chinese, Japanese, Korean, or...? Which is the Ghostscript commandline you're using?) ... here is a thing to check. But it is only a first guess: try to add "-c "100000000 setvmthreshold" -f /path/to/pdffile.pdf" to your command:
gswin32c.exe ^
-o c:/path/to/output.png ^
-sDEVICE=png ^
-r600x600 ^
-c "100000000 setvmthreshold" ^
-f /path/to/pdffile.pdf
This will allow for ~100 MByte extra RAM usage by Ghostscript. If you are on X-Windows (Linux, Unix), then "-dMaxBitmap=..." could help (provided you've enough of RAM):
gs \
-o /path/to/output.png \
-sDEVICE=png \
-r600x600 \
-dMaxBitmap=100000000 \
-c "100000000 setvmthreshold" \
-f /path/to/pdffile.pdf