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

Plugin always adds e-content div to post content. Should it? #294

Open
snarfed opened this issue Nov 9, 2023 · 4 comments
Open

Plugin always adds e-content div to post content. Should it? #294

snarfed opened this issue Nov 9, 2023 · 4 comments

Comments

@snarfed
Copy link
Member

snarfed commented Nov 9, 2023

Hi @dshanske et al! I'm seeing an odd behavior with HTML content: two <div class="e-content">s, one inside the other. I assume that's not expected? For example, this JSON request:

{
  "type": ["h-entry"],
  "properties": {
    "name": ["foo"],
    "category": ["reply"],
    "content": [{"html": "well <em>ok</em> is <a href=\"http://yahoo.com\">that so</a> <a href=\"http://bar.org\">http://bar.org</a>"}],
  }
}

results in this HTML:

<div class="entry-content clear">
<div class='e-content'><a class="u-in-reply-to" href="https://micropub.spec.indieweb.org/"></a></p>
<div class="e-content">
well <em>ok</em> is <a href="http://yahoo.com">that so</a> <a href="http://bar.org">http://bar.org</a>
</div>
</div>
<div class="syndication-links"></div>
</div><!-- .entry-content -->

I'm guessing because of this code?

if ( ! empty( $post_content ) ) {
$lines[] = '<div class="e-content">';
$lines[] = $post_content;
$lines[] = '</div>';
}

e-content is probably up to the theme, right? Should the plugin be injecting this extra e-content div?

snarfed added a commit to snarfed/misc that referenced this issue Nov 21, 2023
...via the marked library, vendored in.

works!...but also triggers indieweb/wordpress-micropub#294
@janboddez
Copy link
Contributor

janboddez commented Nov 22, 2023

Just FYI: What I do in my theme (or rather, plugin, but a theme could do the same) is I check if there's a .e-content in the post content already and only add the class if there isn't. (For some post types, it makes sense to have a, e.g., reply context outside of .e-context, and since---in my case---both are part of my post content I can't just add an overall e-content class. Hence the check.)

But I also completely override the Micropub post content in a filter callback, so ... That could work too, at least temporarily. Just remove the div in a filter.

@dshanske
Copy link
Member

There's a setting that disables it entirely which my Post Kinds plugin turns on... I have some ideas I might pursue though.

@snarfed
Copy link
Member Author

snarfed commented Feb 20, 2024

FWIW, I debugged this a bit more just now, and it's not specific to HTML content or JSON input, evidently the plugin always does this when it creates posts. Eg a form-encoded micropub request with content=fooey results in this content HTML:

<div class="e-content">
fooey
</div>

@snarfed snarfed changed the title HTML content results in duplicate e-content div? Plugin always adds e-content div to post content. Should it? Feb 20, 2024
@snarfed
Copy link
Member Author

snarfed commented Feb 20, 2024

(I don't actually know what should happen here! Just adding info for now.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants