all repos

clerk @ 1b934a8

missing tooling for ledger/hledger
4 files changed, 38 insertions(+), 4 deletions(-)
fix directives printer, support quoted tags
Author: Oleksandr Smirnov olexsmir@gmail.com
Committed at: 2026-06-22 18:38:26 +0300
Authored at: 2026-06-22 18:09:26 +0300
Change ID: tnmkvotpwzrwvnslvqrmmqtsuwxtkpxp
Parent: 8489d4c
M journal/parser/parser.go
···
        496
        496
         	if p.got(token.TEXT) {

      
        497
        497
         		name = p.cur.Literal

      
        498
        498
         		p.advance()

      
        
        499
        +	} else if p.got(token.STRING) {

      
        
        500
        +		name = unquote(p.cur.Literal)

      
        
        501
        +		p.advance()

      
        499
        502
         	}

      
        500
        503
         

      
        501
        504
         	comment := p.parseOptInlineComment()

      
M journal/printer/directives.go
···
        21
        21
         

      
        22
        22
         func (p *printer) writeCommodityDirective(c *ast.CommodityDirective) {

      
        23
        23
         	p.buf.WriteString("commodity ")

      
        24
        
        -	p.buf.WriteString(c.Commodity)

      
        
        24
        +	if c.Format.Quantity.IsZero() {

      
        
        25
        +		p.buf.WriteString(c.Commodity)

      
        
        26
        +		p.writeInlineComment(c.Comment)

      
        
        27
        +		return

      
        
        28
        +	}

      
        
        29
        +	prec := max(c.Format.QuantityFmt.Precision, 2)

      
        
        30
        +	switch c.Format.CommodityPos {

      
        
        31
        +	case ast.CommodityBefore:

      
        
        32
        +		p.buf.WriteString(c.Format.Commodity)

      
        
        33
        +		if c.Format.HasSpace {

      
        
        34
        +			p.buf.WriteByte(' ')

      
        
        35
        +		}

      
        
        36
        +		p.writeDecimal(c.Format.Quantity, c.Format.QuantityFmt, prec)

      
        
        37
        +	case ast.CommodityAfter:

      
        
        38
        +		p.writeDecimal(c.Format.Quantity, c.Format.QuantityFmt, prec)

      
        
        39
        +		if c.Format.HasSpace {

      
        
        40
        +			p.buf.WriteByte(' ')

      
        
        41
        +		}

      
        
        42
        +		p.buf.WriteString(c.Format.Commodity)

      
        
        43
        +	}

      
        25
        44
         	p.writeInlineComment(c.Comment)

      
        26
        45
         }

      
        27
        46
         

      
M journal/printer/testdata/directives.golden
···
        1
        1
         ; Directives

      
        2
        2
         account Assets:Cash  ; cash account

      
        3
        3
         commodity $

      
        4
        
        -include 

      
        
        4
        +commodity UAH

      
        
        5
        +commodity 1000.00 USD

      
        
        6
        +commodity $1000.00

      
        
        7
        +commodity 1,000.00 UAH

      
        
        8
        +include ./other.journal

      
        
        9
        +include ../one../another.journal

      
        5
        10
         alias Assets:Checking = Assets:Cash

      
        6
        11
         payee "Test Payee"

      
        7
        
        -tag 

      
        
        12
        +tag important

      
        
        13
        +tag something-else

      
        8
        14
         year 2026

      
        9
        15
         decimal-mark ,

      
        10
        16
         

      
M journal/printer/testdata/directives.input
···
        1
        1
         ; Directives

      
        2
        2
         account Assets:Cash ; cash account

      
        3
        3
         commodity $

      
        4
        
        -include "other.journal"

      
        
        4
        +commodity UAH

      
        
        5
        +commodity 1000.00 USD

      
        
        6
        +commodity $1000.00

      
        
        7
        +commodity 1,000.00 UAH

      
        
        8
        +include ./other.journal

      
        
        9
        +include ../one../another.journal

      
        5
        10
         alias Assets:Checking = Assets:Cash

      
        6
        11
         payee "Test Payee"

      
        7
        12
         tag "important"

      
        
        13
        +tag something-else

      
        8
        14
         year 2026

      
        9
        15
         decimal-mark ,

      
        10
        16