Skip to content
This repository has been archived by the owner on Apr 12, 2019. It is now read-only.

simoncropparchived/Strike

Repository files navigation

Icon

Wraps Marked.js to make it usable from .net.

Nuget

The project is shipped in several nugets. You only need to pick one.

There are now five packages to choose from

Strike.IE NuGet Status

Uses the MSIE engine and has a dependency on the MSIE package. http://nuget.org/packages/Strike.IE

PM> Install-Package Strike.IE

Strike.IE.Merged NuGet Status

Uses the MSIE engine and merges the MSIE assembly. http://nuget.org/packages/Strike.IE.Merged

PM> Install-Package Strike.IE.Merged

Strike.Jint NuGet Status

Uses the Jint engine and has a dependency on the Jint package. http://nuget.org/packages/Strike.Jint

PM> Install-Package Strike.Jint

Strike.Jint.Merged NuGet Status

Uses the Jint engine and merges the Jint assembly. http://nuget.org/packages/Strike.Jint.Merged

PM> Install-Package Strike.Jint.Merged

Strike.V8 NuGet Status

Uses the V8 engine and has a dependency on the ClearScript V8 package. http://www.nuget.org/packages/Strike.V8/

PM> Install-Package Strike.V8

Usage

So if you run this

var input = @"
| Tables        | Are           | Cool  |
| ------------- |:-------------:| -----:|
| col 3 is      | right-aligned | $1600 |
| col 2 is      | centered      |   $12 |
";

using (var markdownify = new Markdownify())
{
    Debug.WriteLine(markdownify.Transform(input));
}

The output will be this

<table>
	<thead>
		<tr>
			<th>Tables</th>
			<th style="text-align:center">Are</th>
			<th style="text-align:right">Cool</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td>col 3 is</td>
			<td style="text-align:center">right-aligned</td>
			<td style="text-align:right">$1600</td>
		</tr>
		<tr>
			<td>col 2 is</td>
			<td style="text-align:center">centered</td>
			<td style="text-align:right">$12</td>
		</tr>
	</tbody>
</table>

Note: The indentation is added for clarity.

MarkedJS

The binary ships with a resource merged version of MarkedJS. Also see the License.

The Marked.js version

The version included in the stable version of Strike is v0.3.6

The version included in the unstable version of Strike is the version as at Tag v0.3.6.

If you feel a newer version should be included at any point in time please raise an issue.

Running a custom version

If you want to run a custom version of MarkedJS simply place the custom marked.js in the current running directory and that file will be used instead of the merged version. The newest MarkedJS file can be obtained here https://github.com/chjj/marked/tree/master/lib.

Controlling Marked

The Markdownify class takes two parameters

Options

Represents Marked Options

public class Options
{
    /// <summary>
    /// Enable GitHub flavored markdown.
    /// https://github.com/chjj/marked#gfm
    /// </summary>
    public bool GitHubFlavor = true;

    /// <summary>
    /// https://github.com/chjj/marked#tables
    /// Enable GFM tables. This option requires the gfm option to be true.
    /// </summary>
    public bool Tables = true;

    /// <summary>
    /// Enable GFM line breaks. This option requires the gfm option to be true.
    /// https://github.com/chjj/marked#breaks
    /// </summary>
    public bool Breaks;

    /// <summary>
    /// Conform to obscure parts of markdown.pl as much as possible. Don't fix any of the original markdown bugs or poor behavior.
    /// https://github.com/chjj/marked#pedantic
    /// </summary>
    public bool Pedantic;

    /// <summary>
    /// Sanitize the output. Ignore any HTML that has been input.
    /// Default: false
    /// https://github.com/chjj/marked#sanitize
    /// </summary>
    public bool Sanitize;

    /// <summary>
    /// Use smarter list behavior than the original markdown. 
    /// Default: true
    /// https://github.com/chjj/marked#smartlists
    /// </summary>
    public bool SmartLists = true;

    /// <summary>
    /// Use "smart" typograhic punctuation for things like quotes and dashes.
    /// Default: false
    /// https://github.com/chjj/marked#smartypants
    /// </summary>
    public bool SmartyPants;

    /// <summary>
    /// Use "Xhtml" rendering.
    /// Default: false
    /// https://github.com/chjj/marked#xhtml
    /// </summary>
    public bool Xhtml;

    /// <summary>
    /// A function to highlight code blocks. 
    /// https://github.com/chjj/marked#highlight
    /// Default: "function (code) {return code;}"
    /// </summary>
    public string Highlight = "function (code) {return code;}";
}

RenderMethods

Represents Block level render methods and Inline level render methods

public class RenderMethods
{
    public string Code;
    public string BlockQuote;
    public string Html;
    public string Heading;
    public string Hr;
    public string List;
    public string ListItem;
    public string Paragraph;
    public string Table;
    public string TableRow;
    public string TableCell;
    public string Strong;
    public string Em;
    public string Codespan;
    public string Br;
    public string Del;
    public string Link;
    public string Text;
    public string Image;
}

Icon

Lightning designed by Thomas Le Bas from The Noun Project