Re: styling a replacement
Oleksandr Gavenko <[email protected]>
| Newsgroups | gmane.text.docutils.user |
|---|---|
| Organization | Oleksandr Gavenko <[email protected]>, http://defun.work/ |
| Message-ID | <[email protected]> |
On 2016-02-29, Tom Roche wrote:
> However I want to combine inline markup and a substitution providing a
> subscript, for something like the following reST:
>
> fail1> Cities produce more than 70% of global fossil-fuel |CO2| emissions
> fail1> (*|FFCO2|*). We have cutting-edge science relating how cities and
> fail1> regions settle and use their land (LULC) to their |FFCO2| emissions.
>
> fail1> .. |CO2| replace:: CO\ :sub:`2`
> fail1> .. |FFCO2| replace:: FFCO\ :sub:`2`
Recently I take notes for Coursera classes in RST and I like :math:
role/directive rendering:
$ cat in.rst
This is :math:`CO_2`.
$ rst2html --math-output=HTML in.rst out.html
$ cat out.html
<span class="formula"><i>CO</i><sub>2</sub></span>
As you see default rendering enclose text in italic tag - so text will look
emphasised.
You source code will be readable in plain text.
:math: try to interpret included text as TeX formula, so relatively complex
typography can be represented with this syntax.
I don't use much of \LaTeX syntax in flavor of Emacs editor abilities for
easy entering complex text.
With binding:
(setq my-russian-input-method 'russian-computer)
(setq my-ukranian-input-method 'ukrainian-computer)
(setq my-ipa-input-method 'ipa-x-sampa)
(when (<= emacs-major-version 21)
(setq my-russian-input-method 'cyrillic-jcuken)
(setq my-ukranian-input-method 'cyrillic-jcuken))
(setq default-input-method my-russian-input-method)
(defun my-toggle-input-method (&optional arg)
(interactive "P")
(if (numberp arg)
(cond
((eq arg 1)
(activate-input-method nil))
((eq arg 2)
(activate-input-method my-russian-input-method))
((eq arg 3)
(activate-input-method my-ukranian-input-method))
((eq arg 4)
(activate-input-method 'greek))
((eq arg 5)
(activate-input-method my-ipa-input-method))
((eq arg 6)
(activate-input-method 'TeX)) )
(toggle-input-method arg)) )
(global-set-key (kbd "C-\\") 'my-toggle-input-method)
I able to enter Ru/Ua/Greek/IPA/TeX symbols without effort. For:
:def:`Chebyshev inequality`: if :math:`X` is a random variable with mean
:math:`μ` and variance :math:`σ²` then
.. math::
P(|X-μ| ≥ c) ≤ σ²/c²
for all :math:`c > 0`.
with TeX input method when I type [^] [2] Emacs automatically place superscript
number 2. Same for [_] [2] which may be useful in your chemistry text.
[\] [s] [u] [m] produces ∑ sign, there are hundreds of symbols can be entered
in such way.
Note that Unicode doesn't hold all subscript/superscript for English alphabet,
so I use LeTeX syntax which look nice in plain text and HTML:
Z_n = ((∑_{1≤i≤n} X_i) - n·μ) / (σ·sqrt(n))
"1≤i≤n" become subscript in HTML.
If you prefer to use limited editor I may suggest you to make file with list
of interesting Unicode chars and copy-paste them.
I don't like --math-output=MathJax because it link to external CDN and it
really slow in may part of world )) --math-output=HTML just fine.
Recently I found that option in form
--math-output=MathJax:http://you.domain/context/mathjax.js
allow link to your own copy of mathjax library but again built-in
--math-output=HTML just fine.
================================================================
I check:
http://docutils.sourceforge.net/docs/ref/rst/directives.html#custom-interpreted-text-roles
If define:
.. role:: chem(math)
:class: chem
This is :chem:`H_2O`.
you unfortunately get:
<span class="formula"><i>CO</i><sub>2</sub></span>
There are no additional class "chem" but it would be great to have to
customise chemical and mathematical formulas.
I file a bug:
https://sourceforge.net/p/docutils/bugs/295/
#295 Custom text role with inheritence on math role should respect additional class
--
http://defun.work/
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Docutils-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/docutils-users
Please use "Reply All" to reply to the list.