mirror of
https://github.com/NohamR/papeer.git
synced 2026-05-25 04:17:19 +00:00
add html format, handle lazy loading images
This commit is contained in:
18
cmd/get.go
18
cmd/get.go
@@ -43,7 +43,7 @@ func init() {
|
||||
|
||||
getCmd.PersistentFlags().StringVarP(&getOpts.name, "name", "n", "", "book name (default: page title)")
|
||||
getCmd.PersistentFlags().StringVarP(&getOpts.author, "author", "a", "", "book author")
|
||||
getCmd.PersistentFlags().StringVarP(&getOpts.Format, "format", "f", "md", "file format [md, epub, mobi]")
|
||||
getCmd.PersistentFlags().StringVarP(&getOpts.Format, "format", "f", "md", "file format [md, html, epub, mobi]")
|
||||
getCmd.PersistentFlags().StringVarP(&getOpts.output, "output", "", "", "file name (default: book name)")
|
||||
getCmd.PersistentFlags().BoolVarP(&getOpts.stdout, "stdout", "", false, "print to standard output")
|
||||
getCmd.PersistentFlags().BoolVarP(&getOpts.images, "images", "", false, "retrieve images only")
|
||||
@@ -74,6 +74,7 @@ var getCmd = &cobra.Command{
|
||||
|
||||
formatEnum := map[string]bool{
|
||||
"md": true,
|
||||
"html": true,
|
||||
"epub": true,
|
||||
"mobi": true,
|
||||
}
|
||||
@@ -178,6 +179,21 @@ var getCmd = &cobra.Command{
|
||||
}
|
||||
}
|
||||
|
||||
if getOpts.Format == "html" {
|
||||
filename := book.ToHtml(c, getOpts.output)
|
||||
|
||||
if getOpts.stdout {
|
||||
bytesRead, err := ioutil.ReadFile(filename)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
fmt.Println(string(bytesRead))
|
||||
} else {
|
||||
fmt.Printf("Html saved to \"%s\"\n", filename)
|
||||
}
|
||||
}
|
||||
|
||||
if getOpts.Format == "epub" {
|
||||
filename := book.ToEpub(c, getOpts.output)
|
||||
|
||||
|
||||
@@ -14,6 +14,6 @@ var versionCmd = &cobra.Command{
|
||||
Use: "version",
|
||||
Short: "Print the version number of papeer",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("papeer v0.5.5")
|
||||
fmt.Println("papeer v0.5.6")
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user