emacs org-mode \label in html export - emacs

I would like to export an org-mode file with labelled latex formulas inside it to HTML without having the \label{eq:1} in the output. Do you know how to do this?

You can try something like this (assuming you are using org-ref https://github.com/jkitchin/org-ref) which exports the ref link to html:
* equations in html
See ref:eq-1.
#+BEGIN_HTML
<div id="eq-1">
#+END_HTML
\begin{equation}
e^x = 4
\end{equation}
This exports to something like:
<div id="eq-1">
\begin{equation}
e^x = 4
\end{equation}
<p>
See eq-1.
</p>

You can likely hide that using CSS, like so:
.figure-number {
display: none;
}

Related

How to customize color, size, and font of emacs inline code

I used to use markdown all the time. Now I use emacs org-mode for everything ("this koolaid tastes good"). One piece that kept driving me nuts was the ability to use backticks for inline code in emacs.
Everything I read wanted me to use easy templates for source code like this:
#+BEGIN_SRC
Just add: " < " + one of the letters below
s #+BEGIN_SRC ... #+END_SRC
e #+BEGIN_EXAMPLE ... #+END_EXAMPLE
q #+BEGIN_QUOTE ... #+END_QUOTE
v #+BEGIN_VERSE ... #+END_VERSE
c #+BEGIN_CENTER ... #+END_CENTER
l #+BEGIN_LaTeX ... #+END_LaTeX
L #+LaTeX:
h #+BEGIN_HTML ... #+END_HTML
H #+HTML:
a #+BEGIN_ASCII ... #+END_ASCII
A #+ASCII:
i #+INDEX: line
I #+INCLUDE: line
#+END_SRC
Then I stumbled onto the post by Mr. Abrams: Exporting inline code to html in org-mode. I just need to use =code= instead of 'code' for emacs inline quotes? OK. Why isn't this noted somewhere simple in the months worth of docs I've been perusing!? (It probably is!)
Now of course, I want to know how to customize the color, font, and size of these inline code snippets in emacs. The default size is too small and there is no subtle background color like with markdown.
Thank you
I believe Org Mode exports your current color theme. To verify that, you can change the colour scheme of your emacs and re-export your buffer to see if things change.
As for myself, I set org-html-htmlize-output-type to css and org-html-head to the following:
<link rel="stylesheet" type="text/css" href="path/to/my.css" />
This way, I can tune the css as I want regardless the colour theme of my emacs.
Below please see the help of org-html-htmlize-output-type:
org-html-htmlize-output-type is a variable defined in ‘ox-html.el’. Its value is ‘css’ Original value was inline-css
Documentation: Output type to be used by htmlize when formatting code snippets. Choices are ‘css’ to export the CSS selectors only,‘inline-css’ to export the CSS attribute values inline in the HTML or ‘nil’ to export plain text. We use as default ‘inline-css’, in order to make the resulting HTML self-containing.
…
To get a start for your css file, start Emacs session and make sure that all the faces you are interested in are defined, for example by loading files in all modes you want. Then, use the command ‘M-x org-html-htmlize-generate-css’ to extract class definitions.
You can customize this variable.
EDIT
Please put the following to your init.el, restart emacs and retry to see if it works:
(setq org-html-htmlize-output-type 'css)
(setq-default org-html-head "<link rel=\"stylesheet\" .../>")
I just need to use =code= instead of 'code' for emacs inline quotes?
I think this is because you didn't go through the manual carefully. Monospace is described in 11.2 Emphasis and Monospace
You can make words ‘bold’, ‘/italic/’, ‘underlined’, ‘=verbatim=’ and ‘~code~
If you want to represent a code block, you can use #+BEGIN_SRC and #+END_SRC pair.
#+BEGIN_SRC emacs-lisp
(defun org-xor (a b)
"Exclusive or."
(if a (not b) b))
#+END_SRC
As you have mentioned in your question description, you can type <s and TAB for auto completion.
I want to know how to customize the color, font, and size of these inline code snippets in emacs.
There are two levels to set font in org.
Change the font on a document-wide level
Add below #+HTML_HEAD_EXTRA: to the begin of your org file.
#+HTML_HEAD_EXTRA: <style>*{font-family:Arial,'Times New Roman','Microsoft YaHei',SimHei; font-size: 20px; font-style: italic; !important}</style>
#Lungang Fang gives you another way to place CSS.
Change the font size locally
#+BEGIN_EXPORT html
<p style="font-family:Monospace; font-size: 30px; font-style: italic;">
This is a customized line.
</p>
#+END_EXPORT
To customize the style of a block mentioned in your quetion description, you can see my other answer.

markdown: HTML block level tags wrapped by <p>

I'm using markdown.pl downloaded from directly from Darring Fireball to translate .md files into html.
I start the file with some block level html, then followed by markdown syntax
<div class="header">title</div>
# header
markdown keeps wrap the <div> class with <p> tags, producing:
<p><div class="header">title</div></p>
<h1>header</h1>
If I start the file with a newline, before the html block level tag, an empty will be produced
<p></p>
<div class="header">title</div>
<h1>header</h1>
I want to know how to stop markdown from wrapping my block-level HTML tags with <p>s.
That code is not maintained because Gruber don't care. ¹ ²
Use Text-Markdown Markdown.pl instead, it works like you expect it to.

How to display HTML content in github README.md?

I am new to github, in README.md want to display a HTML content using an Iframe or something is this possible ?
What I have tried is I just create HTML tags other then anchor, that is not working.
Github's markdown interpreter can include HTML. However, there is only so much you can do in HTML. I would suggest checking out this article which provides more information on what tags can be used. Personally, I have never used much more than line-breaks, horizontal rules, etc... Unfortunately, I don't see Iframes mentioned in the article.
As answered by mjgpy3, you can include html - no <html> tags needed, but it'll be sanitized before display and the only tags allowed are in this whitelist.
The list currently includes:
h1 h2 h3 h4 h5 h6 h7 h8 br b i strong em a pre code img tt div ins del sup sub p ol ul table thead tbody tfoot blockquote dl dt dd kbd q samp var hr ruby rt rp li tr td th s strike summary details caption figure figcaption abbr bdo cite dfn mark small span time wbr
but no iframe.
You can use svg to work around, example code (./path/example.svg):
<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg">
<foreignObject width="100" height="100">
<div xmlns="http://www.w3.org/1999/xhtml">
<ul>
<li>text</li>
</ul>
<!-- Other embed HTML element/text into SVG -->
</div>
</foreignObject>
</svg>
and then use image insert way to embed the svg file in any other markdown file, like this:
![](./path/example.svg)

org-mode export as html: inline images displayed and linked?

If I use the folowing syntax,
#+ATTR_HTML: width="200"
[[file:highres.jpg][file:highres.jpg]]
I should expect that the page would display highres.jpg in the specified size, and when clicked on, would like to the file itself? Which is what I get from these instructions. However, when I generate the html from an org-mode file, the image is displayed but not linked/clickable. Am I doing something wrong or have I misunderstood?
In more recent versions of org-mode, the format seems to have changed. The following works for me in Emacs 24.4.1:
#+ATTR_HTML: :width 200
[[file:highres.jpg]]
In your example it is treating it as being without description because the description is identical to the link itself. The instructions you link to say to use a generated thumbnail for the description (which will be displayed instead of the full image).
On the other hand, I wasn't able to get it to respect #+ATTR_HTML: width="200" when I did change the description text to allow for a difference
#+ATTR_HTML: width="200"
[[file:highres.jpg][./highres.jpg]]
Instead the inlined clickable image was full-size. I don't know if this is intended or not, the best place to ask that would likely be the mailing list (where they may also be able to fix it if it is a bug).
Added Testing of issue
Using the following Org snippet
* SVG test
#+CAPTION: Test
#+ATTR_HTML: width="200" title="Hello"
[[./img/Bitmap.svg][file:./img/Bitmap.svg]]
#+Caption: Test2
#+ATTR_HTML: width="200" title="Hello as well"
[[./Bitmap.svg]]
I get the following HTML, which does explain why the strange result with regards to image sizes occurs:
<p>
<img src="./img/Bitmap.svg" alt="Bitmap.svg"/>
</p>
<div class="figure">
<p><img src="./Bitmap.svg" width="200" title="Hello as well" alt="./Bitmap.svg" /></p>
<p>Test2</p>
</div>
The initial image is being adjusted in size, instead of the link image. Definitely a question of how the exporter interprets the #+ATTRL_HTML information. Under the current exporter the best choice might well be to generate a thumbnail of the image for insertion.

Org-mode: protect emphasis

How could I protect emphasis like italics or code within Emacs org-mode
when I have things like
/cologne/dome/
or
=<pre language="python">=
?
The following org-block demonstrates which parts work by default and which need a small amount of work-around to work.
The following was created using Org-mode version 7.8.03 (release_7.8.03.321.gaac1c). If you're using an older version it is possible that the behaviour is slightly different.
See Literal Examples and Monospace in the Org-Manual for full details
ORG
* Italics
- Your example simply works\\
/cologne/dome/
- It also works if your /example had / spaces within it/
- It will only fail if / your /have spaces on one end or the other /
* Code
Code blocks can be delimited in multiple ways:
** Inline formatting
- Using ~ for verbatim text works\\
~<pre language="python">~
- ~ renders the same as = for blocks =test= ~test~
** Code Blocks
- Single-line blocks
: <pre language="python">
- Multi-line blocks
#+BEGIN_EXAMPLE
asdf
#+END_EXAMPLE
HTML Export
<div id="outline-container-1" class="outline-2">
<h2 id="sec-1"><span class="section-number-2">1</span> Italics</h2>
<div class="outline-text-2" id="text-1">
<ul>
<li>Your example simply works<br/>
<i>cologne/dome</i>
</li>
<li>It also works if your <i>example had / spaces within it</i>
</li>
<li>It will only fail if / your /have spaces on one end or the other /
</li>
</ul>
</div>
</div>
<div id="outline-container-2" class="outline-2">
<h2 id="sec-2"><span class="section-number-2">2</span> Code</h2>
<div class="outline-text-2" id="text-2">
<p>Code blocks can be delimited in multiple ways:
</p>
</div>
<div id="outline-container-2-1" class="outline-3">
<h3 id="sec-2-1"><span class="section-number-3">2.1</span> Inline formatting</h3>
<div class="outline-text-3" id="text-2-1">
<ul>
<li>Using ~ for verbatim text works<br/>
<code><pre language="python"></code>
</li>
<li>~ renders the same as = for blocks <code>test</code> <code>test</code>
</li>
</ul>
</div>
</div>
<div id="outline-container-2-2" class="outline-3">
<h3 id="sec-2-2"><span class="section-number-3">2.2</span> Code Blocks</h3>
<div class="outline-text-3" id="text-2-2">
<ul>
<li>Single-line blocks
<pre class="example">
<pre language="python">
</pre>
</li>
<li>Multi-line blocks
<pre class="example">asdf
</pre>
</li>
</ul>
LaTeX Export
\section{Italics}
\label{sec-1}
\begin{itemize}
\item Your example simply works\\
\emph{cologne/dome}
\item It also works if your \emph{example had / spaces within it}
\item It will only fail if / your /have spaces on one end or the other /
\end{itemize}
\section{Code}
\label{sec-2}
Code blocks can be delimited in multiple ways:
\subsection{Inline formatting}
\label{sec-2-1}
\begin{itemize}
\item Using \~{} for verbatim text works\\
\verb~<pre language="python">~
\item \~{} renders the same as = for blocks \texttt{test} \verb~test~
\end{itemize}
\subsection{Code Blocks}
\label{sec-2-2}
\begin{itemize}
\item Single-line blocks
\begin{verbatim}
<pre language="python">
\end{verbatim}
\item Multi-line blocks
\begin{verbatim}
asdf
\end{verbatim}
\end{itemize}
I guess you want to output the original /cologne/dome/, but not <i>cologne/dome</i>, right?
Two ways:
set #+OPTIONS: *:nil to turn off all emphasis symbols
modify org-emphasis-alist, remove the relevant items
I also asked a similar question here: How do I escape slash in org-mode?