Syntax-highlighting for ##-comments in knitr not working as expected - syntax-highlighting

I am using knitr and RStudioto create a report mainly consisting of R code. I want to use headers in the code to structure the text, example
## First part
##############
When I compile a notebookto PDF then
# comment
is syntax-highlighted/ printed in the PDF in some textcolor for comments.
However, if I compile this to PDF, then
## comment
will not be syntax-highlighted. See the example:
I would like to have ##type comments syntax-highlighted in PDFs. However, when I knit to HTML, ##type comments are syntax-highlighted.
What am I missing here? How can I turn on syntax-highlighted for ##comments in PDFs?
Any help is appreciated! Thanks,
Sebastian

Related

How can I the image start from a new line when using dita-ot-3.0 pdf plug outputting PDF?

hope someone to help me, thanks!
When I use dita-ot-3.0 to output pdf, I find in many places, the images are displayed in the same line with text.
I try two plugins:
- default pdf2 plugin
- a customization pdf plugin using PDF Plugin Generator at https://github.com/jelovirt/dita-generator (I didnot find any place to set image attribute)
So here is my question, I write xml like this:
source xml file
When I output pdf, I get this:
image is shown in the same line with text
there are many other images showing like that. How can I make the image show starting from a new line? Am I misusing the element? Is the difference between inline element or block?
You should be able to do this by setting the attribute placement="break" to the <image> element. This is explained in the spec.

How to avoid img size tags on markdown when converting docx to markdown?

I'm converting docx files using pandoc 1.16.0.2 and everything works great except right after each image, the size attributes are showing as text in teh
![](./media/media/image4.png){width="3.266949912510936in"
height="2.141852580927384in"}
So it shows the image fine in the md but also the size tag as plain text right behind/after/below each image. The command I'm using is:
pandoc --extract-media ./media2 -s word.docx markdown -o exm_word2.md
I've read the manual as best I can but don’t see any flags to use to control this. Also most searches are coming up where people want to have the attributes and control them.
Any suggestions to kill the size attributes or is my markdown app (MarkdownPad2 - v-2.5.x) reading this md wrong?
Use -w gfm as argument in the command line to omit the dimensional of Images.
You could write a filter to do this. You'll need to install panflute. Save this as remove_img_size.py:
import panflute as pf
def change_md_link(elem, doc):
if isinstance(elem, pf.Image):
elem.attributes.pop('width', None)
elem.attributes.pop('height', None)
return elem
if __name__ == "__main__":
pf.run_filter(change_md_link)
Then compile with
pandoc word.docx -F remove_img_size.py -o exm_word2.md
There are two ways to do this: either remove all image attributes with a Lua filter or choose an output format that doesn't support attributes on images.
Output format
The easiest (and most standard-compliant) method is to convert to commonmark. However, CommonMark allows raw HTML snippets, so pandoc tries to be helpful and creates an HTML <img> element for images with attributes. We can prevent that by disabling the raw_html format extension:
pandoc --to=commonmark-raw_html ...
If you intend to publish the document on GitHub, then GitHub Flavored Markdown (gfm) is a good choice.
pandoc --to=gfm-raw_html ...
For pandoc's Markdown, we have to also disable the link_attributes extension:
pandoc --to=markdown-raw_html-link_attributes ...
This last method is the only one that works with older (pre 2.0) pandoc version; all other suggestions here require newer versions.
Lua filter
The filter is straight-forward, it simply removes all attributes from all images
function Image (img)
img.attr = pandoc.Attr{}
return img
end
To apply the filter, we need to save the above into a file no-img-attr.lua and pass that file to pandoc with
pandoc --lua-filter=no-img-attr.lua ...

Prevent asciidoc from converting a file path into a link

I'm manually converting a MS Word document to asciidoc format.
By doing so I ran into an issue that I can't work around yet.
There is an example where I want to show the reader of how the syntax of a file link should look like.
So I used this as an example:
file:///<Path>/<to>/<Keytab>
Asciidoc now renders this pseudo link into an actual link and warns me about this while converting my asciidoc document into HTML and PDF.
Usually, I would simply use the [source] element to prevent the link rendering. But the file link is part of a table.
[options="header,footer",cols="15%,85%"]
|=======================
|parameter|usage
|keyTabLocation |file:///<Path>/<to>/<Keytab>
|=======================
Is there a way to prevent the rendering/convertion of the file link?
Okay, I found the solution. I had to escape the whole macro using a \ at the beginning.
So this did the trick:
[options="header,footer",cols="15%,85%"]
|=======================
|parameter|usage
|keyTabLocation |\file:///<Path>/<to>/<Keytab>
|=======================

Sphinx & reStructuredText : how to link an image to a document page

In the RST syntax, you can specify a :target: attribute for setting a link. I would like to link the image to a "materials.rst" doc page, whose main section title is "Materials"
But neither of these work as target value:
:target: `materials`_
:target: :doc: materials
:target: materials
How can I achieve this?
Not fixed even after 6 years, although :ref: works now across files just fine. However, you can't use :ref: within image or figure directives.
try using this:
:target: materials.html
...and hope for the best! The :target: role seems to accept HTML links only.
Let's assume there is some file named doc.rst which I want to access via the thumbnail in another document:
.. _doc:
Some Title
==========
...and then, in another document, I use the following solutions:
.. image:: /media/thumbnail_of_my_doc.jpg
:ref:`doc` <- doesn't compute
:target: doc (or doc.rst, or doc_) <- doesn't work either
:target: doc.html <- works im my case
The last option works just because I assumed the name of the HTML to be generated. What if I was wrong? This is a pure hack.
I can't believe no one got bothered to fix this.
I use RTD theme on Sphinx 4.2.0. all is updated to the newest versions.

How to change default comment color in vs2010

Tool/Options/Environment/Fonts and Colors
I have problems to find which color display item I should change in order to change the default color for triple slash comments:
/// code here
Now, I am able to change color display item for the standard single line comments like
// code here.
Any tips?
Thank you
Finally, I found the solution as follows:
Options/Environment/Fonts and Colors/XML Doc Comments
There are several comments types that you can change, I just ran through all of my settings and outputting what matched my styles so it may be overkill, but it is the exhaustive list. I like all of my comments to appear the same so I change them all at once.
Comment
CSS Comment
HTML Comment
VB Xml Comment
VB XML Doc Comment
VB Xml Doc Tag
VB Script Comment
XAML Comment
XML Comment
XML Doc Comment
XML Doc Tag
In the Fonts and Colors menu you mentioned, you want to change the XML Doc Tag display item. You can change the other XML properties there to further customize the attributes within the triple slash comment.

Resources