Pandoc highlighting theme - pandoc

I'm trying to generate a highlighting theme for my site created with pandoc framework.
I followed this guide : guide
I create my theme this way:
pandoc --print-highlight-style breezedark > my_style.theme
and then I add it to my command like this:
pandoc ..\articles\$_
-f markdown
-t html --template=..\template\article.html
--defaults=..\defaults\params_$($_.BaseName).yaml
--highlight-style my_style.theme <-------------------
--output ..\articles\$($_.BaseName).html
The problem is that when I go to fill it out, I get this error back, and the code doesn't get colored:
Could not read highlighting theme my_style.theme
What's the problem?
EDIT:
i try adding this:
--highlight-style=breezedark
but my code doesn't get colored in html view..
i try this:
```bash
java -version
```
~~~bash
java -version
~~~
This is the source code of html:
<div class="sourceCode" id="cb2">
<pre class="sourceCode bash">
<code class="sourceCode bash">
<span id="cb2-1">
<span class="ex">java</span> -version</span>
</code>
</pre>
</div>
<div class="sourceCode" id="cb3">
<pre class="sourceCode python">
<code class="sourceCode python">
<span id="cb3-1">
<span class="bu">print</span>(<span class="st">"Hello, world!"</span>)
</span>
</code>
</pre>
</div>

The reason is the encoding of file. By default, the theme file output by pandoc is UTF-16 LE (seen from vscode). Saving the file with encoding UTF-8 will help.

I encountered the same problem. I wrote color names in the theme file such as chartreuse and crimson. This was the reason of the failure: one has to enter the hex codes of the colors.

Related

How to right-align text in markdown code block?

I have the following markdown code
<pre>
┣━━ 📦 t_databases - this is text
┃ ┗━━ MongoDB-Go.md - this is text
┗━━ t_webdev
┣━━ editor-Swagger.md
┗━━ packages-Go.md
┗━━ MongoDB-Go.md
</pre>
This looks like this:
How can I make this is text perfectly in line? Is there a programmatic way? Doens't seem to work if I just use tab key.

tooltip in dot (graphviz)

I have the following graphviz file:
digraph ServerDependency {
Server02 -> Server01 [tooltip="Database"];
Server02 -> Server06 [tooltip="Images"];
}
dot -Timap -oserverdependency.map -Tgif -oserverdependency.gif serverdependency.gv
Then I have a html file that looks like this:
<html>
<head>
</head>
<body>
<IMG SRC="serverdependency.gif" ismap="ismap"/>
</body>
</html>
Based on the name tooltip I would expect to hover over the node and see the text, but I don't.
How can I change the command or html to actually be able to hover over the node to see the tooltip.
I am following the example at this URL about 1/3 down the page:
https://www.graphviz.org/doc/info/output.html
It looks like you are trying to output to a .map and .gif format. I am unsure about .map but .gif doesn't support tooltop as the image doesn't support a hover over type.
Try outputting to .svg as well and opening this in a browser.
dot -Timap -oserverdependency.map -Tgif -oserverdependency.gif -Tsvg -oserverdependency.svg serverdependency.gv

pandoc generate InvalidUrlException when the link contains full path file

Pandoc is a great tool to transform files from one format to another. Among all the diverse functions it provides, one interesting function is to generate self-contained portable HTML file. This function is very useful when you want to share your HTML files with your colleagues. However, when the link contains full path file. For example, the html file original.html contains the following HTML items:
<a href="file:///media/distribution/file_num.png" target="_blank" />
<img src="file:///media/distribution/file_num.png" /></a>
When I use pandoc original.html --self-contained -o transformed.html to generate a portable HTML file, the following error message is given:
pandoc: Could not fetch file:///media/distribution/file_num.png
InvalidUrlException"file:///media/distribution/file_num.png" "Invalid scheme".
Any ideas? Thanks.
EDIT:
I also tried to use pypandoc,
output=pypandoc.convert_file('data.html','html',outputfile="ddd.html",extra_args=['--self-contained'])
but the same error happens:
'Pandoc died with exitcode "%s" during conversion: %s' % (p.returncode, stderr)
RuntimeError: Pandoc died with exitcode "61" during conversion:

Pandoc: [WARNING] Could not convert TeX math

I tried to convert html to docx by using Pandoc:
here is my html code:
<p> Example: ${v_1} = {\rm{ }}{v_2}$</p>
with MathJax config in head:
MathJax.Hub.Config({
extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
jax: ["input/TeX", "output/HTML-CSS"],
tex2jax: {
inlineMath: [['$', '$'], ["\(", "\)"]],
displayMath: [['$$', '$$'], ["\[", "\]"]],
},
"HTML-CSS": {availableFonts: ["TeX"]}
});
Pandoc command that i used (Pandoc version 2.2.3.2):
pandoc -s test.html --mathjax -f html+tex_math_dollars --pdf-engine=xelatex -o xxx.docx
then i got a warning:
[WARNING] Could not convert TeX math '{v_1} = {\rm{ }}{v_2}', rendering as TeX:
{v_1} = {\rm{ }}{v_2}
^
unexpected "{"
expecting "%", "\\label", "\\nonumber" or whitespace
Someone please tell me how to fix this. Thanks!
Use the LaTeX \textrm instead of the plain tex \rm, and pandoc will be able to handle it.
Since 7k users have viewed this question since it was asked... perhaps others have made the same mistake I made as a novice RStudio user.
The first comment in both the README.md and the README.Rmd file is
<!-- README.md is generated from README.Rmd. Please edit that file -->
The intended meaning is (at least arguably) apparent if you pay sufficient attention to the this/that relative pronouns!
<!-- You should edit the README.Rmd file, not the README.md file -->
To repair the damage... I'm currently trying the suggestion to use an explicit devtools::build_readme() which I found in RStudio README.Rmd and README.md should be both staged use 'git commit --no-verify' to override this check
No luck yet ... but I feel like I'm (finally!) making forward progress on getting $\sqrt{x}$ to display properly in my github README!

use pandoc to embed images into a docx file that are in a HTML

Is it possible to embed images into a docx file that are embedded in a HTML file?
I am trying and it's not working for me, and perhaps I am not adding some extra parameter when I am running pandoc.
pandoc -f html -t docx -o testdoc.docx image.html
Thank you very much!
I managed to solve this by executing the following command:
pandoc -s file_name.html -o file_name.docx;
There are actually 2 important points that you need to consider:
The quality of the output file is pretty much related to how pandoc interpret your HTML file, so that if the source was pretty complex then you wouldn't really expect a pretty good quality output, for instance the <hr/> tag is not recognized by pandoc, while the <p> tag is.
The path of the image is not an HTTP path but instead it is a full desk path, meaning:
This is NO good:
<img src="http://www.example.com/images/img.jpg" />
And This is what pandoc can really read:
<img src="/var/www/example.com/images/img.jpg" />
HTH

Resources