How can I specify global and local chunk options for a quarto pdf book? - r-markdown

I am trying to create a PDF book using Quarto. In particular, I want to know if there is a way to specify the global chunk options, which would be used for all the chunks in all the qmd pages. The global option is
echo = TRUE
(I think this syntax is in R Markdown, not Quarto.) But only for some code chunks in some of the pages, I want to hide the code (by setting echo = FALSE). How can I do this?

Setting Global Options
In quarto documents, books or presentation, to set options like echo, eval, warning, error, include, output globally, we need to specify them under execute yaml key.
So in quarto book, to set echo to true globally, we set echo: true under execute.
_quarto.yml
project:
type: book
execute:
echo: true
book:
title: "Quarto book"
author: "Jane Doe"
date: "8/7/2022"
chapters:
- index.qmd
- intro.qmd
- summary.qmd
- references.qmd
bibliography: references.bib
format:
pdf:
documentclass: scrreprt
Setting local options
And setting these options locally (for some specific chunk in a specific qmd page) is same as r-markdown.
Say in my index.qmd, I can specify echo=FALSE for a chunk like this,
index.qmd
# Preface {.unnumbered}
This is a Quarto book.
To learn more about Quarto books visit <https://quarto.org/docs/books>.
```{r echo=FALSE}
1 + 1
```

Related

Google Speech-to-Text: Cannot use Custom Classes

I am following the Google Docs to do Transcription jobs by providing it with a PhraseSet and CustomClass. From my understanding, the PhraseSet defines the kind of structures with the phrases that Google should expect. the CustomClass defines specific words in those phrases.
Example Phrase Set:
# Name: TextFriend
Items: [
'Text my friend ${Name}', 'Write a message to ${Name}', 'Shoot a text to ${Name}'
]
Example Custom Class:
# Name: Name
Items: [
'Kabena', 'Breagieszky', 'Sunni', 'Facebook', 'Bitbucket', 'GitHub'
]
When I try to create a transcription job, it fails with this error:
Error running recognize request. Invalid recognition 'config': Undefined custom class references. referenced class ids: Archwires. defined class ids: .
I doubled checked things and it all seems to be set up correctly. I did it through the GCP Console. Here's all the relevant resources:
Custom Class:
Phrase Set:
Job Configuration:
I appreciate any help or insight to resolve this issue!
I figured out the problem.
For those of you who land here, I found the solution by digging deeper into the code samples.
Instead of just using the customClassId in your phrase, you need to use the full path.
So:
// Don't do this:
Items: ['Shoot a text to ${Name}']
// Do this:
Items: ['Shoot a text to ${projects/0000/locations/global/customClasses/Name}']

How to review a paragraph on page and search for keywords? (and also building a list/directory of keywords redirecting to the correct result)

I am trying to do something that would go something like this below. I am trying to determine the language of a job description so my assumption is that if there is not a div class or h2 for it already, I would have to review the job description to find keywords that represent each language (such as 'and'), that I could preferably build some kind of directory. How could I do something like below but in python?
P.S. I am a complete beginner to python and code in general, so simple terms if possible. This is my assumption of framework structures if I made one up myself. I hope it is easy to understand. The purpose is for scraping job offers from company pages.
## Last one is the language. I would need to to first review the language of the text
if there's a tool to do that automatically
## or I could set up a review job description and create a keyword list for each
language.
Of course it is easier if they have this part on the job offer page.
language = joblink.get('h2', class_ = language)(language.redirect)
#keep reading for this directory
return if True #if the page has this
if False: #if the page doesn't have this
language = jobdescription.search(languagetxt.review & language.review):
if duplicates.remove
if multiple(language.redirect)
#'languagetxt.review' Directory
' und ' => 'German'
' and ' => 'English'
' et ' => 'French'
#'language.review' Directory
'German' => 'German'
'Native German' => 'German'
'Fluent in German' => 'German'
#'language.redirect' Directory
'English and German' => 'German and English'
'German, English' => 'German and English'
#expect it to read something like (German, English, English) = 'German and
English'
because of multiple
# result would look something like
# German and English

Run .Rmd posts on HUGO's Academic theme?

Anyone knows a way to publish .Rmd files on Academic's Theme on HUGO? Normally .md and HTML files are easily read by Academic theme but when it comes to .Rmd they are nowhere to be found in the post. I can't find a way to make my website react to
This is a portion of my config.toml, which I thought may have something to do:
paginate = 10 # Number of items per page in paginated lists.
enableEmoji = true
footnotereturnlinkcontents = "<sup>^</sup>"
ignoreFiles = [".ipynb$", ".ipynb_checkpoints$", "_files$", "_cache$"]
[outputs]
home = [ "HTML", "RSS", "JSON", "WebAppManifest" ]
section = [ "HTML", "RSS" ]
[mediaTypes."application/manifest+json"]
suffixes = ["webmanifest"]
[outputFormats.WebAppManifest]
mediaType = "application/manifest+json"
rel = "manifest"
Thank you very much for your attention.
A list of supported file formats in hugo can be found here. As you can see .Rmd is not among them. .Rmd files have to be .html (or .md) in order to be understood and rendered by hugo.
If you use blogdown and run the command blogdown::serve_site() instead of usual cli hugo server this should be done automatically, if I am not mistaken.
Best

Custom module in drupal 8, tab not created in admin section

I created custom module in Drupal 8. This module should create tab in admin/content. But unfortunately tab does not display in admin/content section. While I can able to access my module. Link to access my module 'localhost/demo/admin/content/book'
Here is my code:-
book.routing.yml
# book.routing.yml snippet
book.admin:
path: '/admin/content/book'
defaults:
_form: '\Drupal\book\Form\bookForm'
_title: 'BOOKS'
requirements:
_permission: 'book access'
book.links.menu.yml
# book.links.menu.yml snippet
book.admin:
route_name: book.admin
title: BOOKS
base_route: system.admin_content
For more information attaching screenshot, where I want tab
Expecting this one
you should rename the file to
book.links.task.yml
because what you want is a "task" of the content instead of a real menu link. Here's a great explanation and guide how to create custom modules:
http://www.sitepoint.com/build-drupal-8-module-routing-controllers-menu-links/
Note that some of his file namings are outdated (e.g. "menu_links"), but the general idea/structure of a module is still well explained.

Python lxml xpath no output

For educational purposes I am trying to scrape this page using lxml and requests in Python.
Specifically I just want to print the research areas of all the professors on the page.
This is what I have done till now
import requests
from lxml import html
response=requests.get('http://cse.iitkgp.ac.in/index.php?secret=d2RkOUgybWlNZzJwQXdLc28wNzh6UT09')
parsed_body=html.fromstring(response.content)
for row in parsed_body.xpath('//div[#id="maincontent"]//tr[position() mod 2 = 1]'):
for column in row.xpath('//td[#class="fcardcls"]/tr[2]/td/font/text()'):
print column.strip()
But it is not printing anything. I was struggling quite a bit with xpaths and was intially using the copy xpath feature in chrome. I followed what was done in the following SO questions/answers and cleaned up my code quite a bit and got rid of ' tbody ' in the xpaths. Still the code returns a blank.
1. Empty List Returned
2. Python-lxml-xpath problem
First of all, the main content with the desired data inside is loaded from a different endpoint via an XHR request - simulate that in your code.
Here is the complete working code printing names and a list of research areas per name:
import requests
from lxml import html
response = requests.get('http://cse.iitkgp.ac.in/faculty4.php?_=1450503917634')
parsed_body = html.fromstring(response.content)
for row in parsed_body.xpath('.//td[#class="fcardcls"]'):
name = row.findtext(".//a[#href]/b")
name = ' '.join(name.split()) # getting rid of multiple spaces
research_areas = row.xpath('.//*[. = "Research Areas: "]/following-sibling::text()')[0].split(", ")
print(name, research_areas)
The idea here is use the fact that all "professor blocks" are located in td elements with class="fcardcls". For every block, get the name from the bold link text and research areas from the following string after Research Areas: bold text.