Skip to content

Instantly share code, notes, and snippets.

@iknowkungfoo
Last active October 6, 2018 17:07
Show Gist options
  • Save iknowkungfoo/2c73f83e081bf4f9f86d9f3426094b99 to your computer and use it in GitHub Desktop.
Save iknowkungfoo/2c73f83e081bf4f9f86d9f3426094b99 to your computer and use it in GitHub Desktop.
Convert BlogCFC blog posts to markdown files, which can then be imported into Jekyll static sites like Github Pages and Gitlab Pages. https://adrianmoreno.com/2018/10/06/converting-blogcfc-posts-to-markdown.html
<cfoutput>
<cfloop query="blog">
<cfset blogPost = blog.post_more>
<cfif len(blogPost) GT 0>
<cfset blogPost = reReplaceNoCase(blogPost, "\<\/h[0-9]\>", "", "all")>
<cfset blogPost = reReplaceNoCase(blogPost, "\<\h1\>", "#chr(35)# ", "all")>
<cfset blogPost = reReplaceNoCase(blogPost, "\<\h2\>", "#chr(35)##chr(35)# ", "all")>
<cfset blogPost = reReplaceNoCase(blogPost, "\<\h3\>", "#chr(35)##chr(35)##chr(35)# ", "all")>
<cfset blogPost = reReplaceNoCase(blogPost, "\<\h4\>", "#chr(35)##chr(35)##chr(35)##chr(35)# ", "all")>
<cfset blogPost = reReplaceNoCase(blogPost, "\<\h5\>", "#chr(35)##chr(35)##chr(35)##chr(35)##chr(35)# ", "all")>
<cfset blogPost = reReplaceNoCase(blogPost, "(\<fieldset\>|\<\/fieldset\>)", "", "all")>
<cfset blogPost = reReplaceNoCase(blogPost, "(\<strong\>|\<\/strong\>)", "#chr(42)##chr(42)#", "all")>
<cfset blogPost = reReplaceNoCase(blogPost, "(\<b\>|\<\/b\>)", "#chr(42)##chr(42)#", "all")>
<cfset blogPost = reReplaceNoCase(blogPost, "(\<em\>|\<\/em\>)", "#chr(95)#", "all")>
<cfset blogPost = reReplaceNoCase(blogPost, "(\<i\>|\<\/i\>)", "#chr(95)#", "all")>
<cfset blogPost = reReplaceNoCase(blogPost, "\<legend\>", "#chr(35)##chr(35)##chr(35)# ", "all")>
<cfset blogPost = reReplaceNoCase(blogPost, "\<\/legend\>", "", "all")>
<cfset blogPost = reReplaceNoCase(blogPost, "\<code\>", "```cfscript#chr(10)##chr(13)#", "all")>
<cfset blogPost = reReplaceNoCase(blogPost, "\<\/code\>", "#chr(10)##chr(13)#cfscript```", "all")>
</cfif>
<cfset blogTitle = blog.post_title>
<cfset blogTitle = reReplaceNoCase(blogTitle, chr(34), chr(39), "all")>
<cfinclude template="blogcfc_to_markdown_03.cfm">
</cfloop>
<h1>#blog.recordcount# Pages Created</h1>
</cfoutput>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment