# Trying to replace / auto-format strings in user posts

**URL:** https://meta.discourse.org/t/trying-to-replace-auto-format-strings-in-user-posts/285326
**Category:** Development
**Created:** [November 13, 2023, 3:32pm UTC](https://meta.discourse.org/t/trying-to-replace-auto-format-strings-in-user-posts/285326 "2023-11-13T15:32:21Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![hemes](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hemes/32/340413_2.png) [@hemes](https://meta.discourse.org/u/hemes)
#### Post date: [November 13, 2023, 5:18pm UTC](https://meta.discourse.org/t/trying-to-replace-auto-format-strings-in-user-posts/285326/4 "2023-11-13T17:18:51Z")

</div>

All right! It seems that `decorateCookedElement` is what I needed (per @Arkshine note).

I also found this post that has some nice examples to filter on elements of interest:  
[How do we fire scripts after topic HTML is rendered in DOM? - dev - Discourse Meta](https://meta.discourse.org/t/how-do-we-fire-scripts-after-topic-html-is-rendered-in-dom/114701)

In particular, I found this very helpful:

```plaintext
$.fn.doSomething = function() {
  const targetElement = $(this).children("[data-theme-test]").length;
  if (!targetElement) return;

  // do your work
  
  return this;
};

api.decorateCooked($elem => $elem.doSomething(), { onlyStream: true });

```

Thank you!

---

_[View the full topic](https://meta.discourse.org/t/trying-to-replace-auto-format-strings-in-user-posts/285326)._
