Add a link to the title of references - r-markdown

I'm creating a document with rmarkdown (pandoc), which includes some bibliography in a .bib file. What I'd like to do is add a link to the title of the references, so that each of them links to a page of the form http://sample.com/citation-key.html, like this:
Author. (2017). Sample Title. Journal, 1(1), 1–2.
I've tried modifying the .csl file by adding prefixes and suffixes to the title, but everything I put in there is escaped, whether I use markdown or HTML syntax. Unfortunately, I can't change the .bib file. The relevant part of the .csl file is this:
<text variable="title"/>
Sample files are:
literature.Rmd:
---
output: html_document
bibliography: literature.bib
csl: literature.csl
---
#author2017word says this doesn't work.
## References
literature.bib
#article{author2017word,
author = {Author},
journal = {Journal},
number = {1},
pages = {1--2},
title = {{Sample Title}},
volume = {1},
year = {2017}
}
literature.csl: I'm using the APA style from here (line 231).

My pull request to citeproc adding support this feature was recently merged, and as a result, the latest release of Pandoc (v2.14.2) now hyperlinks titles by default when the citation does not already show a raw URL! From the citeproc readme:
When linkBibliography=True automatically linkifies any identifiers (DOI, PMCID, PMID, or URL) appearing in a bibliography entry. When an entry has a DOI, PMCID, PMID, or URL available but none of these are rendered by the style, add a link to the title (or, if no title is present, the whole entry), using the URL for the DOI, PMCID, PMID, or URL (in that order of priority). See Appendix VI of the CSL v1.0.2 spec.
In pandoc, this option is controlled by the link-bibliography metadata field, which is True by default.

Related

In ColdFusion do I add to the title tag from a document that is "Included"?

I have an index page that calls several includes using variables. Part of my site has an inventory section. I would like to insert the name of the inventory item into the title tag. From the index, I can tailor the title tag in the header to show the section and categories, but since the query for the individual item is in the included file, that variable doesn't exist yet when the index comes up. I tried to use the cfhtmlhead from the inventory page, but it neither adds to nor replaces the title that is called in the index.cfm page. Here is my code, but it doesn't work.
<cfhtmlhead text="<title>xxxx</title>"></cfhtmlhead>
I guess, I could pass the inventory item name in the URL, but most items have spaces in them and then I have to deal with that too.
Thanks,
Kirk
cfhtmlhead doesn't seem to work when it is in cfincludes

RMarkdown References section -name change

I'm currently writing in R Studio an R Markdown document. Since I am not using English, I want to change the name of the # References header to "Referencias". My output is HTML.
I went thru the pandoc documentation and tried reference-section-title: Referencias in my YALM header, with no luck.
The easiest way is to set the metadata field reference-section-title in the YAML header:
---
reference-section-title: Referencias
---
Alternatively, you could write the section title directly into the document, then use a special fenced div with id #refs to place the bibliography anywhere you need it:
# Referencias
::: #refs
:::

Add image before bookdown title

I'm trying to add an image before the title in gitbook style bookdown project. This is similar to this question from the RStudio Community page, but I would like the image to appear only before the title, not every top-level heading.
I've created a reprex here: https://bd-reprex.netlify.app/
I've edited the _output.yml to include:
bookdown::gitbook:
...
includes:
before_body: assets/logo.html
However, as can be seen in the example above, the image now appears before every chapter, not just before the title.
Any help would be greatly appreciated!
This question was answered here.
The solution is to add a JS codeblock to the end of the index.Rmd file, such as
```{js, echo = FALSE}
title=document.getElementById('header');
title.innerHTML = '<img src="/path/to/img.png" alt="Test Image">' + title.innerHTML
```
From https://bookdown.org/yihui/rmarkdown-cookbook/latex-logo.html
title: |
![](logo.jpg){width=1in}
Adding a Logo to LaTeX Title
NB: although you cannot see them, there are two trailing spaces after {width=1in}, which means a line break in Markdown. Without the line break, the image and the title would be on the same line, which may not be what you desire.
See also related question: How to have Frontpage Image before chapter title and book title?

Use the title= HTML attribute with RMarkdown

I am trying to understand if it is possible to insert the HTML title= attribute (not necessarily inside an <abbr> tag) within an RMarkdown document (e.g. a blog post written through blogdown)
From W3C: the title attribute specifies extra information about an element. The information is most often shown as a tooltip text when the mouse moves over the element.
The <abbr title="World Health Organization">WHO</abbr> was founded in 1948.
Couldn't find anything regarding using in in RMarkdown tho
You can write raw HTML in Markdown. However, if you are using Hugo >= v0.60.0, raw HTML will be ignored by default. You need to set an option in your config file to enable it:
[markup.goldmark.renderer]
unsafe= true

Is it possible to read tweet-text of a tweet URL without twitter API?

I am using Goose to read the title/text-body of an article from a URL. However, this does not work with a twitter URL, I guess due to the different HTML tag structure. Is there a way to read the tweet text from such a link?
One such example of a tweet (shortened link) is as follows:
https://twitter.com/UniteAlbertans/status/899468829151043584/photo/1
NOTE: I know how to read Tweets through twitter API. However, I am not interested in that. I just want to get the text by parsing the HTML source without all the twitter authentication hassle.
Scrape yourself
Open the url of the tweet, pass to HTML parser of your choice and extract the XPaths you are interested in.
Scraping is discussed in: http://docs.python-guide.org/en/latest/scenarios/scrape/
XPaths can be obtained by right-clicking to element you want, selecting "Inspect", right clicking on the highlighted line in Inspector and selecting "Copy" > "Copy XPath" if the structure of the site is always the same. Otherwise choose properties that define exactly the object you want.
In your case:
//div[contains(#class, 'permalink-tweet-container')]//strong[contains(#class, 'fullname')]/text()
will get you the name of the author and
//div[contains(#class, 'permalink-tweet-container')]//p[contains(#class, 'tweet-text')]//text()
will get you the content of the Tweet.
The full working example:
from lxml import html
import requests
page = requests.get('https://twitter.com/UniteAlbertans/status/899468829151043584')
tree = html.fromstring(page.content)
tree.xpath('//div[contains(#class, "permalink-tweet-container")]//p[contains(#class, "tweet-text")]//text()')
results in:
['Breaking:\n10 sailors missing, 5 injured after USS John S. McCain collides with merchant vessel near Singapore...\n\n', 'https://www.', 'washingtonpost.com/world/another-', 'us-navy-destroyer-collides-with-a-merchant-ship-rescue-efforts-underway/2017/08/20/c42f15b2-8602-11e7-9ce7-9e175d8953fa_story.html?utm_term=.e3e91fff99ba&wpisrc=al_alert-COMBO-world%252Bnation&wpmk=1', u'\xa0', u'\u2026', 'pic.twitter.com/UiGEZq7Eq6']