getpelican / pelican

Static site generator that supports Markdown and reST syntax. Powered by Python.
https://getpelican.com
GNU Affero General Public License v3.0
12.5k stars 1.81k forks source link

Double-quote symbol got replaced with ” in middle of plugin generation stage #2986

Closed egberts closed 2 years ago

egberts commented 2 years ago

Issue

I noticed that just_table was not exactly fully working.

Specifically the basic [jtable] keyword works just fine; it is the additional but various attributes that did not even work such as:

like in [jtable separator="|" ai=0 th=1 caption="A nice table of something"]; only the basic [jtable] just works.

My question now is just before my plugin troubleshooting of Pelican generation stage (over various loaded plugins), the original file had the following:

    [jtable separator=","]

and within and during this SAME generator stage, one of the earlier plugin performed the replacement of double-quote with ” of that file's content into this:

    [jtable separator=”,&rdquo]

So, my question from a Pelican plugin architect POV is this:

  1. Are we supposed to make dual-REGEX (double-effort) for both the double-quote being as-is (") as well as the webified variants ("”") in case the ordering of plugin-loading gets different for each user?
  2. Reorder the jtable plugin during Pelican plugin loading to beat out before other plugin's double-quote replacement effort begin?
  3. or fix the other plugin's "bastardizing" of double-quote during generator-stage and make the plugin do that substitution/replacement/translation later.
egberts commented 2 years ago

Looks like I have narrowed the plugin loading down to just the just_table as well as the Pelican overhead and the m.htmlsanity part of m.css plugin for this issue of double-quote being replaced with a webify variant of ”.

@mosra (author of m.css), what can you chime in about, on this topic?

mosra commented 2 years ago

I tried to find something about what jump_table is or what it does, but failed. Can you provide a link? I'm lost.

Yes, m.htmlsanity has an option for smart quotes -- did you try to disable it, if you have it enabled? But so does Docutils, and Pelican provided its own option via SmartyPants, so you might want to investigate these as well: https://mcss.mosra.cz/plugins/htmlsanity/#typography

Besides that, I'm not aware of the plugin doing anything rogue if M_HTMLSANITY_SMART_QUOTES is off. If you have it enabled and it changes stuff where you think it shouldn't, please give me more info about the other plugin, if it's processing reST or Markdown content, what exactly it generates and how can I try to reproduce this on my side.

egberts commented 2 years ago

SMARTYQUOTE are all disabled.

I obtained just_table from here https://github.com/getpelican/pelican-plugins.

Did I say "jump_table"? ARGH! My apology, it is just_table over at https://github.com/burakkose/just_table/tree/7100e984e30e2d3c00cb77037d6ce7e5da8119c3

MASSIVE RE-EDIT: And I've re-edited all the thread to reflect just_table. (shaking my head). Thanks for the heads up.

An example link: https://egbert.net/blog/articles/asus-router-ports.html demonstrates the just_table plugin by responding to [jtable] tags in a Markdown/ReST file.

I got this; will do some more research debugging.

mosra commented 2 years ago

SMARTYQUOTE are all disabled.

Err, just to be clear -- does that mean that even if you set M_HTMLSANITY_SMART_QUOTES, TYPOGRIFY, and the smart_quotes Docutils option in DOCUTILS_SETTINGS to False, it still happens? Then I'm afraid I can't help, as this is then outside the control of my m.htmlsanity plugin.

If, however, it works when M_HTMLSANITY_SMART_QUOTES is False and you need it to work with it enabled, we can continue the discussion over at mosra/m.css#220.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your participation and understanding.

justinmayer commented 2 years ago

@egberts: Hope you got this resolved. Please let us know if you need further assistance with this issue.

egberts commented 2 years ago

i wasnt able to resolve this for my just_table plugin. it’s stale.

2 years later, restarted work on just_table for this. (As well as plugin modernization)

egberts commented 2 months ago

Reworking for just_table handling &rdquo

egberts commented 2 months ago

WORKAROUND

Remove smarty extension from MARKDOWN setting in your pelicanconf.py (or publishconf.py) Python configuration file:

MARKDOWN = {
  'extension_configs': {
#    'markdown.extensions.smarty': {},
    'markdown.extensions.extra': {},
    'markdown.extensions.footnotes': {},
    'markdown.extensions.meta': {},
    'markdown.extensions.toc': {'baselevel': 1},
    'markdown.extensions.codehilite': {'css_class': 'codehilite'}
  },
  'output_format': 'html5'}

While it is an effective workaround, this took away the ability to do smart quoting for your Markdown text files, but you have table features back.

HOW

The original Markdown file containing just_table tag+attribute looked like this:

[jtable th="1" caption="A captioned phrase"]
...
[/jtable]

And Markdown smarty extension replaced all double-quotes each with &rdquo, looking like this:

[jtable th=&rdquo1&rdquo caption=&rdquoA captioned phrase&rdquo]
...
[/jtable]

just_table plugin preprocessor and processor had zero chance to examine the original source line (devoid of &rdquo) in which to extract the settings of just_table from within.

I think some redesign of just_table must be made to accommodate such 'bastardization' of [jtable option=&rdquooptions], OR .... or perhaps like PRE-PREPROCESSING the just_table before the Markdown smarty extension starts munging the Jinja/just_table stuff, no?

EDIT: Right now, I do not see a way for just_table plugin to avoid Markdown smarty extension from kicking in FIRSTLY so that just_table options can be properly examined and extracted their own tag+attributes correctly.