How do I set pandoc latex template options with knitr's pandoc() function using an embedded pandoc config? - knitr

Is it possible to use knitr's pandoc() function with an embedded pandoc config in a markdown file to change the default pandoc latex template options?
For example, if I use the following embedded pandoc() config at the beginning of foo.md:
<!--pandoc
format: latex
s:
V: geometry:margin=1.5cm
o: foobar.pdf
-->
Then, from R prompt,
pandoc("foo.md","latex")
produces the following system call from R:
pandoc -s -V=geometry:margin=1.5cm -f markdown -t latex -o foobar.pdf 'foo.md'
However, For the page margins to actually be adjusted to 1.5cm, the system call needs to NOT have the "=" after the -V. In other words, the system call needs to be:
pandoc -s -V geometry:margin=1.5cm -f markdown -t latex -o foobar.pdf 'foo.md'

Sorry this is a bug of knitr that has been fixed in the development version (1.2.7) on Github.

Related

How do I create my own custom command line script in zsh?

I want to be able to run simple one line commands on my terminal, but instead of them being complicated I want them to be very simple, writing my own commands for these complex command lines that I have to write out so frequently. I am using the zsh command line and for example I would want to do this.
% npx tailwindcss -i ./static/styles.css -o ./static/output.css --watch
into something much easier to read such as
% build tailwindcss
Another problem/example is where if I would like to use http-server, but I want to turn off the caching, I don't think you can change the default settings for http-server module to turn off the caching, I have to do this:
% http-server -c-1
I know it is not too much of a big deal but I would like to at least pretend that the zero caching is the default. So I could do something like this with the command line:
% run server
And that would just run the server.
Also as a side note if this is not the best command line tool to do stuff like this in like maybe bash would be better I would be open to using a different command line tool as well.
Using aliases
If you run the exact same command every time you could alias it like this:
alias http-server="http-server -c-1"
alias <alias-name>="npx tailwindcss -i ./static/styles.css -o ./static/output.css --watch"
Now http-server expands to http-server -c-1 and <alias-name> expands to npx tailwindcss -i ./static/styles.css -o ./static/output.css --watch
Using functions
If you want to choose the input file each time you could write a function instead:
build(){
npx tailwindcss -i $1 -o ./static/output.css --watch
}
Then you can build with build file.css
Add the alias or function to ~/.zshrc if you want it available every time you start zsh
Using bck-i-search
Use Ctrl+r to search history. Pressing Ctrl+r and writing "tailwind" will likely show you the full command. You can even comment the function with some arbitrary words to make them easier to find in history (e.g. "aaa")
npx tailwindcss -i ./static/styles.css -o ./static/output.css --watch #aaa

lpr command - how to force black and white?

I have troubles with the LPR command. Before the printer has changed. I ran my instructions using
lpr -P printer_name -o raw file_name
Now I need to run print instructions on the new printer which only accepts black and white printed colors.
After browsing the internet, I found the option saturation=0 but without success.
example : lpr -P printer_name -o saturation=0 -o raw file_name
I have also tried to edit the *DefaultColorModel: CMYK parameter of the ppd file and change it ofr *DefaultColorModel: Gray but it doesn't work either.
By using meld, I compared the .ppd file and printer.conf after printing with my ubuntu and ctrl+P but I don't see anything useful.
Can you help me ? Thanks
Ok, i found the right option.
If you need lock black and white for printing. You need use ColorModel option like this :
lpr -P printer_name -o ColorModel=KGray file_name

Is there a way to beautify curl command in Vscode?

I've a complex curl command that I want to analyze but it's all minfied into one line. Is there a formatter that would beautify it?
shell-format can format bash files. Assuming you put that curl command to be part of a bash script, it should work.
curl http://example.com/api/getPosts | node <<< "var o = $(cat); console.log(JSON.stringify(o, null, 4));"
Got it from here: https://stackoverflow.com/a/27238477/2159159

how to use -o flag in wget with -i?

I understand that -i flag takes a file (which may contain list of URLs) and I know that -o followed by a name can be specified to rename a item being downloaded using wget.
example:
wget -i list_of_urls.txt
wget -o my_custom_name.mp3 http://example.com/some_file.mp3
I have a file that looks like this:
file name: list_of_urls.txt
http://example.com/some_file.mp3
http://example.com/another_file.mp3
http://example.com/yet_another_file.mp3
I want to use wget to download these files with the -i flag but also save each file as 1.mp3, 2.mp3 and so on.
Can this be done?
You can use any script language (PHP or Python) for generate batch file. In thin batch file each line will contains run wget with url and -O options.
Or you can try write cycle in bash script.
I ran a web search again and found https://superuser.com/questions/336669/downloading-multiple-files-and-specifying-output-filenames-with-wget
Wget can't seem to do it but Curl can with -K flag, the file supplied can contain url and output name. See http://curl.haxx.se/docs/manpage.html#-K
If you are willing to use some shell scripting then https://unix.stackexchange.com/questions/61132/how-do-i-use-wget-with-a-list-of-urls-and-their-corresponding-output-files has the answer.

Doxygen does not show Namespaces tab in document although show is YES

I am using doxygen for sometime. I previously generated a documentation for my source code with namespaces. It was working OK. But now I created a new project for my new sources and Doxygen does not put Namespaces tab to the documents although SHOW_NAMESPACES is YES and there are lots of namespaces in the source code. The namespace of classes are seen when selected but I dont have the tab.
What could be the problem?
You either need to give the namespaces some documentation or set EXTRACT_ALL to YES.
Example:
$ mkdir test-dir
$ cd test-dir
$ echo 'namespace test {}' > test.hpp
$ doxygen -g # generate default config file
(output)
$ grep -P '^(EXTRACT_ALL|SHOW_NAMESPACES)' Doxyfile # show default settings
EXTRACT_ALL = NO
SHOW_NAMESPACES = YES
$ doxygen # generate docs
(output)
Now open html/index.html, there won't be a namespace tab. This is what you're seeing.
$ sed -i '/^EXTRACT_ALL/s/NO/YES/' Doxyfile # change setting
$ grep -P '^(EXTRACT_ALL|SHOW_NAMESPACES)' Doxyfile # show change
EXTRACT_ALL = YES
SHOW_NAMESPACES = YES
$ doxygen
(output)
Now open html/index.html, there will be a namespace tab.
Tested with doxygen 1.6.3.