AutoIt
AutoIt
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 AutoIt Downloads
Local $bSuccess = False
$bSuccess = False
$oOptions = ObjCreate("Chilkat.JsonObject")
; Instead of specifying a "theme", provide values for the HTML document parts.
$oSbHead = ObjCreate("Chilkat.StringBuilder")
Local $bCrlf = True
$oSbHead.AppendLine("<head>",$bCrlf)
$oSbHead.AppendLine("<style>",$bCrlf)
$oSbHead.AppendLine("body {",$bCrlf)
$oSbHead.AppendLine(" font-family: ""Segoe UI"", Tahoma, Geneva, Verdana, sans-serif;",$bCrlf)
$oSbHead.AppendLine("}",$bCrlf)
$oSbHead.AppendLine("</style>",$bCrlf)
$oSbHead.AppendLine("</head>",$bCrlf)
; Each HTML section can be set individually.
$oOptions.UpdateString("docType","<!DOCTYPE html>")
$oOptions.UpdateString("rootElement","<html lang=""en"">")
$oOptions.UpdateString("head",$oSbHead.GetAsString())
$oOptions.UpdateString("bodyStart","<body>" & @LF & "<div id=""content""")
$oOptions.UpdateString("bodyEnd","</div>" & @LF & "</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.
$oOptions.UpdateString("extraHead","<link rel=""stylesheet"" href=""https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-coy.min.css"" />")
$oOptions.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>")
$oSbMarkdown = ObjCreate("Chilkat.StringBuilder")
$oSbHtml = ObjCreate("Chilkat.StringBuilder")
$bSuccess = $oSbMarkdown.LoadFile("qa_data/markdown/test1.md","utf-8")
If ($bSuccess = False) Then
ConsoleWrite($oSbMarkdown.LastErrorText & @CRLF)
Exit
EndIf
$oSbMarkdown.MarkdownToHtml($oOptions,$oSbHtml)
$oSbHtml.ToCRLF()
ConsoleWrite($oSbHtml.GetAsString() & @CRLF)
; 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:
;