Markdown, Knitr, Pandoc Header block disappears from output when styles sheet is added - knitr

---
title: "![logo](../Shared/logo.jpg) Title Text"
author: "Author Name"
output: html_document
css: styles.css
---
This header information gets output with render or knit2html, but when the css: styles.css and associated code
options(rstudio.markdownToHTML =
function(inputFile, outputFile) {
require(markdown)
markdownToHTML(inputFile, outputFile, stylesheet='custom.css')
}
)
is added to the start up file, the rendered output file has no header output. The first line in the file is the first line after the last "---" in the *.Rmd file. By the way, "Knit HTML" on the individual *.Rmd content works as expected.
Thanks,
Alan

The option rstudio.markdownToHTML is for R Markdown v1 only. The version based on Pandoc is v2, in which case the css field must be put under the html_document field:
---
title: "![logo](../Shared/logo.jpg) Title Text"
author: "Author Name"
output:
html_document:
css: styles.css
---
Please read the documentation.

Related

Easy way to cite academic references in the README.md of a github-repo

I was just wondering if there is any easy way that I can use a .bib-file to create academic references in the README of a github site.
In rmarkdown I'm used to just do the following in the text:
#test2010
and if I have specified the correct bibtex-file in the yaml-header it works perfectly.
Is there anything similar in "normal" github markdown?
Bibliographies are not supported in GitHub Flavored Markdown(GFM). The workaround is producing GFM from R Markdown.
Step: create README.Rmd and bibliography.bib and knit README.Rmd.
README.Rmd:
---
output:
md_document:
variant: markdown_github
bibliography: bibliography.bib
---
[#xie2018]
bibliography.bib:
#Book{xie2018,
title = {R Markdown: The Definitive Guide},
author = {Yihui Xie and J.J. Allaire and Garrett Grolemund},
publisher = {Chapman and Hall/CRC},
address = {Boca Raton, Florida},
year = {2018},
note = {ISBN 9781138359338},
url = {https://bookdown.org/yihui/rmarkdown},
}
The output README.md:
(Xie, Allaire, and Grolemund 2018)
<div id="refs" class="references csl-bib-body hanging-indent">
<div id="ref-xie2018" class="csl-entry">
Xie, Yihui, J. J. Allaire, and Garrett Grolemund. 2018. *R Markdown: The
Definitive Guide*. Boca Raton, Florida: Chapman; Hall/CRC.
<https://bookdown.org/yihui/rmarkdown>.
</div>
</div>

SharePoint Office365 Powershell Webpart AllItems.aspx

Using powershell, add webpart (image) to the list view page, e.g. AllItems.aspx.
This code is ok when I adding webpart to sitepage but what/how can do the same things in list
$mySite = Get-PnPClientSidePage -Identity "TestWP.aspx"
$jsonProp = '{
"imageSourceType":0,
"imageSource":"https://MMMMMM.sharepoint.com/sites/pwa/SiteAssets/img01.jpg",
"captionText":" ",
"altText":" ",
"linkUrl":"",
"overlayText":"",
"fileName":"",
"siteId":"",
"webId":"",
"listId":"",
"uniqueId":"",
"imgWidth":"100%",
"imgHeight":"100%"
}'
Add-PnPClientSideWebPart -Page $mySite -Section 1 -Column 1 -Order 1 -DefaultWebPartType Image -WebPartProperties $jsonProp
E.g. in the AllItems.aspx view -> edit page -> Insert -> Image
or Add a Web Part.
example in the link.
img01
img02
coffee, a little break and I got it
first manually adding a web part to the test page then download webpart in xml format
# get xml
$imgWebPart = Get-PnPWebPartXml -ServerRelativePageUrl "/sites/pwa/Lists/TestList03/AllItems.aspx" -Identity "Image Viewer"
Add-PnPWebPartToWebPartPage -ServerRelativePageUrl "/sites/pwa/Lists/TestList03/aa.aspx" -Xml $imgWebPart -ZoneId Main -ZoneIndex 0
sorry for the confusion.

Selecting a field in Protractor

<hs-details-item>
<hs-label>Location</hs-label>
<hs-value-block>
<hs>
<hs-text-box ng-class="{'disabled': isAmenityPosting }" class="required" input-control="{title:'Location', okCallback:setJobSite, value:jobSiteName,
autocomplete:{ values:getJobSiteList, reload: true }, ss:'location'}">
<i class="icon-room"></i><span hs-placeholder="Select Location" class="ng-binding"></span>
</hs-text-box>
</hs>
<hs>
<!-- ngIf: isBarcodeShow() --><hs-button ng-class="{'disabled': soCreating }" class="barcode-special-btn smaller ng-scope" ng-if="isBarcodeShow()" hs-gesture="{handler:startScan, param: onBarcodeScanCompleted}"><i class="icon-br-code"></i></hs-button><!-- end ngIf: isBarcodeShow() -->
</hs>
</hs-value-block>
</hs-details-item>
Scenario: click on “Location” field...
What would be the best way to come up with a command in Protractor to select "location" field from the above Snippet Code?
Can it be done by not using Xpath?
Multiple options here. A sort of a non-welcomed, but short and readable way, would be to use an XPath expression and check the preceding label:
var locationTextBox = element(by.xpath("//hs-label[. = 'Location']/following::hs-text-box"));
locationTextBox.click();

Pulling Data from Google spreadsheet

I am having difficulty pulling data from Google spreadsheet
I have added following gem files
gem 'roo'
gem 'google_drive'
gem 'google-spreadsheet-ruby'
My jobs file is
require 'roo'
require 'rubygems'
def fetch_spreadsheet_data()
google_user = "MY EMAIL ADDRESS"
google_password = "MY PASSWORD"
workbook = Roo::Google.new("https://docs.google.com/spreadsheet/ccc?key=1hdwnrDsuJId1FLE0yWICYP1HGqYNu2NHH2IcoPyAzOQ#gid=0",user: google_user, password: google_password)
send_event('catchup_data', {current: s.cell('B',2) })
send_event('Bounced_back', {current: s.cell('B',3) )
end
SCHEDULER.every '5m' do
fetch_spreadsheet_data()
end
My dashboard.erb file has following html
<li data-row="2" data-col="3" data-sizex="1" data-sizey="1">
<div data-id="bounce_back" data-view="Number" data-title="Triage - Work in Progress" style="background-color:#5AC352;"></div>
</li>
<li data-row="2" data-col="4" data-sizex="1" data-sizey="1">
<div data-id="catchup_data" data-view="Number" data-title="Squad catchup sessions last month" style="background-color:#DBA901;"></div>
</li>
Not sure what am I missing that the data is not coming through. Can anyone please help me?
There are a few things wrong that I can see:
You're sending 'Bounced_back' but binding to the id of 'bounce_back'
You are trying to get the cell data from 's' but 's' is undefined
Looking at the Roo docs, I believe you have copied 's' from there. Just above that, they use sheet instead so I believe you have to grab the sheet from the workbook before using it.
I googled a bit and found this: http://etzelstorfer.com/en/dashing-graph-from-google-spreadsheet/
In summary, this should work for you:
def fetch_spreadsheet_data()
google_user = "MY EMAIL ADDRESS"
google_password = "MY PASSWORD"
workbook = Roo::Google.new("https://docs.google.com/spreadsheet/ccc?key=1hdwnrDsuJId1FLE0yWICYP1HGqYNu2NHH2IcoPyAzOQ#gid=0",user: google_user, password: google_password)
s = workbook.sheets[0] # assuming first sheet in workbook
send_event('catchup_data', {current: s.cell('B',2) })
send_event('bounce_back', {current: s.cell('B',3) )
end
SCHEDULER.every '5m' do
fetch_spreadsheet_data()
end

How do I access structured metadata using DocPad?

I'm evaluating DocPad at the moment to see if it will be suitable for our website amongst other things. I'm having trouble working out how to use structured metadata in eco templates. I'm pretty sure it's related to How to display Backbone nested attribute using Eco? but that's unanswered too.
My page looks like:
--- yaml
layout: 'post'
title: "Samuel Johnson's garret - an unexpected lull"
category: 'Digital Publishing'
author:
name: Author Name
page: author
email: author.name#ourdomain.co.uk
---
Unexpected free time, a chilly walk, a brown plaque leads me to
[Dr Johnson's house (http://www.drjohnsonshouse.org/) near Fleet-Street…
and the eco template like:
---
layout: default
---
<article id="post" class="post">
<h1><%= #document.title %></h1>
<h2>By: <%= #document.author.email %></h2>
<div class="post-content"><%- #content %></div>
</article>
The #document.author.email leads to the following error being logged:
TypeError: Cannot read property 'email' of undefined
How do I access that structured metadata?
thanks
Everything seems ok. When I test the same structure, the line <%= #document.author.email %> works. Maybe you have some kind of inconsistency using white spaces and tabs ? You can validate your YAML on this site : http://yamllint.com.
Personally I also use arrays of objects in metadata :
choices:
-
text: "Mercure"
feedback: "Mercure est la planète la plus proche du Soleil, elle se situe à une distance de 0,4 UA"
value: 0
-
text: "Neptune"
feedback: "C'est effectivement la planète la plus éloignée avec une distance de 30 UA."
value: 1
and it works great. Sorry for the text in French but I guess it doesn't really matter for an example.
you can see this example, it works perfectly now, i found my issue and i want to share the solution with you:
---
slides:
-
detailimage: "heliski-img.png"
mainimage: "heliski-g.jpg"
title: "Powder South Heliski Guides"
-
detailimage: "nuevos-vientos-img.png"
mainimage: "nuevos-vientos.jpg"
title: "Centro Experiencial Nuevos Vientos"
---
#full-width-slider.royalSlider.heroSlider.rsMinW
each slide in document.slides
.rsContent
img.rsImg(src='/slideshow/#{slide.mainimage}', alt='#{slide.title}')
.infoBlock.infoBlockLeftBlack.rsABlock(data-fade-effect='', data-move-offset='10', data-move-effect='bottom', data-speed='200')
p #{slide.title}
img.rsImg(src='/slideshow/#{slide.detailimage}', alt='#{slide.title}')
the important thing is the each line, it must say "in document.slides" so i can access from jade the document metadata. :D
the final render will look like this:
<div id="full-width-slider" class="royalSlider heroSlider rsMinW">
<div class="rsContent"><img src="/slideshow/heliski-g.jpg" alt="Powder South Heliski Guides" class="rsImg">
<div data-fade-effect="" data-move-offset="10" data-move-effect="bottom" data-speed="200" class="infoBlock infoBlockLeftBlack rsABlock"></div>
<p>Powder South Heliski Guides</p><img src="/slideshow/heliski-img.png" alt="Powder South Heliski Guides" class="rsImg">
</div>
<div class="rsContent"><img src="/slideshow/nuevos-vientos.jpg" alt="Centro Experiencial Nuevos Vientos" class="rsImg">
<div data-fade-effect="" data-move-offset="10" data-move-effect="bottom" data-speed="200" class="infoBlock infoBlockLeftBlack rsABlock"></div>
<p>Centro Experiencial Nuevos Vientos</p><img src="/slideshow/nuevos-vientos-img.png" alt="Centro Experiencial Nuevos Vientos" class="rsImg">
</div>
</div>