https://github.com/cyotek/markdig.keyboard
Markdig extension for inserting kbd tags
https://github.com/cyotek/markdig.keyboard
csharp markdig
Last synced: about 1 year ago
JSON representation
Markdig extension for inserting kbd tags
- Host: GitHub
- URL: https://github.com/cyotek/markdig.keyboard
- Owner: cyotek
- License: mit
- Created: 2020-11-28T05:46:29.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-06-01T17:26:46.000Z (almost 5 years ago)
- Last Synced: 2025-03-29T19:01:05.484Z (about 1 year ago)
- Topics: csharp, markdig
- Language: C#
- Homepage:
- Size: 106 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Markdig.Keyboard.Extension
[![NuGet][nugetbadge]][nuget]
[![Donate][paypalbadge]][paypal]
![A basic demonstration showing the output][1]
The **Markdig.Keyboard** library is an extension for use with
the [Markdig][2] processing library and allows easier insertion
of `kbd` elements without having to resort to raw HTML.
## Getting the library
The easiest way of obtaining the library is via [NuGet][nuget].
> `Install-Package Cyotek.Markdig.Keyboard`
## Using the library
When you build your Markdig pipeline, call `UseKeyboard()`. Any
text wrapped in double angled brackets will be converted to
`kbd` tags.
```csharp
_markdownPipeline = new MarkdownPipelineBuilder()
.UseAdvancedExtensions()
.UseKeyboard()
.Build();
```
## Options
There is also a `KeyboardOptions` class you can use to control
the output. Currently it allows you either to assign a CSS class
to generated elements via the `ClassName` property, or specify a
different HTML tag via the `TagName` property.
```csharp
_markdownPipeline = new MarkdownPipelineBuilder()
.UseAdvancedExtensions()
.UseKeyboard(new KeyboardOptions
{
ClassName = "my-class",
TagName = "code"
})
.Build();
```
## Examples
This first example uses default options, which output `kbd` tags
with no further processing.
```csharp
var markdownPipeline = new MarkdownPipelineBuilder()
.UseAdvancedExtensions()
.UseKeyboard()
.Build();
var output = Markdown.ToHtml(@"### File Menu
| Description | Shortcut Keys |
| ----------- | ------------- |
| New | <> |
| Open | <> |
| Save | <> |
| Save As | |
| Export | |
| Exit | <> |
", markdownPipeline);
```
```html
File Menu
Description
Shortcut Keys
New
Ctrl+N
Open
Ctrl+O
Save
Ctrl+S
Save As
Export
Exit
Alt+F4
```
This second example uses custom options to change the output tag
to `code` and apply a custom class.
```csharp
var markdownPipeline = new MarkdownPipelineBuilder()
.UseAdvancedExtensions()
.UseKeyboard(new KeyboardOptions
{
ClassName = "keyboard",
TagName = "code"
})
.Build();
var output = Markdown.ToHtml("Press <> to exit.", markdownPipeline);
```
```html
Press Alt+F4 to exit.
```
## Requirements
.NET Framework 3.5 or later.
Pre-built binaries are available via a signed [NuGet package][nuget]
containing the following targets.
* .NET 4.8
* .NET 4.7.2
* .NET 4.6.2
* .NET 4.6
* .NET Standard 2.0
* .NET Standard 2.1
* .NET Core 2.1
* .NET Core 3.1
* .NET 5.0
Is there a target not on this list you'd like to see? Raise an
[issue][ghissue], or even better, a [pull request][ghpull].
## Acknowledgements
Interim package icon derived from the [Tango Icon Library][3].
## License
This source is licensed under the MIT license. See `LICENSE.txt`
for the full text.
[nugetbadge]: https://img.shields.io/nuget/v/Cyotek.Markdig.Keyboard.svg
[nuget]: https://www.nuget.org/packages/Cyotek.Markdig.Keyboard/
[paypalbadge]: https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif
[paypal]: https://paypal.me/cyotek
[ghissue]: https://github.com/cyotek/Markdig.Keyboard/issues
[ghpull]: https://github.com/cyotek/Markdig.Keyboard/pulls
[ghrel]: https://github.com/cyotek/Markdig.Keyboard/releases
[gh]: https://github.com/cyotek/Markdig.Keyboard
[1]: res/screenshot.png
[2]: https://github.com/lunet-io/markdig/
[3]: https://www.iconfinder.com/icons/118804/map_character_accessories_icon