package d2svg

import (
	

	
	
)

// Copied private functions from chroma. Their public functions do too much (write the whole SVG document)
// https://github.com/alecthomas/chroma
// >>> BEGIN

var svgEscaper = strings.NewReplacer(
	`&`, "&",
	`<`, "&lt;",
	`>`, "&gt;",
	`"`, "&quot;",
	` `, "&#160;",
	`	`, "&#160;&#160;&#160;&#160;",
)

func styleToSVG( *chroma.Style) map[chroma.TokenType]string {
	 := map[chroma.TokenType]string{}
	// NOTE this is in the original source code, but it just makes unhighlightable code turn into the bg color
	// Which I don't understand, and I get the results I want when I remove it.
	// bg := style.Get(chroma.Background)
	for  := range chroma.StandardTypes {
		 := .Get()
		// if t != chroma.Background {
		//   entry = entry.Sub(bg)
		// }
		if .IsZero() {
			continue
		}
		[] = svg.StyleEntryToSVG()
	}
	return 
}

func styleAttr( map[chroma.TokenType]string,  chroma.TokenType) string {
	if ,  := []; ! {
		 = .SubCategory()
		if ,  := []; ! {
			 = .Category()
			if ,  := []; ! {
				return ""
			}
		}
	}
	// Custom code
	 := []
	 := []string{}

	if strings.Contains(, `font-weight="bold"`) {
		 = strings.Replace(, `font-weight="bold"`, ``, 1)
		 = append(, "text-mono-bold")
	}
	if strings.Contains(, `font-style="italic"`) {
		 = strings.Replace(, `font-style="italic"`, ``, 1)
		 = append(, "text-mono-italic")
	}

	if len() > 0 {
		 += `class="` + strings.Join(, " ") + `"`
	}

	return strings.TrimSpace()
}

// <<< END