HTML Tagged text to Array

Hi All, apologies if this is really simple however I am lost.

  1. Have used Anthropic Claude to generate some original content (a basic article with a title, content, meta description etc).
  2. I have specified the text output be formatted using html tags
  3. The output arrives as expected (a single string of text broken up by html title, body, meta tags etc.

I simply wish to split the text output into a usable array based on the HTML tags for the purposes of posting it on a Ghost io blog.

I am totally lost as to how to do this. I have tried splitt and get however I cannot seem to get anywhere close. Please tell me there is an elegant solution?!?!?! Any help would be hugely appreciated!!!

Thanks!

Claude output as follows:

Welcome to the Make community!

1. This forum might have or already changed your text

When pasting text into this forum, you should format the JSON output bundle using the rich-text editor, otherwise the forum software might modify the displayed text, and you might get incorrect answers from others because of it.

Some things this forum software might do to mangle your text:

– remove extra spaces (which may be necessary)
– convert links to titles (when copied is incorrect)
– incorrect joined links
– convert single and double quotes to smart angled quotes
– emojis
– etc.

This interferes with you receiving correct answers, because it:

makes JSON invalid (you can verify when copy-paste into https://jsonformatter.org)
– makes incorrect text examples when we need to build a pattern for text parsing

2. To prevent this in future, please format text in code blocks

A. Type code fence manually
Either add three backticks ``` before and after the text, like this:

```
content goes here
```

B. Highlight and click the format button
Or use the format code button in the editor:
Screenshot_2023-10-02_191027

3. You might need to re-copy the original text

Once the post has been submitted, it’s too late to format it since it’s already butchered, and you need to make a re-copy of the text, and format it before submitting the forum post.

Please let us know once you have corrected the issue. This will avoid others potentially providing wrong answers based on incorrect text in your question.

Thank you!

[
    {
        "textResponse": "<title>Lennon vs. Young: The Great Rock 'n' Roll Burnout</title>\n\n<article>\n\nPicture this: It's 1979, and John Lennon's sitting in his Dakota apartment, probably wearing those iconic round glasses and sipping a cup of tea, when he hears Neil Young's latest track \"My My, Hey Hey\" blasting from some teenager's boombox on the street below. As the chorus hits – \"It's better to burn out than to fade away\" – Lennon nearly spits out his Earl Grey in disgust. \"Garbage!\" he mutters, reaching for the phone to call his Playboy interview and give them a juicy soundbite.\n\nAh, the delicious drama of rock legends beefing over lyrics. It's like watching your cool uncles argue at Thanksgiving dinner, except instead of politics, they're debating the metaphysics of fame and mortality. And let me tell you, folks, this particular disagreement is a doozy.\n\nOn one side, we've got Neil Young, the Canadian troubadour with a voice like a rusty hinge and the soul of a poet. Young, who cut his teeth in the Winnipeg dance scene (imagine a bunch of teenagers awkwardly swaying to \"Sugar Mountain\" – pure comedy gold), had the audacity to pen what would become one of rock's most enduring mantras. It's the kind of line that sounds profound when you're 17 and scribbling it on your Converse, but gets a little more complicated when you hit your 40s and realize you've got a mortgage to pay.\n\nOn the other side, we've got John Lennon, the quick-witted Beatle with a tongue sharper than a Hofner bass string. Lennon, bless his peace-loving heart, took Young's lyric as a personal affront to his newfound domesticity. Here he was, trying to bake bread and raise little Sean, and Neil's out there telling kids it's cool to flame out like a Roman candle. No wonder John was miffed.\n\nIn his infamous Playboy interview, Lennon didn't just disagree with Young – he went full scorched earth. \"It's garbage to me,\" he declared, probably while adjusting his granny glasses for maximum dramatic effect. He even threw in a jab about Young fading away and coming back \"like all of us,\" which is a bit rich coming from a guy who took a five-year hiatus to be a househusband.\n\nBut here's the thing: both Lennon and Young had a point. Rock 'n' roll is all about that incandescent moment, the electric thrill of a perfect chord or a soaring chorus. It's Hendrix setting his guitar on fire, it's Bowie reinventing himself for the umpteenth time, it's Freddie Mercury in that yellow jacket at Live Aid. Those moments burn bright in our collective memory, outlasting the artists themselves.\n\nYet Lennon's perspective is equally valid. There's something to be said for sticking around, for evolving, for showing that rock isn't just a young person's game. It's Paul McCartney still touring in his 80s, it's Mick Jagger defying physics (and possibly making a deal with the devil) to strut across stadiums at 70+. It's the wisdom that comes with age, the depth that experience brings to the music.\n\nIn the end, maybe the real lesson here is that rock 'n' roll is big enough for both philosophies. It can burn bright and fade gracefully. It can be a shooting star and a steady flame. And sometimes, it can even be two rock legends bickering like an old married couple.\n\nAs for me? I'm with Lennon on this one. I'd rather stick around and keep writing snarky articles about feuding rock stars. After all, it's better to fade away than to burn out... of career options.\n\n</article>\n\n<meta_description>John Lennon vs. Neil Young: The epic clash over rock philosophy. Burn out or fade away? SugarApe dives into the juicy details of this legendary feud.</meta_description>\n\n<url>sugarape.com/lennon-young-rock-burnout-feud</url>\n\n<keywords>\nJohn Lennon, Neil Young, rock feud, burn out vs fade away, rock philosophy, My My Hey Hey, music controversy\n</keywords>\n",
        "id": "msg_01A6nWJVp3TF1iQy7rRndwug",
        "type": "message",
        "role": "assistant",
        "model": "claude-3-5-sonnet-20240620",
        "content": [
            {
                "type": "text",
                "text": "<title>Lennon vs. Young: The Great Rock 'n' Roll Burnout</title>\n\n<article>\n\nPicture this: It's 1979, and John Lennon's sitting in his Dakota apartment, probably wearing those iconic round glasses and sipping a cup of tea, when he hears Neil Young's latest track \"My My, Hey Hey\" blasting from some teenager's boombox on the street below. As the chorus hits – \"It's better to burn out than to fade away\" – Lennon nearly spits out his Earl Grey in disgust. \"Garbage!\" he mutters, reaching for the phone to call his Playboy interview and give them a juicy soundbite.\n\nAh, the delicious drama of rock legends beefing over lyrics. It's like watching your cool uncles argue at Thanksgiving dinner, except instead of politics, they're debating the metaphysics of fame and mortality. And let me tell you, folks, this particular disagreement is a doozy.\n\nOn one side, we've got Neil Young, the Canadian troubadour with a voice like a rusty hinge and the soul of a poet. Young, who cut his teeth in the Winnipeg dance scene (imagine a bunch of teenagers awkwardly swaying to \"Sugar Mountain\" – pure comedy gold), had the audacity to pen what would become one of rock's most enduring mantras. It's the kind of line that sounds profound when you're 17 and scribbling it on your Converse, but gets a little more complicated when you hit your 40s and realize you've got a mortgage to pay.\n\nOn the other side, we've got John Lennon, the quick-witted Beatle with a tongue sharper than a Hofner bass string. Lennon, bless his peace-loving heart, took Young's lyric as a personal affront to his newfound domesticity. Here he was, trying to bake bread and raise little Sean, and Neil's out there telling kids it's cool to flame out like a Roman candle. No wonder John was miffed.\n\nIn his infamous Playboy interview, Lennon didn't just disagree with Young – he went full scorched earth. \"It's garbage to me,\" he declared, probably while adjusting his granny glasses for maximum dramatic effect. He even threw in a jab about Young fading away and coming back \"like all of us,\" which is a bit rich coming from a guy who took a five-year hiatus to be a househusband.\n\nBut here's the thing: both Lennon and Young had a point. Rock 'n' roll is all about that incandescent moment, the electric thrill of a perfect chord or a soaring chorus. It's Hendrix setting his guitar on fire, it's Bowie reinventing himself for the umpteenth time, it's Freddie Mercury in that yellow jacket at Live Aid. Those moments burn bright in our collective memory, outlasting the artists themselves.\n\nYet Lennon's perspective is equally valid. There's something to be said for sticking around, for evolving, for showing that rock isn't just a young person's game. It's Paul McCartney still touring in his 80s, it's Mick Jagger defying physics (and possibly making a deal with the devil) to strut across stadiums at 70+. It's the wisdom that comes with age, the depth that experience brings to the music.\n\nIn the end, maybe the real lesson here is that rock 'n' roll is big enough for both philosophies. It can burn bright and fade gracefully. It can be a shooting star and a steady flame. And sometimes, it can even be two rock legends bickering like an old married couple.\n\nAs for me? I'm with Lennon on this one. I'd rather stick around and keep writing snarky articles about feuding rock stars. After all, it's better to fade away than to burn out... of career options.\n\n</article>\n\n<meta_description>John Lennon vs. Neil Young: The epic clash over rock philosophy. Burn out or fade away? SugarApe dives into the juicy details of this legendary feud.</meta_description>\n\n<url>sugarape.com/lennon-young-rock-burnout-feud</url>\n\n<keywords>\nJohn Lennon, Neil Young, rock feud, burn out vs fade away, rock philosophy, My My Hey Hey, music controversy\n</keywords>"
            }
        ],
        "stop_reason": "end_turn",
        "stop_sequence": null,
        "usage": {
            "input_tokens": 1719,
            "output_tokens": 992
        }
    }
]

Welcome to the Make community!

You can use a Text Parser “Match Pattern” module with this Pattern (regular expression):

<(?<tag>[^>]+)>\s*(?<text>[^<]+?)\s*<\/\1>

Proof

https://regex101.com/r/pBo2Ya/1

Important Info

  • :warning: Global match must be set to YES!

Then use an array aggregator to combine the results into a single operation.

Output


For more information, see Text Parser in the Make Help Center:

Match Pattern
The Match pattern module enables you to find and extract string elements matching a search pattern from a given text. The search pattern is a regular expression (aka regex or regexp), which is a sequence of characters in which each character is either a metacharacter, having a special meaning, or a regular character that has a literal meaning.

Hope this helps!

This worked perfectly! Thank you @samliew

No problem, glad I could help!

Just another quick trick – if you want, you can even convert the aggregated array into a collection for easier mapping of variables.

Screenshot_2024-07-02_190742

Screenshot_2024-07-02_190713

1. If anyone has a new question in the future, please start a new thread. This makes it easier for others with the same problem to search for the answers to specific questions, and you are more likely to receive help since newer questions are monitored closely.

2. The Make Community guidelines encourages users to try to mark helpful replies as solutions to help keep the Community organized.

This marks the topic as solved, so that:

  • others can save time when catching up with the latest activity here, and
  • allows others to quickly jump to the solution if they come across the same problem

To do this, simply click the checkbox at the bottom of the post that answers your question:
Screenshot_2023-10-04_161049

3. Don’t forget to like and bookmark this topic so you can get back to it easily in future!

4. Do join the unofficial Make Discord server for live chat and video assistance

samliewrequest private consultation

Join the Make Fans Discord server to chat with other makers!

This is really helpful, thank you @samliew, may I ask you a final related question?

Having followed all of your steps I get a nice clean array collection (yes I implemented your additional step of mapping the array to a collection which is awesome).

Ironically, the output is so clean that my Claude generated “article” content loses all of its formatting when updating my Ghost blog (the next step in the string) and populates as a single body of text.

The Ghost module allows for a HTML upload so I figured the simple solution was to specify that Claude output the “article” tagged content as HTML which it can do, however the problem is the text parser then splits this content (all sub-heading and paragraph tags) into arrays which isn’t the desired outcome.

My question is: Is there a way to specify that the HTML tags within the content tagged “article” remain untouched and are not parsed out as arrays?

I hope this makes sense. Any help appreciated.

Claude is set to output as follows:

Present your final output in the following format:

<title>
[Insert H1 article title here]
</title>

<article>
[Insert your 500-1500 word article as HTML here]
</article>

<slug>
[Insert SEO-optimized URL slug here]
</slug>

<custom-excerpt>
[Insert custom excerpt here]
</custom-excerpt>

<meta-title>
[Insert SEO-optimized meta title here]
</meta-title>

<meta-description>
[Insert SEO-optimized meta description here]
</meta-description>

<keywords>
[List 5-7 suggested keywords here]
</keywords>

Claudes generated text is as follows:

[
    {
        "textResponse": "<title>Stevie Nicks: From Fleetwood Witch to Solo Sorceress</title>\n\n<article>\n<h1>Stevie Nicks: From Fleetwood Witch to Solo Sorceress</h1>\n\n<p>Picture this: It's 1981, and Stevie Nicks is about to drop her solo debut like it's a steaming cauldron of musical potion. But hold onto your crystal balls, folks, because our favorite twirling enchantress is quaking in her platform boots.</p>\n\n<p>You'd think after bewitching millions with Fleetwood Mac, Stevie would be cool as a cucumber. But nope, she was more nervous than a long-tailed cat in a room full of rocking chairs. As she told NPR, \"I was terrified that was going to tank.\" Stevie, honey, if by \"tank\" you meant \"launch you into the stratosphere of 80s pop royalty,\" then yeah, it totally tanked.</p>\n\n<h2>The Witching Hour: Fleetwood Mac Years</h2>\n\n<p>Before we dive into Stevie's solo sorcery, let's rewind to her Fleetwood Mac days. This was when Stevie first cast her spell on the world, turning gentle tunes into full-blown spiritual experiences. 'Rhiannon' wasn't just a song; it was a séance set to a killer bassline.</p>\n\n<p>Rumor had it that Stevie might actually be a witch. I mean, have you seen her twirl on stage? That's some next-level Hogwarts stuff right there. But let's be real - if Stevie was actually a witch, don't you think she would've turned certain exes into toads by now? Just saying.</p>\n\n<h2>Dreams and Nightmares: The Human Touch</h2>\n\n<p>Despite the mystical aura, Stevie's songs were deeply human. 'Dreams' wasn't conjured from a spellbook; it was pulled from the depths of heartbreak. And 'Sara'? That's not a potion recipe, folks. It's a raw, emotional ode to an unborn child.</p>\n\n<p>Stevie had more unsung bangers than George Harrison after a Beatles album. But unlike our favorite quiet Beatle, she wasn't about to let her tunes gather dust. No sir, this white-winged dove was ready to spread her wings and fly solo.</p>\n\n<h2>Bella Donna: The Solo Spell</h2>\n\n<p>Enter 'Bella Donna', Stevie's solo debut. She might've been shaking in her shawl, but let me tell you, this album is tighter than the leather pants in a 80s hair metal video.</p>\n\n<p>Working with producer Jimmy Iovine, Stevie approached the studio like she was prepping for a magical showdown. No time for potion-brewing or crystal-gazing here. As she put it, \"We were so ready to make that record.\" And boy, does it show.</p>\n\n<p>'Leather and Lace' could've been a Fleetwood Mac track, sure. But 'Edge of Seventeen'? That guitar riff is so sharp it could cut through the tension at a Mac reunion. Sorry, Lindsey, but this was Stevie's time to shine brighter than a disco ball at Studio 54.</p>\n\n<h2>The Sorcerer's Apprentice No More</h2>\n\n<p>With 'Bella Donna', Stevie proved she didn't need a coven to create magic. She may have played the Welsh witch on stage, but in the studio, she was pure rock 'n' roll sorceress. 'Beauty and the Beast' isn't just a song title; it's a metaphor for Stevie's transformation from band member to solo superstar.</p>\n\n<p>So here's to Stevie Nicks, the woman who turned her fears into fierce independence. She didn't just release an album; she released herself from the shadows of her bandmates. And in doing so, she gave us mere mortals a glimpse into her world - a world where dreams are spun into gold records, and white-winged doves sing a song that sounds like she's singing.</p>\n\n<p>Stevie once sang, \"Thunder only happens when it's raining.\" Well, with 'Bella Donna', Stevie made it rain and thunder all at once. And we've been dancing in that storm ever since.</p>\n</article>\n\n<slug>stevie-nicks-fleetwood-mac-bella-donna-solo-debut</slug>\n\n<custom-excerpt>Can a witch make hits? Stevie Nicks says \"Hold my crystal ball\"</custom-excerpt>\n\n<meta-title>Stevie Nicks: From Fleetwood Mac to Solo Stardom | SugarApe</meta-title>\n\n<meta-description>Discover how Stevie Nicks overcame her fears to release 'Bella Donna', transforming from Fleetwood Mac's mystic to a solo rock sorceress.</meta-description>\n\n<keywords>\nStevie Nicks, Fleetwood Mac, Bella Donna, solo career, 1980s music, rock music, female artists\n</keywords>\n",
        "id": "msg_01Lw4peTzsAxcfhgJYUMoMsW",
        "type": "message",
        "role": "assistant",
        "model": "claude-3-5-sonnet-20240620",
        "content": [
            {
                "type": "text",
                "text": "<title>Stevie Nicks: From Fleetwood Witch to Solo Sorceress</title>\n\n<article>\n<h1>Stevie Nicks: From Fleetwood Witch to Solo Sorceress</h1>\n\n<p>Picture this: It's 1981, and Stevie Nicks is about to drop her solo debut like it's a steaming cauldron of musical potion. But hold onto your crystal balls, folks, because our favorite twirling enchantress is quaking in her platform boots.</p>\n\n<p>You'd think after bewitching millions with Fleetwood Mac, Stevie would be cool as a cucumber. But nope, she was more nervous than a long-tailed cat in a room full of rocking chairs. As she told NPR, \"I was terrified that was going to tank.\" Stevie, honey, if by \"tank\" you meant \"launch you into the stratosphere of 80s pop royalty,\" then yeah, it totally tanked.</p>\n\n<h2>The Witching Hour: Fleetwood Mac Years</h2>\n\n<p>Before we dive into Stevie's solo sorcery, let's rewind to her Fleetwood Mac days. This was when Stevie first cast her spell on the world, turning gentle tunes into full-blown spiritual experiences. 'Rhiannon' wasn't just a song; it was a séance set to a killer bassline.</p>\n\n<p>Rumor had it that Stevie might actually be a witch. I mean, have you seen her twirl on stage? That's some next-level Hogwarts stuff right there. But let's be real - if Stevie was actually a witch, don't you think she would've turned certain exes into toads by now? Just saying.</p>\n\n<h2>Dreams and Nightmares: The Human Touch</h2>\n\n<p>Despite the mystical aura, Stevie's songs were deeply human. 'Dreams' wasn't conjured from a spellbook; it was pulled from the depths of heartbreak. And 'Sara'? That's not a potion recipe, folks. It's a raw, emotional ode to an unborn child.</p>\n\n<p>Stevie had more unsung bangers than George Harrison after a Beatles album. But unlike our favorite quiet Beatle, she wasn't about to let her tunes gather dust. No sir, this white-winged dove was ready to spread her wings and fly solo.</p>\n\n<h2>Bella Donna: The Solo Spell</h2>\n\n<p>Enter 'Bella Donna', Stevie's solo debut. She might've been shaking in her shawl, but let me tell you, this album is tighter than the leather pants in a 80s hair metal video.</p>\n\n<p>Working with producer Jimmy Iovine, Stevie approached the studio like she was prepping for a magical showdown. No time for potion-brewing or crystal-gazing here. As she put it, \"We were so ready to make that record.\" And boy, does it show.</p>\n\n<p>'Leather and Lace' could've been a Fleetwood Mac track, sure. But 'Edge of Seventeen'? That guitar riff is so sharp it could cut through the tension at a Mac reunion. Sorry, Lindsey, but this was Stevie's time to shine brighter than a disco ball at Studio 54.</p>\n\n<h2>The Sorcerer's Apprentice No More</h2>\n\n<p>With 'Bella Donna', Stevie proved she didn't need a coven to create magic. She may have played the Welsh witch on stage, but in the studio, she was pure rock 'n' roll sorceress. 'Beauty and the Beast' isn't just a song title; it's a metaphor for Stevie's transformation from band member to solo superstar.</p>\n\n<p>So here's to Stevie Nicks, the woman who turned her fears into fierce independence. She didn't just release an album; she released herself from the shadows of her bandmates. And in doing so, she gave us mere mortals a glimpse into her world - a world where dreams are spun into gold records, and white-winged doves sing a song that sounds like she's singing.</p>\n\n<p>Stevie once sang, \"Thunder only happens when it's raining.\" Well, with 'Bella Donna', Stevie made it rain and thunder all at once. And we've been dancing in that storm ever since.</p>\n</article>\n\n<slug>stevie-nicks-fleetwood-mac-bella-donna-solo-debut</slug>\n\n<custom-excerpt>Can a witch make hits? Stevie Nicks says \"Hold my crystal ball\"</custom-excerpt>\n\n<meta-title>Stevie Nicks: From Fleetwood Mac to Solo Stardom | SugarApe</meta-title>\n\n<meta-description>Discover how Stevie Nicks overcame her fears to release 'Bella Donna', transforming from Fleetwood Mac's mystic to a solo rock sorceress.</meta-description>\n\n<keywords>\nStevie Nicks, Fleetwood Mac, Bella Donna, solo career, 1980s music, rock music, female artists\n</keywords>"
            }
        ],
        "stop_reason": "end_turn",
        "stop_sequence": null,
        "usage": {
            "input_tokens": 1657,
            "output_tokens": 1238
        }
    }
]

The result from the text parser is a follows:

[
    {
        "i": 1,
        "tag": "title",
        "text": "Stevie Nicks: From Fleetwood Witch to Solo Sorceress"
    },
    {
        "i": 2,
        "tag": "h1",
        "text": "Stevie Nicks: From Fleetwood Witch to Solo Sorceress"
    },
    {
        "i": 3,
        "tag": "p",
        "text": "Picture this: It's 1981, and Stevie Nicks is about to drop her solo debut like it's a steaming cauldron of musical potion. But hold onto your crystal balls, folks, because our favorite twirling enchantress is quaking in her platform boots."
    },
    {
        "i": 4,
        "tag": "p",
        "text": "You'd think after bewitching millions with Fleetwood Mac, Stevie would be cool as a cucumber. But nope, she was more nervous than a long-tailed cat in a room full of rocking chairs. As she told NPR, \"I was terrified that was going to tank.\" Stevie, honey, if by \"tank\" you meant \"launch you into the stratosphere of 80s pop royalty,\" then yeah, it totally tanked."
    },
    {
        "i": 5,
        "tag": "h2",
        "text": "The Witching Hour: Fleetwood Mac Years"
    },
    {
        "i": 6,
        "tag": "p",
        "text": "Before we dive into Stevie's solo sorcery, let's rewind to her Fleetwood Mac days. This was when Stevie first cast her spell on the world, turning gentle tunes into full-blown spiritual experiences. 'Rhiannon' wasn't just a song; it was a séance set to a killer bassline."
    },
    {
        "i": 7,
        "tag": "p",
        "text": "Rumor had it that Stevie might actually be a witch. I mean, have you seen her twirl on stage? That's some next-level Hogwarts stuff right there. But let's be real - if Stevie was actually a witch, don't you think she would've turned certain exes into toads by now? Just saying."
    },
    {
        "i": 8,
        "tag": "h2",
        "text": "Dreams and Nightmares: The Human Touch"
    },
    {
        "i": 9,
        "tag": "p",
        "text": "Despite the mystical aura, Stevie's songs were deeply human. 'Dreams' wasn't conjured from a spellbook; it was pulled from the depths of heartbreak. And 'Sara'? That's not a potion recipe, folks. It's a raw, emotional ode to an unborn child."
    },
    {
        "i": 10,
        "tag": "p",
        "text": "Stevie had more unsung bangers than George Harrison after a Beatles album. But unlike our favorite quiet Beatle, she wasn't about to let her tunes gather dust. No sir, this white-winged dove was ready to spread her wings and fly solo."
    },
    {
        "i": 11,
        "tag": "h2",
        "text": "Bella Donna: The Solo Spell"
    },
    {
        "i": 12,
        "tag": "p",
        "text": "Enter 'Bella Donna', Stevie's solo debut. She might've been shaking in her shawl, but let me tell you, this album is tighter than the leather pants in a 80s hair metal video."
    },
    {
        "i": 13,
        "tag": "p",
        "text": "Working with producer Jimmy Iovine, Stevie approached the studio like she was prepping for a magical showdown. No time for potion-brewing or crystal-gazing here. As she put it, \"We were so ready to make that record.\" And boy, does it show."
    },
    {
        "i": 14,
        "tag": "p",
        "text": "'Leather and Lace' could've been a Fleetwood Mac track, sure. But 'Edge of Seventeen'? That guitar riff is so sharp it could cut through the tension at a Mac reunion. Sorry, Lindsey, but this was Stevie's time to shine brighter than a disco ball at Studio 54."
    },
    {
        "i": 15,
        "tag": "h2",
        "text": "The Sorcerer's Apprentice No More"
    },
    {
        "i": 16,
        "tag": "p",
        "text": "With 'Bella Donna', Stevie proved she didn't need a coven to create magic. She may have played the Welsh witch on stage, but in the studio, she was pure rock 'n' roll sorceress. 'Beauty and the Beast' isn't just a song title; it's a metaphor for Stevie's transformation from band member to solo superstar."
    },
    {
        "i": 17,
        "tag": "p",
        "text": "So here's to Stevie Nicks, the woman who turned her fears into fierce independence. She didn't just release an album; she released herself from the shadows of her bandmates. And in doing so, she gave us mere mortals a glimpse into her world - a world where dreams are spun into gold records, and white-winged doves sing a song that sounds like she's singing."
    },
    {
        "i": 18,
        "tag": "p",
        "text": "Stevie once sang, \"Thunder only happens when it's raining.\" Well, with 'Bella Donna', Stevie made it rain and thunder all at once. And we've been dancing in that storm ever since."
    },
    {
        "i": 19,
        "tag": "slug",
        "text": "stevie-nicks-fleetwood-mac-bella-donna-solo-debut"
    },
    {
        "i": 20,
        "tag": "custom-excerpt",
        "text": "Can a witch make hits? Stevie Nicks says \"Hold my crystal ball\""
    },
    {
        "i": 21,
        "tag": "meta-title",
        "text": "Stevie Nicks: From Fleetwood Mac to Solo Stardom | SugarApe"
    },
    {
        "i": 22,
        "tag": "meta-description",
        "text": "Discover how Stevie Nicks overcame her fears to release 'Bella Donna', transforming from Fleetwood Mac's mystic to a solo rock sorceress."
    },
    {
        "i": 23,
        "tag": "keywords",
        "text": "Stevie Nicks, Fleetwood Mac, Bella Donna, solo career, 1980s music, rock music, female artists"
    }
]

The goal is to maintain the HTML tags within the article, but clean the remaining claude output. My guess is that I might have to generate the article and corresponding meta (title, description etc) separately, but wondering if there is an easier way? Maybe change the way Claude is outputting the data? Tagging it with something else other than HTML so that I can maintain the HTML within the article content and then adjust the text parser to clean the remaining data? Any thoughts?

Maybe you shouldn’t use angled brackets then.

What about

[title]

or

{title}

@samliew this was my thinking exactly, however if I change the Claude output tags to be {tag name} as suggested the resulting text parser then outputs the array based on the {article} HTML tags contained within the content.

I’m still trying to get my head around how the text parser works. What would the pattern need to be revised to in this instance?

Claude output:

[
    {
        "textResponse": "{title}\nStevie Nicks: The Reluctant Goddess of Rock's Solo Flight\n\n{article}\n<article>\n<h2>From Witchy Woman to Solo Sorceress</h2>\n\n<p>Picture this: It's 1981, and Stevie Nicks, the reigning queen of rock 'n' roll mysticism, is about to unleash her first solo album upon the world. But here's the kicker – she's scared out of her witchy little mind. Who knew that the woman who could cast a spell over millions with a twirl of her shawl could get stage fright?</p>\n\n<p>Now, I know what you're thinking. \"Dan, how could Stevie freaking Nicks be afraid of anything?\" Well, my dear reader, even goddesses have their moments of doubt. It's like when I tried to make a soufflé for the first time – sure, I could whip up a mean microwave burrito, but a fancy French egg dish? That's a whole other level of culinary sorcery.</p>\n\n<h2>The Mac Attack: Stevie's Fleetwood Foundation</h2>\n\n<p>Before we dive into Stevie's solo journey, let's rewind a bit. Picture Fleetwood Mac in their heyday – a band so dysfunctional they made the Kardashians look like the Brady Bunch. Yet, somehow, they managed to create pure magic. Stevie was the ethereal force behind classics like \"Rhiannon\" and \"Dreams.\" She wasn't just singing; she was conjuring spirits and breaking hearts with every breathy note.</p>\n\n<p>But here's the thing about being in a band – it's like being in a really complicated group chat. Sometimes your messages get lost in the shuffle, or worse, left on read. Stevie had more songs up her billowy sleeves than Fleetwood Mac albums could hold. It was time for her to break free, like a beautiful, emotionally damaged butterfly.</p>\n\n<h2>Bella Donna: The Birth of Solo Stevie</h2>\n\n<p>Enter \"Bella Donna,\" Stevie's solo debut. Now, you'd think after years of performing with Fleetwood Mac, she'd strut into the studio like she owned the place. But nope, our girl was shaking in her platform boots. As she told NPR, \"I was terrified that was going to tank.\" It's like when you post a selfie and refresh Instagram every two seconds to see if anyone's liked it. Except, you know, with millions of dollars and your entire career on the line.</p>\n\n<p>But here's where Stevie proved she wasn't just a pretty voice in a flowing dress. She went into that studio with legendary producer Jimmy Iovine and knocked it out of the park faster than you can say \"Edge of Seventeen.\" It was like watching a master chef work their magic – efficient, focused, and absolutely delicious.</p>\n\n<h2>Breaking Free from the Mac Mold</h2>\n\n<p>Now, if you're expecting \"Bella Donna\" to be Fleetwood Mac 2.0, you're in for a surprise. This album is pure, unadulterated Stevie. It's like she took all the witchy woman vibes, cranked them up to eleven, and added a dash of '80s rock goddess for good measure.</p>\n\n<p>Take \"Edge of Seventeen,\" for example. That guitar riff hits you like a freight train of coolness. It's the kind of song that makes you want to put on your best leather jacket and strut down the street in slow motion. Lindsey Buckingham could never.</p>\n\n<p>And let's not forget \"Leather and Lace,\" her duet with Don Henley. It's like the aural equivalent of a really good rom-com – sweet, a little cheesy, but damn if it doesn't make you feel things.</p>\n\n<h2>The Stevie Nicks Effect</h2>\n\n<p>What makes Stevie Nicks so special isn't just her music – it's the whole package. She's got that mystical, otherworldly vibe that makes you wonder if she really might be a witch. (Spoiler alert: she's not. Probably.) But behind all the twirling and the shawls, there's a songwriter of immense depth and humanity.</p>\n\n<p>Songs like \"Sara\" and \"Silver Springs\" aren't just pretty melodies – they're raw, emotional powerhouses. Stevie has this incredible ability to take her personal pain and turn it into something universal. It's like she's singing straight to your soul, telling you, \"Hey, I've been there too, and it sucks, but we're gonna get through this.\"</p>\n\n<h2>The Legacy of a Rock Goddess</h2>\n\n<p>Looking back, it's hard to believe Stevie was ever worried about her solo career. \"Bella Donna\" wasn't just a success – it was a game-changer. It proved that Stevie Nicks wasn't just a member of Fleetwood Mac; she was a force of nature in her own right.</p>\n\n<p>So here's to Stevie Nicks – the reluctant goddess who faced her fears and came out singing. She might not be an actual witch, but she sure as hell worked her magic on the music world. And honestly? I'd take Stevie's brand of sorcery over a real spell any day. After all, has Harry Potter ever written a song as good as \"Dreams\"? I think not.</p>\n</article>\n\n{slug}\nstevie-nicks-solo-career-bella-donna\n\n{custom-excerpt}\nStevie Nicks: From Fleetwood Witch to Solo Sorceress\n\n{meta-title}\nStevie Nicks: The Reluctant Goddess of Rock's Solo Flight\n\n{meta-description}\nDive into Stevie Nicks' journey from Fleetwood Mac to solo stardom. Discover how the rock goddess overcame her fears to create the iconic \"Bella Donna\" album.\n\n{keywords}\nStevie Nicks, Bella Donna, Fleetwood Mac, solo career, rock goddess, 80s music, Edge of Seventeen\n",
        "id": "msg_013EQsy8xKC9KJNfsSYtNH4Z",
        "type": "message",
        "role": "assistant",
        "model": "claude-3-5-sonnet-20240620",
        "content": [
            {
                "type": "text",
                "text": "{title}\nStevie Nicks: The Reluctant Goddess of Rock's Solo Flight\n\n{article}\n<article>\n<h2>From Witchy Woman to Solo Sorceress</h2>\n\n<p>Picture this: It's 1981, and Stevie Nicks, the reigning queen of rock 'n' roll mysticism, is about to unleash her first solo album upon the world. But here's the kicker – she's scared out of her witchy little mind. Who knew that the woman who could cast a spell over millions with a twirl of her shawl could get stage fright?</p>\n\n<p>Now, I know what you're thinking. \"Dan, how could Stevie freaking Nicks be afraid of anything?\" Well, my dear reader, even goddesses have their moments of doubt. It's like when I tried to make a soufflé for the first time – sure, I could whip up a mean microwave burrito, but a fancy French egg dish? That's a whole other level of culinary sorcery.</p>\n\n<h2>The Mac Attack: Stevie's Fleetwood Foundation</h2>\n\n<p>Before we dive into Stevie's solo journey, let's rewind a bit. Picture Fleetwood Mac in their heyday – a band so dysfunctional they made the Kardashians look like the Brady Bunch. Yet, somehow, they managed to create pure magic. Stevie was the ethereal force behind classics like \"Rhiannon\" and \"Dreams.\" She wasn't just singing; she was conjuring spirits and breaking hearts with every breathy note.</p>\n\n<p>But here's the thing about being in a band – it's like being in a really complicated group chat. Sometimes your messages get lost in the shuffle, or worse, left on read. Stevie had more songs up her billowy sleeves than Fleetwood Mac albums could hold. It was time for her to break free, like a beautiful, emotionally damaged butterfly.</p>\n\n<h2>Bella Donna: The Birth of Solo Stevie</h2>\n\n<p>Enter \"Bella Donna,\" Stevie's solo debut. Now, you'd think after years of performing with Fleetwood Mac, she'd strut into the studio like she owned the place. But nope, our girl was shaking in her platform boots. As she told NPR, \"I was terrified that was going to tank.\" It's like when you post a selfie and refresh Instagram every two seconds to see if anyone's liked it. Except, you know, with millions of dollars and your entire career on the line.</p>\n\n<p>But here's where Stevie proved she wasn't just a pretty voice in a flowing dress. She went into that studio with legendary producer Jimmy Iovine and knocked it out of the park faster than you can say \"Edge of Seventeen.\" It was like watching a master chef work their magic – efficient, focused, and absolutely delicious.</p>\n\n<h2>Breaking Free from the Mac Mold</h2>\n\n<p>Now, if you're expecting \"Bella Donna\" to be Fleetwood Mac 2.0, you're in for a surprise. This album is pure, unadulterated Stevie. It's like she took all the witchy woman vibes, cranked them up to eleven, and added a dash of '80s rock goddess for good measure.</p>\n\n<p>Take \"Edge of Seventeen,\" for example. That guitar riff hits you like a freight train of coolness. It's the kind of song that makes you want to put on your best leather jacket and strut down the street in slow motion. Lindsey Buckingham could never.</p>\n\n<p>And let's not forget \"Leather and Lace,\" her duet with Don Henley. It's like the aural equivalent of a really good rom-com – sweet, a little cheesy, but damn if it doesn't make you feel things.</p>\n\n<h2>The Stevie Nicks Effect</h2>\n\n<p>What makes Stevie Nicks so special isn't just her music – it's the whole package. She's got that mystical, otherworldly vibe that makes you wonder if she really might be a witch. (Spoiler alert: she's not. Probably.) But behind all the twirling and the shawls, there's a songwriter of immense depth and humanity.</p>\n\n<p>Songs like \"Sara\" and \"Silver Springs\" aren't just pretty melodies – they're raw, emotional powerhouses. Stevie has this incredible ability to take her personal pain and turn it into something universal. It's like she's singing straight to your soul, telling you, \"Hey, I've been there too, and it sucks, but we're gonna get through this.\"</p>\n\n<h2>The Legacy of a Rock Goddess</h2>\n\n<p>Looking back, it's hard to believe Stevie was ever worried about her solo career. \"Bella Donna\" wasn't just a success – it was a game-changer. It proved that Stevie Nicks wasn't just a member of Fleetwood Mac; she was a force of nature in her own right.</p>\n\n<p>So here's to Stevie Nicks – the reluctant goddess who faced her fears and came out singing. She might not be an actual witch, but she sure as hell worked her magic on the music world. And honestly? I'd take Stevie's brand of sorcery over a real spell any day. After all, has Harry Potter ever written a song as good as \"Dreams\"? I think not.</p>\n</article>\n\n{slug}\nstevie-nicks-solo-career-bella-donna\n\n{custom-excerpt}\nStevie Nicks: From Fleetwood Witch to Solo Sorceress\n\n{meta-title}\nStevie Nicks: The Reluctant Goddess of Rock's Solo Flight\n\n{meta-description}\nDive into Stevie Nicks' journey from Fleetwood Mac to solo stardom. Discover how the rock goddess overcame her fears to create the iconic \"Bella Donna\" album.\n\n{keywords}\nStevie Nicks, Bella Donna, Fleetwood Mac, solo career, rock goddess, 80s music, Edge of Seventeen"
            }
        ],
        "stop_reason": "end_turn",
        "stop_sequence": null,
        "usage": {
            "input_tokens": 1637,
            "output_tokens": 1443
        }
    }
]

Text parser output:

[
    {
        "i": 1,
        "tag": "h2",
        "text": "From Witchy Woman to Solo Sorceress"
    },
    {
        "i": 2,
        "tag": "p",
        "text": "Picture this: It's 1981, and Stevie Nicks, the reigning queen of rock 'n' roll mysticism, is about to unleash her first solo album upon the world. But here's the kicker – she's scared out of her witchy little mind. Who knew that the woman who could cast a spell over millions with a twirl of her shawl could get stage fright?"
    },
    {
        "i": 3,
        "tag": "p",
        "text": "Now, I know what you're thinking. \"Dan, how could Stevie freaking Nicks be afraid of anything?\" Well, my dear reader, even goddesses have their moments of doubt. It's like when I tried to make a soufflé for the first time – sure, I could whip up a mean microwave burrito, but a fancy French egg dish? That's a whole other level of culinary sorcery."
    },
    {
        "i": 4,
        "tag": "h2",
        "text": "The Mac Attack: Stevie's Fleetwood Foundation"
    },
    {
        "i": 5,
        "tag": "p",
        "text": "Before we dive into Stevie's solo journey, let's rewind a bit. Picture Fleetwood Mac in their heyday – a band so dysfunctional they made the Kardashians look like the Brady Bunch. Yet, somehow, they managed to create pure magic. Stevie was the ethereal force behind classics like \"Rhiannon\" and \"Dreams.\" She wasn't just singing; she was conjuring spirits and breaking hearts with every breathy note."
    },
    {
        "i": 6,
        "tag": "p",
        "text": "But here's the thing about being in a band – it's like being in a really complicated group chat. Sometimes your messages get lost in the shuffle, or worse, left on read. Stevie had more songs up her billowy sleeves than Fleetwood Mac albums could hold. It was time for her to break free, like a beautiful, emotionally damaged butterfly."
    },
    {
        "i": 7,
        "tag": "h2",
        "text": "Bella Donna: The Birth of Solo Stevie"
    },
    {
        "i": 8,
        "tag": "p",
        "text": "Enter \"Bella Donna,\" Stevie's solo debut. Now, you'd think after years of performing with Fleetwood Mac, she'd strut into the studio like she owned the place. But nope, our girl was shaking in her platform boots. As she told NPR, \"I was terrified that was going to tank.\" It's like when you post a selfie and refresh Instagram every two seconds to see if anyone's liked it. Except, you know, with millions of dollars and your entire career on the line."
    },
    {
        "i": 9,
        "tag": "p",
        "text": "But here's where Stevie proved she wasn't just a pretty voice in a flowing dress. She went into that studio with legendary producer Jimmy Iovine and knocked it out of the park faster than you can say \"Edge of Seventeen.\" It was like watching a master chef work their magic – efficient, focused, and absolutely delicious."
    },
    {
        "i": 10,
        "tag": "h2",
        "text": "Breaking Free from the Mac Mold"
    },
    {
        "i": 11,
        "tag": "p",
        "text": "Now, if you're expecting \"Bella Donna\" to be Fleetwood Mac 2.0, you're in for a surprise. This album is pure, unadulterated Stevie. It's like she took all the witchy woman vibes, cranked them up to eleven, and added a dash of '80s rock goddess for good measure."
    },
    {
        "i": 12,
        "tag": "p",
        "text": "Take \"Edge of Seventeen,\" for example. That guitar riff hits you like a freight train of coolness. It's the kind of song that makes you want to put on your best leather jacket and strut down the street in slow motion. Lindsey Buckingham could never."
    },
    {
        "i": 13,
        "tag": "p",
        "text": "And let's not forget \"Leather and Lace,\" her duet with Don Henley. It's like the aural equivalent of a really good rom-com – sweet, a little cheesy, but damn if it doesn't make you feel things."
    },
    {
        "i": 14,
        "tag": "h2",
        "text": "The Stevie Nicks Effect"
    },
    {
        "i": 15,
        "tag": "p",
        "text": "What makes Stevie Nicks so special isn't just her music – it's the whole package. She's got that mystical, otherworldly vibe that makes you wonder if she really might be a witch. (Spoiler alert: she's not. Probably.) But behind all the twirling and the shawls, there's a songwriter of immense depth and humanity."
    },
    {
        "i": 16,
        "tag": "p",
        "text": "Songs like \"Sara\" and \"Silver Springs\" aren't just pretty melodies – they're raw, emotional powerhouses. Stevie has this incredible ability to take her personal pain and turn it into something universal. It's like she's singing straight to your soul, telling you, \"Hey, I've been there too, and it sucks, but we're gonna get through this.\""
    },
    {
        "i": 17,
        "tag": "h2",
        "text": "The Legacy of a Rock Goddess"
    },
    {
        "i": 18,
        "tag": "p",
        "text": "Looking back, it's hard to believe Stevie was ever worried about her solo career. \"Bella Donna\" wasn't just a success – it was a game-changer. It proved that Stevie Nicks wasn't just a member of Fleetwood Mac; she was a force of nature in her own right."
    },
    {
        "i": 19,
        "tag": "p",
        "text": "So here's to Stevie Nicks – the reluctant goddess who faced her fears and came out singing. She might not be an actual witch, but she sure as hell worked her magic on the music world. And honestly? I'd take Stevie's brand of sorcery over a real spell any day. After all, has Harry Potter ever written a song as good as \"Dreams\"? I think not."
    }
]
{(?<tag>[^}]+)}\s*(?<text>[\w\W]+?)\s*(?={|$)

Demo: https://regex101.com/r/KKUI0f/1

samliewrequest private consultation

Join the Make Fans Discord server to chat with other makers!

Thank you so much @samliew you’ve been more than helpful and this solution is perfect!

No problem, glad I could help!

1. If anyone has a new question in the future, please start a new thread. This makes it easier for others with the same problem to search for the answers to specific questions, and you are more likely to receive help since newer questions are monitored closely.

2. The Make Community guidelines encourages users to try to mark helpful replies as solutions to help keep the Community organized.

This marks the topic as solved, so that:

  • others can save time when catching up with the latest activity here, and
  • allows others to quickly jump to the solution if they come across the same problem

To do this, simply click the checkbox at the bottom of the post that answers your question:
Screenshot_2023-10-04_161049

3. Don’t forget to like and bookmark this topic so you can get back to it easily in future!

4. Do join the unofficial Make Discord server for live chat and video assistance

samliewrequest private consultation

Join the Make Fans Discord server to chat with other makers!