A text-centric [[Datalog]]-like language based on a superset of [[Markdown]] that adds dynamic properties and querying to wiki-like organization of plain text files. Defines macros and a simplistic query syntax.
# Definitions
## Entities
Entities are are a unique identity with at least a `name` property. Most have `file`, `body`, and `parent` properties. In general, these are created by creating a markdown file in the workspace or defining a link using wikilink syntax `[[name]]`.
**Optional:** elements that would generate a `<br/>` element such as lists, double newlines, and other blocks may create *anonymous entities* which have no title (but do have a synthetic ID) and must have a `parent` property whose value must recursively resolve to the synthetic ID of the containing note (to support arbitrary nesting). The `file` property should be the same as the note.
## Formatted Reference
A *formatted reference* is a wikilink-style link using `[[name]]` syntax *or* a `((entity-id))` formatted block reference (syntax stolen from [[Logseq]]) if block references are supported.
## Properties
Properties are references to either a symbol, a [[D-Log#Formatted Reference]], a collection of properties, or a literal value such as a string, number, or boolean.
## Symbol
A symbol is an unquoted utf-8 sequence that starts with a non-numeric or any of the following characters: `{}(),`.
## Operators
*Operators* are a subset of [[D-Log#Properties]] that only allow [[D-Log#Formatted Reference]]s and symbols.
## Unary Assertions
Any *entity* maybe have a unary assertion made using the `{{target property}}` / `{{property}}` syntax. With the latter syntax, the `target` may be omitted in which case `note` is assumed.
Tags using the `#tag` syntax are automatically unary assertions for the enclosing *note* but are restricted in their syntax.
# Binary Assertions
Binary assertions use the `{{left-property operator right-property}}` syntax. Both targets and the operand must all be specified.
Frontmatter formatted properties are automatically converted into binary assertions with the `left-property` being set to the current note.
Wikilink and block property references automatically using the `refderences` operator.
Binary assertions are equivalent to facts in most prologs.
## Special Properties
- `note` is an alias for the current note
- Equivalent to a wikilink reference
- `self` the current block if block properties are supported or the same as `note`
- `parent` is automatically generated for block properties if available
- `file` is only allowed for binary assertions on notes and block references and may not be overriden
- `name` when used as an operator always has the url decoded name of a note in the right operand and the filename in the left
- `body` when used as an operator always has the full UTF-8 contents of a note as the right operand and the note identity as the left
# Rules
Rules are defined as in other prologs using the special `{$ assertion assertion ... $}` syntax. Symbols that start with a question mark may be used as placeholders. Any character that is a valid symbol name may follow the `?` to create a named placeholder. When a placeholder appears multiple times in an expression, the same value will be bound to the placeholder.
# Queries
Queries follow traditional prolog semantics and use the `{? assertion ?}` syntax wrap the query. A `!` may prefix a query to embed the result of the query virtually in a note (similar to the `![[wikilink]]` embeded reference): `!{? assertion ?}`.
- [ ] formatting for embedded query results
# Examples
## Task management
*Assumes block properties are availble.*
Task management could be implemented like so:
*tasks.md*
```
{$ {{? task}} {{? status TODO }} $}
{$ {{? task}} {{? status DOING }} $}
{$ {{? task}} {{? status DONE }} $}
{$ {{? task}} {{? status NOW }} $}
{$ {{? task}} {{? status LATER }} $}
```