Trying to add custom font to Sphinx-RTD-theme - python-sphinx

I am in process documenting my python library. I would like to add custom icons. I see I can add font awesome icons. However, I must not be googling very well or...
Is it possible to add custom icons to Sphinx(-rtd-theme)? If so, is there an example? I cannot find one. Thank you.

The closest thing I found was the sphinx-design package then using the avatars class with the {div} directive (Myst). e.g.:
:::{div}
<img src="images/whale_trace.png" class="sd-avatar-md sd-border-1">
:::
note: i use .md instead of .rst. Thus, I use the Myst parser. In order to copy the image over and use the right path, the conf.py file needs to be modified :
myst_enable_extensions = ["colon_fence", "html_image"]
adding html_image will all resolution of the image. See Myst documentation:
> Blockquote
HTML parsing to the rescue!
By adding "html_image" to myst_enable_extensions (in the sphinx conf.py configuration file), MySt-Parser will attempt to convert any isolated img tags (i.e. not wrapped in any other HTML) to the internal representation used in sphinx.
_

Related

How to remove modules not used in quilljs

We are using Quill for basic formatting (Bold, Italic, Link, BlockQuote). However Quill.min.js is the largest file that we've in our page.
We are looking to cut the size of the file by including the necessary modules only (for e.g. remove Syntax and Formula).
What is the way to get them removed? Do we need to setup the environment as described in Development page? Would it be possible to comment or remove the codes in quill.js? Appreciate any guidance
You can use quill.core.js and quill.core.css instead which will not have extra modules like Syntax and Formula. These files are not minified for you however. If you want to customize further then you will have to build Quill yourself.

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>
|=======================

how to use markdown and eco together?

I want to have a template variable pre-processed in a markdown doc.
I tried converting the filename to file.html.md.eco but it just comes out as plain text - ie the markdown plugin doesn't seem to get applied.
The file just as html.md renders fine.
Is it needed to add the plugins to the docpad.coffee to make sure they're applied when using multiple passes?
the FAQ states how to use multiple processors
http://docpad.org/docs/faq
... Alternatively, we can get pretty inventive and do something like this: .html.md.eco which means process this with Eco, then Markdown and finally render it as HTML.

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.

Resources