Class MarkdownDocument

Class that wraps the Active Markdown document used in the editor. [ComVisible] is important as we access this from JavaScript

System.Object
  MarkdownMonster.MarkdownDocument
public class MarkdownDocument : object, INotifyPropertyChanged

Class Members

MemberDescription

Constructor

BeforeDocumentRendered

Event that fires just before the document is rendered. It's passed the Markdown text before it is converted to HTML so you can intercept and modify the markdown before rendering.

Return back the final markdown.

DocumentRendered

Event that fires after the final HTML document has been created when merging with a preview template. The html contains the fully rendered HTML document before it is returned or written to file.

Parameters: * Rendered Html * Original Markdown

You return: * Updated (or unaltered) HTML

IsDirtyChanged

Event fired when the dirty changed of the document changes

MarkdownRendered

Event that fires after the raw markdown has been rendered to html. Note this will be an HTML fragment not an HTML document.

Parameters: * Rendered Html * Original Markdown

You return: * Updated (or unaltered) HTML

PropertyChanged

PREVIEW_HTML_FILENAME

PREVIEW_HTML_SOURCE_FILENAME

AddExtraHeaders

Allows adding extra headers that are embedded into the HTML output file's HEAD section

public void AddExtraHeaders(string extraHeaderText)

AutoSaveAsync

Creates a backup file

public void AutoSaveAsync(string filename)

CleanupBackupFile

Cleans up the backup file and removes the timer

public void CleanupBackupFile(string filename)

Close

Cleans up after the file is closed by deleting the HTML render file.

public void Close()

GetFileEncoding

Retrieve the file encoding for a given file so we can capture and store the Encoding when writing the file back out after editing.

Default is Utf-8 (w/ BOM). If file without BOM is read it is assumed it's UTF-8.

public void GetFileEncoding(string filename)

GetPreviewWebRootPath

Sets the PreviewWebRootPath from content in the YAML of the document: webRootPath: c:\temp\post\Topic\

public string GetPreviewWebRootPath()

HasBackupFile

Checks to see whether there's a backup file present

public bool HasBackupFile()

HasFileChanged

Determines whether text has changed from original.

This method exists to explicitly check the dirty state which can be set from a number of sources.

public bool HasFileChanged(string currentText)

HasFileCrcChanged

Checks to see if the CRC has changed

public bool HasFileCrcChanged()

IsFileEncrypted

Determines whether the file on disk is encrypted

public bool IsFileEncrypted(string filename)

Load

Loads the markdown document into the CurrentText

public bool Load(string filename,     SecureString password)

OnPropertyChanged

public virtual void OnPropertyChanged(string propertyName)

RenderHtml

Renders markdown of the current document text into raw HTML

public string RenderHtml(string markdown,     bool usePragmaLines,     bool noBanner)

RenderHtmlToFile

Renders markdown from the current document using the appropriate Theme Template and writing an output file. Options allow customization and can avoid writing out a file.

public string RenderHtmlToFile(string markdown,     string filename,     string theme,     bool usePragmaLines,     bool noFileWrite,     bool removeBaseTag,     bool noBanner)

RenderHtmlWithTemplate

Renders HTML output with the active Template to a full HTML document as a string.

public string RenderHtmlWithTemplate(string markdown,     string theme,     bool usePragmaLines,     bool removeBaseTag,     bool noBanner)

Save

Saves the CurrentText into the specified filename

public bool Save(string filename,     bool noBackupFileCleanup,     SecureString password)

SetHtmlRenderFilename

Allows you to explicitly override the render filename used for previewing. This allows addins to render out of custom folders when previewing since the previewer uses the HtmlRenderFilename.

This overrides the default location in the temp folder.

public void SetHtmlRenderFilename(string filename)

ToString

public virtual string ToString()

UpdateCrc

Stores the CRC of the file as currently exists on disk

public void UpdateCrc(string filename)

WriteFile

Writes the file with a retry

public bool WriteFile(string filename,     string html)

AutoSaveBackup

Determines whether backups are automatically saved

Defaults to Configuration.AutoSaveBackups

AutoSaveDocument

Determines whether documents are automatically saved in the background as soon as changes are made and you stop typing for a second. This setting takes precendence over AutoSaveBackups.

Defaults to Configuration.AutoSaveDocuments

BackupFilename

Name of the auto save backup file

CurrentText

Holds the actively edited Markdown text

Dispatcher

Window dispatcher to ensure we're synchronizing in the right context always.

Encoding

Document encoding used when writing the document to disk. Default: UTF-8 without a BOM

ExtraHtmlHeaders

Extra HTML document headers that get get added to the document in the headsection of the HTML document.

FileCrc

Holds the disk file Crc of the document. This value is used to determine if the document on disk has changed when activating a document after having navigated off and when saving.

Filename

Name of the Markdown file. If this is a new file the file is named 'untitled'

FilenamePathWithIndicator

Returns a filename plus path and a change indicator Used when multiple tabs with the same file are open

FilenameWithIndicator

Returns the filename with a dirty indicator (*) if the document has changed

HtmlRenderFilename

This is the filename used when rendering this document to HTML

IsActive

Determines whether the document is the active document

IsDirty

Determines whether the active document has changes that have not been saved yet

IsEncrypted

Determines whether the file is encrypted

IsUntitled

LastEditorLineNumber

Holds the last preview window browser scroll position so it can be restored when refreshing the preview window.

LastImageFolder

The last Image Folder used for this document

LastSaveTime

OriginalText

The original text of the document since the last save operation. Updated whenever a document is saved.

Password

Holds the username and password

PreviewWebRootPath

Path that maps / in the rendered document. If non-null this value is fixed up for special case translation in the HTML output.

Useful for fixing up root links when generating previews so the renderer can figure out a base path to render ~/ or / links from.

ProcessScripts

Internal property used to identify whether scripts are processed

Title

Tries to return the title from the active Markdown document by looking at:

1 - For # title line in the first 5 lines of text 2 - Camel Case File names 3 - Untitled - stays untitled.

Requirements

Namespace: MarkdownMonster
Assembly: markdownmonster.exe

© West Wind Technologies, 1996-2021 • Updated: 02/14/20
Comment or report problem with topic