Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(plugin): command-line data-filter-out not working #1706

Closed
muuvmuuv opened this issue Jan 14, 2019 · 5 comments
Closed

bug(plugin): command-line data-filter-out not working #1706

muuvmuuv opened this issue Jan 14, 2019 · 5 comments
Labels

Comments

@muuvmuuv
Copy link

I'm trying to get this to work:

<pre class="command-line language-bash" data-filter-output="(out)" data-user="user" data-host="remotehost">
  <code>
  pwd
  (out)/usr/home/user/bin
  ls -la
  (out)total 2
  (out)drwxr-xr-x   2 user  group     11 Jan 10 16:48 .
  (out)drwxr--r-x  45 user  group     92 Feb 14 11:10 ..
  (out)-rwxr-xr-x   1 user  group    444 Aug 25  2013 backup
  (out)-rwxr-xr-x   1 user  group    642 Jan 17 14:42 deploy
  </code>
</pre>

I'm loading the core and plugins like this:

import 'prismjs/prism.js';
import 'prismjs/plugins/unescaped-markup/prism-unescaped-markup.min.js';
import 'prismjs/plugins/normalize-whitespace/prism-normalize-whitespace.min.js';
import 'prismjs/plugins/autolinker/prism-autolinker.min.js';
import 'prismjs/plugins/command-line/prism-command-line.min.js'; // BUG: output not rendered correctly
import 'prismjs/plugins/line-numbers/prism-line-numbers.min.js';

and prism is rendering it to this:

bildschirmfoto 2019-01-14 um 10 56 42
bildschirmfoto 2019-01-14 um 10 56 16

I have tried disabling all plugins but still not the result I expected.

@RunDevelopment
Copy link
Member

The leading spaces are the problem (I think). Because of them, you don't have any lines with the prefix (out) but a few with the prefix [ ][ ](out) ([ ] for one space).

Also, please don't indent your code. For pre elements, every (leading) space counts. They will not be removed as in other tags.

@muuvmuuv
Copy link
Author

Hey @RunDevelopment, I have tried this with no success:

            <tr>
              <td>
                <pre class="command-line language-bash" data-filter-output="(out)" data-user="user" data-host="remotehost">
<code>
pwd
(out)/usr/home/user/bin
ls -la
(out)total 2
(out)drwxr-xr-x   2 user  group     11 Jan 10 16:48 .
(out)drwxr--r-x  45 user  group     92 Feb 14 11:10 ..
(out)-rwxr-xr-x   1 user  group    444 Aug 25  2013 backup
(out)-rwxr-xr-x   1 user  group    642 Jan 17 14:42 deploy
</code>
                </pre>
              </td>
              <td>

renders to:

<code class=" language-bash"><span class="command-line-prompt"><span data-user="user" data-host="remotehost"></span><span data-user="user" data-host="remotehost"></span><span></span><span data-user="user" data-host="remotehost"></span><span></span><span></span><span></span><span></span><span></span><span data-user="user" data-host="remotehost"></span></span>
pwd

ls -la





</code>

I have also tried to just activate the core and command-line again.

@muuvmuuv
Copy link
Author

I have created a fiddle: https://jsfiddle.net/muuvmuuv/tckqsa1j/

@muuvmuuv
Copy link
Author

I have found the issue, I had not imported the required languages... 😆 sorry, so obvious

@RunDevelopment
Copy link
Member

It should work even without the grammar being imported, so I still think that this needs fixing.

The first version of my fix can be found here. I will make a PR for this.

mAAdhaTTah pushed a commit that referenced this issue Jan 22, 2019
Fixes #1706 (also includes a demo).

The problem was that the `insert-before` hook was not called if `grammar` is undefined.
This also fixes that `callback` was not called in that case and that `env` of the `complete` hook did not have a `highlightedCode` property.

All other hooks are unchanged. The `insert-before` hook is only used by the Command line plugin, so there should be no other side effects.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants