Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bonomali/592b39dc5b0268a330f618957a3c12df to your computer and use it in GitHub Desktop.
Save bonomali/592b39dc5b0268a330f618957a3c12df to your computer and use it in GitHub Desktop.
TryCF Gist
<cfsavecontent variable="theTagContent">
<p>
one<br />
<img src="//yaffa-cdn.s3.amazonaws.com/adnews/live/images/dmImage/StandardImage/dsc04193_sm.jpg" border="0" alt="dsc04193_sm.jpg" width="630" height="420" /><br />
<div>DIV</div>
two<br />
<img src="//yaffa-cdn.s3.amazonaws.com/adnews/live/images/dmImage/StandardImage/michaelmiller-kimportrate2.jpg" border="0" alt="Michael Miller and Kim Portrate" width="630" height="428" /><br />
three<br />
<img src="//yaffa-cdn.s3.amazonaws.com/adnews/live/images/dmImage/StandardImage/food-health-junk-getty-thinkstock2.jpg" border="0" alt="junk - image description in article" width="630" height="500" /><br />
end
</p>
<hr />
<h1>Test for Apple News</h1> <h2>Pargraphs</h2> <p>The Heart Foundation and News Corp have teamed up in a campaign urging the government to take action against Australia’s number one killer – heart disease.</p> <p>Created by News Corp’s media and marketing division Newsamp, and creative agency Host/Havas Australia, the ‘Serial Killer’ campaign taps into the current popularity of true crime stories by highlighting that heart disease kills 51 people per day.</p> <p>In the lead up to its launch today, the work has been teased across News Corp’s publications, including its Sunday metro newspapers and True Crime Australia site, telling Australian’s to stay tuned for the reveal of Australia’s number one killer.</p> <h2>YouTube</h2> <p>YouTube link by itself</p> <p>https://www.youtube.com/watch?v=Xva5nDw-VQI</p> <p>YouTube in paragraph<br />https://www.youtube.com/watch?v=Xva5nDw-VQI</p> <p>2 Youtubes in Paragraph<br />https://www.youtube.com/watch?v=Xva5nDw-VQI<br />https://www.youtube.com/watch?v=Xva5nDw-VQI</p> <p>as a link<br /><a href="https://www.youtube.com/watch?v=Xva5nDw-VQI">https://www.youtube.com/watch?v=Xva5nDw-VQI</a></p> <h2>Twitter</h2> <p>https://twitter.com/daemonites/status/1028894923272200192</p> <p>in a paragraph<br />https://twitter.com/daemonites/status/1028894923272200192</p> <p>2 in 1 paragraph<br />https://twitter.com/daemonites/status/1028894923272200192<br />https://twitter.com/daemonites/status/1028894923272200192</p> <p>as a link<br /><a href="https://twitter.com/daemonites/status/1028894923272200192">https://twitter.com/daemonites/status/1028894923272200192</a> </p> <h2>Images</h2> <p><img src="//yaffa-cdn.s3.amazonaws.com/adnews/live/images/dmImage/StandardImage/dsc04193_sm.jpg" border="0" alt="dsc04193_sm.jpg" width="630" height="420" /></p> <p><img src="//yaffa-cdn.s3.amazonaws.com/adnews/live/images/dmImage/StandardImage/michaelmiller-kimportrate2.jpg" border="0" alt="Michael Miller and Kim Portrate" width="630" height="428" /></p> <p><img src="//yaffa-cdn.s3.amazonaws.com/adnews/live/images/dmImage/StandardImage/food-health-junk-getty-thinkstock2.jpg" border="0" alt="junk - image description in article" width="630" height="500" /></p> <h2>Figure with caption</h2> <figure class="align-center "><br /> <img src="https://images.theconversation.com/files/315866/original/file-20200218-10995-gbbu2y.jpg?ixlib=rb-1.1.0&amp;q=45&amp;auto=format&amp;w=754&amp;fit=clip" border="0" alt="" width="554" height="690" /><br /> <figcaption><br /> <span class="caption">A Holden ad published in the Daily Mercury on June 22 1932, with General Motors’ slogan, ‘More wealth for Australia, more jobs for Australians’.</span><br /> <span class="attribution"><a class="source" href="https://trove.nla.gov.au/newspaper/article/172806804?searchTerm=%22more%20wealth%20for%20Australia%2C%20more%20jobs%20for%20Australians%22&amp;searchLimits=">National Library of Australia</a></span><br /> </figcaption></figure> <h2>Blockquote</h2> <blockquote> <p>This is a blockquote which should be indented with left border to copy the website</p> </blockquote> <h1>Frames</h1> <h2>LinkedIn</h2> <p><iframe title="Embedded post" src="https://www.linkedin.com/embed/feed/update/urn:li:share:6633177277427486720" width="504" height="452" frameborder="0" allowfullscreen="allowfullscreen"></iframe></p> <h2>embed.acast.com</h2> <p><iframe style="border: none; overflow: hidden;" src="https://embed.acast.com/theadnewspodcast/ngen-podcast-how-to-avoid-burn-out" width="100%" height="188" frameborder="0" scrolling="no"></iframe> <iframe style="border: none; overflow: hidden;" src="https://embed.acast.com/theadnewspodcast/ngen-podcast-diversity-in-the-workplace" width="100%" height="188" frameborder="0" scrolling="no"></iframe></p> <h2>Facebook - p / iframe</h2> <p><iframe style="border: none; overflow: hidden;" src="https://www.facebook.com/plugins/post.php?href=https%3A%2F%2Fwww.facebook.com%2Fjacindaardern%2Fposts%2F10155849854267441&amp;width=500" width="500" height="299" frameborder="0" scrolling="no"></iframe></p> <p><iframe style="border: none; overflow: hidden; display: block; margin-left: auto; margin-right: auto;" src="https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2Fnewscorpaustralia%2Fvideos%2F1083502861856801%2F&amp;show_text=0&amp;width=560" width="585" height="329" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen"></iframe></p> <h2>Vimeo - p / iframe</h2> <p><iframe src="https://player.vimeo.com/video/390656926" width="640" height="360" frameborder="0" allowfullscreen="allowfullscreen"></iframe></p> <h2>Ticktok - p / iframe</h2> <p><iframe src="https://www.tiktok.com/embed/6702982021351886082" width="100%" height="700" frameborder="0" allowfullscreen="allowfullscreen"></iframe></p> <h2>e.infogram.com</h2> <p><iframe style="border: none;" title="TV Ratings Week 30" src="//e.infogram.com/tv_ratings_week_30?src=embed" width="554" height="4448" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen"></iframe></p> <div style="padding: 8px 0; font-family: Arial!important; font-size: 13px!important; line-height: 15px!important; text-align: center; border-top: 1px solid #dadada; margin: 0 30px;"><a style="color: #989898!important; text-decoration: none!important;" href="https://infogram.com/tv_ratings_week_30" target="_blank">TV Ratings Week 30</a><br /> <a style="color: #989898!important; text-decoration: none!important;" href="https://infogram.com/create/pie-chart?utm_source=embed_bottom&amp;utm_medium=seo&amp;utm_campaign=pie_chart" target="_blank" rel="nofollow">Infogram</a></div>
</cfsavecontent>
<cfsavecontent variable="match"><(\w+)( [^>]+)?(.*?)></cfsavecontent>
<cfsavecontent variable="match"><(\w+)( [^>]+)?(.*?)>?(.*?)(</\1>)?</cfsavecontent>
<cfscript>
private array function getAllTags(
required string content
) {
// var matchALL = "<(\w+)( [^>]+)?>.*?</\1>"; // open/close tags - Blair 2
var matchALL = "<(\w+)( [^>]+)?/?>.*?</\1>?"; // open/close tags - Blair 2 + mod for <hr/>
var aALLTags = REMatchNoCase(matchALL,arguments.content);
return aALLTags;
}
private array function getAllMatches (
required string match,
required string content
) {
var aMatches = [];
var stMatch = {};
var start = 1;
var realMataches = [];
var realMatch = '';
stMatch = REFindNoCase( ARGUMENTS.match, ARGUMENTS.content, start, true );
while (stMatch.len[1] != 0) {
if (stMatch.len[1] != 0) {
realMatch = Mid(ARGUMENTS.content, stMatch['pos'][1], stMatch['len'][1]);
} else {
realMatch = '';
}
realMataches.append(realMatch);
start = stMatch.pos[1] + stMatch.len[1];
aMatches.append(stMatch);
stMatch = REFindNoCase( ARGUMENTS.match, ARGUMENTS.content, start, true );
} // while
return realMataches;
} // getAllMatches
private string function getTagContent(
required string tag
) {
var match = "<(\w+)( [^>]+)?/?>(.*)?</\1>?";
var tagContent = '';
var stTags = REFindNoCase( match, arguments.tag, 1, true );
if (stTags.len[1] != 0 AND stTags.len[4] > 0) {
tagContent = Mid(arguments.tag,stTags.pos[4], stTags.len[4]);
}
tagContent = Trim(tagContent);
return tagContent;
}
private boolean function hasContent (
required string tag
) {
var content = '';
var matchPcontent = "<(\w+)( [^>]+)?/?>(.*?)?</\1>?";
var stMatch = REFindNoCase(matchPcontent , arguments.tag, 1, true );
if ( stMatch.len[1] > 0) {
content = Mid(arguments.tag, stMatch.pos[4], stMatch.len[4]);
if (content == '') {
return false;
}
// if this is a tag, recurse
stMatch = REFindNoCase(matchPcontent , content, 1, true );
if (stMatch.len[1] > 0) {
return hasContent(content);
} else {
return true;
}
} else {
return false;
}
}
writeDump(theTagContent);
aTags = getAllTags(theTagContent);
for (tag in aTags) {
if (hasContent(tag)) {
writeDump(var="#tag#", label="tag has content");
} else {
writeDump(var="#tag#", label="tag has NO content");
aTags2 = getAllTags(theTagContent);
writeDump(var="#aTags2#", label="tag has NO content");
}
}
//writeDump(getAllMatches(match,theTagContent));
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment