Skip to content

Commit

Permalink
add --metadata-yaml option
Browse files Browse the repository at this point in the history
- NEW: --metadata-yaml option to include source info as YAML front matter
  • Loading branch information
ttscoff committed Sep 10, 2022
1 parent a9cd163 commit 6227a40
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions Sources/gather/gather.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ var escapeSpecial = false
var grafLinks = true
var includeAnswerComments = false
var includeMetadata = false
var includeMetadataYAML = false
var titleFallback = ""
var includeSourceLink = true
var includeTitleAsH1 = true
Expand Down Expand Up @@ -132,7 +133,10 @@ func markdownify_html(html: String?, read: Bool?, url: String?, baseurl: String?
var source = ""
var meta = ""

if includeMetadata {
if includeMetadata || includeMetadataYAML {
if includeMetadataYAML {
meta += "---\n"
}
let date = iso_datetime()

if title != nil {
Expand All @@ -150,7 +154,11 @@ func markdownify_html(html: String?, read: Bool?, url: String?, baseurl: String?
}

meta += "\ndate: \(date)"
meta += "\n\n"
if includeMetadataYAML {
meta += "\n---\n"
} else {
meta += "\n\n"
}
}

if includeSourceLink, sourceUrl != nil {
Expand Down Expand Up @@ -356,6 +364,9 @@ struct Gather: ParsableCommand {
@Flag(help: "Include page title, date, source url as MultiMarkdown metadata")
var metadata = false

@Flag(help: "Include page title, date, source url as YAML front matter")
var metadataYaml = false

@Flag(name: .shortAndLong, help: "Get input from clipboard")
var paste = false

Expand Down Expand Up @@ -434,6 +445,7 @@ struct Gather: ParsableCommand {
includeTitleAsH1 = includeTitle
onlyOutputTitle = titleOnly
includeMetadata = metadata
includeMetadataYAML = metadataYaml
includeSourceLink = includeSource
titleFallback = fallbackTitle
// escapeSpecial = escape
Expand Down
Binary file modified buildnotes.md.secret
Binary file not shown.
2 changes: 1 addition & 1 deletion src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<!--GITHUB-->![Howzit banner image](https://cdn3.brettterpstra.com/uploads/2022/08/gatherheader-rb.webp)<!--END GITHUB-->
<!--JEKYLL{% img aligncenter 800 220 /uploads/2022/08/gatherheader-rb.jpg "Howzit banner image" %}-->

Current version: <!--VER-->2.0.42<!--END VER-->
Current version: <!--VER-->2.0.43<!--END VER-->

This project is the successor to read2text, which was a Python based tool that used Arc90 Readability and html2text to convert web URLs to Markdown documents, ready to store in your notes. It takes its name from another of my similar projects that I've since retired. It was this, but with a GUI, and this is infinitely more scriptable and is designed to nestle into your favorite tools and projects.

Expand Down

0 comments on commit 6227a40

Please sign in to comment.