This makes gmnhg parse TOML/YAML/JSON/org-mode front matter in Hugo posts.
This also makes the library no longer render metadata in posts, removing
the API to do so. The metadata parsing code itself moves to
internal/gmnhg.
As the library no longer has a preset to include metadata in rendered
document, md2gmn will from now on silently discard front matter if it
encounters any.
Fixes#28. Unblocks #13.
This implements RSS timeline generation in gmnhg.
RSS is generated both for the whole site, and for the content
directories as an rss.xml file inside these directories.
RSS requires the absolute URI to the article. For this to work,
a geminiBaseURL setting is required to be set in the Hugo
configuration file (config.toml/json/yaml).
RSS template can be ovewritten on the site-wide /
directory-wise basis; see godoc on how to do this.
As there's no discovery method of an RSS timeline in Gemini,
the users are expected to put a link to rss.xml on their site
where necessary.
Before this, links would only be scraped from paragraphs and
rendered as a block after parent paragraph. This replaces this logic
with a generic links extractor that would recursively collect every link
from any parent node, including footnotes, blockquotes, and lists.
The renderer splits links block in three separate blocks, one
containing footnotes, the second containing images, and the third
links. Blocks are separated by a single line break.
This also makes the renderer skip link-only lists from rendering,
making them behave like links-only paragraphs (which are already
rendered as a series of consecutive links). The old behavior of
extracting links from links-only paragraphs (where the paragraph
itself is treated as just a set of links) remains, and can be still used.
The text extraction is also now unified across headings, paragraphs,
table headings, blockquotes, and other elements where it was used.
This fixes a number of bugs (like panicking on links inside headings)
and shortcomings where renderer would render text differently
based on container element type.
Fixes#17 and #23.
With Hugo, a page bundle can be skipped from rendering if
it specifies headless = true in its front matter. This makes
gmnhg properly skip these pages from rendering.
Fixes#11.
This makes the renderer write --- in place of
Markdown/HTML horizontal lines, and render super/subscript
as ^(superscript) and _{subscript} respectively.
The original implementation would incorrectly prefix the rest of the terms
if there were multiple terms going after each other (forming a list
themselves).
Fixup f17a959fe2.
This makes the Go compiler automatically calculate renderer
flags bitmask values by putting 1 << iota as the first meaningful flag.
This has a downside of having the first flag always meaning 2, and not
1, whereas WithMetadata already meaned 1, therefore this is a breaking
change.
This changes gomarkdown parser behavior to allow code blocks, lists, etc
to come after other blocks (like paragraphs) and get processed as
independent blocks without a separate newline (putting gomarkdown in
charge to decide whether a new block is started).
This is a breaking change as this affects how some existing Markdown
source might get rendered. Nonetheless, this is probably the expected
default by most users. This has no configurable switch yet.
See #14.
This adds generic sort / sortRev functions for use in gmnhg templates
which use sort.Sort to sort anything that implements sort.Interface
(which includes lists of posts).
The existing sortPosts function that used to sort posts in reverse order
becomes an alias to sortRev for backwards compatibility.
This patch adds support for Hugo's branch and leaf bundles: https://gohugo.io/content-management/page-bundles/
Content directories can now have nested subdirectories, and content from each level will be converted to Gemini. If a subdirectory has a file named index.md (or any index.* file per the footnote on the Hugo page) then it becomes a leaf bundle. For leaf bundles, only the generated index.gmi file will be passed up to parent directories as a page. The rest will be treated as "resources" that are not normally visible to pages in parent folders.
Each parent _index.md receives a list of pages from all nested subdirectories (except for the aforementioned leaf resource pages). This allows for content "rollup" pages. For instance, /series could show all pages under /series/first-season and /series/second-season, while allowing each subfolder to have its own more limited index. This also allows for "clean" URLs, as leaf bundles can be used to make pages that are basically just an index.md page under a named folder. You can then use the trimSuffix function (from sprig) in your gotmpl templates to clean up any links, by stripping "/index.md".
This patch also adds the copying of non-Markdown resource files from content directories, so that bundled resources can be pulled in. Theoretically if someone puts carefully named .gmi files in their content folder then this could cause a name collision, but you'd almost have to try to make that happen, so I didn't put in any checks for it. If this happens then any generated files with the same name are simply overwritten, so there's no serious harm done.
Hugo's leaf bundles support a special front matter attribute, "headless", which if set to true will cause the index.md file to be "invisible" and it will not be passed up to the parent. This is not currently implemented.
This makes the renderer preserve existing line breaks in blockquotes,
provided they do not split paragraphs. Some clients/sites may use this
to form semantic around line breaks (for instance, for poems).
See #5.
This adds support for Markdown table rendering with
github.com/olekukonko/tablewriter. Tables are rendered as ASCII text
in a preformatted text block. Cells are hard-aligned with spaces.
tablewriter options are not yet configurable, although they should be.
For now, extra formatting inside tables is omitted.
Fixes#2.
Unlike Markdown, which has 6 levels of headings, Gemini spec (p. 5.5.1)
only allows up to 3 shebang characters before a space. This adds an extra
space before levels 4-6 in order to comply with the spec.
Fixes#1.