Get rmarkdown to completely ignore inline and/or block? - knitr

What I'd like to do:
I'd like to use rmarkdown to create rails *.html.erb files.
If you're unfamiliar with *.html.erb files, they're basically html files with ruby enclosed between <% and %> or between <%= and %> (latter if result should be included in final html rendering).
Problem:
I can not find a way to get rmarkdown to ignore <%, %>, <%= and everything between them.
Q: Any ideas how this might be done?
Thanks in advance.

Related

How to change title format for HTML files generated by doxygen?

I am trying to generate documentation from Matlab files like this
%> #file fooBar.m
%> #ingroup KEK
%> #brief Documentation file example.
Now title is this
fooBar.m File Reference
But I need this
fooBar Reference

Cannot export org mode to collapsible HTML

I am trying to have basic collapsing/folding functionality for sections in the HTML file that has been exported from org-mode, since the files I want to share are very large. I am using Emacs 26.2 (9.0) and Org 9.1.9 on a Mac.
This seems like a built in feature, but I haven't seen any effect from adding #+INFOJS_OPT commands to my org files before exporting to HTML. I also saw another tool mentioned on the mailing lists, but without any examples I don't know how apply it to a specific org file I have.
For example, the following file is converted to HTML which looks identical to the same file without the INFOJS_OPT lines
#+Title+: JS test
#+INFOJS_OPT: path:js/org-info.js
#+INFOJS_OPT: toc:nil ltoc:nil view:overview mouse:underline
#+INFOJS_OPT: home:https://orgmode.org buttons:nil
* Chapter 1
** Section 1
*** Part 1
- csp
** Section 2
- cs2p
I have a freshly-downloaded copy of js/org-info.js.
There is a slight difference in the HTML generated, but this seems to have no effect. I'm at a loss for how I can have folding in the resulting HTML - open to solutions even outside of org-info.js.
Seems that org-info.js is not maintained anymore. Here they provide the source code in JavaScript, for anyone willing to tweak/update it.
https://lists.gnu.org/r/emacs-orgmode/2017-07/msg00049.html
Luckily someone updated it (thanks Daniel Clemente!).
The procedure is:
Download esquemadorg.js at the following link: https://www.danielclemente.com/pagina/esquemadorg.js
Add the following lines at the top of your .org file
#+HTML_HEAD_EXTRA: <script type="text/javascript" src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
#+HTML_HEAD_EXTRA: <script type="text/javascript" src="esquemadorg.js"></script>
Make sure that src="esquemadorg.js" points at the file relative to where the html exported file is located.
Some text in Spanish (or Portuguese?) will appear on the exported document. You can do a full search in the esquemadorg.js file and change it to English. Mine looks like this now.
par.append(document.createTextNode("Press on a section header to collaps/expand it."));
par.append( $( document.createElement('a') ).text(" COLLAPSE ALL ").addClass("globalexpandtool").click(close_all_sections));
par.append( $( document.createElement('a') ).text(" SHOW ALL ").addClass("globalexpandtool").click(open_all_sections));
$("div#table-of-contents").after(par);

How can I get github to display inline math in README.org file

I have tried numerous HTML preambles such as the following minimal example:
#+TITLE: Some math stuff
#+BEGIN_HTML
<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
#+END_HTML
=(solve a b)= should return $X$, from $AX=B$
The inline math works on my desktop if I export to HTML and view in my browser, but does not seem to be rendered in Github where the dollar signs are just echoed in the output.
Any idea on how to get Github to render inline math? Please note the answer to this question on how to do the same with README.md doesn't help as markdown is dissimilar to the much more featureful org mode.
EDIT: I have now learned how Github processes the .org file using github/markup which in turn uses org-ruby to parse the file. It appears that code blocks with #+BeginSrc etc are parsed very well but not the preamble lines or the inline math---though I have not really confirmed this yet.
#david This is the partial but hopefully relevant source from my webpage:
README.org
<article class="markdown-body entry-content" itemprop="mainContentOfPage"><h1><a id="user-content-some-math-stuff" class="anchor" href="#some-math-stuff" aria-hidden="true"><span class="octicon octicon-link"></span></a>Some math stuff</h1>
<p><code>(solve a b)</code> should return $X$, from $AX=B$</p>
</article>
</div>
Edit 2:
Signal for #VonC in the comments: GitHub supports Latex/MathJax since May 2022
https://github.com/github/markup/issues/274 seems to indicate that it's not currently possible. The issue was closed with no resolution.

How to do strikethrough in a reStructuredText file hosted on GitHub?

I am converting a README.md file to README.rst. The reason is, I am going to make a package available to PyPi. I am forced to use .rst.
My conversion is nearly complete, but I have a strikethrough line in my markdown file, e.g.:
~~This text is crossed out~~
which renders on GitHub as crossed out. But I am unable to do this in reStructuredText. A similar post on StackOverflow suggests defining a strike like this:
.. role:: strike
:class: strike
And using something like this in the CSS file:
.strike {
text-decoration: line-through;
}
And do strikethrough like this:
:strike:`This text is crossed out`
But the problem is I have no control over CSS file of GitHub.
You can also use substitutions to make multiple uses easier. Put this markup somewhere in your file:
.. |ss| raw:: html
<strike>
.. |se| raw:: html
</strike>
Then just enclose the text to be struck out with |ss| & |se|:
One, |ss| two |se|, three |ss| strikes |se| you're out!
will render as:
One, two , three strikes you're out!
Just be sure to have space around the substitution elements, so they are parsed correctly. It looks a bit awkward here, but this is a contrived example.
Not so clean solution, but works for me.
.. raw:: html
<s>
This text is crossed out
.. raw:: html
</s>
This is not possible right now as the Markdown equivalent is top level GitHub Flavored Markdown syntax, whereas with the RST it is a document-specific style. On GitHub's repository rendering, there are currently no CSS additions permitted.
Or you can use https://www.thefancytext.com/strikethrough-text-generator.
S̶t̶r̶i̶k̶e̶o̶u̶t̶
Ain't fancy, but if you copy and paste it in your editor, pandoc should take it.

Can I embed a custom title in a perlpod document?

When writing perlpod documentation that will be exported to HTML, can I embed the title of the resulting HTML file in the POD directives?
I want to be able to convert multiple POD text files to HTML with the pod2html command, and don't want to have to give the --title="My Title" parameter on the command-line.
For example, here is a text file with perlpod formatting:
=pod
=head1 This is a heading
This is some text. I'd like to set the title of this document in the resulting HTML file.
=cut
When I convert it to HTML, pod2html gives a warning about there being no title:
$ pod2html test.txt > test.html
/usr/bin/pod2html: no title for test.txt
In the resulting HTML file, the title is set to the filename (test.txt):
<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>test.txt</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:root#localhost" />
</head>
<body style="background-color: white">
<p><a name="__index__"></a></p>
<!-- INDEX BEGIN -->
<ul>
<li>This is a heading.</li>
</ul>
<!-- INDEX END -->
<hr />
<p>
</p>
<hr />
<h1><a name="this_is_a_heading_">This is a heading.</a></h1>
<p>This is some text. I'd like to set the title of this document.</p>
</body>
</html>
I'd like to find a way to have the title given in the perpod document, perhaps with a directive like this:
=title This is my custom title
In the Perl documentation, I see that the document titles are set nicely. Is this all done without having the document title in the pod document itself?
There is nothing in the Pod documentation that controls the title of the document. This up to the program that converts the Pod documentation to the format you want. Most of the pod2doc programs that you use to generate the documentation will have a module like Pod::Text or Pod::Html. These do most of the grunt work in converting.
pod2html takes a --title parameter. However, what you want is for pod2html to do it without you having to specify it. What you can do is roll your own version of pod2html. Let's look at pod2html script itself, and maybe you can figure out what you can do to get what you want.
Removing all the POD document, I see::
use Pod::Html
pod2html #ARGV
That's the entire program.
It looks like you could make a pod2steve program to do what you want. You want to take the last parameter (which I assume is what you want the title to be), and simply pass it through the pod2html subroutine. Your pod2steve would look something like this:
use strict;
use warnings;
use Pod::Html
my $program_name = $ARGV[$#ARGV];
pod2html --title=$program_name #ARGV
That should work.
No.
POD exists mainly¹ to write Perl module documentation², and therefore doesn't have many fancy features. Also, the primary output medium for POD is the terminal, where no such thing as a title exists conceptially³. It is, after all, just Plain and Old documentation.
    1. Suprisingly many Perl books are written in POD.
    2. The location of the POD document coincides with the thing discussed in the text.
    3. The ps name / $0 variable comes close, but is useless here.
This is also a technical problem: pod2html uses Pod::Html, which parses the command line, and wraps itself around Pod::Simple::XHTML or something, without doing, or interfering with, the actual parsing. However, it already supplies a header and a footer, which sensibly overrides any default headers that might be emitted.
There are two interesting options how your problem can be solved:
You write a postprocessor that puts the value of the first h1 into the title. This should be <10 lines in a parser with XPath-support. Then you write a little script that ties these together, and can be invoked instead of pod2html.
You take the existing wealth of POD parsers (and source code), and whip up your own HTML from POD generator. If all you are actually doing is a small fork, you could try to offer the modification to the original module.