Is there any way to include formatting in the sphinx_toolbox.collapse extension's collapse block? - python-sphinx

This question is about https://sphinx-toolbox.readthedocs.io/en/latest/extensions/collapse.html.
I need to make individual words bold or italic. I've tried surrounding the text with asterisks, but they aren't processed. I've tried creating custom roles such as :bold: and :italic:, but they aren't processed either. Is there any way to do this?
EDIT: Specifically, I have tried both this:
.. collapse:: **id**: *String*
And this:
.. role:: bold
:class: bold
.. role:: italic
:class: italic
.. collapse:: :bold:`id` :italic:`String`
In both cases, the text of the collapse string was output entirely literally, asterisks and fancy-quotes and all.

Related

Why does text turn grey when editing a document in R Markdown?

On occasion, starting paragraphs with excess spaces in R Markdown/RStudio changes the text color from the color I expect to grey. This behavior isn't consistent, and it doesn't affect the output in any appreciable way. Does anyone know what's happening?
On my machine the second **Response** is grey, and all others are blue.
---
title: "Untitled"
author: "Unnamed"
date: "6/1/2018"
output: pdf_document
---
**Response**
**Response**
**Response**
**Response**
As far as I can tell, everything about the conditions in the two examples is the same.
If you process your document you will see something like this:
The empty line plus before the second "Response" together with the indentation makes markdown interpret this as code. In RStudio code sections are shown with a grey font. In the PDF output, a fixed width font is used and the ** are treated literally instead of interpreted as commands for bold.
Since there is no empty line between the third and the forth "Response", these are treated as one paragraph, making the indentation irrelevant.
Solution: Do not indent text but only code.

Bold code in rst

How can I get code (monospace) text that is bold in rst (I'm using Sphinx)? Anything in :: seems to be rendered literally, as with ``, so ``**bold**`` doesn't work.
In general, nested inline markup is not possible in reStructuredText. There are more or less ugly workarounds, such as using raw HTML. Like this:
.. raw:: html
<div>Some stuff <pre>some <b>bold</b> text</pre>...</div>
Actually using raw for code is a very bad thing to do as it ignores the beautiful Pygments highlighting and complicates things to extreme. First thing to do is to play with different Pygments highlighting styles. You can find a functional demo here. Then you may set the appropriate highlighting in conf.py. If none of the styles make the desired part of your code bold, you may consider creating your own Pygments theme, which is unfamiliar territory for me, but shouldn't be that hard.
There is third thing to try though, you could look up the class of the word you need to highlight and add a rule to your CSS. Pygments produce this seemingly gibberish classes like nv, ls, etc for every type of the highlighted words. But keep in mind, that every instance of this type will be highlighted. If your chosen word is a class definition - all class definitions will be highlighted.
Only if none of these options apply should you consider using something as atrocious as raw, because every time someone uses raw, Sphinx dies a little. Do you really want Sphinx to die?
Most likely restructured text does not support formatting options you are asking for.
However you are free to add your own :: admonition directives which have custom CSS styling over them.
Example for a custom block and CSS styling. RST:
.. admonition:: foobar
My custom text here
CSS:
.admonition-foobar {
font-weight: bold;
}

Text Extraction with bold and italics identification

I want to extract text from pdf with bold and italics identifiction. for example bold letters need t be extracted like this.<b>TEST</b> and italics must be enclosed like <i> test </i>
Currently i am using texttopdf.exe to extract text..the accuracy was good.but not able to identify bold italics.
any one have another idea or the same pdftoexe having the feature?
Thanks in Advance

Convert markdown backticks to asciidoc

I'm switching over from markdown to asciidoc and have a question. In my markdown file, I use backticks to indicate code font (foo.bar()). When this is converted to html, the text gets placed inside code blocks (foo.bar()).
How should I format a text fragment in asciidoc if I want it to appear within code blocks when the document is converted to html?
Late and short answer:
You can use backticks just like in Markdown.
From the AsciiDoc User manual:
Monospaced text
Word phrases +enclosed in plus characters+ are rendered in a monospaced font. Word phrases `enclosed in backtick characters` (grave accents) are also rendered in a monospaced font but in this case the enclosed text is rendered literally and is not subject to further expansion
As you can see here, you can use `foo.bar()` the same way in asciidoc.
Here's an example of that:
* Utilizar as funções `fgetc` ou `getc` para ler carácteres (...);

Syntax Highlighting for plain text (Sublime Text)

I am a great fan of syntax highlighting in any form. But i am missing something similar for plain text files. Imagine different colors for indented lines or lines preceded by special chars. Does anything like that already exist? I'd especially appreciate a plugin for Sublime Text.
The closest thing I know of is the PlainTasks plugin:
It's a plugin to make styled TODO lists, but what you see in the screenshot is basically it.
You could modify the Markdown or reStructuredText files to actually color the text.

Resources