How to stop R Markdown from converting LaTeX to odt/word formulae? - r-markdown

I use R Markdown to write some statistical analysis reports that then need to be modified in LibreOffice (or Word). I use a library (papaja) that is extremely useful but forces me to use LaTeX that Pandoc then converts to formulae. I don't want it to be converted. The only thing I want to preserve form LaTeX formatting is italic for letters. That's exactly what I get when I use rtf_document as my output format – LaTeX letters are converted to italic, numbers to regular text. Is there a way to stop Pandoc from converting LaTeX to formulae when using odt_document or word_document as output? A work-around is to use rtf_document and then convert it to .odt with LibreOffice.
Example:
---
output: odt_document
---
The model fits the data ($F(3, 596) = 13.19$, $p < .001$).
What I get:
What I want to get:

Related

Rendering non-ascii characters from R markdown (Rmd) to both HTML and PDF

I'm writing a R markdown document that I wish to be able to render as HTML and as PDF. It includes some special characters, for instance λ, which I wish to appear in plain text (as it does here).
Typing λ or simply pasting λ into the markdown works in HTML, but is rendered invisible in the PDF. $\lambda$ looks good in the PDF, but is rendered unpredictably in HTML, either in a separate font with a different line height or as an image that cannot be copied as text.
There are a number of cases where I wish to include symbols, so I'd rather avoid a complicated if-else statement predicated on the output format.
Is there a simple way to consistently render special characters in the document's default font, regardless of output format?

What is the Markdown equivalent to LaTeX's description environment?

Is there a Markdown equivalent to LaTeX's description environment? This gives an author the ability to generate lists where the first word is boldfaced, like this:
The LaTeX source would be:
\begin{description}
\item[First] The first item
\item[Second] The second item
\item[Third] The third etc \ldots
\end{description}
I'd like to replicate this in Markdown so that if I run the Markdown through a tool such as pandoc I will get similar results.
Markdown isn't as comprehensive as LaTeX, or even HTML:
Markdown’s syntax is intended for one purpose: to be used as a format for writing for the web.
Markdown is not a replacement for HTML, or even close to it. Its syntax is very small, corresponding only to a very small subset of HTML tags.
It supports bulleted and numbered lists, but not defiition lists.
However, you mention using "a tool such as pandoc" to process your input file. Pandoc supports inline LaTeX using the raw_tex extension:
Extension: raw_tex
In addition to raw HTML, pandoc allows raw LaTeX, TeX, and ConTeXt to be included in a document. Inline TeX commands will be preserved and passed unchanged to the LaTeX and ConTeXt writers. Thus, for example, you can use LaTeX to include BibTeX citations:
This result was proved in \cite{jones.1967}.
Note that in LaTeX environments, like
\begin{tabular}{|l|l|}\hline
Age & Frequency \\ \hline
18--25 & 15 \\
26--35 & 33 \\
36--45 & 22 \\ \hline
\end{tabular}
the material between the begin and end tags will be interpreted as raw LaTeX, not as markdown.
Inline LaTeX is ignored in output formats other than Markdown, LaTeX, and ConTeXt.
So simply including your LaTeX description environment and running Pandoc with the raw_tex extension should give you the result you want.
You may have to specify the source format manually, e.g. by using something like -f markdown_strict+raw_tex in your command.
If you are using the latest version of Pandoc (ver 2.0+), you can use the definition lists notation, as shown below. This would be much easier.
First
: The first item
Second
: The second item
Third
: The third etc

Classic ASP: encoding text outside tags with regex

I'm in the need of a function that could process a string and replace textual parts with html encoded ones:
Sample 1
Input: "<span>Total amount:<br>€ 50,00</span>"
Output: "<span>Total amount:<br>€ 50,00</span>"
Sample 2
Input: "<span>When threshold > x<br>act as described below:</span>"
Output: "<span>When threshold > x<br>act as described below:</span>"
These are simplified cases of course, and yes, I know I could do that by a series of replace on each specific char I need to encode, but I'd rather have a function that can recognize and skip HTML tags using Regex and perform a Server.HTMLEncode on the textual part of the input string.
Any help will be highly appreciated.
I'm not sure why you'd want to do this. Why don't you just pass the innerHTML into your parser using javascript and have Javascript create your span tag? Then you can encode the entire thing. I'd be worried that the encoding here won't have any added security for your application if that's what you are trying to do.

Convert Scientific notation to text or integer using regex in Notepad++

I am looking to convert a scientific notation number into the full integer number.
E.g:
8.18234E+11 => 818234011668
Excel reformatted all my upc codes within a csv and this solution is not working for me.
I have my csv open in Notepad++ and would love to do this using a regex find and replace.
Thanks.
The damage is already done and cannot be recovered from the CSV file. 8.18234E+11 could be anything* from 818233500000 to 818234499999.
To prevent Excel from rounding large numbers, you need to store them as text. If you set the cell format to text, any value inserted from then on should be automatically interpreted as text. In OpenOffice Calc (I don't have MS Excel), you can also prefix a numeric value with ' to get it interpreted as text no matter the cell format.
There is a chance that the correct value is stored in the original XLS (or XSLX or ODS or the live Excel session or ...) file. If not, then you'll have to enter the data again. If the data is there, you need to store it as text or increase the number of significant digits in the exported CSV. If you only have the exported data, then you're out of luck.
*UPC has a single check digit, so only 100 000 out of the 1 000 000 codes are actually valid UPC codes.

Replacing special characters from HTML source

I'm new to HTML coding and I know HTML has some reserved characters for its use and it also displays some characters by their character code. For example -:
Œ is Œ
© is ©
® is ®
I have the HTML source in std::string. how can i decipher them into their actual form and replace from std::string? is there any library with source available or can it be done using macros preprocessors?
I would recommend using some HTML/XML parser that can automatically do the conversion for you. Parsing HTML correctly by hand is extremely difficult. If you insist on doing it yourself, Boost String Algorithms library provides useful replacement functions.
Œ is Œ
No it isn't. Œ is 'PARTIAL LINE BACKWARD'. The correct numeric entities for Œ are Œ and Œ.
One method for the numeric entities would be to use a regular expression like &#([0-9]+);, grab the numeric value and convert it to the ASCII character (probably with sprintf in C++).
For the named entities you would need to build a mapping. You could probably do a simple string replace to convert to the numbers, then use the method above. W3C has a table here: http://www.w3.org/TR/WD-html40-970708/sgml/entities.html
But if you're trying to read or parse a bunch of HTML in a string, you should use an HTML parser. Search for the many questions on SO.