CommonDoc / common-doc

A framework for representing and manipulating documents.
http://commondoc.github.io
40 stars 4 forks source link

Fixed constructors for WEB-LINK and DOCUMENT-LINK to fill metadata with necessary attributes. #26

Closed svetlyak40wt closed 2 years ago

svetlyak40wt commented 2 years ago

This fixes links emitting by Scriba for the case when a WEB-LINK or a DOCUMENT-LINK was created using a constructor.

@eudoxia0 please, advise me what is the best strategy to fix the problem? I've commented my first attempt here: https://github.com/CommonDoc/common-doc/pull/26/files#diff-1df10903b05ac9f82a1904e20bbd18582495568eed10144e222700554cbc2d2fR12-R24

eudoxia0 commented 2 years ago

Hmm maybe the Scriba emitter should instead be rewritten to emit the URI/document ID/ref ID values especially? Rather than just dumping the metadata table. I think I'd rather keep metadata "clean" so users can stuff it with what they want.

Of course I haven't touched the code in some time so I'm not super clear on some of the details.

svetlyak40wt commented 2 years ago

Ok, then probably the Scriba's parser should be fixed as well, because right now it populates metadata with attributes like this:

COMMON-DOC-TEST> (common-doc.format:parse-document (make-instance 'scriba:scriba)
                                                   "@link[uri=https://foo.com](blah)")
#<DOCUMENT "">
COMMON-DOC-TEST> (first (children *))
#<WEB-LINK children: TEXT-NODE>
COMMON-DOC-TEST> (metadata *)
#<HASH-TABLE :TEST EQUAL :COUNT 1 {7007588263}>
COMMON-DOC-TEST> (alexandria:hash-table-alist *)
(("uri" . "https://foo.com"))

COMMON-DOC-TEST> (common-doc.format:parse-document (make-instance 'scriba:scriba)
                                                   "@ref[doc=some-doc id=section-id](blah)")
#<DOCUMENT "">
COMMON-DOC-TEST> (first (children *))
#<DOCUMENT-LINK document: some-doc, section: section-id>
COMMON-DOC-TEST> (metadata *)
#<HASH-TABLE :TEST EQUAL :COUNT 1 {70099C6A73}>
COMMON-DOC-TEST> (alexandria:hash-table-alist *)
(("doc" . "some-doc"))
COMMON-DOC-TEST>