Using custom filter in filters metadata tag

16 views
Skip to first unread message

Jim Schmitz

unread,
Oct 19, 2020, 5:11:04 PM10/19/20
to nikola-...@googlegroups.com
The documentation says I can "apply filters to specific posts or pages by using the filters metadata field", like so:

.. filters: filters.html_tidy_nowrap

I can get that to work, but how do I do it if is my own custom filter? I get the below error, which is the same error I get if set the filters field to nonsense. I believe the problem is my filter just isn't found by the code that runs the filters. How do I make it available?

PythonAction Error
Traceback (most recent call last):
  File "/home/jim/INSTALL/anaconda3/envs/py5/lib/python3.8/site-packages/doit/action.py", line 437, in execute
    returned_value = self.py_callable(*self.args, **kwargs)
  File "/home/jim/INSTALL/anaconda3/envs/py5/lib/python3.8/site-packages/nikola/utils.py", line 968, in unlessLink
    subprocess.check_call(action % target, shell=True)
TypeError: not all arguments converted during string formatting


Thanks!

Roberto Alsina

unread,
Oct 19, 2020, 5:24:12 PM10/19/20
to Nikola—Discuss
On Mon, Oct 19, 2020 at 6:11 PM Jim Schmitz <james....@gmail.com> wrote:
The documentation says I can "apply filters to specific posts or pages by using the filters metadata field", like so:

.. filters: filters.html_tidy_nowrap

I can get that to work, but how do I do it if is my own custom filter? I get the below error, which is the same error I get if set the filters field to nonsense. I believe the problem is my filter just isn't found by the code that runs the filters. How do I make it available?


Custom filters in metadata seem to be limited to external tools. So, for example, if you have a script called "upperify" that turns everything into upper case and want to use that:

.. filters: upperify %s

I will do a MR clarifying the documentation.

 
PythonAction Error
Traceback (most recent call last):
  File "/home/jim/INSTALL/anaconda3/envs/py5/lib/python3.8/site-packages/doit/action.py", line 437, in execute
    returned_value = self.py_callable(*self.args, **kwargs)
  File "/home/jim/INSTALL/anaconda3/envs/py5/lib/python3.8/site-packages/nikola/utils.py", line 968, in unlessLink
    subprocess.check_call(action % target, shell=True)
TypeError: not all arguments converted during string formatting


Thanks!

--
You received this message because you are subscribed to the Google Groups "nikola-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nikola-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nikola-discuss/CAKUYxW%2Bc_w6QkLoZuooWG4T7yO%3DkVgRJ4vr13T3vn6aA7qRaNw%40mail.gmail.com.

Roberto Alsina

unread,
Oct 19, 2020, 5:27:26 PM10/19/20
to Nikola—Discuss
On Mon, Oct 19, 2020 at 6:23 PM Roberto Alsina <ral...@kde.org> wrote:
On Mon, Oct 19, 2020 at 6:11 PM Jim Schmitz <james....@gmail.com> wrote:
The documentation says I can "apply filters to specific posts or pages by using the filters metadata field", like so:

.. filters: filters.html_tidy_nowrap

I can get that to work, but how do I do it if is my own custom filter? I get the below error, which is the same error I get if set the filters field to nonsense. I believe the problem is my filter just isn't found by the code that runs the filters. How do I make it available?


Custom filters in metadata seem to be limited to external tools. So, for example, if you have a script called "upperify" that turns everything into upper case and want to use that:

.. filters: upperify %s

I will do a MR clarifying the documentation.


BTW: that program needs to modify the file in place.

Jim Schmitz

unread,
Oct 20, 2020, 10:34:20 AM10/20/20
to nikola-...@googlegroups.com
Roberto, thank you for your reply. Writing a script for the filter feature works well for my use case, and I was able to accomplish what I needed to accomplish.

Roberto Alsina

unread,
Oct 20, 2020, 11:45:15 AM10/20/20
to Nikola—Discuss
Reply all
Reply to author
Forward
0 new messages