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 document has been rendered Parameters: * Rendered Html * Original Markdown

You return: * Updated (or unaltered) HTML

IsDirtyChanged

Event fired when the dirty changed of the document changes

PropertyChanged

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)

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 renderLinksExternal,     bool usePragmaLines)

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,     bool renderLinksExternal,     string theme,     bool usePragmaLines,     bool noFileWrite,     bool removeBaseTag)

Save

Saves the CurrentText into the specified filename

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

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)

AutoSaveBackups

Determines whether backups are automatically saved

Defaults to Configuration.AutoSaveBackups

AutoSaveDocuments

Determines whether documents are automatically saved in the background as soon as changes are made and you stop typiing 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

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

OriginalText

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

Password

Holds the username and password

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, 2019 • Updated: 01/06/19
Comment or report problem with topic