Browse Source

Format

pull/36/head
Jure Šorn 5 years ago
parent
commit
935c390f8c
4 changed files with 84 additions and 24 deletions
  1. 25
      README.md
  2. 25
      index.html
  3. 29
      parse.js
  4. 29
      web/script_2.js

25
README.md

@ -429,19 +429,20 @@ Format
{1.23456:10.3%} # ' 123.456%'
```
#### Comparison of float presentation types:
```text
+---------------+--------------+---------------+---------------+---------------+
| | {<float>:.2} | {<float>:.2f} | {<float>:.2e} | {<float>:.2%} |
+---------------+--------------+---------------+---------------+---------------+
| 0.00056789 | '0.00057' | '0.00' | '5.68e-04' | '0.06%' |
| 0.0056789 | '0.0057' | '0.01' | '5.68e-03' | '0.57%' |
| 0.056789 | '0.057' | '0.06' | '5.68e-02' | '5.68%' |
| 0.56789 | '0.57' | '0.57' | '5.68e-01' | '56.79%' |
| 5.6789 | '5.7' | '5.68' | '5.68e+00' | '567.89%' |
| 56.789 | '5.7e+01' | '56.79' | '5.68e+01' | '5678.90%' |
| 567.89 | '5.7e+02' | '567.89' | '5.68e+02' | '56789.00%' |
| 5678.9 | '5.7e+03' | '5678.90' | '5.68e+03' | '567890.00%' |
+---------------+--------------+---------------+---------------+---------------+
+----------------+--------------+---------------+---------------+---------------+
| | {<float>:.2} | {<float>:.2f} | {<float>:.2e} | {<float>:.2%} |
+----------------+--------------+---------------+---------------+---------------+
| 0.000056789 | '5.7e-05' | '0.00' | '5.68e-05' | '0.01%' |
| 0.00056789 | '0.00057' | '0.00' | '5.68e-04' | '0.06%' |
| 0.0056789 | '0.0057' | '0.01' | '5.68e-03' | '0.57%' |
| 0.056789 | '0.057' | '0.06' | '5.68e-02' | '5.68%' |
| 0.56789 | '0.57' | '0.57' | '5.68e-01' | '56.79%' |
| 5.6789 | '5.7' | '5.68' | '5.68e+00' | '567.89%' |
| 56.789 | '5.7e+01' | '56.79' | '5.68e+01' | '5678.90%' |
| 567.89 | '5.7e+02' | '567.89' | '5.68e+02' | '56789.00%' |
+----------------+--------------+---------------+---------------+---------------+
```
### Ints

25
index.html

@ -500,18 +500,19 @@ to_exclusive = &lt;range&gt;.stop
{<span class="hljs-number">1.23456</span>:<span class="hljs-number">10.3</span>e} <span class="hljs-comment"># ' 1.235e+00'</span>
{<span class="hljs-number">1.23456</span>:<span class="hljs-number">10.3</span>%} <span class="hljs-comment"># ' 123.456%'</span>
</code></pre>
<pre><code class="text language-text">+---------------+--------------+---------------+---------------+---------------+
| | {&lt;float&gt;:.2} | {&lt;float&gt;:.2f} | {&lt;float&gt;:.2e} | {&lt;float&gt;:.2%} |
+---------------+--------------+---------------+---------------+---------------+
| 0.00056789 | '0.00057' | '0.00' | '5.68e-04' | '0.06%' |
| 0.0056789 | '0.0057' | '0.01' | '5.68e-03' | '0.57%' |
| 0.056789 | '0.057' | '0.06' | '5.68e-02' | '5.68%' |
| 0.56789 | '0.57' | '0.57' | '5.68e-01' | '56.79%' |
| 5.6789 | '5.7' | '5.68' | '5.68e+00' | '567.89%' |
| 56.789 | '5.7e+01' | '56.79' | '5.68e+01' | '5678.90%' |
| 567.89 | '5.7e+02' | '567.89' | '5.68e+02' | '56789.00%' |
| 5678.9 | '5.7e+03' | '5678.90' | '5.68e+03' | '567890.00%' |
+---------------+--------------+---------------+---------------+---------------+
<h4 id="comparisonoffloatpresentationtypes">Comparison of float presentation types:</h4>
<pre><code class="text language-text">┏━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┓
┃ │ {&lt;float&gt;:.2} │ {&lt;float&gt;:.2f} │ {&lt;float&gt;:.2e} │ {&lt;float&gt;:.2%} ┃
┠────────────────┼──────────────┼───────────────┼───────────────┼───────────────┨
┃ 0.000056789 │ '5.7e-05' │ '0.00' │ '5.68e-05' │ '0.01%' ┃
┃ 0.00056789 │ '0.00057' │ '0.00' │ '5.68e-04' │ '0.06%' ┃
┃ 0.0056789 │ '0.0057' │ '0.01' │ '5.68e-03' │ '0.57%' ┃
┃ 0.056789 │ '0.057' │ '0.06' │ '5.68e-02' │ '5.68%' ┃
┃ 0.56789 │ '0.57' │ '0.57' │ '5.68e-01' │ '56.79%' ┃
┃ 5.6789 │ '5.7' │ '5.68' │ '5.68e+00' │ '567.89%' ┃
┃ 56.789 │ '5.7e+01' │ '56.79' │ '5.68e+01' │ '5678.90%' ┃
┃ 567.89 │ '5.7e+02' │ '567.89' │ '5.68e+02' │ '56789.00%' ┃
┗━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛
</code></pre>
<h3 id="ints">Ints</h3>
<pre><code class="python language-python hljs">{<span class="hljs-number">90</span>:c} <span class="hljs-comment"># 'Z'</span>

29
parse.js

@ -112,6 +112,34 @@ const DIAGRAM_4_B =
'┃ complex │ │ │ │ ✓ │ ✓ ┃\n' +
'┗━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━┷━━━━━━━━━┷━━━━━━━━┛\n';
const DIAGRAM_5_A =
"+----------------+--------------+---------------+---------------+---------------+\n" +
"| | {<float>:.2} | {<float>:.2f} | {<float>:.2e} | {<float>:.2%} |\n" +
"+----------------+--------------+---------------+---------------+---------------+\n" +
"| 0.000056789 | '5.7e-05' | '0.00' | '5.68e-05' | '0.01%' |\n" +
"| 0.00056789 | '0.00057' | '0.00' | '5.68e-04' | '0.06%' |\n" +
"| 0.0056789 | '0.0057' | '0.01' | '5.68e-03' | '0.57%' |\n" +
"| 0.056789 | '0.057' | '0.06' | '5.68e-02' | '5.68%' |\n" +
"| 0.56789 | '0.57' | '0.57' | '5.68e-01' | '56.79%' |\n" +
"| 5.6789 | '5.7' | '5.68' | '5.68e+00' | '567.89%' |\n" +
"| 56.789 | '5.7e+01' | '56.79' | '5.68e+01' | '5678.90%' |\n" +
"| 567.89 | '5.7e+02' | '567.89' | '5.68e+02' | '56789.00%' |\n" +
"+----------------+--------------+---------------+---------------+---------------+\n";
const DIAGRAM_5_B =
"┏━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┓\n" +
"┃ │ {<float>:.2} │ {<float>:.2f} │ {<float>:.2e} │ {<float>:.2%} ┃\n" +
"┠────────────────┼──────────────┼───────────────┼───────────────┼───────────────┨\n" +
"┃ 0.000056789 │ '5.7e-05' │ '0.00' │ '5.68e-05' │ '0.01%' ┃\n" +
"┃ 0.00056789 │ '0.00057' │ '0.00' │ '5.68e-04' │ '0.06%' ┃\n" +
"┃ 0.0056789 │ '0.0057' │ '0.01' │ '5.68e-03' │ '0.57%' ┃\n" +
"┃ 0.056789 │ '0.057' │ '0.06' │ '5.68e-02' │ '5.68%' ┃\n" +
"┃ 0.56789 │ '0.57' │ '0.57' │ '5.68e-01' │ '56.79%' ┃\n" +
"┃ 5.6789 │ '5.7' │ '5.68' │ '5.68e+00' │ '567.89%' ┃\n" +
"┃ 56.789 │ '5.7e+01' │ '56.79' │ '5.68e+01' │ '5678.90%' ┃\n" +
"┃ 567.89 │ '5.7e+02' │ '567.89' │ '5.68e+02' │ '56789.00%' ┃\n" +
"┗━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛\n";
function main() {
const html = getMd();
@ -143,6 +171,7 @@ function switchClassDiagrams(readme) {
readme = readme.replace(DIAGRAM_2_A, DIAGRAM_2_B)
readme = readme.replace(DIAGRAM_3_A, DIAGRAM_3_B)
readme = readme.replace(DIAGRAM_4_A, DIAGRAM_4_B)
readme = readme.replace(DIAGRAM_5_A, DIAGRAM_5_B)
return readme
}

29
web/script_2.js

@ -80,6 +80,34 @@ const DIAGRAM_4_B =
'┃ complex │ │ │ │ ✓ │ ✓ ┃\n' +
'┗━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━┷━━━━━━━━━┷━━━━━━━━┛\n';
const DIAGRAM_5_A =
"+----------------+--------------+---------------+---------------+---------------+\n" +
"| | {<float>:.2} | {<float>:.2f} | {<float>:.2e} | {<float>:.2%} |\n" +
"+----------------+--------------+---------------+---------------+---------------+\n" +
"| 0.000056789 | '5.7e-05' | '0.00' | '5.68e-05' | '0.01%' |\n" +
"| 0.00056789 | '0.00057' | '0.00' | '5.68e-04' | '0.06%' |\n" +
"| 0.0056789 | '0.0057' | '0.01' | '5.68e-03' | '0.57%' |\n" +
"| 0.056789 | '0.057' | '0.06' | '5.68e-02' | '5.68%' |\n" +
"| 0.56789 | '0.57' | '0.57' | '5.68e-01' | '56.79%' |\n" +
"| 5.6789 | '5.7' | '5.68' | '5.68e+00' | '567.89%' |\n" +
"| 56.789 | '5.7e+01' | '56.79' | '5.68e+01' | '5678.90%' |\n" +
"| 567.89 | '5.7e+02' | '567.89' | '5.68e+02' | '56789.00%' |\n" +
"+----------------+--------------+---------------+---------------+---------------+\n";
const DIAGRAM_5_B =
"┏━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┓\n" +
"┃ │ {<float>:.2} │ {<float>:.2f} │ {<float>:.2e} │ {<float>:.2%} ┃\n" +
"┠────────────────┼──────────────┼───────────────┼───────────────┼───────────────┨\n" +
"┃ 0.000056789 │ '5.7e-05' │ '0.00' │ '5.68e-05' │ '0.01%' ┃\n" +
"┃ 0.00056789 │ '0.00057' │ '0.00' │ '5.68e-04' │ '0.06%' ┃\n" +
"┃ 0.0056789 │ '0.0057' │ '0.01' │ '5.68e-03' │ '0.57%' ┃\n" +
"┃ 0.056789 │ '0.057' │ '0.06' │ '5.68e-02' │ '5.68%' ┃\n" +
"┃ 0.56789 │ '0.57' │ '0.57' │ '5.68e-01' │ '56.79%' ┃\n" +
"┃ 5.6789 │ '5.7' │ '5.68' │ '5.68e+00' │ '567.89%' ┃\n" +
"┃ 56.789 │ '5.7e+01' │ '56.79' │ '5.68e+01' │ '5678.90%' ┃\n" +
"┃ 567.89 │ '5.7e+02' │ '567.89' │ '5.68e+02' │ '56789.00%' ┃\n" +
"┗━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛\n";
// isFontAvailable:
(function(d){function c(c){b.style.fontFamily=c;e.appendChild(b);f=b.clientWidth;e.removeChild(b);return f}var f,e=d.body,b=d.createElement("span");b.innerHTML=Array(100).join("wi");b.style.cssText=["position:absolute","width:auto","font-size:128px","left:-99999px"].join(" !important;");var g=c("monospace"),h=c("serif"),k=c("sans-serif");window.isFontAvailable=function(b){return g!==c(b+",monospace")||k!==c(b+",sans-serif")||h!==c(b+",serif")}})(document);
@ -89,6 +117,7 @@ if (!isFontAvailable('Menlo')) {
$(`code:contains(${DIAGRAM_2_B})`).html(DIAGRAM_2_A);
$(`code:contains(${DIAGRAM_3_B})`).html(DIAGRAM_3_A);
$(`code:contains(${DIAGRAM_4_B})`).html(DIAGRAM_4_A);
$(`code:contains(${DIAGRAM_5_B})`).html(DIAGRAM_5_A);
// var htmlString = $('code:contains(ᴺᴱᵂ)').html().replace(/ᴺᴱᵂ/g, '');
// $('code:contains(ᴺᴱᵂ)').html(htmlString);
}

Loading…
Cancel
Save