Memo-style header in RMarkdown to Word - r

I would like to include a memo style header in my Word document created with RMarkdown. The header would look like this:
<logo here> <Date here>
TO: John Doe, Frank Rich
FROM: Sally Slippers
CC: Lots of other, people, who, get, copied
SUBJECT: A line or two describing the memo
______________________________________________________________________
What is the best way to do this? Is there a way to use the YAML header for this? Or should I just create an inline "table" and completely bypass the header?

Related

Bookdown "Remark" environment

I'm trying to add numbered remarks (like in the definition or theorem environments) that I could referenced in a bookdown document. Something like:
```{remark, mylab}
my comment
```
In Remark \#ref(rem:mylab) we discussed...
which would produce:
Remark 1.1 my comment
In Remark 1.1 we discussed ...
Would anyone know if this is possible? Also, is it possible to change the numbering to A, B and so on? That is to have instead:
Remark A my comment
In Remark A we discussed ...
Thank you very much!
The general solution is:
Choose one of the predefined theorem like environments that you are not using otherwise, e.g. example.
Redefine the printed name for that environment in _bookdown.yml (c.f. https://bookdown.org/yihui/bookdown/internationalization.html) via:
language:
label:
exm: 'Remark '
In your Rmd files use
```{example, mylab}
my comment
```
In Remark \#ref(exm:mylab) we discussed...
Note that you have to use example and the correspoding label prefix exm.
I do not know of a general solution to use alphabetic instead of numeric numbering. I am sure that this would be possible if one would use only LaTeX/PDF output.

How to create a link to a header in restructuredtext?

I have a document in restructuredtest like:
Header 1
========
and from some any other point (might be the same 'rst' file or a different one) I want to create a hyperlink to that header. So that when a user clicks on it, he gets to the page with the header Header 1
How to do that?
I tried to put the following line in the other document (according to this documentation):
see :ref:`Header 1`
but what I get is the following:
see Header 1
without any link...
I also tried to follow this documentation:
What I put in to the rst file is the following
see `Header 1`_
and what I see is the following link:
see `Header 1`_
which does not look very nice ...
Your first link was almost correct. You need to add a label preceding the section header, separated by a blank line. See Inline markup, Cross-referencing arbitrary locations, using the :ref: directive.
In your case:
.. _header-1-label-name:
Header 1
========
Some text
Here is a section reference: :ref:`header-1-label-name`.
Here is a section reference with a title: :ref:`Header 1 with a title <header-1-label-name>`.
In addition to the accepted answer, the label you add (in this case .. _header-1-label-name:) is required to have a dash. So a simple .. _label: won't do. Took me a while to figure that out.

How to represent markdown properly with escaping and line breaks?

I'm currently trying to build a chat app, using the official markdown package as well as underscore's escape function, and my template contains something like this:
<span class="message-content">
{{#markdown}}{{text}}{{/markdown}}
</span>
When I grab the text from the chat input box, I try to escape any HTML and then add in line breaks. safeText is then inserted into the database and displayed in the above template.
rawText = $("#chat-input-textbox").val();
safeText = _.escape(rawText).replace(/(?:\r\n|\r|\n)/g, '\n');
The normal stuff like headings, italics, and bold looks okay. However, there are two major problems:
Code escape issue - With the following input:
<script>alert("test")</script>
```
alert('hello');
```
This is _italics_!
Everything looks fine, except the alert('hello'); has become alert('hello'); instead. The <pre> blocks aren't rendering the escaped characters, which makes sense. But the problem is, the underscore JS escape function escapes everything.
SOLVED: Line break Issue - With the following input:
first
second
third
I get first second third being displayed with no line breaks. I understand this could be a markdown thing. Since I believe you need an empty line between paragraphs to get linebreaks in markdown. But having the above behaviour would be the most ideal, anyone know how to do this?
UPDATE Line break issue has been solved by adding an extra \n to my regex. So now I'm making sure that any line break will be represented with at least two \n characters (i.e. \n\n).
You should check the showdown docs and the wiki article they have on the topic.
The marked npm package, which is used by Telescope removes disallowed-tags. These include <script> of course. As the article I linked to above explains, there's still another problem with this:
<a href='javascript:alert("kidding! Im more the world domination kinda guy. Muhahahah")'>
click me for world peace!
</a>
Which isn't prevented by marked. I'd follow the advice of the author and use a HTML sanitation library. Like OWASP's ESAPI or Caja's html-sanitizer. Both of these project's seem outdated dough. I also found a showdown extension for it called showdown-xss-filter. So my advice is to write your own helper, and use showdown-xss-filter.

LyX: citation style author, year

I would like to use the citation style: author, year. Which configuration do I have to use? If I do \usepackage[comma]{natbib} it collides with the preferences where I can only chose between numerical and author-year.
It does not need to be natbib, I even prefer the Standard plain style, but simply would have author,year instead of [1].
Would be thankful for any help.
Maybe you'd like style authordate1, see here for sme examples: http://www.cs.stir.ac.uk/~kjt/software/latex/showbst.html
Nothing bibliography related has to be written to the preamble. Select natbib/plainnat and author-year in Documents -> Settings -> Bibliography. Then, right-click on inserted references and select desired citation style.

How to force line break in Symfony2 translation file

In my messages.en.yml I have an entry that is used for an email body which is in plaintext, so I cannot use any HTML tags. Now when I need a line break and I add a blank line after, the line break appears in my email body.
But when I try to do a line break with a non empty line following, it does not break the lines.
email:
subject: My Subject
message: >
Hello %name%,
This is my second line
Best regards,
John Smith
Customer Care
Arrives like this in my mailbox
Hello Tom,
This is my second line
Best regards, John Smith Customer Care
I've tried to play around with HTML tags or with the \n which I know from PHP. But if I use <br> or <br /> in the translation file and apply the |raw filter in my twig file, the HTML tags still appear in my email body. And also if I use \n to force a line break, no line break is given and instead, the \n appear in my email as well.
Now how can I force the line break if a non empty line is following?
Use |
email:
subject: My Subject
message: |
Hello %name%,
This is my second line
Best regards,
John Smith
Customer Care
In your translations file (e.g. messages.en.yml):
your
translation
key:
here: |
Lorem ipsum.
CRMPICCO.
www.crmpicco.co.uk.
Accessing it in your Twig template:
{{ 'your.translation.key.here'|trans|nl2br }}

Resources