Skip to content

Commit e2ce2c8

Browse files
committed
- [+] add the initial wireframe
1 parent 2a58677 commit e2ce2c8

7 files changed

Lines changed: 355 additions & 0 deletions

File tree

.gitattributes

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# used to remove files from deployment via `git archive`
2+
# git files
3+
.gitattributes export-ignore
4+
.gitignore export-ignore
5+
# general text files
6+
*.e.md export-ignore
7+
# CI/CD
8+
.travis.yml export-ignore
9+
.gitlab-ci.yml export-ignore
10+
bintray-*.json export-ignore
11+
12+
## This project
13+
html2md_proj.yaml export-ignore

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,8 @@
1313

1414
# Dependency directories (remove the comment below to include it)
1515
# vendor/
16+
17+
# Under *nix
18+
*~
19+
20+
html2md

html2md_cli.yaml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# program name, name for the executable
2+
ProgramName: html2md
3+
Authors: Tong Sun
4+
5+
PackageName: main
6+
7+
Name: html2md
8+
Desc: HTML to Markdown
9+
Text: HTML to Markdown converter on command line
10+
#NumArg: cli.AtLeast(1)
11+
NumOption: cli.AtLeast(1)
12+
13+
UsageLead: "Usage:\\n html2md [Options...]"
14+
15+
16+
Options:
17+
- Name: Filei
18+
Type: '*clix.Reader'
19+
Flag: "*i,in"
20+
Usage: 'The html/xml file to read from (or stdin)'
21+
22+
- Name: Sel
23+
Type: 'string'
24+
Flag: 's,sel'
25+
Usage: "CSS/goquery selectors\\n"
26+
27+
- Name: OptHeadingStyle
28+
Type: "string"
29+
Flag: "opt-heading-style"
30+
Usage: Option HeadingStyle
31+
32+
- Name: OptHorizontalRule
33+
Type: "string"
34+
Flag: "opt-horizontal-rule"
35+
Usage: Option HorizontalRule
36+
37+
- Name: OptBulletListMarker
38+
Type: "string"
39+
Flag: "opt-bullet-list-marker"
40+
Usage: Option BulletListMarker
41+
42+
- Name: OptCodeBlockStyle
43+
Type: "string"
44+
Flag: "opt-code-block-style"
45+
Usage: Option CodeBlockStyle
46+
47+
- Name: OptFence
48+
Type: "string"
49+
Flag: "opt-fence"
50+
Usage: Option Fence
51+
52+
- Name: OptEmDelimiter
53+
Type: "string"
54+
Flag: "opt-em-delimiter"
55+
Usage: Option EmDelimiter
56+
57+
- Name: OptStrongDelimiter
58+
Type: "string"
59+
Flag: "opt-strong-delimiter"
60+
Usage: Option StrongDelimiter
61+
62+
- Name: OptLinkStyle
63+
Type: "string"
64+
Flag: "opt-link-style"
65+
Usage: Option LinkStyle
66+
67+
- Name: OptLinkReferenceStyle
68+
Type: "string"
69+
Flag: "opt-link-reference-style"
70+
Usage: "Option LinkReferenceStyle\\n"
71+
72+
- Name: PluginConfluenceAttachments
73+
Type: bool
74+
Flag: "plugin-conf-attachment"
75+
Usage: Plugin ConfluenceAttachments
76+
77+
- Name: PluginConfluenceCodeBlock
78+
Type: bool
79+
Flag: "plugin-conf-code"
80+
Usage: Plugin ConfluenceCodeBlock
81+
82+
- Name: PluginFrontMatter
83+
Type: bool
84+
Flag: "plugin-frontmatter"
85+
Usage: Plugin FrontMatter
86+
87+
- Name: PluginGitHubFlavored
88+
Type: bool
89+
Flag: "plugin-gfm"
90+
Usage: Plugin GitHubFlavored
91+
92+
- Name: PluginStrikethrough
93+
Type: bool
94+
Flag: "plugin-strikethrough"
95+
Usage: Plugin Strikethrough
96+
97+
- Name: PluginTable
98+
Type: bool
99+
Flag: "plugin-table"
100+
Usage: Plugin Table
101+
102+
- Name: PluginTaskListItems
103+
Type: bool
104+
Flag: "plugin-task-list"
105+
Usage: Plugin TaskListItems
106+
107+
- Name: PluginVimeoEmbed
108+
Type: bool
109+
Flag: "plugin-vimeo"
110+
Usage: Plugin VimeoEmbed
111+
112+
- Name: PluginYoutubeEmbed
113+
Type: bool
114+
Flag: "plugin-youtube"
115+
Usage: Plugin YoutubeEmbed

html2md_cliDef.go

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
////////////////////////////////////////////////////////////////////////////
2+
// Program: html2md
3+
// Purpose: HTML to Markdown
4+
// Authors: Tong Sun (c) 2020, All rights reserved
5+
////////////////////////////////////////////////////////////////////////////
6+
7+
package main
8+
9+
import (
10+
// "fmt"
11+
// "os"
12+
13+
"github.com/mkideal/cli"
14+
// "github.com/mkideal/cli/clis"
15+
clix "github.com/mkideal/cli/ext"
16+
)
17+
18+
////////////////////////////////////////////////////////////////////////////
19+
// Constant and data type/structure definitions
20+
21+
//==========================================================================
22+
// html2md
23+
24+
type rootT struct {
25+
cli.Helper
26+
Filei *clix.Reader `cli:"*i,in" usage:"The html/xml file to read from (or stdin)"`
27+
Sel string `cli:"s,sel" usage:"CSS/goquery selectors\n"`
28+
OptHeadingStyle string `cli:"opt-heading-style" usage:"Option HeadingStyle"`
29+
OptHorizontalRule string `cli:"opt-horizontal-rule" usage:"Option HorizontalRule"`
30+
OptBulletListMarker string `cli:"opt-bullet-list-marker" usage:"Option BulletListMarker"`
31+
OptCodeBlockStyle string `cli:"opt-code-block-style" usage:"Option CodeBlockStyle"`
32+
OptFence string `cli:"opt-fence" usage:"Option Fence"`
33+
OptEmDelimiter string `cli:"opt-em-delimiter" usage:"Option EmDelimiter"`
34+
OptStrongDelimiter string `cli:"opt-strong-delimiter" usage:"Option StrongDelimiter"`
35+
OptLinkStyle string `cli:"opt-link-style" usage:"Option LinkStyle"`
36+
OptLinkReferenceStyle string `cli:"opt-link-reference-style" usage:"Option LinkReferenceStyle\n"`
37+
PluginConfluenceAttachments bool `cli:"plugin-conf-attachment" usage:"Plugin ConfluenceAttachments"`
38+
PluginConfluenceCodeBlock bool `cli:"plugin-conf-code" usage:"Plugin ConfluenceCodeBlock"`
39+
PluginFrontMatter bool `cli:"plugin-frontmatter" usage:"Plugin FrontMatter"`
40+
PluginGitHubFlavored bool `cli:"plugin-gfm" usage:"Plugin GitHubFlavored"`
41+
PluginStrikethrough bool `cli:"plugin-strikethrough" usage:"Plugin Strikethrough"`
42+
PluginTable bool `cli:"plugin-table" usage:"Plugin Table"`
43+
PluginTaskListItems bool `cli:"plugin-task-list" usage:"Plugin TaskListItems"`
44+
PluginVimeoEmbed bool `cli:"plugin-vimeo" usage:"Plugin VimeoEmbed"`
45+
PluginYoutubeEmbed bool `cli:"plugin-youtube" usage:"Plugin YoutubeEmbed"`
46+
}
47+
48+
var root = &cli.Command{
49+
Name: "html2md",
50+
Desc: "HTML to Markdown\nVersion " + version + " built on " + date +
51+
"\nCopyright (C) 2020, Tong Sun",
52+
Text: "HTML to Markdown converter on command line" +
53+
"\n\nUsage:\n html2md [Options...]",
54+
Argv: func() interface{} { return new(rootT) },
55+
Fn: html2md,
56+
57+
NumOption: cli.AtLeast(1),
58+
}
59+
60+
// Template for main starts here
61+
////////////////////////////////////////////////////////////////////////////
62+
// Constant and data type/structure definitions
63+
64+
// The OptsT type defines all the configurable options from cli.
65+
// type OptsT struct {
66+
// Filei *clix.Reader
67+
// Sel string
68+
// OptHeadingStyle string
69+
// OptHorizontalRule string
70+
// OptBulletListMarker string
71+
// OptCodeBlockStyle string
72+
// OptFence string
73+
// OptEmDelimiter string
74+
// OptStrongDelimiter string
75+
// OptLinkStyle string
76+
// OptLinkReferenceStyle string
77+
// PluginConfluenceAttachments bool
78+
// PluginConfluenceCodeBlock bool
79+
// PluginFrontMatter bool
80+
// PluginGitHubFlavored bool
81+
// PluginStrikethrough bool
82+
// PluginTable bool
83+
// PluginTaskListItems bool
84+
// PluginVimeoEmbed bool
85+
// PluginYoutubeEmbed bool
86+
// Verbose int
87+
// }
88+
89+
////////////////////////////////////////////////////////////////////////////
90+
// Global variables definitions
91+
92+
// var (
93+
// progname = "html2md"
94+
// version = "0.1.0"
95+
// date = "2020-07-25"
96+
97+
// rootArgv *rootT
98+
// // Opts store all the configurable options
99+
// Opts OptsT
100+
// )
101+
102+
////////////////////////////////////////////////////////////////////////////
103+
// Function definitions
104+
105+
// Function main
106+
// func main() {
107+
// cli.SetUsageStyle(cli.DenseNormalStyle) // left-right, for up-down, use ManualStyle
108+
// //NOTE: You can set any writer implements io.Writer
109+
// // default writer is os.Stdout
110+
// if err := cli.Root(root,).Run(os.Args[1:]); err != nil {
111+
// fmt.Fprintln(os.Stderr, err)
112+
// os.Exit(1)
113+
// }
114+
// fmt.Println("")
115+
// }
116+
117+
// Template for main dispatcher starts here
118+
//==========================================================================
119+
// Dumb root handler
120+
121+
// func html2md(ctx *cli.Context) error {
122+
// ctx.JSON(ctx.RootArgv())
123+
// ctx.JSON(ctx.Argv())
124+
// fmt.Println()
125+
126+
// return nil
127+
// }
128+
129+
// Template for CLI handling starts here

html2md_cliGen.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
easygen ../../go-easygen/wireframe/cli-ext html2md_cli | gofmt > html2md_cliDef.go

html2md_main.go

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
////////////////////////////////////////////////////////////////////////////
2+
// Program: html2md
3+
// Purpose: HTML to Markdown
4+
// Authors: Tong Sun (c) 2020, All rights reserved
5+
////////////////////////////////////////////////////////////////////////////
6+
7+
package main
8+
9+
//go:generate sh -v html2md_cliGen.sh
10+
11+
import (
12+
"fmt"
13+
"os"
14+
15+
"github.com/mkideal/cli"
16+
clix "github.com/mkideal/cli/ext"
17+
)
18+
19+
////////////////////////////////////////////////////////////////////////////
20+
// Constant and data type/structure definitions
21+
22+
// The OptsT type defines all the configurable options from cli.
23+
type OptsT struct {
24+
Filei *clix.Reader
25+
Sel string
26+
OptHeadingStyle string
27+
OptHorizontalRule string
28+
OptBulletListMarker string
29+
OptCodeBlockStyle string
30+
OptFence string
31+
OptEmDelimiter string
32+
OptStrongDelimiter string
33+
OptLinkStyle string
34+
OptLinkReferenceStyle string
35+
PluginConfluenceAttachments bool
36+
PluginConfluenceCodeBlock bool
37+
PluginFrontMatter bool
38+
PluginGitHubFlavored bool
39+
PluginStrikethrough bool
40+
PluginTable bool
41+
PluginTaskListItems bool
42+
PluginVimeoEmbed bool
43+
PluginYoutubeEmbed bool
44+
Verbose int
45+
}
46+
47+
////////////////////////////////////////////////////////////////////////////
48+
// Global variables definitions
49+
50+
var (
51+
progname = "html2md"
52+
version = "0.1.0"
53+
date = "2020-07-25"
54+
55+
rootArgv *rootT
56+
// Opts store all the configurable options
57+
Opts OptsT
58+
)
59+
60+
////////////////////////////////////////////////////////////////////////////
61+
// Function definitions
62+
63+
// Function main
64+
func main() {
65+
cli.SetUsageStyle(cli.DenseNormalStyle) // left-right, for up-down, use ManualStyle
66+
//NOTE: You can set any writer implements io.Writer
67+
// default writer is os.Stdout
68+
if err := cli.Root(root).Run(os.Args[1:]); err != nil {
69+
fmt.Fprintln(os.Stderr, err)
70+
os.Exit(1)
71+
}
72+
fmt.Println("")
73+
}
74+
75+
//==========================================================================
76+
// Dumb root handler
77+
78+
func html2md(ctx *cli.Context) error {
79+
ctx.JSON(ctx.RootArgv())
80+
ctx.JSON(ctx.Argv())
81+
fmt.Println()
82+
83+
return nil
84+
}

html2md_proj.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Wireframe:
2+
Proj: html2md
3+
Desc: HTML to Markdown converter
4+
Lang: Go
5+
User: suntong
6+
Author: Tong Sun <suntong@cpan.org>
7+
License: MIT
8+

0 commit comments

Comments
 (0)