diff options
| author | Tong Sun <[email protected]> | 2020-07-26 00:01:52 -0400 |
|---|---|---|
| committer | Tong Sun <[email protected]> | 2020-07-26 00:01:52 -0400 |
| commit | e2ce2c8953645aec761efb46313ece1e82635b93 (patch) | |
| tree | 6cb1a24ba559231d33814d5966f7382842e99244 | |
| parent | Initial commit (diff) | |
| download | html2md-e2ce2c8953645aec761efb46313ece1e82635b93.tar.xz html2md-e2ce2c8953645aec761efb46313ece1e82635b93.zip | |
- [+] add the initial wireframe
| -rw-r--r-- | .gitattributes | 13 | ||||
| -rw-r--r-- | .gitignore | 5 | ||||
| -rw-r--r-- | html2md_cli.yaml | 115 | ||||
| -rw-r--r-- | html2md_cliDef.go | 129 | ||||
| -rwxr-xr-x | html2md_cliGen.sh | 1 | ||||
| -rw-r--r-- | html2md_main.go | 84 | ||||
| -rw-r--r-- | html2md_proj.yaml | 8 |
7 files changed, 355 insertions, 0 deletions
diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..502c1cd --- /dev/null +++ b/.gitattributes @@ -0,0 +1,13 @@ +# used to remove files from deployment via `git archive` +# git files +.gitattributes export-ignore +.gitignore export-ignore +# general text files +*.e.md export-ignore +# CI/CD +.travis.yml export-ignore +.gitlab-ci.yml export-ignore +bintray-*.json export-ignore + +## This project +html2md_proj.yaml export-ignore @@ -13,3 +13,8 @@ # Dependency directories (remove the comment below to include it) # vendor/ + +# Under *nix +*~ + +html2md diff --git a/html2md_cli.yaml b/html2md_cli.yaml new file mode 100644 index 0000000..6252dae --- /dev/null +++ b/html2md_cli.yaml @@ -0,0 +1,115 @@ +# program name, name for the executable +ProgramName: html2md +Authors: Tong Sun + +PackageName: main + +Name: html2md +Desc: HTML to Markdown +Text: HTML to Markdown converter on command line +#NumArg: cli.AtLeast(1) +NumOption: cli.AtLeast(1) + +UsageLead: "Usage:\\n html2md [Options...]" + + +Options: + - Name: Filei + Type: '*clix.Reader' + Flag: "*i,in" + Usage: 'The html/xml file to read from (or stdin)' + + - Name: Sel + Type: 'string' + Flag: 's,sel' + Usage: "CSS/goquery selectors\\n" + + - Name: OptHeadingStyle + Type: "string" + Flag: "opt-heading-style" + Usage: Option HeadingStyle + + - Name: OptHorizontalRule + Type: "string" + Flag: "opt-horizontal-rule" + Usage: Option HorizontalRule + + - Name: OptBulletListMarker + Type: "string" + Flag: "opt-bullet-list-marker" + Usage: Option BulletListMarker + + - Name: OptCodeBlockStyle + Type: "string" + Flag: "opt-code-block-style" + Usage: Option CodeBlockStyle + + - Name: OptFence + Type: "string" + Flag: "opt-fence" + Usage: Option Fence + + - Name: OptEmDelimiter + Type: "string" + Flag: "opt-em-delimiter" + Usage: Option EmDelimiter + + - Name: OptStrongDelimiter + Type: "string" + Flag: "opt-strong-delimiter" + Usage: Option StrongDelimiter + + - Name: OptLinkStyle + Type: "string" + Flag: "opt-link-style" + Usage: Option LinkStyle + + - Name: OptLinkReferenceStyle + Type: "string" + Flag: "opt-link-reference-style" + Usage: "Option LinkReferenceStyle\\n" + + - Name: PluginConfluenceAttachments + Type: bool + Flag: "plugin-conf-attachment" + Usage: Plugin ConfluenceAttachments + + - Name: PluginConfluenceCodeBlock + Type: bool + Flag: "plugin-conf-code" + Usage: Plugin ConfluenceCodeBlock + + - Name: PluginFrontMatter + Type: bool + Flag: "plugin-frontmatter" + Usage: Plugin FrontMatter + + - Name: PluginGitHubFlavored + Type: bool + Flag: "plugin-gfm" + Usage: Plugin GitHubFlavored + + - Name: PluginStrikethrough + Type: bool + Flag: "plugin-strikethrough" + Usage: Plugin Strikethrough + + - Name: PluginTable + Type: bool + Flag: "plugin-table" + Usage: Plugin Table + + - Name: PluginTaskListItems + Type: bool + Flag: "plugin-task-list" + Usage: Plugin TaskListItems + + - Name: PluginVimeoEmbed + Type: bool + Flag: "plugin-vimeo" + Usage: Plugin VimeoEmbed + + - Name: PluginYoutubeEmbed + Type: bool + Flag: "plugin-youtube" + Usage: Plugin YoutubeEmbed diff --git a/html2md_cliDef.go b/html2md_cliDef.go new file mode 100644 index 0000000..8afc467 --- /dev/null +++ b/html2md_cliDef.go @@ -0,0 +1,129 @@ +//////////////////////////////////////////////////////////////////////////// +// Program: html2md +// Purpose: HTML to Markdown +// Authors: Tong Sun (c) 2020, All rights reserved +//////////////////////////////////////////////////////////////////////////// + +package main + +import ( + // "fmt" + // "os" + + "github.com/mkideal/cli" + // "github.com/mkideal/cli/clis" + clix "github.com/mkideal/cli/ext" +) + +//////////////////////////////////////////////////////////////////////////// +// Constant and data type/structure definitions + +//========================================================================== +// html2md + +type rootT struct { + cli.Helper + Filei *clix.Reader `cli:"*i,in" usage:"The html/xml file to read from (or stdin)"` + Sel string `cli:"s,sel" usage:"CSS/goquery selectors\n"` + OptHeadingStyle string `cli:"opt-heading-style" usage:"Option HeadingStyle"` + OptHorizontalRule string `cli:"opt-horizontal-rule" usage:"Option HorizontalRule"` + OptBulletListMarker string `cli:"opt-bullet-list-marker" usage:"Option BulletListMarker"` + OptCodeBlockStyle string `cli:"opt-code-block-style" usage:"Option CodeBlockStyle"` + OptFence string `cli:"opt-fence" usage:"Option Fence"` + OptEmDelimiter string `cli:"opt-em-delimiter" usage:"Option EmDelimiter"` + OptStrongDelimiter string `cli:"opt-strong-delimiter" usage:"Option StrongDelimiter"` + OptLinkStyle string `cli:"opt-link-style" usage:"Option LinkStyle"` + OptLinkReferenceStyle string `cli:"opt-link-reference-style" usage:"Option LinkReferenceStyle\n"` + PluginConfluenceAttachments bool `cli:"plugin-conf-attachment" usage:"Plugin ConfluenceAttachments"` + PluginConfluenceCodeBlock bool `cli:"plugin-conf-code" usage:"Plugin ConfluenceCodeBlock"` + PluginFrontMatter bool `cli:"plugin-frontmatter" usage:"Plugin FrontMatter"` + PluginGitHubFlavored bool `cli:"plugin-gfm" usage:"Plugin GitHubFlavored"` + PluginStrikethrough bool `cli:"plugin-strikethrough" usage:"Plugin Strikethrough"` + PluginTable bool `cli:"plugin-table" usage:"Plugin Table"` + PluginTaskListItems bool `cli:"plugin-task-list" usage:"Plugin TaskListItems"` + PluginVimeoEmbed bool `cli:"plugin-vimeo" usage:"Plugin VimeoEmbed"` + PluginYoutubeEmbed bool `cli:"plugin-youtube" usage:"Plugin YoutubeEmbed"` +} + +var root = &cli.Command{ + Name: "html2md", + Desc: "HTML to Markdown\nVersion " + version + " built on " + date + + "\nCopyright (C) 2020, Tong Sun", + Text: "HTML to Markdown converter on command line" + + "\n\nUsage:\n html2md [Options...]", + Argv: func() interface{} { return new(rootT) }, + Fn: html2md, + + NumOption: cli.AtLeast(1), +} + +// Template for main starts here +//////////////////////////////////////////////////////////////////////////// +// Constant and data type/structure definitions + +// The OptsT type defines all the configurable options from cli. +// type OptsT struct { +// Filei *clix.Reader +// Sel string +// OptHeadingStyle string +// OptHorizontalRule string +// OptBulletListMarker string +// OptCodeBlockStyle string +// OptFence string +// OptEmDelimiter string +// OptStrongDelimiter string +// OptLinkStyle string +// OptLinkReferenceStyle string +// PluginConfluenceAttachments bool +// PluginConfluenceCodeBlock bool +// PluginFrontMatter bool +// PluginGitHubFlavored bool +// PluginStrikethrough bool +// PluginTable bool +// PluginTaskListItems bool +// PluginVimeoEmbed bool +// PluginYoutubeEmbed bool +// Verbose int +// } + +//////////////////////////////////////////////////////////////////////////// +// Global variables definitions + +// var ( +// progname = "html2md" +// version = "0.1.0" +// date = "2020-07-25" + +// rootArgv *rootT +// // Opts store all the configurable options +// Opts OptsT +// ) + +//////////////////////////////////////////////////////////////////////////// +// Function definitions + +// Function main +// func main() { +// cli.SetUsageStyle(cli.DenseNormalStyle) // left-right, for up-down, use ManualStyle +// //NOTE: You can set any writer implements io.Writer +// // default writer is os.Stdout +// if err := cli.Root(root,).Run(os.Args[1:]); err != nil { +// fmt.Fprintln(os.Stderr, err) +// os.Exit(1) +// } +// fmt.Println("") +// } + +// Template for main dispatcher starts here +//========================================================================== +// Dumb root handler + +// func html2md(ctx *cli.Context) error { +// ctx.JSON(ctx.RootArgv()) +// ctx.JSON(ctx.Argv()) +// fmt.Println() + +// return nil +// } + +// Template for CLI handling starts here diff --git a/html2md_cliGen.sh b/html2md_cliGen.sh new file mode 100755 index 0000000..e66f913 --- /dev/null +++ b/html2md_cliGen.sh @@ -0,0 +1 @@ + easygen ../../go-easygen/wireframe/cli-ext html2md_cli | gofmt > html2md_cliDef.go diff --git a/html2md_main.go b/html2md_main.go new file mode 100644 index 0000000..23f5c03 --- /dev/null +++ b/html2md_main.go @@ -0,0 +1,84 @@ +//////////////////////////////////////////////////////////////////////////// +// Program: html2md +// Purpose: HTML to Markdown +// Authors: Tong Sun (c) 2020, All rights reserved +//////////////////////////////////////////////////////////////////////////// + +package main + +//go:generate sh -v html2md_cliGen.sh + +import ( + "fmt" + "os" + + "github.com/mkideal/cli" + clix "github.com/mkideal/cli/ext" +) + +//////////////////////////////////////////////////////////////////////////// +// Constant and data type/structure definitions + +// The OptsT type defines all the configurable options from cli. +type OptsT struct { + Filei *clix.Reader + Sel string + OptHeadingStyle string + OptHorizontalRule string + OptBulletListMarker string + OptCodeBlockStyle string + OptFence string + OptEmDelimiter string + OptStrongDelimiter string + OptLinkStyle string + OptLinkReferenceStyle string + PluginConfluenceAttachments bool + PluginConfluenceCodeBlock bool + PluginFrontMatter bool + PluginGitHubFlavored bool + PluginStrikethrough bool + PluginTable bool + PluginTaskListItems bool + PluginVimeoEmbed bool + PluginYoutubeEmbed bool + Verbose int +} + +//////////////////////////////////////////////////////////////////////////// +// Global variables definitions + +var ( + progname = "html2md" + version = "0.1.0" + date = "2020-07-25" + + rootArgv *rootT + // Opts store all the configurable options + Opts OptsT +) + +//////////////////////////////////////////////////////////////////////////// +// Function definitions + +// Function main +func main() { + cli.SetUsageStyle(cli.DenseNormalStyle) // left-right, for up-down, use ManualStyle + //NOTE: You can set any writer implements io.Writer + // default writer is os.Stdout + if err := cli.Root(root).Run(os.Args[1:]); err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } + fmt.Println("") +} + +//========================================================================== +// Dumb root handler + +func html2md(ctx *cli.Context) error { + ctx.JSON(ctx.RootArgv()) + ctx.JSON(ctx.Argv()) + fmt.Println() + + return nil +} diff --git a/html2md_proj.yaml b/html2md_proj.yaml new file mode 100644 index 0000000..79ad8cc --- /dev/null +++ b/html2md_proj.yaml @@ -0,0 +1,8 @@ +Wireframe: + Proj: html2md + Desc: HTML to Markdown converter + Lang: Go + User: suntong + Author: Tong Sun <[email protected]> + License: MIT + |