This file is indexed.

/usr/share/gocode/src/github.com/miekg/mmark/mmark/titleblock.go is in golang-github-miekg-mmark-dev 1.3.6+dfsg-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
package main

// Parse template.xml and output TOML titleblock.

import (
	"bytes"
	"encoding/xml"
	"fmt"
	"strings"
)

// parseXMLtoTOML parses XML to TOML (in a slightly brain dead way).
func parseXMLtoTOML(input []byte) {
	parser := xml.NewDecoder(bytes.NewReader(input))
	keywords := []string{}
	name := ""
	fmt.Println("% # Quick 'n dirty translated by mmark")
	for {
		token, err := parser.Token()
		if err != nil {
			break
		}
		switch t := token.(type) {
		case xml.StartElement:
			elmt := xml.StartElement(t)
			name = elmt.Name.Local
			switch name {
			case "author":
				fmt.Println("%\n% [[author]]")
				outAttr(elmt.Attr)
			case "rfc":
				fallthrough
			case "title":
				outAttr(elmt.Attr)
			case "address":
				fmt.Println("% [author.address]")
			case "postal":
				fmt.Println("% [author.address.postal]")
			case "date":
				outDate(elmt.Attr)
			}
		case xml.CharData:
			if name == "" {
				continue
			}
			data := xml.CharData(t)
			data = bytes.TrimSpace(data)
			if len(data) == 0 {
				continue
			}
			if name == "keyword" {
				keywords = append(keywords, "\""+string(data)+"\"")
				continue
			}
			outString(name, string(data))
		case xml.EndElement:
			name = ""
		case xml.Comment:
			// don't care
		case xml.ProcInst:
			// don't care
		case xml.Directive:
			// don't care
		default:
		}
	}
	outArray("keyword", keywords)
}

func outString(k, v string) {
	fmt.Printf("%% %s = \"%s\"\n", k, v)
}

func outDate(attr []xml.Attr) {
	/*
		year, month, day := time.Now().Date()
		for _, a := range attr {
			switch a.Name.Local {
			case "day":
				day, err := strconv.Atoi(a.Value)
			case "month":
				_ = a.Value
			case "year":
				year, err := strconv.Atoi(a.Value)
			}
		}
	*/
	fmt.Printf("%%\n%% # TODO date \n%%\n")
}

func outArray(k string, arr []string) {
	all := strings.Join(arr, ", ")
	fmt.Printf("%%\n%% keyword = [ %s ]\n%%", all)
}

func outAttr(attr []xml.Attr) {
	for _, a := range attr {
		outString(a.Name.Local, a.Value)
	}
}