subconsciousnetwork / subtext

Markup for note taking
Apache License 2.0
271 stars 20 forks source link

Machine header envelopes for Subtext #41

Closed gordonbrander closed 1 year ago

gordonbrander commented 1 year ago

This issue exists to document background and decisions w/r/t machine headers in Subtext. Related to #19. No action is necessary.

Background

Key-value metadata is a generally useful primitive (see If headers did not exist it would be necessary to invent them). In our design discussions, we broadly identified two kinds of key-value metadata:

Both of these use-cases can technically be supported by the same mechanism. However, machine headers are often visually noisy and potentially confusing. We believe it is valuable to have separate mechanisms for these two features so that the mess of machine headers can be hidden from the user.

Design goals

Prior art and notes

HTTP-like

Packets, HTTP, and email all use the memo pattern for key-value metadata.

A document begins with a series of key: value lines, followed by an empty line. Lines after the first empty line are considered content.

Title: Floop
Date: 2022-01-15
exotic-header: {"msg": "you can put anything in header body"}

Content.

This design has been very successful in the wild, and our sense is that our design solution should be heavily influenced by this pattern.

Note: earlier version of HTTP allowed for multi-line headers through line folding, then later obsoleted this feature. We wish to avoid line folding in Subtext. See #40.

Observations:

Sidecar files

Another option is to make metadata a separate file that references the content file. In this case, the obvious choice for metadata format would be JSON. Like the envelope format approach, no specification would be necessary for Subtext to support this.

Tradeoffs:

Prior art:

Reference:

gordonbrander commented 1 year ago

Design decision