2025-05-12

전역 하루 전!!!!

norg-rs & norgolith

Footnote problem

Still struggling with footnote implementation.

How I want to write footnotes

Named definition

when index id is not provided, hash markup and use it as footnote identifier.

paragraph\fn[text]

.def-fn text;footnote definition content

Indexed definition

paragraph\fn(2)

paragraph\fn(1)

#def-fn-list
~ footnote definition content 1
~ footnote definition content 2

Short version

paragraph{^ 1}

#def-fn-list
~ footnote definition content 1

I'm not sure if it should be first-class feature...

I can implement footnote references right now, but I cannot implement footnote definition yet.

Implementation plan:

  • make method to walk through tree and find the required node. (this can be used to query headings)

  • use it for:

    • find anchor definition with hashid to resolve anchor reference

    • query heading & get it's id (replace original definition)

Being referenced can occur change on referenced node (e.g. add id field, etc) So first, collect all unique link targets from document. Walk through document and find referenced node's id. Add id to that nodes.

...But this won't work for nodes that are referenced from external documents.

So every reference-able nodes should have uid field regardless of they are actually referenced or not. Querying a node is a job finding node's uid based on given query (* heading : ** heading). Every inline nodes aren't referenceable by default. uid in an inline node is an optional field. User can use \ref or \fn inline tags to add uid.

Exporter will be given a LinkTarget -> UID hashmap and MarkupHash -> LinkTarget hashmap.

Ahhh no. First one cannot be pre-provided. Again, think when referencing external file's node. And second one cannot be provided until we expand all tags. So actual steps will be:

  1. parse document

  2. expand all tags (including inline tags) and collect MarkupHash -> LinkTarget table.

  3. pass expanded AST & MarkupHash -> LinkTarget table to exporter

  4. exporter will first resolve anchor with given anchor-table

  5. and then find for UID when link target contains Scopes (cache it for later use of course)

So my actual TODO is:

  1. rewrite Node types (to include uid and attributes field for each nodes)

  2. split (norg/export/doc) to (norg/expand/ast) and (norg/export/ast)

    (norg/expand/ast) will return

    1. ast (Vec<Block>)

    2. anchor-table (HashMap<Markup, LinkTarget>)

  3. implement (norg/find/ast) to search for node (query node by structural position or anchor definition hashid)

  4. using all these, refactor entire export system

But this will take quite a time. So I'll first migrate my blog with current semi-working system, introduce CommonNorg spec to others, and then start refactoring entire system.

I'll set a time limit.

  1. migrate blog until Wednesday. (hopefuly Tuesday)

  2. introduce CommonNorg on Thursday.

  3. rewrite node types until Friday. (ignore inline nodes for now)

  4. rewrite entire system until Sunday.

  5. finish with migrating inline nodes until Monday.