torchlight-api / torchlight-cli

Node CLI for Torchlight
15 stars 2 forks source link

'$' breaks replacement in page when running the CLI #5

Open awcodes opened 1 year ago

awcodes commented 1 year ago

When having code blocks that have '$' in them the CLI run breaks and causes unexpected output in the html file.

use Filament\Forms\Components\TextInput;

TextInput::make('cost')->mask(fn (TextInput\Mask $mask) => $mask->money(prefix: '$', thousandsSeparator: '.', decimalPlaces: 2))

Screen Shot 2022-12-29 at 2 19 08 PM

mcgrealife commented 1 year ago

testing note: when using torchlight-cli on javascript code <pre><code data-language='js'></code></pre>, the $ character works as expected (so this problem might be language specific)

awcodes commented 1 year ago

Thanks for the reply. Are there any know caveats with mdx? I'm getting the issue in Astro with mdx.

awcodes commented 1 year ago

Here's the output html it's running against:

<pre><code class="language-php">use Filament\Forms\Components\TextInput;

TextInput::make(&#39;cost&#39;)-&gt;mask(fn (TextInput\Mask $mask) =&gt; $mask-&gt;money(prefix: &#39;$&#39;, thousandsSeparator: &#39;,&#39;, decimalPlaces: 2))
</code></pre>
<p>You can also control whether the number is signed or not. While the default is to allow both negative and positive numbers, <code>isSigned: false</code> allows only positive numbers:</p>
<pre><code class="language-php">use Filament\Forms\Components\TextInput;

TextInput::make(&#39;cost&#39;)-&gt;mask(fn (TextInput\Mask $mask) =&gt; $mask-&gt;money(prefix: &#39;$&#39;, thousandsSeparator: &#39;,&#39;, decimalPlaces: 2, isSigned: false))
</code></pre>
<h3 id="datalists">Datalists</h3>
<p>You may specify <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/datalist">datalist</a> options for a text input using the <code>datalist()</code> method:</p>
<pre><code class="language-php">TextInput::make(&#39;manufacturer&#39;)
    -&gt;datalist([
        &#39;BWM&#39;,
        &#39;Ford&#39;,
        &#39;Mercedes-Benz&#39;,
        &#39;Porsche&#39;,
        &#39;Toyota&#39;,
        &#39;Tesla&#39;,
        &#39;Volkswagen&#39;,
    ])
</code></pre>
mcgrealife commented 1 year ago

Hey again @awcodes.

Just to confirm, are you providing torchlight-cli an html file (output from astro), or mdx? If you are providing it mdx, the remark-torchlight package might be better.

I am still testing this myself, but here is what I've learned so far. Maybe something will be useful:

Sorry I don't have a better answer yet, but I will let you know as soon as I test this remark-mdx plugin. Within the next few days.

awcodes commented 1 year ago

Yea. I'm running it after the build against the dist html files.

Also ran into the same issue you did with nextjs.

awcodes commented 1 year ago

Also just kinda want to run it after the build so it's not possibly getting throttled during dev with hmr, etc.

Thanks for taking the time to help though.

tonypartridge commented 1 year ago

+1 on this is anyone can find a solution.

danharrin commented 1 year ago

For clarification, it's not $, its ('$') as a combination