Skip to content

Commit

Permalink
Prevent Blackfriday/smartParens from running inside equations
Browse files Browse the repository at this point in the history
Fixes #104
  • Loading branch information
kaushalmodi committed Nov 29, 2017
1 parent 06687c3 commit 39be582
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 11 deletions.
8 changes: 7 additions & 1 deletion ox-blackfriday.el
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,13 @@ INFO is a plist holding contextual information."
;; Need to escape the backslash in "\(", "\)", .. to
;; make Blackfriday happy. So \( -> \\(, \) -> \\),
;; \[ -> \\[ and \] -> \\].
(frag (replace-regexp-in-string "\\(\\\\[]()[]\\)" "\\\\\\1" frag)))
(frag (replace-regexp-in-string "\\(\\\\[]()[]\\)" "\\\\\\1" frag))
;; Insert an extra space to trick Blackfriday/smartParens
;; from activating inside equations. That extra space
;; anyways doesn't matter in equations.
;; https://github.com/kaushalmodi/ox-hugo/issues/104
;; (c) -> ( c), (r) -> ( r), (tm) -> ( tm)
(frag (replace-regexp-in-string "(\\(c\\|r\\|tm\\))" "( \\1)" frag)))
frag))
((assq processing-type org-preview-latex-process-alist)
(let ((formula-link
Expand Down
30 changes: 29 additions & 1 deletion test/site/content-org/all-posts.org
Original file line number Diff line number Diff line change
Expand Up @@ -1781,6 +1781,34 @@ If $a^2=b$ and \( b=2 \), then the solution must be either
$$ a=+\sqrt{2} $$ or \[ a=-\sqrt{2} \]

(Note that the last two equations show up on their own lines.)
** Equations with (r), (c), .. :@upstream:
:PROPERTIES:
:EXPORT_FILE_NAME: equations-with-r-c
:END:
{{{oxhugoissue(104)}}}

Below, =(r)= or =(R)= should not get converted to ®, =(c)= or
=(C)= should not get converted to ©, and =(tm)= or =(TM)= should
not get converted to ™:

- $(r)$ $(R)$
- $(c)$ $(C)$
- $(tm)$ $(TM)$


- \( (r) \) \( (R) \)
- \( (c) \) \( (C) \)
- \( (tm) \) \( (TM) \)

Same as above but in /Block Math equations/:

$$ (r) (R) $$
$$ (c) (C) $$
$$ (tm) (TM) $$

\[ (r) (R) \]
\[ (c) (C) \]
\[ (tm) (TM) \]
* Lists :lists:
** List following a list
:PROPERTIES:
Expand Down Expand Up @@ -2626,7 +2654,7 @@ auto-prefixed with the section for the current post.
*** Multifractal definition
- Consider a given object $\Omega$, its multifractal nature is
practically determined by covering the system with a set of boxes
$\{B_i(r)\}$ with $(i=1,..., N(r))$ of side lenght $r$
$\{B_i(r)\}$ with $(i=1,..., N(r))$ of side length $r$
- These boxes are nonoverlaping and such that

$$\Omega = \bigcup_{i=1}^{N(r)} B_i(r)$$
Expand Down
32 changes: 32 additions & 0 deletions test/site/content/posts/equations-with-r-c.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
+++
title = "Equations with (r), (c), .."
tags = ["equations"]
categories = ["upstream"]
draft = false
+++

`ox-hugo` Issue #[104](https://github.com/kaushalmodi/ox-hugo/issues/104)

Below, `(r)` or `(R)` should not get converted to ®, `(c)` or
`(C)` should not get converted to ©, and `(tm)` or `(TM)` should
not get converted to ™:

- \\(( r)\\) \\(( R)\\)
- \\(( c)\\) \\(( C)\\)
- \\(( tm)\\) \\(( TM)\\)

<!--listend-->

- \\( ( r) \\) \\( ( R) \\)
- \\( ( c) \\) \\( ( C) \\)
- \\( ( tm) \\) \\( ( TM) \\)

Same as above but in _Block Math equations_:

\\[ ( r) ( R) \\]
\\[ ( c) ( C) \\]
\\[ ( tm) ( TM) \\]

\\[ ( r) ( R) \\]
\\[ ( c) ( C) \\]
\\[ ( tm) ( TM) \\]
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ source = "https://github.com/lsaravia/MultifractalsInR/blob/master/Curso3.md"

- Consider a given object \\(\Omega\\), its multifractal nature is
practically determined by covering the system with a set of boxes
\\(\{B\_i(r)\}\\) with \\((i=1,..., N(r))\\) of side lenght \\(r\\)
\\(\{B\_i( r)\}\\) with \\((i=1,..., N( r))\\) of side length \\(r\\)
- These boxes are nonoverlaping and such that

\\[\Omega = \bigcup\_{i=1}^{N(r)} B\_i(r)\\]
\\[\Omega = \bigcup\_{i=1}^{N( r)} B\_i( r)\\]

This is the box-counting method but now a measure \\(\mu(B\_n)\\) for each
box is computed. This measure corresponds to the total population or
Expand All @@ -51,16 +51,16 @@ source = "https://github.com/lsaravia/MultifractalsInR/blob/master/Curso3.md"
infinite spectrum of so-called correlation dimension of order \\(q\\) or
also called Renyi entropies.

\\[D\_q = \lim\_{r \to 0} \frac{1}{q-1}\frac{log \left[ \sum\_{i=1}^{N(r)}p\_i^q \right]}{\log r}\\]
\\[D\_q = \lim\_{r \to 0} \frac{1}{q-1}\frac{log \left[ \sum\_{i=1}^{N( r)}p\_i^q \right]}{\log r}\\]

where \\(p\_i=\mu(B\_i)\\) and a normalization is assumed:

\\[\sum\_{i=1}^{N(r)}p\_i=1\\]
\\[\sum\_{i=1}^{N( r)}p\_i=1\\]

- For \\(q=0\\) we have the familiar definition of fractal dimension. To see
this we replace \\(q=0\\)

\\[D\_0 = -\lim\_{r \to 0}\frac{N(r)}{\log r}\\]
\\[D\_0 = -\lim\_{r \to 0}\frac{N( r)}{\log r}\\]


## Generalized dimensions 1 {#generalized-dimensions-1}
Expand All @@ -69,7 +69,7 @@ source = "https://github.com/lsaravia/MultifractalsInR/blob/master/Curso3.md"
\\(q' \geq q\\)
- The sum

\\[M\_q(r) = \sum\_{i=1}^{N(r)}[\mu(B\_i(r))]^q = \sum\_{i=1}^{N(r)}p\_i^q\\]
\\[M\_q( r) = \sum\_{i=1}^{N( r)}[\mu(B\_i( r))]^q = \sum\_{i=1}^{N( r)}p\_i^q\\]

is the so-called moment or partition function of order \\(q\\).
- Varying q allows to measure the non-homogeneity of the pattern. The
Expand All @@ -94,11 +94,11 @@ source = "https://github.com/lsaravia/MultifractalsInR/blob/master/Curso3.md"
the Shannon entropy or also called by ecologist the Shannon's index of
diversity.

\\[D\_1 = -\lim\_{r \to 0}\sum\_{i=1}^{N(r)} p\_i \log p\_i\\]
\\[D\_1 = -\lim\_{r \to 0}\sum\_{i=1}^{N( r)} p\_i \log p\_i\\]

and the second is the so-called correlation dimension:

\\[D\_2 = -\lim\_{r \to 0} \frac{\log \left[ \sum\_{i=1}^{N(r)} p\_i^2 \right]}{\log r} \\]
\\[D\_2 = -\lim\_{r \to 0} \frac{\log \left[ \sum\_{i=1}^{N( r)} p\_i^2 \right]}{\log r} \\]

the numerator is the log of the Simpson index.

Expand All @@ -125,7 +125,7 @@ source = "https://github.com/lsaravia/MultifractalsInR/blob/master/Curso3.md"
- The same information contained in the generalized dimensions can be
expressed using mass exponents:

\\[M\_q(r) \propto r^{-\tau\_q}\\]
\\[M\_q( r) \propto r^{-\tau\_q}\\]

This is the scaling of the partition function. For monofractals
\\(\tau\_q\\) is linear and related to the Hurst exponent:
Expand Down

0 comments on commit 39be582

Please sign in to comment.