// ElementsUsingStyle returns the children within the element matching the
// stlye restrictions passed.
// NOTE: is uses StyleContains
511437
func ElementsUsingStyle(e Markup, f, val string) []Markup {
	return DeepElementsUsingStyle(e, f, val, 1)
}
836626
func (inliner *Inliner) inlineStyleRules() error {
	for _, element := range inliner.elements {
		// remove marker
		element.elt.RemoveAttr(eltMarkerAttr)

		// inline element
		err := element.inline()
		if err != nil {
			return err
		}
	}

	return nil
}
999799
func EnvStyle(s string) string {
	return envStyleRegexp.ReplaceAllStringFunc(s, func(s string) string {
		return "$" + strings.ToUpper(s[1:len(s)-1])
	})
}
325120
func (f *Fpdf) SetLineCapStyle(styleStr string) {
	var capStyle int
	switch styleStr {
	case "round":
		capStyle = 1
	case "square":
		capStyle = 2
	default:
		capStyle = 0
	}
	f.capStyle = capStyle
	if f.page > 0 {
		f.outf("%d J", f.capStyle)
	}
}
1012547
func NewStyleRule(selector string, declarations []*css.Declaration) *StyleRule {
	return &StyleRule{
		Selector:     selector,
		Declarations: declarations,
		Specificity:  ComputeSpecificity(selector),
	}
}
1194519
func (inliner *Inliner) insertRawStylesheet() {
	rawCSS := inliner.computeRawCSS()
	if rawCSS != "" {
		// create <style> element
		cssNode := &html.Node{
			Type: html.TextNode,
			Data: "\n" + rawCSS,
		}

		styleNode := &html.Node{
			Type: html.ElementNode,
			Data: "style",
			Attr: []html.Attribute{{Key: "type", Val: "text/css"}},
		}

		styleNode.AppendChild(cssNode)

		// append to <head> element
		headNode := inliner.doc.Find("head")
		if headNode == nil {
			// @todo Create head node !
			panic("NOT IMPLEMENTED: create missing <head> node")
		}

		headNode.AppendNodes(styleNode)
	}
}
711723
func GetStyles(e Markup, f, val string) []*Style {
	var found []*Style
	var styles = e.Styles()

	for _, as := range styles {
		if as.Name != f {
			continue
		}

		if val != "" {
			if !strings.Contains(as.Value, val) {
				continue
			}
		}

		found = append(found, as)
	}

	return found
}
44454
func (v ElementBuildingVisitor) replaceListElement(meta apply.FieldMetaImpl, item *listItem) (*apply.ListElement, error) {
	meta.Name = item.Name
	result := &apply.ListElement{
		FieldMetaImpl:   meta,
		ListElementData: item.ListElementData,
		Values:          []apply.Element{},
	}

	// Use the max length to iterate over the slices
	for i := 0; i < max(len(item.GetRecordedList()), len(item.GetLocalList()), len(item.GetRemoteList())); i++ {

		// Lookup the item from each list
		data := apply.RawElementData{}
		if recorded, recordedSet := boundsSafeLookup(i, item.GetRecordedList()); recordedSet {
			data.SetRecorded(recorded)
		}
		if local, localSet := boundsSafeLookup(i, item.GetLocalList()); localSet {
			data.SetLocal(local)
		}
		if remote, remoteSet := boundsSafeLookup(i, item.GetRemoteList()); remoteSet {
			data.SetRemote(remote)
		}

		// Create the Item
		var s proto.Schema
		if item.Array != nil && item.Array.SubType != nil {
			s = item.Array.SubType
		}
		subitem, err := v.getItem(s, fmt.Sprintf("%d", i), data)
		if err != nil {
			return nil, err
		}

		// Build the element
		newelem, err := subitem.CreateElement(v)
		if err != nil {
			return nil, err
		}

		// Append the element to the list
		result.Values = append(result.Values, newelem)
	}

	return result, nil
}
414196
func (element *Element) computeDeclarations() ([]*css.Declaration, error) {
	result := []*css.Declaration{}

	styles := make(map[string]*StyleDeclaration)

	// First: parsed stylesheets rules
	mergeStyleDeclarations(element.styleRules, styles)

	// Then: inline rules
	inlineRules, err := element.parseInlineStyle()
	if err != nil {
		return result, err
	}

	mergeStyleDeclarations(inlineRules, styles)

	// map to array
	for _, styleDecl := range styles {
		result = append(result, styleDecl.Declaration)
	}

	// sort declarations by property name
	sort.Sort(css.DeclarationsByProperty(result))

	return result, nil
}
546098
func (inliner *Inliner) collectElementsAndRules() {
	for _, stylesheet := range inliner.stylesheets {
		for _, rule := range stylesheet.Rules {
			if rule.Kind == css.QualifiedRule {
				// Let's go!
				inliner.handleQualifiedRule(rule)
			} else {
				// Keep it 'as is'
				inliner.rawRules = append(inliner.rawRules, rule)
			}
		}
	}
}
1354974
func NewStyle(tags core.TagSlice) (*Style, error) {
	style := new(Style)

	style.Height = 1.0
	style.Width = 1.0

	style.Init(map[int]core.TypeParser{
		2:  core.NewStringTypeParserToVar(&style.Name),
		3:  core.NewStringTypeParserToVar(&style.Font),
		4:  core.NewStringTypeParserToVar(&style.BigFont),
		40: core.NewFloatTypeParserToVar(&style.Height),
		41: core.NewFloatTypeParserToVar(&style.Width),
		50: core.NewFloatTypeParserToVar(&style.Oblique),
		70: core.NewIntTypeParser(func(flags int) {
			style.IsShape = flags&shapeBit != 0
			style.IsVerticalText = flags&verticalTextBit != 0
		}),
		71: core.NewIntTypeParser(func(flags int) {
			style.IsBackwards = flags&backwardsBit != 0
			style.IsUpsideDown = flags&upsideDownBit != 0
		}),
	})

	err := style.Parse(tags)
	return style, err
}
153290
func newElementBase(ln *line, parent element) elementBase {
	return elementBase{
		ln:     ln,
		parent: parent,
	}
}
897470
func (parser *Parser) ParseStylesheet() (*css.Stylesheet, error) {
	result := css.NewStylesheet()

	// Parse BOM
	if _, err := parser.parseBOM(); err != nil {
		return result, err
	}

	// Parse list of rules
	rules, err := parser.ParseRules()
	if err != nil {
		return result, err
	}

	result.Rules = rules

	return result, nil
}
1355327
func NewGetMatchedStylesForNodeArgs(nodeID dom.NodeID) *GetMatchedStylesForNodeArgs {
	args := new(GetMatchedStylesForNodeArgs)
	args.NodeID = nodeID
	return args
}
1136945
func (self htmlIdImpl) StyleAttribute(name string) DomAttribute {
	return self.getOrCreateAttribute("style:"+name, func() DomAttribute {
		return NewStyleAttr(name, self.t)
	})
}
709620
func (p *Painter) WithStyle(n string, fn func(*Painter)) {
	prev := p.style
	new := prev.mergeIn(p.theme.Style(n))
	p.SetStyle(new)
	fn(p)
	p.SetStyle(prev)
}
171626
func parseFormatStyleSet(style string) (*formatStyle, error) {
	format := formatStyle{
		DecimalPlaces: 2,
	}
	err := json.Unmarshal([]byte(style), &format)
	return &format, err
}