-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: simple markdown structure, document header parser
- Loading branch information
0 parents
commit 3abc71c
Showing
31 changed files
with
1,129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# top-most EditorConfig file | ||
root = true | ||
|
||
# charset | ||
[*] | ||
charset = utf-8 | ||
|
||
# lines | ||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
max_line_length = off | ||
|
||
# tabs | ||
[*] | ||
indent_style = space | ||
indent_size = 4 | ||
tab_width = 4 | ||
|
||
[*.{csproj,props,resx,targets}] | ||
indent_style = space | ||
indent_size = 2 | ||
tab_width = 2 | ||
|
||
# rules | ||
# CA2225: Operator overloads have named alternates | ||
dotnet_diagnostic.CA2225.severity = none | ||
# CA1716: Identifiers should not match keywords | ||
dotnet_diagnostic.CA1716.severity = none | ||
# CA1054: URI-like parameters should not be strings | ||
dotnet_diagnostic.CA1054.severity = none | ||
# CA1056: URI-like properties should not be strings | ||
dotnet_diagnostic.CA1056.severity = none | ||
# CA1062: Validate arguments of public methods | ||
dotnet_diagnostic.CA1062.severity = none | ||
# CA1033: Interface methods should be callable by child types | ||
dotnet_diagnostic.CA1033.severity = none | ||
# CA1034: Nested types should not be visible | ||
dotnet_diagnostic.CA1034.severity = none | ||
# CA1308: Normalize strings to uppercase | ||
dotnet_diagnostic.CA1308.severity = none | ||
# CA1805: Do not initialize unnecessarily | ||
dotnet_diagnostic.CA1805.severity = none | ||
# CA1031: Do not catch general exception types | ||
dotnet_diagnostic.CA1031.severity = none | ||
# CA1714: Flags enums should have plural names | ||
dotnet_diagnostic.CA1714.severity = none |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: build & test | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
build-and-test: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: TagBites/actions/dotnet-build@master | ||
with: | ||
solution: TagBites.Text.Markdown.sln | ||
#- uses: TagBites/actions/dotnet-test@master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: publish preview | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v?[0-9]+.[0-9]+.[0-9]+-preview.[0-9]+" | ||
|
||
jobs: | ||
publish-preview: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: TagBites/actions/dotnet-build@master | ||
with: | ||
solution: TagBites.Text.Markdown.sln | ||
- uses: TagBites/actions/nuget-publish@master | ||
with: | ||
nuget-source: "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" | ||
nuget-key: "${{ secrets.GITHUB_TOKEN }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: publish | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v?[0-9]+.[0-9]+.[0-9]+" | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: TagBites/actions/dotnet-build@master | ||
with: | ||
solution: TagBites.Text.Markdown.sln | ||
- uses: TagBites/actions/nuget-publish@master | ||
with: | ||
nuget-source: "https://api.nuget.org/v3/index.json" | ||
nuget-key: "${{ secrets.NUGET_KEY }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# User-specific files | ||
*.DotSettings | ||
*.user | ||
|
||
# Folders | ||
/Build/keys | ||
/Build/*.exe | ||
/Build/*.dll | ||
/Build/*.nupkg | ||
/TestResults | ||
.vs/ | ||
packages/ | ||
[Bb]in/ | ||
[Oo]bj/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<Project> | ||
|
||
<!-- Company/Copyright --> | ||
<PropertyGroup> | ||
<Company>Tag Bites sp. z o.o.</Company> | ||
<Authors>Tag Bites sp. z o.o.</Authors> | ||
<CopyrightSinceYear>2012</CopyrightSinceYear> | ||
|
||
<Copyright>© $(CopyrightSinceYear)-$([System.DateTime]::Today.ToString(`yyyy`)) $(Company)</Copyright> | ||
</PropertyGroup> | ||
|
||
<!-- Bin/Obj directories --> | ||
<PropertyGroup> | ||
<BaseOutputPath>$(SolutionDir)bin\$(MSBuildProjectName)\</BaseOutputPath> | ||
<PackageOutputPath>$(SolutionDir)bin\</PackageOutputPath> | ||
<BaseIntermediateOutputPath>$(SolutionDir)bin\obj\$(MSBuildProjectName)\</BaseIntermediateOutputPath> | ||
</PropertyGroup> | ||
|
||
<!-- Compilation settings --> | ||
<PropertyGroup> | ||
<LangVersion>latest</LangVersion> | ||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo> | ||
<Deterministic>true</Deterministic> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<!-- Documentation --> | ||
<PropertyGroup> | ||
<GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
</PropertyGroup> | ||
|
||
<!-- Warnings --> | ||
<PropertyGroup> | ||
<NoWarn>1701;1702;1591;NU5048;NU5125;IDE0290</NoWarn> | ||
</PropertyGroup> | ||
|
||
<!-- Globalization --> | ||
<PropertyGroup> | ||
<NeutralLanguage>en-US</NeutralLanguage> | ||
</PropertyGroup> | ||
|
||
<!-- Ignored files/folders --> | ||
<PropertyGroup> | ||
<DefaultItemExcludes>$(DefaultItemExcludes);*.csproj.DotSettings</DefaultItemExcludes> | ||
</PropertyGroup> | ||
|
||
<!-- Usings --> | ||
<ItemGroup> | ||
<Using Include="System" /> | ||
<Using Include="System.Collections" /> | ||
<Using Include="System.Collections.Generic" /> | ||
<Using Include="System.IO" /> | ||
<Using Include="System.Linq" /> | ||
<Using Include="System.Threading" /> | ||
<Using Include="System.Threading.Tasks" /> | ||
</ItemGroup> | ||
|
||
<!-- Includes --> | ||
<Import Condition="exists('Version.props')" Project="Version.props" /> | ||
<Import Condition="exists('Package.props')" Project="Package.props" /> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<Project> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="MinVer" Version="2.5.0"> | ||
<PrivateAssets>All</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<!-- Copy package to local packages repository --> | ||
<Target Name="CopyPackage" AfterTargets="Pack" Condition="exists('$(MSBuildThisFileDirectory)..\LocalPackages\')"> | ||
<Message Text="Copy '$(PackageOutputPath)$(PackageId).$(PackageVersion).nupkg' to '$(MSBuildThisFileDirectory)..\LocalPackages\'" Importance="high"/> | ||
<Copy | ||
SourceFiles="$(PackageOutputPath)$(PackageId).$(PackageVersion).nupkg" | ||
DestinationFolder="$(MSBuildThisFileDirectory)..\LocalPackages\" | ||
ContinueOnError="false" /> | ||
|
||
<Message Text="Delete local package folder 'C:\Users\$([System.Environment]::UserName)\.nuget\packages\$(PackageId)\$(PackageVersion)'" Importance="high"/> | ||
<RemoveDir Directories="C:\Users\$([System.Environment]::UserName)\.nuget\packages\$(PackageId)\$(PackageVersion)" /> | ||
</Target> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Tag Bites | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<Description>C# library for programmatically building Markdown documents.</Description> | ||
<PackageTags>markdown; markdown builder; markdown syntax</PackageTags> | ||
|
||
<PackageProjectUrl>https://github.com/TagBites/TagBites.Text.Markdown</PackageProjectUrl> | ||
<PackageIconUrl></PackageIconUrl> | ||
|
||
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance> | ||
<PackageLicenseExpression>MIT</PackageLicenseExpression> | ||
|
||
<RepositoryType>git</RepositoryType> | ||
<RepositoryUrl>https://github.com/TagBites/TagBites.Text.Markdown.git</RepositoryUrl> | ||
|
||
<PackageReadmeFile>README.md</PackageReadmeFile> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# TagBites.Text.Markdown | ||
|
||
[![Nuget](https://img.shields.io/nuget/v/TagBites.Text.Markdown.svg)](https://www.nuget.org/packages/TagBites.Text.Markdown/) | ||
[![License](http://img.shields.io/github/license/TagBites/TagBites.Text.Markdown)](https://github.com/TagBites/TagBites.Text.Markdown/blob/master/LICENSE) | ||
|
||
C# library for programmatically building Markdown documents. Easily add headers, tables, checklists, and more with a simple, object-oriented API. | ||
|
||
Supported elements: | ||
- headers | ||
- paragraphs | ||
- code blocks | ||
- quotes | ||
- unordered lists | ||
- ordered lists | ||
- checklists | ||
- tables | ||
|
||
Inline syntax generated by `MarkdownSyntax`: | ||
- bold | ||
- italic | ||
- strike | ||
- code | ||
- link | ||
- image | ||
- html escape | ||
|
||
## Example | ||
|
||
```csharp | ||
var doc = new MarkdownDocument(); | ||
doc.AddHeader(1, "My Document"); | ||
doc.AddHeader(2, "Some section"); | ||
|
||
doc.AddParagraph("Some table below."); | ||
|
||
var table = doc.AddTable(); | ||
table.WithHeaders("col1", "col2", "col3"); | ||
table.WithRow("a", "b", "c"); | ||
table.WithRow("1", "2", "3"); | ||
|
||
doc.AddParagraph("Some check list below."); | ||
|
||
var list = doc.AddCheckList(); | ||
list.AddElement(true, "task 1"); | ||
list.AddElement(true, "task 2"); | ||
list.AddElement(false, "task 3"); | ||
list.AddElement(false, "task 4"); | ||
``` | ||
|
||
Output: | ||
```markdown | ||
# My Document | ||
|
||
## Some section | ||
|
||
Some table below. | ||
|
||
| col1 | col2 | col3 | | ||
| ---- | ---- | ---- | | ||
| a | b | c | | ||
| 1 | 2 | 3 | | ||
|
||
Some check list below. | ||
|
||
- [x] task 1 | ||
- [x] task 2 | ||
- [ ] task 3 | ||
- [ ] task 4 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.4.33205.214 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TagBites.Text.Markdown", "src\TagBites.Text.Markdown\TagBites.Text.Markdown.csproj", "{1035955E-2C67-450B-B6A3-90EA111F637B}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{62CB84CB-ABBE-4834-BBD3-9084940552FE}" | ||
ProjectSection(SolutionItems) = preProject | ||
.editorconfig = .editorconfig | ||
.gitignore = .gitignore | ||
Directory.Build.props = Directory.Build.props | ||
Directory.Build.targets = Directory.Build.targets | ||
Package.props = Package.props | ||
README.md = README.md | ||
Version.props = Version.props | ||
EndProjectSection | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{1035955E-2C67-450B-B6A3-90EA111F637B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{1035955E-2C67-450B-B6A3-90EA111F637B}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{1035955E-2C67-450B-B6A3-90EA111F637B}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{1035955E-2C67-450B-B6A3-90EA111F637B}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {4C4ED72A-E0F0-44B5-8F52-EBB27C7E235B} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<MinVerDefaultPreReleasePhase>preview</MinVerDefaultPreReleasePhase> | ||
</PropertyGroup> | ||
|
||
<Target Name="VersionFromGit" AfterTargets="MinVer"> | ||
<PropertyGroup> | ||
<VersionPrefix>$(MinVerMajor).$(MinVerMinor).$(MinVerPatch)</VersionPrefix> | ||
<VersionSuffix>$(MinVerPreRelease)</VersionSuffix> | ||
<VersionFull Condition=" '$(VersionSuffix)' == '' ">$(VersionPrefix)</VersionFull> | ||
<VersionFull Condition=" '$(VersionSuffix)' != '' ">$(VersionPrefix)-$(VersionSuffix)</VersionFull> | ||
|
||
<Version>$(VersionFull)</Version> | ||
<PackageVersion>$(VersionFull)</PackageVersion> | ||
<AssemblyVersion>$(VersionPrefix).0</AssemblyVersion> | ||
<AssemblyFileVersion>$(VersionPrefix).0</AssemblyFileVersion> | ||
<InformationalVersion>$(VersionFull)</InformationalVersion> | ||
</PropertyGroup> | ||
|
||
<Message Importance="High" Text="InformationalVersion: $(InformationalVersion)"/> | ||
</Target> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace TagBites.Text.Markdown | ||
{ | ||
public class MarkdownCheckList : MarkdownList | ||
{ | ||
protected override bool IsCheckList => true; | ||
|
||
|
||
public MarkdownListElement AddElement(bool isChecked, string text) | ||
{ | ||
var element = new MarkdownCheckListElement(isChecked, text); | ||
Elements.Add(element); | ||
return element; | ||
} | ||
} | ||
} |
Oops, something went wrong.