rmarkdown: hanging-indent citation - r-markdown

The rmarkdown package uses the biblatex with the chicago author-date style as default.
I would like to use hanging-indent in the references, like it the biblatex-chicago package.
This suggestion by David Sanson of using this:
\setlength{\parindent}{-0.2in}
\setlength{\leftskip}{0.2in}
\setlength{\parskip}{8pt}
Comes very close, but unfortunately it also indents the first line of the first reference, which does not look very good. Any idea's on how to make this work?

Simply add the \noindent command.
# Bibliography
\setlength{\parindent}{-0.2in}
\setlength{\leftskip}{0.2in}
\setlength{\parskip}{8pt}
\noindent

Related

Regex to emulate GitHub autolink references in Markdown

What would be the regex emulating GitHub's autolinked references?
It takes Markdown on input and outputs enriched Markdown where strings like #123 are converted to [#123](https://github.com/owner/repo/issues/123).
These are some examples of the transformations that I'd like the regex to do:
Input:
1. #123
2. https://github.com/owner/repo/issues/123
3. https://github.com/shoptet/sofa/pull/456
4. owner/repo#123
5. https://github.com/owner/repo/issues/123#issuecomment-123456789
Output:
1. [#123](https://github.com/owner/repo/issues/123)
2. [#123](https://github.com/owner/repo/issues/123)
3. [#123](https://github.com/owner/repo/pull/456)
4. [owner/repo#123](https://github.com/owner/repo/issues/123)
5. [#123 (comment)](https://github.com/owner/repo/issues/123#issuecomment-123456789)
I'd prefer one giant regex if possible (I know it's not going to be nice but would allow me to process Markdown in a couple of my favorite editors directly).
If you don't mind changing the format a little (using [#123-comment] instead of [#123 (comment)] for comments), you may use this:
(?:(owner/repo)?#(\d+)\b|https?://github\.com/([^/]+/[^/]+/(?:issues|pull))/(\d+)(#issue(comment)(-)\d+)?)
Replace by: [\1#\2\4\7\6](https://github.com/owner/repo/issues/\2\4\5)
You have a demo here.
I'd still prefer a (complex) regex but if anyone is looking for the same post-processing like me, this package can solve it in a Node.js script:
https://github.com/remarkjs/remark-github

VSCode Snippets: Format File Name from my_file_name to MyFileName

I am creating custom snippets for flutter/dart. My goal is to pull the file name (TM_FILENAME_BASE) remove all of the underscores and convert it to PascalCase (or camelCase).
Here is a link to what I have learned so far regarding regex and vscode's snippets.
https://code.visualstudio.com/docs/editor/userdefinedsnippets
I have been able to remove the underscores nicely with the following code
${TM_FILENAME_BASE/[\\_]/ /}
I can even make it all caps
${TM_FILENAME_BASE/(.*)/${1:/upcase}/}
However, it seems that I cannot do two steps at a time. I am not familiar with regex, this is just me fiddling around with this for the last couple of days.
If anyone could help out a fellow programmer just trying make coding simpler, it would be really appreciated!
I expect the output of "my_file_name" to be "MyFileName".
It's as easy as that: ${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/}
For the camelCase version you mentioned, you can use:
${TM_FILENAME_BASE/(.*)/${1:/camelcase}/}

Regex for remove citation

I searched regex for removing citation from text ( they sound strange from voice reading software ).
I want to remove from text all citation in form
(Author, 2000), (Author, in press)
and
(Author something, something 2004, Author2 2005)
But in same time not remove normal text in braces, and for ex. (Figure 3) (which might be helpful for reader).
Example of text with citations: http://journal.frontiersin.org/article/10.3389/fnhum.2014.00114/full
I've better:
\([^\)]*,[^\)]*\)
See LiveDemo
I use the one I found here:
r"([A-Z][\w\-]+ )?\((\D*\d{4}(: ?[\d\-]*)*(, \d{4}(: ?[\d\-]*)*)*;?)*\)"
Best i found is
[\(].?[^\)]*?[\d\d\d\d]{1}.*?[\)]{1}
It might not be optimal, because it selects (1) which in some cases might not be what reader want, still it is close to optimum.

Textile: using code and footnotes

Hi I'm using Redmine to write a wiki of my software. I need to put some notes next to a code section like this:
class.method()[1]
Where the "one" is a link to my note at the end of the page.
I've tried to use any method defined in the Textile syntax but it seems that it doesn't work. In fact when you use the code tag '# #' any other tag stops working.
It's good even if I can use the link tag [[ ]] but only if it is like this google.com
Thanks for any help,
Alessandro
Redmine uses Coderay to parse the code sections in the Wiki. Take a look at the documentation for the different languages. Otherwise I would suggest using comments instead of footnotes or in worst case line references to the code.
The footnote will only work if there is an alphanumeric character directly before the opening square bracktet:
this[1], whereas this()[2] or this [3]
fn1. will work
fn2. won't work.
fn3. won't work.
At least this is true with Redmine 3.1. See this issue for more information.
Note that you need blank lines between fn1., fn2. and fn3. to get a correct rendering.
This extension for Redmine supports footnotes and custom styles in the wiki.
Redmine supports Textile markup syntax. Textile has support for footnotes. As noted on ticket ticket #974, this is the syntax for using footnotes in Redmine:
Text with a footnote[1]
fn1. and here the actual footnote.

To comment out matches in Vim - independent on comment leader?

I want to comment out lines in some code I have. I have different kinds of codes, and they use different comment leaders. E.g. in latex: '%', in Fortran 90: '!' and in python: '#'. I want to do a substitute command that looks something like this:
:g/<search-string>/s/^/<add-comment-leader-here>/
If this is possible, I could also make a command in Vim that automatically commented out the selected text. Something like this:
vmap <z> :'<,'>s/^/<add-comment-leader-here>/
Any ideas are welcome! :)
If you haven't seen it already, you may be interested in the NERD Commenter Vim plugin.
Check out Enhanced Commentify: I think this does what you want: it determines the comment leader based on the file type.
If you want to do it yourself, the easiest way would be to define a mapping that uses exec to build a command and include a variable that is set in your ~/.vim/after/ftplugin/c.vim and other ftplugin files. Alternatively, just add the same mapping (with a different leader) to each ftplugin file.