Cantor Function, Cruel A ripoff of this challenge. Go upvote it!
Objective
Given a rational number amongst \$[0,1]\$, apply the Cantor function to it and output the rational number that's produced.
The Cantor function
The Cantor function is continuous everywhere and constant almost everywhere, but has an average slope of 1:

The Cantor function \$f(x)\$ can be expressed as a limit \$f(x)=\lim\limits_{n\to\infty} f_n(x)\$ of a sequence of functions \$f_0, f_1, f_2, \dots\$, which are defined recursively as:
\$f_0(x)=x\$
\$f_{n+1}(x)=\left\{\begin{matrix}\frac{1}{2}f_n(3x)&amp;x\in[0,\frac{1}{3})\\ \frac{1}{2}&amp;x\in[\frac{1}{3},\frac{2}{3})\\ \frac{1}{2}+\frac{1}{2}f_n(3x-2)&amp;x\in[\frac{2}{3},1] \end{matrix}\right.\$

Your task is to compute \$f(x)\$ for the rational \$x \in [0,1] \cap \mathbb{Q}\$ given as input.
How?
Though this task might seem impossible, this is actually possible, for the Cantor function is computable.
A step-by-step solution for \$x \in \mathbb{R}\$:

Ternary-expand \$x\$ to \$0.t_1t_2t_3\cdots\$.

Write &quot;0.&quot;.

Set \$n=1\$.

If \$t_n = 1\$, write &quot;1&quot; and halt.



Otherwise, if \$t_n = 0\$, write &quot;0&quot;, increment \$n\$, then continue doing step #4.

Otherwise (\$t_n = 2\$), write &quot;1&quot;, increment \$n\$, then continue doing step #4.



Parse the resulting string as a binary expansion of a real number.

As \$x\$ actually is in \$\mathbb{Q}\$ in this challenge, you should exploit the fact that the ternary expansion of \$x\$ repeats. It follows that the output is also in \$\mathbb{Q}\$.
Examples
$$
\begin{array}{r|c|c|c|c|c|c|c|c|c|c}
x &amp; 0 &amp; ½ &amp; ⅓ &amp; ¼ &amp; ⅕ &amp; ⅚ &amp; 1 \\ \hline
\text{Ternary expansion of }x &amp; 0.\overline{0} &amp; 0.\overline{1} &amp; 0.1\overline{0} &amp; 0.\overline{02} &amp; 0.\overline{0121} &amp; 0.2\overline{1} &amp; 0.\overline{2}  \\ \hline
\text{Binary expansion of } f(x) &amp; 0.\overline{0} &amp; 0.1 &amp; 0.1 &amp; 0.\overline{01} &amp; 0.01 &amp; 0.11 &amp; 0.\overline{1} \\ \hline
f(x) &amp; 0 &amp; ½ &amp; ½ &amp; ⅓ &amp; ¼ &amp; ¾ &amp; 1
\end{array}
$$
Rules

Invalid inputs fall in don't care situation. In particular, you don't need to deal with numbers outside of \$[0,1]\$.

Input and output must be exact rational numbers. If your language doesn't natively support rational number arithmetic, use a pair of integers.
JavaScript (ES7),  141 ... 128  125 bytes
Saved 2 bytes thanks to @Ada
Expects the fraction \$p/q\$ as (p)(q). Returns \$P/Q\$ as [P,Q].

p=&gt;q=&gt;(k='0b'+(n=0,g=p=&gt;(r=n-g[p])?'':p/q&amp;1||[p/q&gt;&gt;1]+g(p%q*3,g[p]=n++))(p),r?[((k&gt;&gt;r)*(m=2**r-1)+(k&amp;m))*2,m&lt;&lt;n-r]:[+k,1&lt;&lt;n])

Try it online!
How?
Ternary and binary expansions
k =                    // build a binary string
  '0b' + (             // append the binary prefix
    n = 0,             // n is a bit counter
    g = p =&gt;           // g is a recursive function taking the numerator p
      (r = n - g[p]) ? //   if p was already encountered, we have a repeating
                       //   pattern, whose length is stored in r; in that case:
        ''             //     stop the recursion
      :                //   else:
        p / q &amp; 1 ||   //     if p/q = 1, append a '1' and stop the recursion
        [p / q &gt;&gt; 1] + //     otherwise, append '1' if p/q = 2 or '0' if p/q = 0
        g(             //     append the result of a recursive call to g:
          3 * (p % q), //       update p to 3 * (p modulo q)
          g[p] = n++   //       store the position of p in g and increment n
        )              //     end of recursive call
  )(p)                 // initial call with the numerator provided in the input

Turning the binary expansion into a decimal fraction
If \$r\$ is NaN after the first step, it means that the binary expansion has no repeating pattern. In that case, the numerator is \$k\$ and the denominator is \$2^n\$.
If \$r\$ is defined, we compute the following bitmask:
m = 2 ** r - 1

The numerator is:
((k &gt;&gt; r) * m + (k &amp; m)) * 2

and the denominator is:
m &lt;&lt; n - r