Skip to content

Commit dabf925

Browse files
committed
Fixed merge conflict and failing test
2 parents dd96654 + 252063c commit dabf925

File tree

7 files changed

+79
-19
lines changed

7 files changed

+79
-19
lines changed

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "nuget"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: on-push-do-docs
2+
on:
3+
push:
4+
jobs:
5+
docs:
6+
runs-on: ubuntu-20.04
7+
steps:
8+
- uses: actions/checkout@v2
9+
- name: Run MarkdownSnippets
10+
run: |
11+
dotnet tool install --global MarkdownSnippets.Tool
12+
mdsnippets ${GITHUB_WORKSPACE}
13+
shell: bash
14+
- name: Push changes
15+
run: |
16+
git config --local user.email "[email protected]"
17+
git config --local user.name "GitHub Action"
18+
git commit -m "Docs changes [skip ci]" -a || echo "nothing to commit"
19+
remote="https://${GITHUB_ACTOR}:${{secrets.GITHUB_TOKEN}}@github.com/${GITHUB_REPOSITORY}.git"
20+
branch="${GITHUB_REF:11}"
21+
git push "${remote}" ${branch} || echo "nothing to push"
22+
shell: bash

README.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
1-
<!--
2-
GENERATED FILE - DO NOT EDIT
3-
This file was generated by [MarkdownSnippets](https://github.com/SimonCropp/MarkdownSnippets).
4-
Source File: /README.source.md
5-
To change this file edit the source file and then run MarkdownSnippets.
6-
-->
7-
81
# Meet ReverseMarkdown
92

103
[![Windows Build status](https://ci.appveyor.com/api/projects/status/xse0bia9olr5shxr?svg=true)](https://ci.appveyor.com/project/BabuAnnamalai/reversemarkdown-net) [![Windows Build status](https://api.travis-ci.org/mysticmind/reversemarkdown-net.svg)](https://travis-ci.org/mysticmind/reversemarkdown-net) [![NuGet Version](https://badgen.net/nuget/v/reversemarkdown)](https://www.nuget.org/packages/ReverseMarkdown/)
114

125
ReverseMarkdown is a Html to Markdown (http://daringfireball.net/projects/markdown/syntax) converter library in C#. Conversion is very reliable since HtmlAgilityPack (HAP) library is used for traversing the Html DOM.
136

14-
Note that the library implementation is based on the Ruby based Html to Markdown converter [ xijo/reverse_markdown](https://github.com/xijo/reverse_markdown).
15-
167
## Usage
178

189
Install the package from NuGet using `Install-Package ReverseMarkdown` or clone the repository and built it yourself.
@@ -81,7 +72,7 @@ var converter = new ReverseMarkdown.Converter(config);
8172
* `UnknownTagsOption.Raise` - Raise an error to let you know
8273
* `WhitelistUriSchemes` - Specify which schemes (without trailing colon) are to be allowed for `<a>` and `<img>` tags. Others will be bypassed (output text or nothing). By default allows everything.
8374

84-
If `string.Empty` provided and when `href` or `src` schema coudn't be determined - whitelists
75+
If `string.Empty` provided and when `href` or `src` schema couldn't be determined - whitelists
8576

8677
Schema is determined by `Uri` class, with exception when url begins with `/` (file schema) and `//` (http schema)
8778
* `TableWithoutHeaderRowHandling` - handle table without header rows
@@ -96,6 +87,9 @@ var converter = new ReverseMarkdown.Converter(config);
9687
* Can deal with nested lists
9788
* Github Flavoured Markdown conversion supported for br, pre and table. Use `var config = new ReverseMarkdown.Config(githubFlavoured:true);`. By default table will always be converted to Github flavored markdown immaterial of this flag.
9889

90+
## Acknowledgement
91+
The library implementation is based on the Ruby based Html to Markdown converter [xijo/reverse_markdown](https://github.com/xijo/reverse_markdown).
92+
9993
## Copyright
10094

10195
Copyright © 2020 Babu Annamalai

README.source.md

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,49 @@ Note that the library implementation is based on the Ruby based Html to Markdown
1010

1111
Install the package from NuGet using `Install-Package ReverseMarkdown` or clone the repository and built it yourself.
1212

13-
snippet: Usage
13+
<!-- snippet: Usage -->
14+
<a id='snippet-usage'></a>
15+
```cs
16+
var converter = new ReverseMarkdown.Converter();
17+
18+
string html = "This a sample <strong>paragraph</strong> from <a href=\"http://test.com\">my site</a>";
19+
20+
string result = converter.Convert(html);
21+
```
22+
<sup><a href='/src/ReverseMarkdown.Test/Snippets.cs#L12-L20' title='Snippet source file'>snippet source</a> | <a href='#snippet-usage' title='Start of snippet'>anchor</a></sup>
23+
<!-- endSnippet -->
1424

1525
Will result in:
1626

17-
snippet: Snippets.Usage.verified.txt
27+
<!-- snippet: Snippets.Usage.verified.txt -->
28+
<a id='snippet-Snippets.Usage.verified.txt'></a>
29+
```txt
30+
This a sample **paragraph** from [my site](http://test.com)
31+
```
32+
<sup><a href='/src/ReverseMarkdown.Test/Snippets.Usage.verified.txt#L1-L1' title='Snippet source file'>snippet source</a> | <a href='#snippet-Snippets.Usage.verified.txt' title='Start of snippet'>anchor</a></sup>
33+
<!-- endSnippet -->
1834

1935
The conversion can be customized:
2036

21-
snippet: UsageWithConfig
37+
<!-- snippet: UsageWithConfig -->
38+
<a id='snippet-usagewithconfig'></a>
39+
```cs
40+
var config = new ReverseMarkdown.Config
41+
{
42+
// Include the unknown tag completely in the result (default as well)
43+
UnknownTags = Config.UnknownTagsOption.PassThrough,
44+
// generate GitHub flavoured markdown, supported for BR, PRE and table tags
45+
GithubFlavored = true,
46+
// will ignore all comments
47+
RemoveComments = true,
48+
// remove markdown output for links where appropriate
49+
SmartHrefHandling = true
50+
};
51+
52+
var converter = new ReverseMarkdown.Converter(config);
53+
```
54+
<sup><a href='/src/ReverseMarkdown.Test/Snippets.cs#L28-L44' title='Snippet source file'>snippet source</a> | <a href='#snippet-usagewithconfig' title='Start of snippet'>anchor</a></sup>
55+
<!-- endSnippet -->
2256

2357
## Configuration options
2458

@@ -38,10 +72,11 @@ snippet: UsageWithConfig
3872
* `UnknownTagsOption.Drop` - Drop the unknown tag and its content
3973
* `UnknownTagsOption.Bypass` - Ignore the unknown tag but try to convert its content
4074
* `UnknownTagsOption.Raise` - Raise an error to let you know
75+
* `PassThroughTags` - Pass a list of tags to pass through as-is without any processing.
4176
* `WhitelistUriSchemes` - Specify which schemes (without trailing colon) are to be allowed for `<a>` and `<img>` tags. Others will be bypassed (output text or nothing). By default allows everything.
4277

43-
If `string.Empty` provided and when `href` or `src` schema coudn't be determined - whitelists
44-
78+
If `string.Empty` provided and when `href` or `src` schema couldn't be determined - whitelists
79+
4580
Schema is determined by `Uri` class, with exception when url begins with `/` (file schema) and `//` (http schema)
4681
* `TableWithoutHeaderRowHandling` - handle table without header rows
4782
* `TableWithoutHeaderRowHandlingOption.Default` - First row will be used as header row (default)

src/ReverseMarkdown.Test/ConverterTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -808,9 +808,9 @@ public void WhenTable_ThenConvertToGFMTable()
808808
const string html =
809809
@"<table><tr><th>col1</th><th>col2</th><th>col3</th></tr><tr><td>data1</td><td>data2</td><td>data3</td></tr></table>";
810810
var expected = $"{Environment.NewLine}{Environment.NewLine}";
811-
expected += $" | col1 | col2 | col3 |{Environment.NewLine}";
812-
expected += $" | --- | --- | --- |{Environment.NewLine}";
813-
expected += $" | data1 | data2 | data3 |{Environment.NewLine}";
811+
expected += $"| col1 | col2 | col3 |{Environment.NewLine}";
812+
expected += $"| --- | --- | --- |{Environment.NewLine}";
813+
expected += $"| data1 | data2 | data3 |{Environment.NewLine}";
814814
expected += Environment.NewLine;
815815

816816
var config = new Config

src/ReverseMarkdown/ReverseMarkdown.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222
<ItemGroup>
2323
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
2424
</ItemGroup>
25-
</Project>
25+
</Project>

src/mdsnippets.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"Convention": "InPlaceOverwrite"
3+
}

0 commit comments

Comments
 (0)