PowerBuilder
PowerBuilder
Markdown to HTML - Full Document, Custom Theme with Code Syntax Highlighting
See more Markdown Examples
Demonstrates how to convert a complete Markdown document to HTML using your own custom theme with Cloudfare Prism's code syntax highlighting.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Options
oleobject loo_SbHead
integer li_BCrlf
oleobject loo_SbMarkdown
oleobject loo_SbHtml
li_Success = 0
li_Success = 0
loo_Options = create oleobject
li_rc = loo_Options.ConnectToNewObject("Chilkat.JsonObject")
if li_rc < 0 then
destroy loo_Options
MessageBox("Error","Connecting to COM object failed")
return
end if
// Instead of specifying a "theme", provide values for the HTML document parts.
loo_SbHead = create oleobject
li_rc = loo_SbHead.ConnectToNewObject("Chilkat.StringBuilder")
li_BCrlf = 1
loo_SbHead.AppendLine("<head>",li_BCrlf)
loo_SbHead.AppendLine("<style>",li_BCrlf)
loo_SbHead.AppendLine("body {",li_BCrlf)
loo_SbHead.AppendLine(" font-family: ~"Segoe UI~", Tahoma, Geneva, Verdana, sans-serif;",li_BCrlf)
loo_SbHead.AppendLine("}",li_BCrlf)
loo_SbHead.AppendLine("</style>",li_BCrlf)
loo_SbHead.AppendLine("</head>",li_BCrlf)
// Each HTML section can be set individually.
loo_Options.UpdateString("docType","<!DOCTYPE html>")
loo_Options.UpdateString("rootElement","<html lang=~"en~">")
loo_Options.UpdateString("head",loo_SbHead.GetAsString())
loo_Options.UpdateString("bodyStart","<body>~n<div id=~"content~"")
loo_Options.UpdateString("bodyEnd","</div>~n</body>")
// We can add extra content to the bottom of the HTML head and body sections like this:
// Here we are using the Cloudfare Prism "coy" theme for code syntax higlighting.
loo_Options.UpdateString("extraHead","<link rel=~"stylesheet~" href=~"https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-coy.min.css~" />")
loo_Options.UpdateString("extraBody","<script src=~"https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js~"></script><script src =~"https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/autoloader/prism-autoloader.min.js~"></script>")
loo_SbMarkdown = create oleobject
li_rc = loo_SbMarkdown.ConnectToNewObject("Chilkat.StringBuilder")
loo_SbHtml = create oleobject
li_rc = loo_SbHtml.ConnectToNewObject("Chilkat.StringBuilder")
li_Success = loo_SbMarkdown.LoadFile("qa_data/markdown/test1.md","utf-8")
if li_Success = 0 then
Write-Debug loo_SbMarkdown.LastErrorText
destroy loo_Options
destroy loo_SbHead
destroy loo_SbMarkdown
destroy loo_SbHtml
return
end if
loo_SbMarkdown.MarkdownToHtml(loo_Options,loo_SbHtml)
loo_SbHtml.ToCRLF()
Write-Debug loo_SbHtml.GetAsString()
// The sample markdown input for this example is identical to the one at Markdown to HTML - Full Document, Raw, where you can view it.
// Sample HTML output as viewed in a browser:
//
destroy loo_Options
destroy loo_SbHead
destroy loo_SbMarkdown
destroy loo_SbHtml